Parent: [e62ade] (diff)

Child: [fa6c78] (diff)

Download this file

ticket_form.py    50 lines (45 with data), 2.5 kB

 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
import tw.forms as twf
import ew
from pyforge.lib.widgets import form_fields as ffw
from pylons import c
from forgetracker import model
class TicketCustomFields(ew.CompoundField):
template='genshi:forgetracker.widgets.templates.ticket_custom_fields'
@property
def fields(self):
fields = []
for field in model.Globals.query.get(app_config_id=c.app.config._id).custom_fields:
if field.type != 'select' and field.type != 'boolean':
fields.append(ew.InputField(label=field.label, name=field.name, attrs={'class':"title wide"}))
elif field.type == 'boolean':
fields.append(ew.Checkbox(label=field.label, name=field.name, suppress_label=True, value=True))
else:
fields.append(ew.SingleSelectField(label=field.label, name=field.name, attrs={'class':"title wide"},
options=[ew.Option(label=opt,html_value=opt,py_value=opt) for opt in field.options.split()]))
return fields
class TicketForm(ew.SimpleForm):
template='genshi:forgetracker.widgets.templates.ticket_form'
submit_text='Save Ticket'
user_tags = []
params=['user_tags', 'submit_text']
def display_field_by_idx(self, idx):
return self.fields[idx].display(**c.widget.context_for(self.fields[idx].name))
@property
def fields(self):
fields = [
ew.InputField(name='summary', label='Name', attrs={'class':"title wide"}),
ffw.MarkdownEdit(label='Description',name='description'),
ew.SingleSelectField(name='status', label='Status', attrs={'class':"title wide"},
options=lambda: model.Globals.query.get(app_config_id=c.app.config._id).status_names.split()),
ffw.ProjectUserSelect(name='assigned_to', label='Assigned To'),
ew.SingleSelectField(name='milestone', label='Milestone', attrs={'class':"title wide"},
options=lambda: [ew.Option(label='None',html_value='',py_value='')] +
model.Globals.query.get(app_config_id=c.app.config._id).milestone_names.split()),
ffw.UserTagEdit(label='Tags',name='tags', className='title wide'),
ew.SubmitButton(label=self.submit_text,name='submit',
attrs={'class':"ui-button ui-widget ui-state-default ui-button-text-only"}),
ew.HiddenField(name='ticket_num'),
ew.HiddenField(name='super_id'),
TicketCustomFields(name="custom_fields")
]
return fields