-
Notifications
You must be signed in to change notification settings - Fork 55
Add extra validations for links, trackers; and news #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d6ba4d0
84db414
ec79de0
7a706af
2552255
676b0ef
e7dffa7
8a91804
46aeada
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
= form.text_field :title, autocomplete: 'off', required: 'required', spellcheck: 'true', maxlength: 100 | ||
%p | ||
= form.label :section_id, "Section de la dépêche" | ||
= form.collection_select :section_id, Section.published, :id, :title | ||
= form.collection_select :section_id, Section.published, :id, :title, { include_blank: true }, { required: "required" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On a aussi besoin d'ajouter la même validation pour la section dans ce controlleur. Si je procède à la même manipulation (enlever l'attribut required), alors, j'ai cette erreur qui apparaît: Ça serait plus sympa d'avoir un bon message d'erreur du controlleur pour éviter de perdre le contenu de la dépêche soumise sans espace de rédaction :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Théoriquement, pour valider une association à une table (donc, pour la section de news ici), on peut utiliser les propriétés: validates_associated (validation de l'appartenance à la liste) et validates_presence_of (validation de la présence de la valeur) ensemble. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. J'ai ajouté "validates_associated" et j'ai changé le système de "prévisualisation" pour ne prévisualiser que si le contenu est valide. La capture d'écran d'erreur que j'ai posté plus haut était due au fait que l'on essaie de faire la preview d'une news sans section. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On peut envoyer en Anonyme en modération une dépêche avec un lien sans langue définie. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On peut injecter des langues inconnues sur un lien de dépêche en Anonyme (et ensuite le site essaie d'afficher une image inexistante). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. En rédaction, on peut générer des 500 en envoyant des identifiants de section invalide pour la dépêche en cours. |
||
%p | ||
= form.label :wiki_body, "Contenu de la dépêche" | ||
= form.text_area :wiki_body, required: 'required', spellcheck: 'true', class: 'markItUp' | ||
|
@@ -51,4 +51,4 @@ | |
= form.label :cc_licensed, 'Je place ce document sous licence Creative Commons Paternité - Partage des conditions initiales à l’identique, version 4.0 (<a href="http://creativecommons.org/licenses/by-sa/4.0/deed.fr">licence CC By-SA 4.0</a>). Ceci est conseillé afin de permettre l’édition coopérative de la dépêche si elle doit être complétée.'.html_safe | ||
%p | ||
= form.submit "Prévisualiser", id: "news_preview" | ||
= form.submit "Soumettre cette dépêche", 'data-disable-with' => "Enregistrement en cours" if @preview_mode | ||
= form.submit "Soumettre cette dépêche", 'data-disable-with' => "Enregistrement en cours" if @preview_mode and @news.valid? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
= form.text_field :title, autocomplete: 'off', required: 'required', spellcheck: 'true', maxlength: 100 | ||
%p | ||
= form.label :category_id, "Catégorie" | ||
= form.collection_select :category_id, Category.all, :id, :title | ||
= form.collection_select :category_id, Category.all, :id, :title, { include_blank: true }, { required: "required" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je n'ai pas eu le temps de testé, mais j'imagine qu'il y aura le même problème que pour la section de There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Encore un 500 si on soumet avec un id de catégorie inconnu. ActiveRecord::InvalidForeignKey (Mysql2::Error: Cannot add or update a child row: a foreign key constraint fails ( |
||
- if @tracker.new_record? | ||
%p.pot_de_miel | ||
= form.label :pot_de_miel, "Ne pas remplir ce champ" | ||
|
@@ -23,4 +23,4 @@ | |
= form.collection_select :assigned_to_user_id, Account.tracker_admin, :user_id, :login, include_blank: true | ||
%p | ||
= form.submit "Prévisualiser", id: "tracker_preview" | ||
= form.submit "Soumettre", 'data-disable-with' => "Enregistrement en cours" if @preview_mode || @tracker.persisted? | ||
= form.submit "Soumettre", 'data-disable-with' => "Enregistrement en cours" if (@preview_mode || @tracker.persisted?) and @tracker.valid? |
Uh oh!
There was an error while loading. Please reload this page.