| author | ymh <ymh.work@gmail.com> |
| Thu, 06 Nov 2014 02:08:12 +0100 | |
| changeset 176 | a343992c55fd |
| parent 145 | 7c6fe1dab213 |
| permissions | -rw-r--r-- |
| 0 | 1 |
# -*- coding: utf-8 -*- |
| 126 | 2 |
# |
| 131 | 3 |
# Copyright IRI (c) 2013 |
| 126 | 4 |
# |
5 |
# contact@iri.centrepompidou.fr |
|
6 |
# |
|
7 |
# This software is governed by the CeCILL-B license under French law and |
|
8 |
# abiding by the rules of distribution of free software. You can use, |
|
9 |
# modify and/ or redistribute the software under the terms of the CeCILL-B |
|
10 |
# license as circulated by CEA, CNRS and INRIA at the following URL |
|
11 |
# "http://www.cecill.info". |
|
12 |
# |
|
13 |
# As a counterpart to the access to the source code and rights to copy, |
|
14 |
# modify and redistribute granted by the license, users are provided only |
|
15 |
# with a limited warranty and the software's author, the holder of the |
|
16 |
# economic rights, and the successive licensors have only limited |
|
17 |
# liability. |
|
18 |
# |
|
19 |
# In this respect, the user's attention is drawn to the risks associated |
|
20 |
# with loading, using, modifying and/or developing or reproducing the |
|
21 |
# software by the user in light of its specific status of free software, |
|
22 |
# that may mean that it is complicated to manipulate, and that also |
|
23 |
# therefore means that it is reserved for developers and experienced |
|
24 |
# professionals having in-depth computer knowledge. Users are therefore |
|
25 |
# encouraged to load and test the software's suitability as regards their |
|
26 |
# requirements in conditions enabling the security of their systems and/or |
|
27 |
# data to be ensured and, more generally, to use and operate it in the |
|
28 |
# same conditions as regards security. |
|
29 |
# |
|
30 |
# The fact that you are presently reading this means that you have had |
|
31 |
# knowledge of the CeCILL-B license and that you accept its terms. |
|
32 |
# |
|
| 0 | 33 |
|
| 126 | 34 |
|
| 0 | 35 |
from django.conf import settings |
36 |
from django.contrib.auth import get_user_model |
|
37 |
from django.contrib.auth.forms import (UserChangeForm as AuthUserChangeForm, |
|
38 |
UserCreationForm as AuthUserCreationForm) |
|
39 |
from django.core.exceptions import ValidationError |
|
|
113
c05567404888
First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
from django.forms.fields import ChoiceField |
| 0 | 41 |
from django.utils.translation import ugettext as _ |
42 |
||
43 |
||
44 |
User = get_user_model() |
|
45 |
||
46 |
class UserCreationform(AuthUserCreationForm): |
|
47 |
class Meta: |
|
48 |
model = User |
|
49 |
||
50 |
def clean_username(self): |
|
51 |
# Since User.username is unique, this check is redundant, |
|
52 |
# but it sets a nicer error message than the ORM. See #13147. |
|
53 |
username = self.cleaned_data["username"] |
|
54 |
try: |
|
55 |
User.objects.get(username=username) |
|
56 |
except User.DoesNotExist: |
|
57 |
return username |
|
58 |
raise ValidationError(self.error_messages['duplicate_username']) |
|
59 |
||
60 |
||
61 |
class UserChangeForm(AuthUserChangeForm): |
|
62 |
language = ChoiceField(label=_("language"), choices=[(k,_(v)) for k,v in settings.LANGUAGES], initial=settings.LANGUAGE_CODE[:2]) |
|
63 |
class Meta: |
|
64 |
model = User |