Commit 6c28d70b476bdd32c8fa7d5ce292651de6da2eef

Authored by Zambom
1 parent 099c72c3

Adding case and accents insensitive topic name verification

amadeus/settings.py
... ... @@ -42,6 +42,7 @@ INSTALLED_APPS = [
42 42 'django.contrib.sessions',
43 43 'django.contrib.messages',
44 44 'django.contrib.staticfiles',
  45 + 'django.contrib.postgres',
45 46  
46 47 'widget_tweaks',
47 48 'rolepermissions',
... ...
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:
... ...
topics/migrations/0003_auto_20170116_2101.py 0 → 100644
... ... @@ -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
... ...