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
| @@ -42,6 +42,7 @@ INSTALLED_APPS = [ | @@ -42,6 +42,7 @@ INSTALLED_APPS = [ | ||
| 42 | 'django.contrib.sessions', | 42 | 'django.contrib.sessions', |
| 43 | 'django.contrib.messages', | 43 | 'django.contrib.messages', |
| 44 | 'django.contrib.staticfiles', | 44 | 'django.contrib.staticfiles', |
| 45 | + 'django.contrib.postgres', | ||
| 45 | 46 | ||
| 46 | 'widget_tweaks', | 47 | 'widget_tweaks', |
| 47 | 'rolepermissions', | 48 | 'rolepermissions', |
topics/forms.py
| @@ -18,7 +18,9 @@ class TopicForm(forms.ModelForm): | @@ -18,7 +18,9 @@ class TopicForm(forms.ModelForm): | ||
| 18 | name = self.cleaned_data.get('name', '') | 18 | name = self.cleaned_data.get('name', '') |
| 19 | repo = self.cleaned_data.get('repository', False) | 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 | if repo: | 24 | if repo: |
| 23 | self._errors['name'] = [_('This subject already has a repository')] | 25 | self._errors['name'] = [_('This subject already has a repository')] |
| 24 | else: | 26 | else: |
| @@ -0,0 +1,17 @@ | @@ -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 | \ No newline at end of file | 18 | \ No newline at end of file |