aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Chatzimichos <tampakrap@gentoo.org>2011-07-19 22:47:42 +0300
committerTheo Chatzimichos <tampakrap@gentoo.org>2011-07-19 22:47:42 +0300
commitaa999f74c4c2c731dca6a67744ea567ce4228306 (patch)
treedf3eb0a5da37e7ac7ea8b58e5ce98b14bcedc071
parentNew style for settings splitting. User has to specify production||development... (diff)
downloadidentity.gentoo.org-aa999f74c4c2c731dca6a67744ea567ce4228306.tar.gz
identity.gentoo.org-aa999f74c4c2c731dca6a67744ea567ce4228306.tar.bz2
identity.gentoo.org-aa999f74c4c2c731dca6a67744ea567ce4228306.zip
Move the ModelForms from models.py to forms.py
-rw-r--r--accounts/forms.py53
-rw-r--r--accounts/models.py54
2 files changed, 53 insertions, 54 deletions
diff --git a/accounts/forms.py b/accounts/forms.py
index c1864a6..3dc4bb2 100644
--- a/accounts/forms.py
+++ b/accounts/forms.py
@@ -1,6 +1,59 @@
from django import forms
+from django.forms import ModelForm
class PasswordForm(forms.Form):
old_password = forms.CharField(max_length = 30, widget = forms.PasswordInput(), label = 'Old password:')
password1 = forms.CharField(max_length = 30, widget = forms.PasswordInput(), label = 'New Password:')
password2 = forms.CharField(max_length = 30, widget = forms.PasswordInput(), label = 'Verify Password:')
+
+def profileExclude(privil):
+ '''
+ Helper function to generate a tuple with attributes that should
+ be excluded from the edit form
+ '''
+ exclude = ['user', 'mail', 'secondary_password', 'base_dn']
+ if not privil:
+ exclude.append('objectClass')
+ for key in settings.LDAP_ACL_GROUPS.keys():
+ exclude.append(key)
+ return tuple(exclude)
+
+'''
+Below are the forms generated by the above models
+'''
+
+class UserProfileForm(ModelForm):
+ '''
+ UserProfile form for unprivileged users
+ Some fields are hidden
+ '''
+ class Meta:
+ model = UserProfile
+ exclude = profileExclude(False)
+
+class UserProfileForm(ModelForm):
+ '''
+ UserProfile form for privileged users
+ All fields are available
+ '''
+ class Meta:
+ model = UserProfile
+ exclude = profileExclude(True)
+
+class GentooProfileForm(ModelForm):
+ '''
+ GentooProfile form for unprivileged users
+ Many fields are hidden
+ '''
+ class Meta:
+ model = GentooProfile
+ exclude = profileExclude(False)
+
+class GentooProfilePrivilForm(ModelForm):
+ '''
+ GentooProfile form for privileged users
+ All the fields are available
+ '''
+ class Meta:
+ model = GentooProfile
+ exclude = profileExclude(True)
diff --git a/accounts/models.py b/accounts/models.py
index 5495474..bf22a71 100644
--- a/accounts/models.py
+++ b/accounts/models.py
@@ -1,7 +1,6 @@
from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
-from django.forms import ModelForm
class UserProfile(models.Model):
'''
@@ -43,56 +42,3 @@ class GentooProfile(UserProfile):
is_docs = models.BooleanField(default = False)
is_security = models.BooleanField(default = False)
is_pr = models.BooleanField(default = False)
-
-
-def profileExclude(privil):
- '''
- Helper function to generate a tuple with attributes that should
- be excluded from the edit form
- '''
- exclude = ['user', 'mail', 'secondary_password', 'base_dn']
- if not privil:
- exclude.append('objectClass')
- for key in settings.LDAP_ACL_GROUPS.keys():
- exclude.append(key)
- return tuple(exclude)
-
-'''
-Below are the forms generated by the above models
-'''
-
-class UserProfileForm(ModelForm):
- '''
- UserProfile form for unprivileged users
- Some fields are hidden
- '''
- class Meta:
- model = UserProfile
- exclude = profileExclude(False)
-
-class UserProfileForm(ModelForm):
- '''
- UserProfile form for privileged users
- All fields are available
- '''
- class Meta:
- model = UserProfile
- exclude = profileExclude(True)
-
-class GentooProfileForm(ModelForm):
- '''
- GentooProfile form for unprivileged users
- Many fields are hidden
- '''
- class Meta:
- model = GentooProfile
- exclude = profileExclude(False)
-
-class GentooProfilePrivilForm(ModelForm):
- '''
- GentooProfile form for privileged users
- All the fields are available
- '''
- class Meta:
- model = GentooProfile
- exclude = profileExclude(True)