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
Fix bug on no tag #3875
Fix bug on no tag #3875
Conversation
Je voudrais être chiant, je dirais qu'il manque un TU. (: |
Je suis d'accord ;) |
Merci @artragis . Outre le test manquant, j'ai quelques questions :
* Un truc dans ce goût-là : + if not raw_string:
+ return []
return TagValidator.validate_string_list(raw_string.split(",")) |
Etant donné que je l'ai introduit, j'ai la casi certitude que oui c'est Le 19/10/2016 à 23:32, victor felder a écrit :
|
Je pense qu'il vaut la peine d'en profiter pour retravailler un peu ce validateur de tag et la pertinence des messages qu'il retourne. Exemple de logique ici. Comme ça on dit à l'utilisateur directement quels tags sont trop longs, et on lui dit aussi quand un ou des tags, et le cas échéant le ou lesquels, contiennent des caractères pas autorisés. C'est mieux que de les virer sans avertir. |
Je suis d'accord. Après, faut voir si on veut ça pour le bugfix ou pour plus tard |
Je pense que vu que le gros du travail est fait et qu'il manque juste l'intégration un peu plus propre du brouillon dont je donne le lien, y a pas de raison de pas faire passer le tout ici. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- intégrer la validation utf8 au validateur de tags.
@@ -265,6 +265,7 @@ def clean(self): | |||
self._errors['image'] = self.error_class( | |||
[_(u'Votre logo est trop lourd, la limite autorisée est de {} Ko') | |||
.format(settings.ZDS_APP['gallery']['image_max_size'] / 1024)]) | |||
# because tags are not mandatory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commentaire inutile.
@@ -58,3 +59,9 @@ def insert_duplicated_tags(tags): | |||
self.assertIn('azerty', all_slugs) | |||
self.assertIn('qwerty', all_slugs) | |||
self.assertIn('another-tag', all_slugs) | |||
|
|||
def test_validator(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ce test n'est pas bon. Une implémentation évidente de la méthode testée ici serait def validate_raw_string(): return True
utf8mb4 validé + refonte du validateur pour que ça soit beau et pythonique. |
Merci @artragis ! @pierre-24 quand t'es motiv, QA ? @GerardPaligot tu vois d'autres trucs à régler pour la v20 ou je peux RC ? |
Tout dépend à quel point tu considère #3842 comme bloquant :) (je vais QA) |
QA: NOK!
|
Je comprends pas pourquoi travis est pas passé par ici. |
Parce qu'il semblerai qu'internet soit cassé (et qu'il suffise que je dise ça pour que Travis se réveille). |
logically fixed |
|
||
def validate_raw_string(self, raw_string): | ||
if raw_string is None or not isinstance(raw_string, basestring): | ||
return self.validate_string_list([]) | ||
return self.validate_string_list(raw_string.split(",")) | ||
|
||
def validate_length(self, raw_string): | ||
if len(_) <= Tag._meta.get_field("title").max_length: | ||
self.errors.append(_(u"Le tag est trop long")) | ||
if len(raw_string) <= Tag._meta.get_field("title").max_length: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T'as oublié d'inverser la condition ;) (du coup les tests sont tout cassés)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... Et si les erreurs doivent ce suivre, il faudrait les faire finir par .
(avec un espace après le point)
to get all internationalized error. | ||
""" | ||
if raw_string is None or not isinstance(raw_string, basestring): | ||
return self.validate_string_list([]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pourquoi pas return True
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question d'évolutivité : si demain pour une raison aussi saugrenue soit-elle on décide qu'une liste vide est invalide ça retournera false.
De plus c'est juste ici de la sémantique "si tu mets None ou autre chose qu'un string, on le considère comme un string vide".
|
||
def test_validator_with_utf8mb4(self): | ||
|
||
raw_string = u"☢☢☢☢☢☢,bla" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remplace ☢
par 🐙
. Le premier est pas utf8mb4, le second l'est. On peut pas vraiment éviter ça malheureusement.
QA OK. On est parti :) |
il faudra donc attendre demain que je m'y mette dans des bonnes conditions. Le 20/10/2016 à 21:00, vhf a écrit :
|
hum, on appelle ça le cache de thunderbird qui finit par se réveiller dès que la connexion est stable il semblerait. Car ce message je l'ai envoyé non pas il y a cinq minutes mais il y a plusieurs jours. Les problèmes récents de DNS sont peut être en cause. |
QA