pep8
This commit is contained in:
parent
fde1c147c9
commit
3a211b74a4
13 changed files with 238 additions and 146 deletions
|
@ -6,26 +6,34 @@ from django_markdown.widgets import MarkdownWidget
|
|||
|
||||
from issue.models import *
|
||||
|
||||
AddProjectForm = modelform_factory(Project, fields=['display_name', 'name', 'description', 'public'])
|
||||
EditProjectForm = modelform_factory(Project, fields=['display_name', 'description', 'public'])
|
||||
LabelForm = modelform_factory(Label, fields=['name', 'color', 'inverted'])
|
||||
|
||||
AddProjectForm = modelform_factory(Project,
|
||||
fields=['display_name', 'name', 'description', 'public'])
|
||||
EditProjectForm = modelform_factory(Project,
|
||||
fields=['display_name', 'description', 'public'])
|
||||
LabelForm = modelform_factory(Label,
|
||||
fields=['name', 'color', 'inverted'])
|
||||
|
||||
|
||||
class MilestoneForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Milestone
|
||||
fields = ['name', 'due_date']
|
||||
widgets = {
|
||||
'due_date': DateTimePicker(format="YYYY-MM-DD HH:mm"),
|
||||
widgets = {
|
||||
'due_date': DateTimePicker(format="YYYY-MM-DD HH:mm"),
|
||||
}
|
||||
|
||||
|
||||
class IssueForm(forms.Form):
|
||||
title = forms.CharField(max_length=128)
|
||||
description = forms.CharField(widget=MarkdownWidget, required=False)
|
||||
|
||||
|
||||
class CommentForm(forms.Form):
|
||||
comment = forms.CharField(widget=MarkdownWidget)
|
||||
|
||||
|
||||
class PermissionForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
|
@ -37,7 +45,7 @@ class PermissionForm(forms.ModelForm):
|
|||
|
||||
data = super(PermissionForm, self).clean()
|
||||
|
||||
if not 'grantee_name' in data or not 'grantee_type' in data:
|
||||
if 'grantee_name' not in data or 'grantee_type' not in data:
|
||||
# a field required error will be printed so we dont care
|
||||
return data
|
||||
|
||||
|
@ -45,22 +53,24 @@ class PermissionForm(forms.ModelForm):
|
|||
|
||||
if int(data['grantee_type']) == PermissionModel.GRANTEE_USER:
|
||||
if not User.objects.filter(username=name).exists():
|
||||
raise ValidationError("User '%s' does not exists." %name)
|
||||
raise ValidationError("User '%s' does not exists." % name)
|
||||
elif int(data['grantee_type']) == PermissionModel.GRANTEE_GROUP:
|
||||
if not Group.objects.filter(name=name).exists():
|
||||
raise ValidationError("Group '%s' does not exists." %name)
|
||||
raise ValidationError("Group '%s' does not exists." % name)
|
||||
elif int(data['grantee_type']) == PermissionModel.GRANTEE_TEAM:
|
||||
if not Team.objects.filter(name=name).exists():
|
||||
raise ValidationError("Team '%s' does not exists." %name)
|
||||
raise ValidationError("Team '%s' does not exists." % name)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
class GlobalPermissionForm(PermissionForm):
|
||||
|
||||
class Meta:
|
||||
model = GlobalPermission
|
||||
exclude = []
|
||||
|
||||
|
||||
class ProjectPermissionForm(PermissionForm):
|
||||
|
||||
class Meta:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue