Skip to content

Commit

Permalink
Merge pull request #428 from CaptainFact/feat/wikidata-auto-fetch
Browse files Browse the repository at this point in the history
Edit speaker minor improvements
  • Loading branch information
Betree authored Apr 1, 2019
2 parents d2a827d + 8425f1b commit e353fca
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 47 deletions.
14 changes: 5 additions & 9 deletions app/components/Speakers/AddSpeakerForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export default class AddSpeakerForm extends React.PureComponent {
return query.length < 3
? []
: SocketApi.push('video_debate', 'search_speaker', { query }).then(
({ speakers }) => {
return speakers.map(s => ({ label: s.full_name, value: s }))
}
)
({ speakers }) => {
return speakers.map(s => ({ label: s.full_name, value: s }))
}
)
}, 250)

promptTextCreator = speakerName => {
Expand Down Expand Up @@ -59,16 +59,12 @@ export default class AddSpeakerForm extends React.PureComponent {
loadOptions={this.searchSpeakerRequest}
onChange={this.onChange}
value=""
noOptionsMessage={() => t('speaker.search')}
components={{
LoadingMessage: () => (
<Container display="flex" p={3} color="black.400" justifyContent="center">
{t('main:actions.loading')}...
</Container>
),
NoOptionsMessage: () => (
<Container display="flex" p={3} color="black.400" justifyContent="center">
{t('speaker.search')}
</Container>
)
}}
styles={ReactSelectStyles}
Expand Down
21 changes: 11 additions & 10 deletions app/components/Speakers/EditSpeakerFormModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { pick, truncate, capitalize } from 'lodash'
import AsyncSelect from 'react-select/lib/Async'
import wikidata from 'wikidata-sdk'
import debounce from 'debounce-promise'
import { Formik } from 'formik'

import { Save } from 'styled-icons/boxicons-regular/Save'
import { Ban } from 'styled-icons/fa-solid/Ban'
Expand All @@ -19,7 +20,6 @@ import { validateLengthI18n } from '../../lib/form_validators'
import { SPEAKER_NAME_LENGTH, SPEAKER_TITLE_LENGTH } from '../../constants'
import capitalizeName from '../../lib/name_formatter'
import { cleanStr } from '../../lib/clean_str'
import { Formik } from 'formik'
import StyledInput from '../StyledUtils/StyledInput'
import Modal from '../Modal/Modal'
import { Span } from '../StyledUtils/Text'
Expand Down Expand Up @@ -122,7 +122,7 @@ class EditSpeakerFormModal extends React.PureComponent {
<Modal
title={t('speaker.edit', { name: this.props.speaker.full_name })}
className="modal-form"
footer={
footer={(
<div className="form-buttons">
<Button
onClick={submitForm}
Expand All @@ -141,7 +141,7 @@ class EditSpeakerFormModal extends React.PureComponent {
<Span ml={1}>{t('main:actions.cancel')}</Span>
</Button>
</div>
}
)}
>
<form className="form" onSubmit={handleSubmit}>
<div className="form-fields">
Expand Down Expand Up @@ -170,7 +170,10 @@ class EditSpeakerFormModal extends React.PureComponent {
loadOptions={this.loadOptions}
styles={ReactSelectStyles}
theme={ReactSelectTheme}
noOptionsMessage={() => t('speaker.search')}
noOptionsMessage={({ inputValue }) => (inputValue.length < 3
? t('speaker.search')
: t('speaker.noneFound'))
}
onChange={({ value }) => {
setValues({
...values,
Expand All @@ -192,8 +195,7 @@ class EditSpeakerFormModal extends React.PureComponent {
name="full_name"
placeholder="Barack Obama, Dark Vador..."
value={values.full_name}
onChange={e =>
setFieldValue('full_name', capitalizeName(cleanStr(e.target.value)))
onChange={e => setFieldValue('full_name', capitalizeName(cleanStr(e.target.value)))
}
/>
{errors.full_name && (
Expand Down Expand Up @@ -227,10 +229,9 @@ class EditSpeakerFormModal extends React.PureComponent {
name="wikidata_item_id"
placeholder="QXXXXXXXX"
value={values.wikidata_item_id || ''}
onChange={e =>
e.target.value.length > 1
? setFieldValue('wikidata_item_id', cleanStr(e.target.value))
: setFieldValue('wikidata_item_id', null)
onChange={e => (e.target.value.length > 1
? setFieldValue('wikidata_item_id', cleanStr(e.target.value))
: setFieldValue('wikidata_item_id', null))
}
autoComplete="off"
/>
Expand Down
2 changes: 1 addition & 1 deletion app/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const ENTITY_USER_ACTION = 'user_action'
export const MIN_REPUTATION_ADD_STATEMENT = -5
export const MIN_REPUTATION_UPDATE_STATEMENT = 15
export const MIN_REPUTATION_FLAG = 15
export const MIN_REPUTATION_UPDATE_SPEAKER = 15
export const MIN_REPUTATION_UPDATE_SPEAKER = 75
export const MIN_REPUTATION_ADD_SPEAKER = 30
export const MIN_REPUTATION_REMOVE_STATEMENT = 75
export const MIN_REPUTATION_RESTORE_ENTITY = 75
Expand Down
3 changes: 2 additions & 1 deletion app/i18n/en/videoDebate.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export default {
search: 'Type at least 3 characters to start searching',
fullName: 'Full name',
title: 'Title',
titlePlaceholder: 'Politician, doctor, journalist...'
titlePlaceholder: 'Politician, doctor, journalist...',
noneFound: 'No speaker found for this name'
},
statement: {
remove: 'Remove statement',
Expand Down
3 changes: 2 additions & 1 deletion app/i18n/fr/videoDebate.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export default {
search: 'Tapez au moins 3 lettres pour lancer la recherche',
fullName: 'Nom complet',
title: 'Titre',
titlePlaceholder: 'Politicien, docteur, journaliste...'
titlePlaceholder: 'Politicien, docteur, journaliste...',
noneFound: 'Aucun intervenant trouvé pour ce nom'
},
statement: {
remove: 'Retirer la citation',
Expand Down
44 changes: 21 additions & 23 deletions app/static/assets/help/en/privileges.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,37 @@
Content creation actions (adding speakers, statements, sources...etc) usually have very few
restrictions. If you don't use this right responsibly, other users flags and down votes
will end up limiting your actions.

Judgement actions such as voting and flagging are limited to avoid abusing them and to
**reinforce their meaning**.

## List of privileges

| Reputation | Privilege |
|------------|------------------------------------------------------------|
| Any | Post comments and sources
| Any | Delete your own comments
| 0 | Create statements
| 0 | Vote Up
| 15 | Vote Down
| 15 | Update statement
| 15 | Update speaker
| 15 | Flag inappropriate content
| 30 | Add / create speakers
| 75 | Add videos
| 75 | Remove / restore statement
| 75 | Shift all video's statements
| 75 | Remove speaker
| 125 | No more new user restrictions
| 125 | Access to the moderation platform
| 125 | Restore speaker
| 200 | Self-vote
| Reputation | Privilege |
| ---------- | --------------------------------- |
| Any | Post comments and sources |
| Any | Delete your own comments |
| 0 | Create statements |
| 0 | Vote Up |
| 15 | Vote Down |
| 15 | Update statement |
| 15 | Flag inappropriate content |
| 30 | Add / create speakers |
| 75 | Update speaker |
| 75 | Add videos |
| 75 | Remove / restore statement |
| 75 | Shift all video's statements |
| 75 | Remove speaker |
| 125 | No more new user restrictions |
| 125 | Access to the moderation platform |
| 125 | Restore speaker |
| 200 | Self-vote |

# New user restrictions

Until you reach a [reputation](/help/reputation) of `125`, you will be considered as a new user.
Your limitations for all actions will be way below the normal.


# Negative reputation

[Reputation](/help/reputation) can be negative if you get too much flags and down votes
Expand All @@ -45,8 +44,7 @@ each day - this gives you a chance to come back in the game with positive contri

However if your reputation goes below `-30` you won't be able to do any action anymore.


## I've been given a negative reputation unfairly !

If you think your situation is not fair, please [contact us](/help/contact)
and we'll investigate.
and we'll investigate.
4 changes: 2 additions & 2 deletions app/static/assets/help/fr/privileges.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ renforcer leur signification.
| 0 | Ajouter des citations |
| 0 | Voter positivement |
| 15 | Voter négativement |
| 15 | Mettre à jour une citation |
| 15 | Mettre à jour un intervenant |
| 15 | Éditer une citation |
| 15 | Signaler un contenu inapproprié |
| 30 | Ajouter ou créer des intervenants |
| 75 | Éditer un intervenant |
| 75 | Ajouter une vidéo |
| 75 | Supprimer / restaurer une citation |
| 75 | Déplacer toutes les citations d'une vidéo (time shift) |
Expand Down

0 comments on commit e353fca

Please sign in to comment.