source: publico/colab/trunk/colab/super_archives/forms.py @ 6126

Última Alteração nesse arquivo desde 6126 foi 6126, incluída por seocam, 8 anos atrás

Merge com a ultima versao do bitcket: https://bitbucket.org/seocam/atu-colab/src/4ee3ca57614e

File size: 2.2 KB
Linha 
1# -*- coding: utf-8 -*-
2
3from django import forms
4from django.core.exceptions import ValidationError
5from django.contrib.auth.models import User
6from django.contrib.auth.forms import UserCreationForm as UserCreationForm_
7
8from colab.super_archives.models import MailingList
9from colab.super_archives.validators import UniqueValidator   
10
11# XXX: I know that this code does not look nice AT ALL.
12#   probably it should be implemented using formsets instead of
13#   the hack below. Feel free to improve it! :)
14
15# User fields
16username_field = UserCreationForm_().fields.get('username')
17first_name_field = forms.CharField(max_length=30, label='Nome')
18last_name_field = forms.CharField(max_length=30, label='Sobrenome')
19email_field = forms.EmailField(validators=[UniqueValidator(User, 'email')])
20
21# UserProfile fields
22institution_field = forms.CharField(max_length=120, label=u'Instituição',
23                                    required=False)
24role_field = forms.CharField(max_length=60, label='Função', required=False)
25twitter_field = forms.URLField(label=u'Twitter', required=False)
26facebook_field = forms.URLField(label=u'Facebook', required=False)
27google_talk_field = forms.EmailField(label=u'Google Talk', required=False)
28webpage_field = forms.URLField(label=u'Página Pessoal/Blog', required=False)
29
30all_lists = MailingList.objects.all()
31lists_names = []
32for list_ in all_lists:
33   choice = (list_.name, list_.name)
34   lists_names.append(choice)
35
36lists_field = forms.MultipleChoiceField(
37    label=u'Listas',
38    required=False,
39    widget=forms.CheckboxSelectMultiple,
40    choices=lists_names
41)
42
43
44class UserCreationForm(UserCreationForm_):
45    first_name = first_name_field
46    last_name = last_name_field
47    email = email_field
48    institution = institution_field
49    role = role_field
50    twitter = twitter_field
51    facebook = facebook_field
52    google_talk = google_talk_field
53    webpage = webpage_field
54    lists = lists_field
55
56   
57class UserUpdateForm(forms.Form):
58    username = username_field
59    username.required = False
60    institution = institution_field
61    role = role_field
62    twitter = twitter_field
63    facebook = facebook_field
64    google_talk = google_talk_field
65    webpage = webpage_field
Note: Veja TracBrowser para ajuda no uso do navegador do trac.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.