Merge lp:~ronnie.vd.c/ubuntu-elections/2-council into lp:ubuntu-elections
- 2-council
- Merge into trunk
Proposed by
Ronnie
Status: | Merged |
---|---|
Merged at revision: | 29 |
Proposed branch: | lp:~ronnie.vd.c/ubuntu-elections/2-council |
Merge into: | lp:ubuntu-elections |
Diff against target: |
260 lines (+52/-41) 9 files modified
INSTALL (+1/-1) ubuntu_voting/elections/forms.py (+32/-28) ubuntu_voting/elections/management/commands/bootstrap.py (+1/-1) ubuntu_voting/elections/models.py (+1/-1) ubuntu_voting/elections/views.py (+8/-8) ubuntu_voting/settings.py (+2/-1) ubuntu_voting/templates/election/election_detail.html (+2/-0) ubuntu_voting/templates/election/election_list.html (+3/-1) ubuntu_voting/templates/election/election_results.html (+2/-0) |
To merge this branch: | bzr merge lp:~ronnie.vd.c/ubuntu-elections/2-council |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sense Egbert Hofstede | Pending | ||
Review via email: mp+76456@code.launchpad.net |
Commit message
Description of the change
Limited to 2 council members for ubuntu-nl intermediate elections. Also disables chair.
To post a comment you must log in.
- 29. By Sense Egbert Hofstede
-
Merging Ronnies changes, updating translation template.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'INSTALL' |
2 | --- INSTALL 2011-04-02 15:41:46 +0000 |
3 | +++ INSTALL 2011-09-21 17:35:26 +0000 |
4 | @@ -10,7 +10,7 @@ |
5 | |
6 | Generally: |
7 | - sudo apt-get install python-django python-django-openid-auth python-django-south python-django-tinymce python-launchpadlib |
8 | - - cd voting |
9 | + - cd ubuntu_voting |
10 | |
11 | Manual: |
12 | - cp local_settings.py.sample local_settings.py |
13 | |
14 | === modified file 'ubuntu_voting/elections/forms.py' |
15 | --- ubuntu_voting/elections/forms.py 2011-04-02 15:41:46 +0000 |
16 | +++ ubuntu_voting/elections/forms.py 2011-09-21 17:35:26 +0000 |
17 | @@ -47,39 +47,43 @@ |
18 | class ApplyForElectionForm(forms.ModelForm, RenderableMixin): |
19 | class Meta: |
20 | model = Candidate |
21 | - fields = ('chair_desired', 'council_desired', 'motivation') |
22 | + fields = ('council_desired', 'motivation')#'chair_desired', |
23 | + |
24 | + def __init__(self, *args, **kwargs): |
25 | + super(ApplyForElectionForm, self).__init__(*args, **kwargs) |
26 | + self.initial['council_desired'] = True |
27 | |
28 | |
29 | class VoteForm(forms.Form, RenderableMixin): |
30 | - chair = forms.ModelChoiceField(label='Voorzitter', queryset=Candidate.objects.all()) |
31 | + #chair = forms.ModelChoiceField(label='Voorzitter', queryset=Candidate.objects.all()) |
32 | council1 = forms.ModelChoiceField(label='Gemeenschapsraad 1e keuze', help_text='Deze persoon krijgt 6 punten', queryset=Candidate.objects.all()) |
33 | council2 = forms.ModelChoiceField(label='Gemeenschapsraad 2e keuze', help_text='Deze persoon krijgt 5 punten', queryset=Candidate.objects.all()) |
34 | - council3 = forms.ModelChoiceField(label='Gemeenschapsraad 3e keuze', help_text='Deze persoon krijgt 4 punten', queryset=Candidate.objects.all()) |
35 | - council4 = forms.ModelChoiceField(label='Gemeenschapsraad 4e keuze', help_text='Deze persoon krijgt 3 punten', queryset=Candidate.objects.all()) |
36 | - council5 = forms.ModelChoiceField(label='Gemeenschapsraad 5e keuze', help_text='Deze persoon krijgt 2 punten', queryset=Candidate.objects.all()) |
37 | - council6 = forms.ModelChoiceField(label='Gemeenschapsraad 6e keuze', help_text='Deze persoon krijgt 1 punten', queryset=Candidate.objects.all()) |
38 | + #council3 = forms.ModelChoiceField(label='Gemeenschapsraad 3e keuze', help_text='Deze persoon krijgt 4 punten', queryset=Candidate.objects.all()) |
39 | + #council4 = forms.ModelChoiceField(label='Gemeenschapsraad 4e keuze', help_text='Deze persoon krijgt 3 punten', queryset=Candidate.objects.all()) |
40 | + #council5 = forms.ModelChoiceField(label='Gemeenschapsraad 5e keuze', help_text='Deze persoon krijgt 2 punten', queryset=Candidate.objects.all()) |
41 | + #council6 = forms.ModelChoiceField(label='Gemeenschapsraad 6e keuze', help_text='Deze persoon krijgt 1 punten', queryset=Candidate.objects.all()) |
42 | |
43 | def __init__(self, election, *args, **kwargs): |
44 | super(VoteForm, self).__init__(*args, **kwargs) |
45 | - chair_choices = Candidate.objects.filter(election=election, chair_desired=True) |
46 | + #chair_choices = Candidate.objects.filter(election=election, chair_desired=True) |
47 | council_choices = Candidate.objects.filter(election=election, council_desired=True) |
48 | - self.fields['chair'].queryset = chair_choices |
49 | + #self.fields['chair'].queryset = chair_choices |
50 | self.fields['council1'].queryset = council_choices |
51 | self.fields['council2'].queryset = council_choices |
52 | - self.fields['council3'].queryset = council_choices |
53 | - self.fields['council4'].queryset = council_choices |
54 | - self.fields['council5'].queryset = council_choices |
55 | - self.fields['council6'].queryset = council_choices |
56 | + #self.fields['council3'].queryset = council_choices |
57 | + #self.fields['council4'].queryset = council_choices |
58 | + #self.fields['council5'].queryset = council_choices |
59 | + #self.fields['council6'].queryset = council_choices |
60 | |
61 | def clean(self, *args, **kwargs): |
62 | cleaned_data = self.cleaned_data |
63 | |
64 | council = [cleaned_data.get('council1'), |
65 | - cleaned_data.get('council2'), |
66 | - cleaned_data.get('council3'), |
67 | - cleaned_data.get('council4'), |
68 | - cleaned_data.get('council5'), |
69 | - cleaned_data.get('council6')] |
70 | + cleaned_data.get('council2'),] |
71 | + #cleaned_data.get('council3'), |
72 | + #cleaned_data.get('council4'), |
73 | + #cleaned_data.get('council5'), |
74 | + #cleaned_data.get('council6')] |
75 | council.reverse() |
76 | |
77 | for candidate in council: |
78 | @@ -97,23 +101,23 @@ |
79 | cleaned_data = self.cleaned_data |
80 | |
81 | votes = [cleaned_data.get('council1'), |
82 | - cleaned_data.get('council2'), |
83 | - cleaned_data.get('council3'), |
84 | - cleaned_data.get('council4'), |
85 | - cleaned_data.get('council5'), |
86 | - cleaned_data.get('council6')] |
87 | + cleaned_data.get('council2'),] |
88 | + #cleaned_data.get('council3'), |
89 | + #cleaned_data.get('council4'), |
90 | + #cleaned_data.get('council5'), |
91 | + #cleaned_data.get('council6')] |
92 | |
93 | for c in range(len(votes)): |
94 | candidate = votes[c] |
95 | candidate.council_votes += len(votes) - c |
96 | candidate.save() |
97 | |
98 | - chair = cleaned_data.get('chair') |
99 | - 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 |
100 | - chair = Candidate.objects.get(pk=cleaned_data.get('chair').pk) |
101 | - |
102 | - chair.chair_votes += 1 |
103 | - chair.save() |
104 | + #chair = cleaned_data.get('chair') |
105 | + #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 |
106 | + # chair = Candidate.objects.get(pk=cleaned_data.get('chair').pk) |
107 | + # |
108 | + #chair.chair_votes += 1 |
109 | + #chair.save() |
110 | |
111 | return True |
112 | |
113 | |
114 | === modified file 'ubuntu_voting/elections/management/commands/bootstrap.py' |
115 | --- ubuntu_voting/elections/management/commands/bootstrap.py 2011-02-14 17:43:22 +0000 |
116 | +++ ubuntu_voting/elections/management/commands/bootstrap.py 2011-09-21 17:35:26 +0000 |
117 | @@ -13,7 +13,7 @@ |
118 | print '\nEdit local_settings.py, then press Return to continue' |
119 | raw_input('\n') |
120 | print 'getting ubuntu website theme' |
121 | - subprocess.call(['bzr', 'branch', 'lp:ubuntu-website/light-django-theme', 'ubuntu_light_theme']) |
122 | + subprocess.call(['bzr', 'branch', 'lp:ubuntu-community-webthemes/light-django-theme', 'ubuntu_light_theme']) |
123 | print 'setting up database' |
124 | subprocess.call(['./manage.py', 'syncdb', '--noinput']) |
125 | print 'doing migrations' |
126 | |
127 | === modified file 'ubuntu_voting/elections/models.py' |
128 | --- ubuntu_voting/elections/models.py 2011-04-02 17:11:31 +0000 |
129 | +++ ubuntu_voting/elections/models.py 2011-09-21 17:35:26 +0000 |
130 | @@ -119,7 +119,7 @@ |
131 | return 0 |
132 | |
133 | def is_council(self): |
134 | - sixth_chair_results = Candidate.objects.filter(election=self.election, council_desired=True).order_by('-council_votes')[5].council_votes |
135 | + sixth_chair_results = Candidate.objects.filter(election=self.election, council_desired=True).order_by('-council_votes')[1].council_votes |
136 | difference = sixth_chair_results - self.council_votes |
137 | if difference > 0: |
138 | return 0 |
139 | |
140 | === modified file 'ubuntu_voting/elections/views.py' |
141 | --- ubuntu_voting/elections/views.py 2011-04-02 15:41:46 +0000 |
142 | +++ ubuntu_voting/elections/views.py 2011-09-21 17:35:26 +0000 |
143 | @@ -94,13 +94,13 @@ |
144 | if datetime.datetime.now() > election.election_end: |
145 | messages.error(request, _('The election has ended already')) |
146 | return redirect(election_detail, electionId=election.pk, electionName=election.name) |
147 | - if len(Candidate.objects.filter(election=election, chair_desired=True)) < 1: |
148 | - messages.error(request, _('There aren\'t enough candidates running for Chair to let the elections begin')) |
149 | - return redirect(election_detail, electionId=election.pk, electionName=election.name) |
150 | - if len(Candidate.objects.filter(election=election, council_desired=True)) < 6: |
151 | + #if len(Candidate.objects.filter(election=election, chair_desired=True)) < 1: |
152 | + # messages.error(request, _('There aren\'t enough candidates running for Chair to let the elections begin')) |
153 | + # return redirect(election_detail, electionId=election.pk, electionName=election.name) |
154 | + if len(Candidate.objects.filter(election=election, council_desired=True)) < 2: |
155 | messages.error(request, _('There aren\'t enough candidates running for the Community Council to let the elections begin')) |
156 | return redirect(election_detail, electionId=election.pk, electionName=election.name) |
157 | - |
158 | + |
159 | # Do some extensive hashing of the voter's OpenID to prevent easy decryption |
160 | openid = UserOpenID.objects.get(user=request.user) |
161 | user_hash = hashlib.sha256(openid.claimed_id) |
162 | @@ -122,7 +122,7 @@ |
163 | |
164 | if request.POST and form.is_valid(): |
165 | form.save() |
166 | - Voter.objects.create(election=election, voter=user_hash) |
167 | + Voter.objects.create(election=election, voter=user_hash.hexdigest()) |
168 | messages.success(request, _('You\'ve voted successfully')) |
169 | return redirect(election_detail, electionId=election.pk, electionName=election.name) |
170 | |
171 | @@ -143,9 +143,9 @@ |
172 | messages.error(request, _('The results will be visible after the vote has finished, on %(date)s.') % election.election_end) |
173 | return redirect(election_detail, electionId=election.pk, electionName=election.name) |
174 | |
175 | - top_chairs = Candidate.objects.filter(election=election, chair_desired=True).order_by('-chair_votes')[:5] |
176 | + #top_chairs = Candidate.objects.filter(election=election, chair_desired=True).order_by('-chair_votes')[:5] |
177 | top_council = Candidate.objects.filter(election=election, council_desired=True).order_by('-council_votes')[:10] |
178 | - return direct_to_template(request, 'election/election_results.html', {'chairs': top_chairs, |
179 | + return direct_to_template(request, 'election/election_results.html', {#'chairs': top_chairs, |
180 | 'council': top_council, |
181 | 'election': election,}) |
182 | |
183 | |
184 | === modified file 'ubuntu_voting/settings.py' |
185 | --- ubuntu_voting/settings.py 2011-04-02 17:11:31 +0000 |
186 | +++ ubuntu_voting/settings.py 2011-09-21 17:35:26 +0000 |
187 | @@ -89,7 +89,8 @@ |
188 | ) |
189 | |
190 | TEMPLATE_CONTEXT_PROCESSORS = ( |
191 | - 'django.core.context_processors.auth', |
192 | + #'django.core.context_processors.auth', |
193 | + 'django.contrib.auth.context_processors.auth', |
194 | 'django.core.context_processors.debug', |
195 | 'django.core.context_processors.i18n', |
196 | 'django.core.context_processors.media', |
197 | |
198 | === modified file 'ubuntu_voting/templates/election/election_detail.html' |
199 | --- ubuntu_voting/templates/election/election_detail.html 2011-04-02 15:41:46 +0000 |
200 | +++ ubuntu_voting/templates/election/election_detail.html 2011-09-21 17:35:26 +0000 |
201 | @@ -28,6 +28,7 @@ |
202 | {% endif %} |
203 | </div> |
204 | {% if election.is_candidature_start %} |
205 | + {% comment %} |
206 | <div class="minor-content alone"> |
207 | <h3>Voorzitterskandidaten</h3> |
208 | {% if election.get_chair_candidates %} |
209 | @@ -40,6 +41,7 @@ |
210 | <strong>{% trans 'There are no candidates yet' %}</strong> |
211 | {% endif %} |
212 | </div> |
213 | + {% endcomment %} |
214 | <div class="minor-content alone"> |
215 | <h3>Gemeenschapsraadskandidaten</h3> |
216 | {% if election.get_council_candidates %} |
217 | |
218 | === modified file 'ubuntu_voting/templates/election/election_list.html' |
219 | --- ubuntu_voting/templates/election/election_list.html 2011-04-02 15:41:46 +0000 |
220 | +++ ubuntu_voting/templates/election/election_list.html 2011-09-21 17:35:26 +0000 |
221 | @@ -40,6 +40,7 @@ |
222 | {% endif %} |
223 | |
224 | {% if election.is_candidature_start %} |
225 | + {% comment %} |
226 | <div class="sub-content"> |
227 | <p> |
228 | Voorzitterskandidaten: |
229 | @@ -52,9 +53,10 @@ |
230 | {% endif %} |
231 | </p> |
232 | </div> |
233 | + {% endcomment %} |
234 | <div class="sub-content"> |
235 | <p> |
236 | - Gemeenschapsraadskandidaten: |
237 | + {% trans 'Community Council candidates:' %} |
238 | {% if election.get_council_candidates %} |
239 | {% for candidate in election.get_council_candidates %} |
240 | <a rel="external" title="{% blocktrans with candidate.display_name as candidate_name %}{{ candidate_name }} in Launchpad{% endblocktrans %}" href="{{ candidate.lp_profile }}">{{ candidate.display_name }}</a><br/> |
241 | |
242 | === modified file 'ubuntu_voting/templates/election/election_results.html' |
243 | --- ubuntu_voting/templates/election/election_results.html 2011-04-02 15:41:46 +0000 |
244 | +++ ubuntu_voting/templates/election/election_results.html 2011-09-21 17:35:26 +0000 |
245 | @@ -6,6 +6,7 @@ |
246 | {% endblock %} |
247 | |
248 | {% block content %} |
249 | + {% comment %} |
250 | <section class="minor-content alone"> |
251 | <h3>{% trans 'Results Chair' %}</h3> |
252 | <div id="council-results"> |
253 | @@ -17,6 +18,7 @@ |
254 | {% endfor %} |
255 | </div> |
256 | </section> |
257 | + {% endcomment %} |
258 | <section class="minor-content alone"> |
259 | <h3>{% trans 'Results Community Council' %}</h3> |
260 | <div id="council-results"> |