Commit 6c28d70b476bdd32c8fa7d5ce292651de6da2eef
1 parent
099c72c3
Exists in
master
and in
3 other branches
Adding case and accents insensitive topic name verification
Showing
3 changed files
with
21 additions
and
1 deletions
Show diff stats
amadeus/settings.py
topics/forms.py
| ... | ... | @@ -18,7 +18,9 @@ class TopicForm(forms.ModelForm): |
| 18 | 18 | name = self.cleaned_data.get('name', '') |
| 19 | 19 | repo = self.cleaned_data.get('repository', False) |
| 20 | 20 | |
| 21 | - if len(self.subject.topic_subject.filter(name = name)) > 0: | |
| 21 | + same_name = len(self.subject.topic_subject.filter(name__unaccent__iexact = name)) | |
| 22 | + | |
| 23 | + if same_name > 0: | |
| 22 | 24 | if repo: |
| 23 | 25 | self._errors['name'] = [_('This subject already has a repository')] |
| 24 | 26 | else: | ... | ... |
| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | +# -*- coding: utf-8 -*- | |
| 2 | +# Generated by Django 1.10 on 2017-01-17 00:01 | |
| 3 | +from __future__ import unicode_literals | |
| 4 | + | |
| 5 | +from django.db import migrations | |
| 6 | + | |
| 7 | +from django.contrib.postgres.operations import UnaccentExtension | |
| 8 | + | |
| 9 | +class Migration(migrations.Migration): | |
| 10 | + | |
| 11 | + dependencies = [ | |
| 12 | + ('topics', '0002_auto_20170116_1841'), | |
| 13 | + ] | |
| 14 | + | |
| 15 | + operations = [ | |
| 16 | + UnaccentExtension() | |
| 17 | + ] | |
| 0 | 18 | \ No newline at end of file | ... | ... |