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
Corrige les erreurs 500 liées à l'attribution des casquettes #4572
Conversation
zds/member/views.py
Outdated
@@ -800,7 +800,7 @@ def add_hat(request, user_pk): | |||
|
|||
user = get_object_or_404(User, pk=user_pk) | |||
|
|||
hat_name = request.POST.get('hat', None) | |||
hat_name = request.POST.get('hat', None).strip() |
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.
du coup vaut mieux remplacer le None
par ''
sinon tu vas avoir un AttributeError
.
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.
Bien vu !
@@ -19,7 +19,7 @@ def handle(self, *args, **options): | |||
except Group.DoesNotExist: | |||
raise CommandError('Group {} does not exist.'.format(options['group'])) | |||
|
|||
hat_name = options['hat'] | |||
hat_name = options['hat'].strip() |
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.
options.get('hat', '').strip()
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.
C'est moins important ici, mais ça vaut le coup quand même, je m'en occupe.
@@ -480,7 +480,7 @@ class Hat(models.Model): | |||
that a moderation message was posted by a staff member. | |||
""" | |||
|
|||
name = models.CharField('Casquette', max_length=40, unique=True) | |||
name = models.CharField('Casquette', max_length=40) |
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.
du coup je suis pas sûr que supprimer le unique
soit une bonne idée.
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.
C'est nécessaire pour résoudre le problème des smileys (deux casquettes identiques avec un caractère UTF-8 différent).
L'erreur est causée par le fait que
unique=True
supporte mal l'UTF-8. Je l'enlève car leget_or_create
fait déjà cette vérification. Par ailleurs, j'empêche les espaces au début et à la fin qui n'ont aucune raison d'être. ^^QA
☆
et♦
) à un membre et vérifier qu'elles sont correctement attribuées.