1 from django import newforms as forms
2 from django.newforms.util import ErrorList
5 SPECIES_LIST = [#('--choose--', '--Choose--'),
6 ('hg18', 'Homo sapiens (Hg18)'),
7 ('Mm8', 'Mus musculus (Mm8)'),
8 ('arabv6', 'Arabadopsis Thaliana v6'),
9 ('other', 'Other species (Include in description)')]
12 class DivErrorList(ErrorList):
13 def __unicode__(self):
17 if not self: return u''
18 return u'<div class="errorlist">%s</div>' % (''.join([u'<div class="error">%s</div>' % e for e in self]))
22 class ConfigForm(forms.Form):
24 flow_cell_number = forms.CharField(min_length=2)
25 run_date = forms.DateTimeField()
26 advanced_run = forms.BooleanField(required=False)
27 read_length = forms.IntegerField(min_value=1, initial=32)
28 #eland_repeat = forms.BooleanField()
30 #needs a for loop or something to allow for n configurations
31 #analysis_type = forms.ChoiceField(choices=[('eland','eland')])
32 lane1_species = forms.ChoiceField(choices=SPECIES_LIST)
33 lane1_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
35 lane2_species = forms.ChoiceField(choices=SPECIES_LIST)
36 lane2_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
38 lane3_species = forms.ChoiceField(choices=SPECIES_LIST)
39 lane3_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
41 lane4_species = forms.ChoiceField(choices=SPECIES_LIST)
42 lane4_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
44 lane5_species = forms.ChoiceField(choices=SPECIES_LIST)
45 lane5_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
47 lane6_species = forms.ChoiceField(choices=SPECIES_LIST)
48 lane6_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
50 lane7_species = forms.ChoiceField(choices=SPECIES_LIST)
51 lane7_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
53 lane8_species = forms.ChoiceField(choices=SPECIES_LIST)
54 lane8_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
56 notes = forms.CharField(widget=forms.Textarea(attrs={'cols':'70'}), required=False)
58 #lane_specific_read_length = forms.IntegerField(min_value=1)
60 #eland_genome_lanes = forms.MultipleChoiceField(choices=[('lane1','1'),
69 #eland_genome = forms.ChoiceField(choices=)
71 #use_bases_lanes = forms.MultipleChoiceField(choices=[('lane1','1'),
80 #use_bases_mask = forms.CharField()
82 #sequence_format = forms.ChoiceField(choices=[('scarf', 'scarf')])
86 #subject = forms.CharField(max_length=100)
87 #message = forms.CharField()
88 #sender = forms.EmailField()
89 #cc_myself = forms.BooleanField()
93 Displays customized html output
97 fcn = self['flow_cell_number']
99 html.append(fcn.label_tag() + ': ' + str(fcn) + str(fcn.errors) + '<br />')
101 run_date = self['run_date']
102 html.append(run_date.label_tag() + ': ' + str(run_date) + str(run_date.errors) + '<br />')
104 arun = self['advanced_run']
105 html.append(arun.label_tag() + ': ' + str(arun) + str(arun.errors) + '<br />')
107 rl = self['read_length']
108 html.append(rl.label_tag() + ': ' + str(rl) + str(rl.errors) + '<br /><br />')
110 html.append('<table border="0">')
111 html.append(' <tr><td>%s</td><td>%s</td><td>%s</td></tr>' \
112 % ('Lane', 'Species', 'Description'))
114 l1s = self['lane1_species']
115 l1d = self['lane1_description']
116 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
117 % ('1', str(l1s), str(l1s.errors), str(l1d), str(l1d.errors)))
119 l2s = self['lane2_species']
120 l2d = self['lane2_description']
121 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
122 % ('2', str(l2s), str(l2s.errors), str(l2d), str(l2d.errors)))
124 l3s = self['lane3_species']
125 l3d = self['lane3_description']
126 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
127 % ('3', str(l3s), str(l3s.errors), str(l3d), str(l3d.errors)))
129 l4s = self['lane4_species']
130 l4d = self['lane4_description']
131 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
132 % ('4', str(l4s), str(l4s.errors), str(l4d), str(l4d.errors)))
134 l5s = self['lane5_species']
135 l5d = self['lane5_description']
136 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
137 % ('5', str(l5s), str(l5s.errors), str(l5d), str(l5d.errors)))
139 l6s = self['lane6_species']
140 l6d = self['lane6_description']
141 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
142 % ('6', str(l6s), str(l6s.errors), str(l6d), str(l6d.errors)))
144 l7s = self['lane7_species']
145 l7d = self['lane7_description']
146 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
147 % ('7', str(l7s), str(l7s.errors), str(l7d), str(l7d.errors)))
149 l8s = self['lane8_species']
150 l8d = self['lane8_description']
151 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
152 % ('8', str(l8s), str(l8s.errors), str(l8d), str(l8d.errors)))
154 html.append('</table><br />')
156 notes = self['notes']
157 html.append('<p>Notes:</p>')
158 html.append(' %s<br />' % (str(notes)))
160 return '\n'.join(html)