Merge lp:~ronnie.vd.c/ubuntu-elections/generic-names into lp:ubuntu-elections
- generic-names
- Merge into trunk
Proposed by
Ronnie
Status: | Merged |
---|---|
Merged at revision: | 32 |
Proposed branch: | lp:~ronnie.vd.c/ubuntu-elections/generic-names |
Merge into: | lp:ubuntu-elections |
Diff against target: |
468 lines (+194/-121) 8 files modified
media/css/voting.css (+0/-4) ubuntu_voting/elections/forms.py (+23/-49) ubuntu_voting/elections/migrations/0012_auto__add_field_election_candidature_amount__del_field_candidate_chair.py (+125/-0) ubuntu_voting/elections/models.py (+18/-46) ubuntu_voting/elections/views.py (+3/-10) ubuntu_voting/templates/election/election_detail.html (+8/-3) ubuntu_voting/templates/election/election_results.html (+4/-4) ubuntu_voting/templates/election/incl_election_item_results.html (+13/-5) |
To merge this branch: | bzr merge lp:~ronnie.vd.c/ubuntu-elections/generic-names |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Elections System Developers | Pending | ||
Review via email: mp+82817@code.launchpad.net |
Commit message
Description of the change
Used generic names instead of chair or council.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'media/css/voting.css' |
2 | --- media/css/voting.css 2011-11-19 16:19:35 +0000 |
3 | +++ media/css/voting.css 2011-11-20 11:21:23 +0000 |
4 | @@ -209,10 +209,6 @@ |
5 | padding: 0; |
6 | } |
7 | |
8 | -/* Election details */ |
9 | -ul#chaircandidateslist li, ul#councilcandidateslist li { list-style: none; margin-bottom: 15px; } |
10 | -ul#chaircandidateslist li li, ul#councilcandidateslist li li { list-style: disc; margin-bottom: 5px; margin-left: 15px; } |
11 | - |
12 | /* Tooltip CSS */ |
13 | .ubuntu .pointyTip{ border-top-color:#DD4814;} |
14 | .ubuntu .pointyTipShadow{ border-top-color:#DD4814;} |
15 | |
16 | === modified file 'ubuntu_voting/elections/forms.py' |
17 | --- ubuntu_voting/elections/forms.py 2011-11-19 16:19:35 +0000 |
18 | +++ ubuntu_voting/elections/forms.py 2011-11-20 11:21:23 +0000 |
19 | @@ -1,5 +1,6 @@ |
20 | from django import forms |
21 | from django.template.defaultfilters import slugify |
22 | +from django.utils.translation import ugettext as _ |
23 | |
24 | from common.forms import RenderableMixin |
25 | from common.widgets import SplitDateTimeWidget |
26 | @@ -56,51 +57,36 @@ |
27 | class ApplyForElectionForm(forms.ModelForm, RenderableMixin): |
28 | class Meta: |
29 | model = Candidate |
30 | - fields = ('council_desired', 'motivation')#'chair_desired', |
31 | - |
32 | - def __init__(self, *args, **kwargs): |
33 | - super(ApplyForElectionForm, self).__init__(*args, **kwargs) |
34 | - self.initial['council_desired'] = True |
35 | + fields = ('motivation',) |
36 | |
37 | |
38 | class VoteForm(forms.Form, RenderableMixin): |
39 | - #chair = forms.ModelChoiceField(label='Voorzitter', queryset=Candidate.objects.all()) |
40 | - council1 = forms.ModelChoiceField(label='Gemeenschapsraad 1e keuze', help_text='Deze persoon krijgt 6 punten', queryset=Candidate.objects.all()) |
41 | - council2 = forms.ModelChoiceField(label='Gemeenschapsraad 2e keuze', help_text='Deze persoon krijgt 5 punten', queryset=Candidate.objects.all()) |
42 | - #council3 = forms.ModelChoiceField(label='Gemeenschapsraad 3e keuze', help_text='Deze persoon krijgt 4 punten', queryset=Candidate.objects.all()) |
43 | - #council4 = forms.ModelChoiceField(label='Gemeenschapsraad 4e keuze', help_text='Deze persoon krijgt 3 punten', queryset=Candidate.objects.all()) |
44 | - #council5 = forms.ModelChoiceField(label='Gemeenschapsraad 5e keuze', help_text='Deze persoon krijgt 2 punten', queryset=Candidate.objects.all()) |
45 | - #council6 = forms.ModelChoiceField(label='Gemeenschapsraad 6e keuze', help_text='Deze persoon krijgt 1 punten', queryset=Candidate.objects.all()) |
46 | - |
47 | def __init__(self, election, *args, **kwargs): |
48 | super(VoteForm, self).__init__(*args, **kwargs) |
49 | - #chair_choices = Candidate.objects.filter(election=election, chair_desired=True) |
50 | - council_choices = Candidate.objects.filter(election=election, council_desired=True) |
51 | - #self.fields['chair'].queryset = chair_choices |
52 | - self.fields['council1'].queryset = council_choices |
53 | - self.fields['council2'].queryset = council_choices |
54 | - #self.fields['council3'].queryset = council_choices |
55 | - #self.fields['council4'].queryset = council_choices |
56 | - #self.fields['council5'].queryset = council_choices |
57 | - #self.fields['council6'].queryset = council_choices |
58 | + |
59 | + self.election = election |
60 | + |
61 | + candidate_choices = Candidate.objects.filter(election=election) |
62 | + for i in range(election.candidature_amount): |
63 | + self.fields['candidate%d' % i] = forms.ModelChoiceField( |
64 | + label=_('Choice %d') % (i + 1), |
65 | + help_text=_('This person receives %d points' % (len(candidate_choices) - i)), |
66 | + queryset=candidate_choices) |
67 | + |
68 | + |
69 | |
70 | def clean(self, *args, **kwargs): |
71 | cleaned_data = self.cleaned_data |
72 | |
73 | - council = [cleaned_data.get('council1'), |
74 | - cleaned_data.get('council2'),] |
75 | - #cleaned_data.get('council3'), |
76 | - #cleaned_data.get('council4'), |
77 | - #cleaned_data.get('council5'), |
78 | - #cleaned_data.get('council6')] |
79 | - council.reverse() |
80 | + candidates = [cleaned_data.get('candidates%d' % i) for i in range(self.election.candidature_amount)] |
81 | + candidates.reverse() |
82 | |
83 | - for candidate in council: |
84 | - if candidate is not None and council.count(candidate) > 1: |
85 | - for same in range(council.count(candidate) - 1): |
86 | - index = council.index(candidate) |
87 | - self._errors['council%d' % (len(council)-index)] = self.error_class(['Je hebt deze persoon al gekozen']) |
88 | - council.pop(index) |
89 | + for candidate in candidates: |
90 | + if candidate is not None and candidates.count(candidate) > 1: |
91 | + for same in range(candidates.count(candidate) - 1): |
92 | + index = candidates.index(candidate) |
93 | + self._errors['candidate%d' % (len(candidates)-index)] = self.error_class([_('Je hebt deze persoon al gekozen')]) |
94 | + candidates.pop(index) |
95 | |
96 | # Always return the full collection of cleaned data. |
97 | return cleaned_data |
98 | @@ -109,24 +95,12 @@ |
99 | def save(self, *args, **kwargs): |
100 | cleaned_data = self.cleaned_data |
101 | |
102 | - votes = [cleaned_data.get('council1'), |
103 | - cleaned_data.get('council2'),] |
104 | - #cleaned_data.get('council3'), |
105 | - #cleaned_data.get('council4'), |
106 | - #cleaned_data.get('council5'), |
107 | - #cleaned_data.get('council6')] |
108 | + votes = [cleaned_data.get('candidate%d' % i) for i in range(self.election.candidature_amount)] |
109 | |
110 | for c in range(len(votes)): |
111 | candidate = votes[c] |
112 | - candidate.council_votes += len(votes) - c |
113 | + candidate.votes += len(votes) - c |
114 | candidate.save() |
115 | |
116 | - #chair = cleaned_data.get('chair') |
117 | - #if chair in votes: # If the chair is in the votes, the new version is not stored in cleaned_data, so use the database version |
118 | - # chair = Candidate.objects.get(pk=cleaned_data.get('chair').pk) |
119 | - # |
120 | - #chair.chair_votes += 1 |
121 | - #chair.save() |
122 | - |
123 | return True |
124 | |
125 | |
126 | === added file 'ubuntu_voting/elections/migrations/0012_auto__add_field_election_candidature_amount__del_field_candidate_chair.py' |
127 | --- ubuntu_voting/elections/migrations/0012_auto__add_field_election_candidature_amount__del_field_candidate_chair.py 1970-01-01 00:00:00 +0000 |
128 | +++ ubuntu_voting/elections/migrations/0012_auto__add_field_election_candidature_amount__del_field_candidate_chair.py 2011-11-20 11:21:23 +0000 |
129 | @@ -0,0 +1,125 @@ |
130 | +# encoding: utf-8 |
131 | +import datetime |
132 | +from south.db import db |
133 | +from south.v2 import SchemaMigration |
134 | +from django.db import models |
135 | + |
136 | +class Migration(SchemaMigration): |
137 | + |
138 | + def forwards(self, orm): |
139 | + |
140 | + # Adding field 'Election.candidature_amount' |
141 | + db.add_column('elections_election', 'candidature_amount', self.gf('django.db.models.fields.IntegerField')(default=1), keep_default=False) |
142 | + |
143 | + # Deleting field 'Candidate.chair_votes' |
144 | + db.delete_column('elections_candidate', 'chair_votes') |
145 | + |
146 | + # Deleting field 'Candidate.council_votes' |
147 | + db.delete_column('elections_candidate', 'council_votes') |
148 | + |
149 | + # Deleting field 'Candidate.chair_desired' |
150 | + db.delete_column('elections_candidate', 'chair_desired') |
151 | + |
152 | + # Deleting field 'Candidate.council_desired' |
153 | + db.delete_column('elections_candidate', 'council_desired') |
154 | + |
155 | + # Adding field 'Candidate.votes' |
156 | + db.add_column('elections_candidate', 'votes', self.gf('django.db.models.fields.IntegerField')(default=0), keep_default=False) |
157 | + |
158 | + |
159 | + def backwards(self, orm): |
160 | + |
161 | + # Deleting field 'Election.candidature_amount' |
162 | + db.delete_column('elections_election', 'candidature_amount') |
163 | + |
164 | + # Adding field 'Candidate.chair_votes' |
165 | + db.add_column('elections_candidate', 'chair_votes', self.gf('django.db.models.fields.IntegerField')(default=0), keep_default=False) |
166 | + |
167 | + # Adding field 'Candidate.council_votes' |
168 | + db.add_column('elections_candidate', 'council_votes', self.gf('django.db.models.fields.IntegerField')(default=0), keep_default=False) |
169 | + |
170 | + # Adding field 'Candidate.chair_desired' |
171 | + db.add_column('elections_candidate', 'chair_desired', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) |
172 | + |
173 | + # Adding field 'Candidate.council_desired' |
174 | + db.add_column('elections_candidate', 'council_desired', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) |
175 | + |
176 | + # Deleting field 'Candidate.votes' |
177 | + db.delete_column('elections_candidate', 'votes') |
178 | + |
179 | + |
180 | + models = { |
181 | + 'auth.group': { |
182 | + 'Meta': {'object_name': 'Group'}, |
183 | + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
184 | + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), |
185 | + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) |
186 | + }, |
187 | + 'auth.permission': { |
188 | + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, |
189 | + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), |
190 | + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), |
191 | + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
192 | + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) |
193 | + }, |
194 | + 'auth.user': { |
195 | + 'Meta': {'object_name': 'User'}, |
196 | + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), |
197 | + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), |
198 | + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), |
199 | + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), |
200 | + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
201 | + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), |
202 | + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), |
203 | + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), |
204 | + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), |
205 | + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), |
206 | + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), |
207 | + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), |
208 | + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) |
209 | + }, |
210 | + 'contenttypes.contenttype': { |
211 | + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, |
212 | + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), |
213 | + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
214 | + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), |
215 | + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) |
216 | + }, |
217 | + 'elections.candidate': { |
218 | + 'Meta': {'ordering': "['display_name']", 'unique_together': "(('user', 'election'),)", 'object_name': 'Candidate'}, |
219 | + 'display_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}), |
220 | + 'election': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['elections.Election']"}), |
221 | + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
222 | + 'lp_profile': ('django.db.models.fields.URLField', [], {'max_length': '200'}), |
223 | + 'motivation': ('tinymce.models.HTMLField', [], {}), |
224 | + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), |
225 | + 'votes': ('django.db.models.fields.IntegerField', [], {'default': '0'}) |
226 | + }, |
227 | + 'elections.election': { |
228 | + 'Meta': {'ordering': "['candidature_start', 'election_start', 'election_end', 'name']", 'object_name': 'Election'}, |
229 | + 'candidature_amount': ('django.db.models.fields.IntegerField', [], {'default': '1'}), |
230 | + 'candidature_end': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2011, 12, 17, 23, 6, 4, 560633)'}), |
231 | + 'candidature_start': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2011, 11, 19, 23, 6, 4, 560584)'}), |
232 | + 'description': ('tinymce.models.HTMLField', [], {}), |
233 | + 'election_end': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2011, 12, 24, 23, 6, 4, 560723)'}), |
234 | + 'election_start': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2011, 12, 17, 23, 6, 4, 560682)'}), |
235 | + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
236 | + 'live_results': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), |
237 | + 'name': ('django.db.models.fields.CharField', [], {'default': "u'Election'", 'max_length': '128'}), |
238 | + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '128', 'db_index': 'True'}) |
239 | + }, |
240 | + 'elections.office': { |
241 | + 'Meta': {'object_name': 'Office'}, |
242 | + 'description': ('tinymce.models.HTMLField', [], {}), |
243 | + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
244 | + 'office': ('django.db.models.fields.CharField', [], {'max_length': '128'}) |
245 | + }, |
246 | + 'elections.voter': { |
247 | + 'Meta': {'unique_together': "(('voter', 'election'),)", 'object_name': 'Voter'}, |
248 | + 'election': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['elections.Election']"}), |
249 | + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
250 | + 'voter': ('django.db.models.fields.CharField', [], {'max_length': '250'}) |
251 | + } |
252 | + } |
253 | + |
254 | + complete_apps = ['elections'] |
255 | |
256 | === modified file 'ubuntu_voting/elections/models.py' |
257 | --- ubuntu_voting/elections/models.py 2011-11-19 16:19:35 +0000 |
258 | +++ ubuntu_voting/elections/models.py 2011-11-20 11:21:23 +0000 |
259 | @@ -16,6 +16,7 @@ |
260 | name = models.CharField(verbose_name=_('Title of the election'), max_length=128, default=_('Election'), help_text=_('The title of the election')) |
261 | slug = models.SlugField(verbose_name=_('Slug'), max_length=128, unique=True, help_text=_('Slug is a newspaper term. A slug is a short label for something, containing only letters, numbers, underscores or hyphens')) |
262 | description = HTMLField(verbose_name=_('Description of the election'), help_text=_('Describe the election')) |
263 | + candidature_amount = models.IntegerField(verbose_name=_('Amount of candidates'), default=1, help_text=_('The minimum amount of candidates to start the election')) |
264 | candidature_start = models.DateTimeField(verbose_name=_('Start candidature'), default=datetime.datetime.now(), help_text=_('On this date the candidature starts')) |
265 | candidature_end = models.DateTimeField(verbose_name=_('End candidature'), default=datetime.datetime.now()+datetime.timedelta(days=28), help_text=_('On this date the candidature ends')) |
266 | election_start = models.DateTimeField(verbose_name=_('Start election'), default=datetime.datetime.now()+datetime.timedelta(days=28), help_text=_('On this date the election starts')) |
267 | @@ -63,20 +64,14 @@ |
268 | def is_results(self): |
269 | return self.is_election_end() or (self.is_election_start() and self.live_results) |
270 | |
271 | - def get_chair_candidates(self): |
272 | - return Candidate.objects.filter(election=self, chair_desired=True) |
273 | - |
274 | - def get_council_candidates(self): |
275 | - return Candidate.objects.filter(election=self, council_desired=True) |
276 | - |
277 | - def total_chair_votes(self): |
278 | - return self.get_chair_candidates().aggregate(models.Sum('chair_votes'))['chair_votes__sum'] |
279 | - |
280 | - def total_council_votes(self): |
281 | - return self.get_council_candidates().aggregate(models.Sum('council_votes'))['council_votes__sum'] |
282 | - |
283 | - def top_council(self): |
284 | - return Candidate.objects.filter(election=self, council_desired=True).order_by('-council_votes')[:10] |
285 | + def get_candidates(self): |
286 | + return Candidate.objects.filter(election=self) |
287 | + |
288 | + def total_votes(self): |
289 | + return self.get_candidates().aggregate(models.Sum('votes'))['votes__sum'] |
290 | + |
291 | + def top(self): |
292 | + return Candidate.objects.filter(election=self).order_by('-votes')[:10] |
293 | |
294 | class Meta: |
295 | verbose_name = 'election' |
296 | @@ -94,10 +89,7 @@ |
297 | display_name = models.CharField(verbose_name=_('Name of the candidate'), max_length=20, editable=False) |
298 | lp_profile = models.URLField(verbose_name=_('The Launchpad profile of the candidate'), editable=False) |
299 | motivation = HTMLField(verbose_name=_('Motivation of the candidate'), help_text=_('Give a motivation why people should vote on you')) |
300 | - chair_desired = models.BooleanField(verbose_name=_('Run for Chair'), default=False) |
301 | - council_desired = models.BooleanField(verbose_name=_('Run for the Community Council'), default=False) |
302 | - chair_votes = models.IntegerField(default=0) |
303 | - council_votes = models.IntegerField(default=0) # 6 for first choice, 1 for 6th choice |
304 | + votes = models.IntegerField(default=0) # 6 for first choice, 1 for 6th choice |
305 | |
306 | class Meta: |
307 | verbose_name = 'candidate' |
308 | @@ -111,35 +103,15 @@ |
309 | def __unicode__(self): |
310 | return self.user.get_full_name() or self.user.username |
311 | |
312 | - def relative_chair_percentage(self): |
313 | - return self.chair_votes * 100 / Candidate.objects.filter(election=self.election, |
314 | - chair_desired=True).order_by('-chair_votes')[0].chair_votes |
315 | - |
316 | - def relative_council_percentage(self): |
317 | - return self.council_votes * 100 / Candidate.objects.filter(election=self.election, |
318 | - council_desired=True).order_by('-council_votes')[0].council_votes |
319 | + def relative_percentage(self): |
320 | + return self.votes * 100 / Candidate.objects.filter(election=self.election).order_by('-votes')[0].votes |
321 | |
322 | - def chair_percentage(self): |
323 | - return self.chair_votes * 100 / self.election.total_chair_votes() |
324 | - |
325 | - def council_percentage(self): |
326 | - return self.council_votes * 100 / self.election.total_council_votes() |
327 | - |
328 | - def is_chair(self): |
329 | - best_chair_results = Candidate.objects.filter(election=self.election, chair_desired=True).order_by('-chair_votes')[0].chair_votes |
330 | - difference = best_chair_results - self.chair_votes |
331 | - if difference <= 0: |
332 | - return 1 |
333 | - else: |
334 | - return 0 |
335 | - |
336 | - def is_council(self): |
337 | - sixth_chair_results = Candidate.objects.filter(election=self.election, council_desired=True).order_by('-council_votes')[1].council_votes |
338 | - difference = sixth_chair_results - self.council_votes |
339 | - if difference > 0: |
340 | - return 0 |
341 | - else: |
342 | - return 1 |
343 | + def percentage(self): |
344 | + return self.votes * 100 / self.election.total_votes() |
345 | + |
346 | + def chosen(self): |
347 | + last_chosen_votes = self.election.candidate_set.order_by('-votes')[self.election.candidature_amount - 1].votes |
348 | + return int(self.votes >= last_chosen_votes) |
349 | |
350 | class Office(models.Model): |
351 | office = models.CharField(verbose_name=_('Title of office'), max_length=128, help_text=_('The title of an office people can run for')) |
352 | |
353 | === modified file 'ubuntu_voting/elections/views.py' |
354 | --- ubuntu_voting/elections/views.py 2011-11-19 16:19:35 +0000 |
355 | +++ ubuntu_voting/elections/views.py 2011-11-20 11:21:23 +0000 |
356 | @@ -97,10 +97,7 @@ |
357 | if datetime.datetime.now() > election.election_end: |
358 | messages.error(request, _('The election has ended already')) |
359 | return redirect(election_detail, slug=election.slug) |
360 | - #if len(Candidate.objects.filter(election=election, chair_desired=True)) < 1: |
361 | - # messages.error(request, _('There aren\'t enough candidates running for Chair to let the elections begin')) |
362 | - # return redirect(election_detail, electionId=election.pk, electionName=election.name) |
363 | - if len(Candidate.objects.filter(election=election, council_desired=True)) < 2: |
364 | + if len(Candidate.objects.filter(election=election)) < election.candidature_amount: |
365 | messages.error(request, _('There aren\'t enough candidates running for the Community Council to let the elections begin')) |
366 | return redirect(election_detail, slug=election.slug) |
367 | |
368 | @@ -122,7 +119,7 @@ |
369 | return redirect(election_detail, slug=election.slug) |
370 | |
371 | form = VoteForm(data=request.POST or None, election=election) |
372 | - |
373 | + print form.fields |
374 | if request.POST and form.is_valid(): |
375 | form.save() |
376 | Voter.objects.create(election=election, voter=user_hash.hexdigest()) |
377 | @@ -146,10 +143,6 @@ |
378 | messages.error(request, _('The results will be visible after the vote has finished, on %(date)s.') % election.election_end) |
379 | return redirect(election_detail, slug=election.slug) |
380 | |
381 | - #top_chairs = Candidate.objects.filter(election=election, chair_desired=True).order_by('-chair_votes')[:5] |
382 | - top_council = Candidate.objects.filter(election=election, council_desired=True).order_by('-council_votes')[:10] |
383 | - return direct_to_template(request, 'election/election_results.html', {#'chairs': top_chairs, |
384 | - 'council': top_council, |
385 | - 'election': election,}) |
386 | + return direct_to_template(request, 'election/election_results.html', {'election': election,}) |
387 | |
388 | |
389 | |
390 | === modified file 'ubuntu_voting/templates/election/election_detail.html' |
391 | --- ubuntu_voting/templates/election/election_detail.html 2011-11-19 16:19:35 +0000 |
392 | +++ ubuntu_voting/templates/election/election_detail.html 2011-11-20 11:21:23 +0000 |
393 | @@ -3,13 +3,18 @@ |
394 | |
395 | {% block election_content %} |
396 | {% include election.template %} |
397 | + |
398 | + {% if election.is_election_start and election.live_results %} |
399 | + {% include 'election/incl_election_item_results.html' %} |
400 | + {% endif %} |
401 | + |
402 | {% if election.is_candidature_start %} |
403 | <article class="content content-medium content-left"> |
404 | <div class="content-inner"> |
405 | <h3>{% trans 'Candidates' %}</h3> |
406 | - {% if election.get_council_candidates %} |
407 | - <ul id="councilcandidateslist"> |
408 | - {% for candidate in election.get_council_candidates %} |
409 | + {% if election.get_candidates %} |
410 | + <ul id="candidate-list"> |
411 | + {% for candidate in election.get_candidates %} |
412 | <li><a rel="external" title="{% blocktrans with candidate.display_name as candidate_name %}{{ candidate_name }} in Launchpad{% endblocktrans %}" href="{{ candidate.lp_profile }}" style="font-size:1.3em;">{{ candidate.display_name }}</a><br/>{% autoescape off %}{{ candidate.motivation }}{% endautoescape %}</li> |
413 | {% endfor %} |
414 | </ul> |
415 | |
416 | === modified file 'ubuntu_voting/templates/election/election_results.html' |
417 | --- ubuntu_voting/templates/election/election_results.html 2011-11-19 16:19:35 +0000 |
418 | +++ ubuntu_voting/templates/election/election_results.html 2011-11-20 11:21:23 +0000 |
419 | @@ -6,15 +6,15 @@ |
420 | {% endblock %} |
421 | |
422 | {% block election_content %} |
423 | - {% include election.template %} |
424 | + {% include 'election/incl_election_item_results.html' %} |
425 | |
426 | {% if election.is_candidature_start %} |
427 | <article class="content content-medium content-left"> |
428 | <div class="content-inner"> |
429 | <h3>{% trans 'Candidates' %}</h3> |
430 | - {% if election.get_council_candidates %} |
431 | - <ul id="councilcandidateslist"> |
432 | - {% for candidate in election.get_council_candidates %} |
433 | + {% if election.get_candidates %} |
434 | + <ul id="candidate-list"> |
435 | + {% for candidate in election.get_candidates %} |
436 | <li><a rel="external" title="{% blocktrans with candidate.display_name as candidate_name %}{{ candidate_name }} in Launchpad{% endblocktrans %}" href="{{ candidate.lp_profile }}" style="font-size:1.3em;">{{ candidate.display_name }}</a><br/>{% autoescape off %}{{ candidate.motivation }}{% endautoescape %}</li> |
437 | {% endfor %} |
438 | </ul> |
439 | |
440 | === modified file 'ubuntu_voting/templates/election/incl_election_item_results.html' |
441 | --- ubuntu_voting/templates/election/incl_election_item_results.html 2011-11-19 16:19:35 +0000 |
442 | +++ ubuntu_voting/templates/election/incl_election_item_results.html 2011-11-20 11:21:23 +0000 |
443 | @@ -7,12 +7,20 @@ |
444 | {% block election_content %} |
445 | <section class="content content-medium content-left"> |
446 | <div class="content-inner"> |
447 | - <h2><a href="{% url election-detail slug=election.slug %}">{% blocktrans with election.name as election_name %}Results: {{ election_name }}{% endblocktrans %}<a></h2> |
448 | - <div id="council-results"> |
449 | - {% for candidate in election.top_council %} |
450 | + <h2> |
451 | + <a href="{% url election-detail slug=election.slug %}"> |
452 | + {% if election.is_election_end %} |
453 | + {% blocktrans with election.name as election_name %}Results: {{ election_name }}{% endblocktrans %} |
454 | + {% else %} |
455 | + {% blocktrans with election.name as election_name %}Interim results: {{ election_name }}{% endblocktrans %} |
456 | + {% endif %} |
457 | + <a> |
458 | + </h2> |
459 | + <div id="results"> |
460 | + {% for candidate in election.top %} |
461 | <div class="graph-item"> |
462 | - <hr class="graph-bar graph-bar-{{ candidate.is_council }}" style="width:{{ candidate.relative_council_percentage }}%;" /> |
463 | - <div class="graph-label graph-label-{{ candidate.is_council }}">{{ candidate }}<span class="result"> ({{ candidate.council_percentage }}%)</span></div> |
464 | + <hr class="graph-bar graph-bar-{{ candidate.chosen }}" style="width:{{ candidate.relative_percentage }}%;" /> |
465 | + <div class="graph-label graph-label-{{ candidate.chosen }}">{{ candidate }}<span class="result"> ({{ candidate.percentage }}%)</span></div> |
466 | </div> |
467 | {% endfor %} |
468 | </div> |