~pjdc/offspring/fix-username-determination

« back to all changes in this revision

Viewing changes to lib/offspring/web/queuemanager/forms.py

  • Committer: Michael Hudson
  • Date: 2011-03-24 21:30:51 UTC
  • mfrom: (13.1.47 offspring)
  • Revision ID: michael.hudson@linaro.org-20110324213051-hmdnv5ivc27s63p6
merge the rest of trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
from django.db import models
5
 
from django.forms import ModelForm
 
5
from django.forms import ModelChoiceField, ModelForm, Textarea, TextInput
6
6
from django.forms import fields
7
7
 
8
8
from offspring.web.queuemanager.models import (
9
9
    Project,
10
 
    Release
 
10
    Release,
 
11
    LaunchpadProject
11
12
)
12
13
 
 
14
from offspring.web.queuemanager.widgets import SelectWithAddNew
13
15
 
14
 
class ProjectForm(ModelForm):
 
16
class ProjectBaseForm(ModelForm):
15
17
    status = fields.CharField(max_length=200,
16
18
        widget=fields.Select(choices=Project.STATUS_CHOICES), required=True)
 
19
 
17
20
    class Meta:
18
21
        model = Project
19
 
        exclude = ('name', 'arch', 'priority', 'is_active', 'config_url')
 
22
        widgets = {
 
23
            'name' : TextInput(attrs={'style': 'text-transform: lowercase;'}),
 
24
            'series' : TextInput(attrs={'style': 'text-transform: lowercase;'}),
 
25
            'config_url': TextInput(attrs={'size': 50}),
 
26
            'notes' : Textarea(attrs={'cols': 73, 'rows' : 4}),
 
27
        }
 
28
 
 
29
    def clean_name(self):
 
30
        return self.cleaned_data['name'].lower()
 
31
 
 
32
    def clean_series(self):
 
33
        return self.cleaned_data['series'].lower()
 
34
 
 
35
 
 
36
class CreateProjectForm(ProjectBaseForm):
 
37
    launchpad_project = ModelChoiceField(
 
38
        LaunchpadProject.objects, widget=SelectWithAddNew, required=False)
 
39
    class Meta(ProjectBaseForm.Meta):
 
40
        exclude = ('priority', 'is_active', 'suite')
 
41
 
 
42
 
 
43
class EditProjectForm(ProjectBaseForm):
 
44
    launchpad_project = ModelChoiceField(
 
45
        LaunchpadProject.objects, widget=SelectWithAddNew, required=False)
 
46
    class Meta(ProjectBaseForm.Meta):
 
47
        exclude = ('name', 'priority', 'is_active')
20
48
 
21
49
 
22
50
class ReleaseForm(ModelForm):
23
51
    class Meta:
24
52
        model = Release
25
53
        fields = ( 'name', 'milestone', 'tag', 'checklist_url', 'notes')
 
54
 
 
55
 
 
56
class LaunchpadProjectForm(ModelForm):
 
57
    class Meta:
 
58
        model = LaunchpadProject
 
59
        widgets = {
 
60
            'name' : TextInput(attrs={'style': 'text-transform: lowercase;'}),
 
61
        }
 
62
 
 
63
    def clean_name(self):
 
64
        return self.cleaned_data['name'].lower()