1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
'''
Created on Jun 24, 2010
@author: leifj
'''
from django import forms
from coip.apps.name.models import Name, Attribute, NameLink
from django.forms import fields
from django.forms.widgets import HiddenInput, CheckboxSelectMultiple
from form_utils.forms import BetterModelForm, BetterForm
class NameForm(forms.ModelForm):
class Meta:
model = Name
class AttributeForm(forms.ModelForm):
class Meta:
model = Attribute
class NameEditForm(BetterModelForm):
description = forms.CharField(widget=forms.Textarea(attrs={'cols': 60, 'rows': 6}))
class Meta:
model = Name
fields = ['short','description']
fieldsets = [('step1', {'fields': ['short', 'description'],
'legend': 'Describe your group',
'classes': ['step submit_step'],
'description': 'Provide a short and (optionally) longer description of your group..'})]
class NewNameForm(BetterModelForm):
description = forms.CharField(widget=forms.Textarea(attrs={'cols': 60, 'rows': 6}))
value = forms.CharField(label="Name")
class Meta:
model = Name
fields = ['value','short','description','type']
fieldsets = [('step1', {'fields': ['value'],
'legend': 'Step 1: Name your group',
'classes': ['step'],
'description': 'Provide a short identifier for your groups. Spaces are not allowed here.'}),
('step2', {'fields': ['short', 'description'],
'legend': 'Step 2: Describe your group',
'classes': ['step'],
'description': 'Provide a short and (optionally) longer description of your group..'}),
('step3', {'fields': ['type'],
'legend': 'Step 3 (optional): Advanced options',
'classes': ['step','submit_step'],
'description': 'Only set the type if you know what you are doing. You almost certainly do not need this.'})]
class NameDeleteForm(BetterForm):
recursive = fields.BooleanField(label="Also delete everything below this name?",required=False)
class Meta:
fieldsets = [('step1', {'fields': ['recursive'],
'legend': 'Confirm deletion of your group',
'classes': ['step'],
'description': 'This is a destructive operation - there is no way to recover your group once it has been deleted!'})]
class NameLinkForm(forms.ModelForm):
class Meta:
model = NameLink
fields = ['dst','type','data']
class NameLinkDeleteForm(forms.Form):
confirm = fields.BooleanField(label="Confirm")
class PermissionForm(forms.Form):
dst = fields.IntegerField(widget=HiddenInput)
subject = fields.CharField(min_length=1024)
permissions = fields.MultipleChoiceField(widget=CheckboxSelectMultiple,choices=[('r','read'),('w','write'),('l','list'),('i','insert'),('d','delete')])
|