Merge lp:~daker/loco-team-portal/fix.960695.common-app into lp:loco-team-portal
- fix.960695.common-app
- Merge into 0.2
Proposed by
Adnane Belmadiaf
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Chris Johnston | ||||
Approved revision: | 533 | ||||
Merged at revision: | 551 | ||||
Proposed branch: | lp:~daker/loco-team-portal/fix.960695.common-app | ||||
Merge into: | lp:loco-team-portal | ||||
Diff against target: |
704 lines (+128/-76) 11 files modified
loco_directory/common/context_processors.py (+14/-7) loco_directory/common/forms.py (+4/-3) loco_directory/common/launchpad.py (+1/-1) loco_directory/common/management/commands/recoverdata.py (+16/-16) loco_directory/common/mixins.py (+4/-5) loco_directory/common/shortcuts.py (+11/-8) loco_directory/common/templatetags/markup.py (+4/-1) loco_directory/common/templatetags/teams_tags.py (+2/-1) loco_directory/common/utils.py (+14/-11) loco_directory/common/views.py (+56/-21) loco_directory/common/widgets.py (+2/-2) |
||||
To merge this branch: | bzr merge lp:~daker/loco-team-portal/fix.960695.common-app | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Johnston | Approve | ||
Review via email: mp+108439@code.launchpad.net |
Commit message
* Fixed the common app coding style
Description of the change
To post a comment you must log in.
Revision history for this message
Chris Johnston (cjohnston) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'loco_directory/common/context_processors.py' | |||
2 | --- loco_directory/common/context_processors.py 2011-04-15 15:05:40 +0000 | |||
3 | +++ loco_directory/common/context_processors.py 2012-06-30 22:09:18 +0000 | |||
4 | @@ -4,14 +4,16 @@ | |||
5 | 4 | 4 | ||
6 | 5 | from django.conf import settings | 5 | from django.conf import settings |
7 | 6 | 6 | ||
8 | 7 | |||
9 | 7 | def loco_version(request): | 8 | def loco_version(request): |
10 | 8 | """ | 9 | """ |
12 | 9 | add the loco version to template context processor. | 10 | add the loco version to template context processor. |
13 | 10 | """ | 11 | """ |
15 | 11 | 12 | ||
16 | 12 | version = getattr(settings, 'VERSION_STRING', 'unknown') | 13 | version = getattr(settings, 'VERSION_STRING', 'unknown') |
17 | 13 | return {'loco_version': version} | 14 | return {'loco_version': version} |
18 | 14 | 15 | ||
19 | 16 | |||
20 | 15 | def google_api_key(request): | 17 | def google_api_key(request): |
21 | 16 | """ | 18 | """ |
22 | 17 | Return the Google API Key or "" if none is defined. | 19 | Return the Google API Key or "" if none is defined. |
23 | @@ -20,29 +22,34 @@ | |||
24 | 20 | google_api_key = getattr(settings, 'GOOGLE_API_KEY', '') | 22 | google_api_key = getattr(settings, 'GOOGLE_API_KEY', '') |
25 | 21 | return {'google_api_key': google_api_key} | 23 | return {'google_api_key': google_api_key} |
26 | 22 | 24 | ||
27 | 25 | |||
28 | 23 | def flickr_api_key(request): | 26 | def flickr_api_key(request): |
29 | 24 | """ | 27 | """ |
30 | 25 | Return the Flickr API Key or "" if none is defined. | 28 | Return the Flickr API Key or "" if none is defined. |
31 | 26 | """ | 29 | """ |
33 | 27 | 30 | ||
34 | 28 | flickr_api_key = getattr(settings, 'FLICKR_API_KEY', '') | 31 | flickr_api_key = getattr(settings, 'FLICKR_API_KEY', '') |
35 | 29 | return {'flickr_api_key': flickr_api_key} | 32 | return {'flickr_api_key': flickr_api_key} |
37 | 30 | 33 | ||
38 | 34 | |||
39 | 31 | def pixie_api_key(request): | 35 | def pixie_api_key(request): |
40 | 32 | """ | 36 | """ |
41 | 33 | Return the Pix.ie API Key or "" if none is defined. | 37 | Return the Pix.ie API Key or "" if none is defined. |
42 | 34 | """ | 38 | """ |
44 | 35 | 39 | ||
45 | 36 | pixie_api_key = getattr(settings, 'PIXIE_API_KEY', '') | 40 | pixie_api_key = getattr(settings, 'PIXIE_API_KEY', '') |
46 | 37 | return {'pixie_api_key': pixie_api_key} | 41 | return {'pixie_api_key': pixie_api_key} |
47 | 38 | 42 | ||
48 | 43 | |||
49 | 39 | def login_redirect(request): | 44 | def login_redirect(request): |
50 | 40 | return {'login_next': request.get_full_path()} | 45 | return {'login_next': request.get_full_path()} |
51 | 41 | 46 | ||
52 | 47 | |||
53 | 42 | def url_base(request): | 48 | def url_base(request): |
54 | 43 | url = request.get_full_path().split('/') | 49 | url = request.get_full_path().split('/') |
57 | 44 | return {'url_base': url[1]} | 50 | return {'url_base': url[1]} |
58 | 45 | 51 | ||
59 | 52 | |||
60 | 46 | def site_search(request): | 53 | def site_search(request): |
61 | 47 | from common.forms import SiteSearchForm | 54 | from common.forms import SiteSearchForm |
62 | 48 | search_form = SiteSearchForm(data=request.GET) | 55 | search_form = SiteSearchForm(data=request.GET) |
63 | 49 | 56 | ||
64 | === modified file 'loco_directory/common/forms.py' | |||
65 | --- loco_directory/common/forms.py 2010-11-20 17:25:50 +0000 | |||
66 | +++ loco_directory/common/forms.py 2012-06-30 22:09:18 +0000 | |||
67 | @@ -2,12 +2,13 @@ | |||
68 | 2 | from django import forms | 2 | from django import forms |
69 | 3 | from django.utils.translation import ugettext as _ | 3 | from django.utils.translation import ugettext as _ |
70 | 4 | 4 | ||
71 | 5 | |||
72 | 5 | # Taken from http://djangosnippets.org/snippets/1732/ | 6 | # Taken from http://djangosnippets.org/snippets/1732/ |
73 | 6 | class RenderableMixin(object): | 7 | class RenderableMixin(object): |
74 | 7 | """ | 8 | """ |
75 | 8 | Mixin to render forms from a predefined template | 9 | Mixin to render forms from a predefined template |
76 | 9 | """ | 10 | """ |
78 | 10 | 11 | ||
79 | 11 | @property | 12 | @property |
80 | 12 | def form_class_name(self): | 13 | def form_class_name(self): |
81 | 13 | return '.'.join([self.__module__, self.__class__.__name__.lower()]) | 14 | return '.'.join([self.__module__, self.__class__.__name__.lower()]) |
82 | @@ -23,7 +24,7 @@ | |||
83 | 23 | 24 | ||
84 | 24 | context_dict = dict( | 25 | context_dict = dict( |
85 | 25 | non_field_errors=self.non_field_errors(), | 26 | non_field_errors=self.non_field_errors(), |
87 | 26 | fields=[ forms.forms.BoundField(self, field, name) for name, field in self.fields.iteritems()], | 27 | fields=[forms.forms.BoundField(self, field, name) for name, field in self.fields.iteritems()], |
88 | 27 | errors=self.errors, | 28 | errors=self.errors, |
89 | 28 | data=self.data, | 29 | data=self.data, |
90 | 29 | form=self, | 30 | form=self, |
91 | @@ -40,6 +41,7 @@ | |||
92 | 40 | Context(context_dict) | 41 | Context(context_dict) |
93 | 41 | ) | 42 | ) |
94 | 42 | 43 | ||
95 | 44 | |||
96 | 43 | class SiteSearchForm(forms.Form): | 45 | class SiteSearchForm(forms.Form): |
97 | 44 | """ | 46 | """ |
98 | 45 | A Search form for the whole site | 47 | A Search form for the whole site |
99 | @@ -49,4 +51,3 @@ | |||
100 | 49 | def as_line(self): | 51 | def as_line(self): |
101 | 50 | "Returns this form rendered. Only the fields. Nothing else HTML." | 52 | "Returns this form rendered. Only the fields. Nothing else HTML." |
102 | 51 | return self._html_output(u'%(label)s %(errors)s%(field)s%(help_text)s', u'%s', '', u'%s', False) | 53 | return self._html_output(u'%(label)s %(errors)s%(field)s%(help_text)s', u'%s', '', u'%s', False) |
103 | 52 | |||
104 | 53 | 54 | ||
105 | === modified file 'loco_directory/common/launchpad.py' | |||
106 | --- loco_directory/common/launchpad.py 2012-06-20 11:02:00 +0000 | |||
107 | +++ loco_directory/common/launchpad.py 2012-06-30 22:09:18 +0000 | |||
108 | @@ -38,7 +38,7 @@ | |||
109 | 38 | if is_debug_user(user.username): | 38 | if is_debug_user(user.username): |
110 | 39 | return True | 39 | return True |
111 | 40 | if user.is_staff: | 40 | if user.is_staff: |
113 | 41 | return True | 41 | return True |
114 | 42 | lc_in_groups = user.groups.filter(name__exact='ubuntu-lococouncil') | 42 | lc_in_groups = user.groups.filter(name__exact='ubuntu-lococouncil') |
115 | 43 | return (lc_in_groups.count() == 1) | 43 | return (lc_in_groups.count() == 1) |
116 | 44 | 44 | ||
117 | 45 | 45 | ||
118 | === modified file 'loco_directory/common/management/commands/recoverdata.py' | |||
119 | --- loco_directory/common/management/commands/recoverdata.py 2011-08-30 19:24:24 +0000 | |||
120 | +++ loco_directory/common/management/commands/recoverdata.py 2012-06-30 22:09:18 +0000 | |||
121 | @@ -13,6 +13,7 @@ | |||
122 | 13 | from venues.models import * | 13 | from venues.models import * |
123 | 14 | from meetings.models import * | 14 | from meetings.models import * |
124 | 15 | 15 | ||
125 | 16 | |||
126 | 16 | class Command(BaseCommand): | 17 | class Command(BaseCommand): |
127 | 17 | args = 'dump_file' | 18 | args = 'dump_file' |
128 | 18 | help = 'Attempt to recover missing data from a json dump' | 19 | help = 'Attempt to recover missing data from a json dump' |
129 | @@ -22,13 +23,13 @@ | |||
130 | 22 | print "You must supply a dumpfile" | 23 | print "You must supply a dumpfile" |
131 | 23 | return | 24 | return |
132 | 24 | dumpfile = args[0] | 25 | dumpfile = args[0] |
134 | 25 | 26 | ||
135 | 26 | try: | 27 | try: |
136 | 27 | json = open(dumpfile) | 28 | json = open(dumpfile) |
137 | 28 | except: | 29 | except: |
138 | 29 | print "Unable to open %s" % dumpfile | 30 | print "Unable to open %s" % dumpfile |
139 | 30 | return | 31 | return |
141 | 31 | 32 | ||
142 | 32 | try: | 33 | try: |
143 | 33 | decoder = simplejson.JSONDecoder() | 34 | decoder = simplejson.JSONDecoder() |
144 | 34 | data = decoder.decode(json.read()) | 35 | data = decoder.decode(json.read()) |
145 | @@ -37,7 +38,7 @@ | |||
146 | 37 | return | 38 | return |
147 | 38 | finally: | 39 | finally: |
148 | 39 | json.close() | 40 | json.close() |
150 | 40 | 41 | ||
151 | 41 | print "Loading %s" % dumpfile | 42 | print "Loading %s" % dumpfile |
152 | 42 | users = dict() | 43 | users = dict() |
153 | 43 | profiles = dict() | 44 | profiles = dict() |
154 | @@ -46,11 +47,11 @@ | |||
155 | 46 | globalevents = dict() | 47 | globalevents = dict() |
156 | 47 | teamevents = dict() | 48 | teamevents = dict() |
157 | 48 | venues = dict() | 49 | venues = dict() |
159 | 49 | basemeetings=dict() | 50 | basemeetings = dict() |
160 | 50 | teammeetings = dict() | 51 | teammeetings = dict() |
161 | 51 | agendaitems = dict() | 52 | agendaitems = dict() |
162 | 52 | agendaitems_needparent = dict() | 53 | agendaitems_needparent = dict() |
164 | 53 | 54 | ||
165 | 54 | # first pass we can collect user, teams and venues | 55 | # first pass we can collect user, teams and venues |
166 | 55 | for record in data: | 56 | for record in data: |
167 | 56 | # recover users | 57 | # recover users |
168 | @@ -65,7 +66,7 @@ | |||
169 | 65 | ) | 66 | ) |
170 | 66 | if user_created: | 67 | if user_created: |
171 | 67 | print "Created User: %s" % users[record['pk']].username | 68 | print "Created User: %s" % users[record['pk']].username |
173 | 68 | 69 | ||
174 | 69 | # recover teams | 70 | # recover teams |
175 | 70 | if record['model'] == 'teams.team': | 71 | if record['model'] == 'teams.team': |
176 | 71 | # print "Checking team %s (%s)" % (record['fields']['name'], record['fields']['lp_name']) | 72 | # print "Checking team %s (%s)" % (record['fields']['name'], record['fields']['lp_name']) |
177 | @@ -111,12 +112,12 @@ | |||
178 | 111 | if record['model'] == 'events.baseevent': | 112 | if record['model'] == 'events.baseevent': |
179 | 112 | # print "Caching baseevent %s" % (record['fields']['name'],) | 113 | # print "Caching baseevent %s" % (record['fields']['name'],) |
180 | 113 | baseevents[record['pk']] = record['fields'] | 114 | baseevents[record['pk']] = record['fields'] |
182 | 114 | 115 | ||
183 | 115 | # save base meeting | 116 | # save base meeting |
184 | 116 | if record['model'] == 'meetings.basemeeting': | 117 | if record['model'] == 'meetings.basemeeting': |
185 | 117 | # print "Caching basemeeting %s" % (record['fields']['name'],) | 118 | # print "Caching basemeeting %s" % (record['fields']['name'],) |
186 | 118 | basemeetings[record['pk']] = record['fields'] | 119 | basemeetings[record['pk']] = record['fields'] |
188 | 119 | 120 | ||
189 | 120 | # recover userprofile | 121 | # recover userprofile |
190 | 121 | if record['model'] == 'userprofiles.userprofile': | 122 | if record['model'] == 'userprofiles.userprofile': |
191 | 122 | if record['fields']['user'] in users: | 123 | if record['fields']['user'] in users: |
192 | @@ -134,7 +135,6 @@ | |||
193 | 134 | else: | 135 | else: |
194 | 135 | print u"Failed to create missing userprofile, no such user: %s" % record['fields']['user'] | 136 | print u"Failed to create missing userprofile, no such user: %s" % record['fields']['user'] |
195 | 136 | 137 | ||
196 | 137 | |||
197 | 138 | # third pass we can collect global events and team meetings, using the | 138 | # third pass we can collect global events and team meetings, using the |
198 | 139 | # baseevent and basemeeting data cached in the previous pass | 139 | # baseevent and basemeeting data cached in the previous pass |
199 | 140 | for record in data: | 140 | for record in data: |
200 | @@ -170,7 +170,7 @@ | |||
201 | 170 | 'logs': basemeeting['logs'], | 170 | 'logs': basemeeting['logs'], |
202 | 171 | 'minutes': basemeeting['minutes'], | 171 | 'minutes': basemeeting['minutes'], |
203 | 172 | 'date_created': basemeeting['date_created'], | 172 | 'date_created': basemeeting['date_created'], |
205 | 173 | 'chair': profiles.get(basemeeting['chair'], None),#profile lookup | 173 | 'chair': profiles.get(basemeeting['chair'], None), # profile lookup |
206 | 174 | 'meeting_tz': record['fields']['meeting_tz'], | 174 | 'meeting_tz': record['fields']['meeting_tz'], |
207 | 175 | } | 175 | } |
208 | 176 | ) | 176 | ) |
209 | @@ -190,14 +190,14 @@ | |||
210 | 190 | name=baseevent['name'], | 190 | name=baseevent['name'], |
211 | 191 | date_begin=baseevent['date_begin'], | 191 | date_begin=baseevent['date_begin'], |
212 | 192 | date_end=baseevent['date_end'], | 192 | date_end=baseevent['date_end'], |
214 | 193 | venue=venues.get(record['fields']['venue'], None), #venue lookup | 193 | venue=venues.get(record['fields']['venue'], None), # venue lookup |
215 | 194 | channel=record['fields']['channel'], | 194 | channel=record['fields']['channel'], |
216 | 195 | defaults={ | 195 | defaults={ |
217 | 196 | 'description': baseevent['description'], | 196 | 'description': baseevent['description'], |
218 | 197 | 'announce': baseevent['announce'], | 197 | 'announce': baseevent['announce'], |
219 | 198 | 'date_created': baseevent['date_created'], | 198 | 'date_created': baseevent['date_created'], |
222 | 199 | 'contact': profiles.get(record['fields']['contact'], None), #profile lookup | 199 | 'contact': profiles.get(record['fields']['contact'], None), # profile lookup |
223 | 200 | 'global_event': globalevents.get(record['fields']['global_event'], None), #global event lookup | 200 | 'global_event': globalevents.get(record['fields']['global_event'], None), # global event lookup |
224 | 201 | 'registration': record['fields']['registration'], | 201 | 'registration': record['fields']['registration'], |
225 | 202 | } | 202 | } |
226 | 203 | ) | 203 | ) |
227 | @@ -219,7 +219,7 @@ | |||
228 | 219 | created_date=record['fields']['created_date'], | 219 | created_date=record['fields']['created_date'], |
229 | 220 | defaults={ | 220 | defaults={ |
230 | 221 | 'description': record['fields']['description'], | 221 | 'description': record['fields']['description'], |
232 | 222 | 'parent': None, #saved for later lookup, since they aren't ordered | 222 | 'parent': None, # saved for later lookup, since they aren't ordered |
233 | 223 | 'order': record['fields']['order'], | 223 | 'order': record['fields']['order'], |
234 | 224 | 'log': record['fields']['log'], | 224 | 'log': record['fields']['log'], |
235 | 225 | } | 225 | } |
236 | @@ -227,7 +227,7 @@ | |||
237 | 227 | if ai_created and record['fields']['parent']: | 227 | if ai_created and record['fields']['parent']: |
238 | 228 | agendaitems_needparent[record['pk']] = record['fields']['parent'] | 228 | agendaitems_needparent[record['pk']] = record['fields']['parent'] |
239 | 229 | print u"Created AgendaItem %s: %s" % (agendaitems[record['pk']].pk, unicode(agendaitems[record['pk']].title).encode('ascii', 'ignore')) | 229 | print u"Created AgendaItem %s: %s" % (agendaitems[record['pk']].pk, unicode(agendaitems[record['pk']].title).encode('ascii', 'ignore')) |
241 | 230 | 230 | ||
242 | 231 | # recover event attendee | 231 | # recover event attendee |
243 | 232 | if record['model'] == 'events.attendee': | 232 | if record['model'] == 'events.attendee': |
244 | 233 | if record['fields']['team_event'] in teamevents: | 233 | if record['fields']['team_event'] in teamevents: |
245 | @@ -259,7 +259,7 @@ | |||
246 | 259 | print u"Created TeamEvent Comment: %s on %s (%s)" % (comment.commenter_profile.user.username, unicode(comment.team_event.name).encode('ascii', 'ignore'), comment.team_event.pk) | 259 | print u"Created TeamEvent Comment: %s on %s (%s)" % (comment.commenter_profile.user.username, unicode(comment.team_event.name).encode('ascii', 'ignore'), comment.team_event.pk) |
247 | 260 | else: | 260 | else: |
248 | 261 | print u"Failed to create TeamEventComment, no such team event: %s" % record['fields']['team_event'] | 261 | print u"Failed to create TeamEventComment, no such team event: %s" % record['fields']['team_event'] |
250 | 262 | 262 | ||
251 | 263 | # after fifth pass, set agendaitem parents | 263 | # after fifth pass, set agendaitem parents |
252 | 264 | for agendaitem_id in agendaitems_needparent: | 264 | for agendaitem_id in agendaitems_needparent: |
253 | 265 | parent_id = agendaitems_needparent[agendaitem_id] | 265 | parent_id = agendaitems_needparent[agendaitem_id] |
254 | 266 | 266 | ||
255 | === modified file 'loco_directory/common/mixins.py' | |||
256 | --- loco_directory/common/mixins.py 2011-06-17 17:10:41 +0000 | |||
257 | +++ loco_directory/common/mixins.py 2012-06-30 22:09:18 +0000 | |||
258 | @@ -1,8 +1,9 @@ | |||
259 | 1 | import pytz | 1 | import pytz |
260 | 2 | 2 | ||
261 | 3 | |||
262 | 3 | class LocalTimeMixin(object): | 4 | class LocalTimeMixin(object): |
263 | 4 | '''Provides methods for converting between UTC and localtime | 5 | '''Provides methods for converting between UTC and localtime |
265 | 5 | 6 | ||
266 | 6 | Classes using this should provide the timezone string as self.tz | 7 | Classes using this should provide the timezone string as self.tz |
267 | 7 | ''' | 8 | ''' |
268 | 8 | 9 | ||
269 | @@ -13,19 +14,17 @@ | |||
270 | 13 | except: | 14 | except: |
271 | 14 | return pytz.utc | 15 | return pytz.utc |
272 | 15 | timezone = property(get_timezone) | 16 | timezone = property(get_timezone) |
274 | 16 | 17 | ||
275 | 17 | def tolocaltime(self, dt): | 18 | def tolocaltime(self, dt): |
276 | 18 | 'Converts a datetime in UTC to a datetime in this object\'s timezone' | 19 | 'Converts a datetime in UTC to a datetime in this object\'s timezone' |
277 | 19 | if dt is None: | 20 | if dt is None: |
278 | 20 | return None | 21 | return None |
279 | 21 | as_utc = pytz.utc.localize(dt) | 22 | as_utc = pytz.utc.localize(dt) |
280 | 22 | return as_utc.astimezone(self.timezone) | 23 | return as_utc.astimezone(self.timezone) |
282 | 23 | 24 | ||
283 | 24 | def fromlocaltime(self, dt): | 25 | def fromlocaltime(self, dt): |
284 | 25 | 'Converts a datetime in this object\'s timezone to a datetime in UTC' | 26 | 'Converts a datetime in this object\'s timezone to a datetime in UTC' |
285 | 26 | if dt is None: | 27 | if dt is None: |
286 | 27 | return None | 28 | return None |
287 | 28 | local = self.timezone.localize(dt) | 29 | local = self.timezone.localize(dt) |
288 | 29 | return local.astimezone(pytz.utc) | 30 | return local.astimezone(pytz.utc) |
289 | 30 | |||
290 | 31 | |||
291 | 32 | 31 | ||
292 | === modified file 'loco_directory/common/shortcuts.py' | |||
293 | --- loco_directory/common/shortcuts.py 2010-04-09 14:10:02 +0000 | |||
294 | +++ loco_directory/common/shortcuts.py 2012-06-30 22:09:18 +0000 | |||
295 | @@ -9,20 +9,22 @@ | |||
296 | 9 | from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect | 9 | from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect |
297 | 10 | from django.core import urlresolvers | 10 | from django.core import urlresolvers |
298 | 11 | 11 | ||
299 | 12 | |||
300 | 13 | # pylint: disable-msg=C0103 | ||
301 | 12 | def redirect(to, *args, **kwargs): | 14 | def redirect(to, *args, **kwargs): |
302 | 13 | """ | 15 | """ |
303 | 14 | Returns an HttpResponseRedirect to the apropriate URL for the arguments | 16 | Returns an HttpResponseRedirect to the apropriate URL for the arguments |
304 | 15 | passed. | 17 | passed. |
306 | 16 | 18 | ||
307 | 17 | The arguments could be: | 19 | The arguments could be: |
309 | 18 | 20 | ||
310 | 19 | * A model: the model's `get_absolute_url()` function will be called. | 21 | * A model: the model's `get_absolute_url()` function will be called. |
312 | 20 | 22 | ||
313 | 21 | * A view name, possibly with arguments: `urlresolvers.reverse()` will | 23 | * A view name, possibly with arguments: `urlresolvers.reverse()` will |
314 | 22 | be used to reverse-resolve the name. | 24 | be used to reverse-resolve the name. |
316 | 23 | 25 | ||
317 | 24 | * A URL, which will be used as-is for the redirect location. | 26 | * A URL, which will be used as-is for the redirect location. |
319 | 25 | 27 | ||
320 | 26 | By default issues a temporary redirect; pass permanent=True to issue a | 28 | By default issues a temporary redirect; pass permanent=True to issue a |
321 | 27 | permanent redirect | 29 | permanent redirect |
322 | 28 | """ | 30 | """ |
323 | @@ -30,11 +32,11 @@ | |||
324 | 30 | redirect_class = HttpResponsePermanentRedirect | 32 | redirect_class = HttpResponsePermanentRedirect |
325 | 31 | else: | 33 | else: |
326 | 32 | redirect_class = HttpResponseRedirect | 34 | redirect_class = HttpResponseRedirect |
328 | 33 | 35 | ||
329 | 34 | # If it's a model, use get_absolute_url() | 36 | # If it's a model, use get_absolute_url() |
330 | 35 | if hasattr(to, 'get_absolute_url'): | 37 | if hasattr(to, 'get_absolute_url'): |
331 | 36 | return redirect_class(to.get_absolute_url()) | 38 | return redirect_class(to.get_absolute_url()) |
333 | 37 | 39 | ||
334 | 38 | # Next try a reverse URL resolution. | 40 | # Next try a reverse URL resolution. |
335 | 39 | try: | 41 | try: |
336 | 40 | return redirect_class(urlresolvers.reverse(to, args=args, kwargs=kwargs)) | 42 | return redirect_class(urlresolvers.reverse(to, args=args, kwargs=kwargs)) |
337 | @@ -42,7 +44,7 @@ | |||
338 | 42 | # If this doesn't "feel" like a URL, re-raise. | 44 | # If this doesn't "feel" like a URL, re-raise. |
339 | 43 | if '/' not in to and '.' not in to: | 45 | if '/' not in to and '.' not in to: |
340 | 44 | raise | 46 | raise |
342 | 45 | 47 | ||
343 | 46 | # Finally, fall back and assume it's a URL | 48 | # Finally, fall back and assume it's a URL |
344 | 47 | return redirect_class(to) | 49 | return redirect_class(to) |
345 | 48 | 50 | ||
346 | @@ -64,6 +66,7 @@ | |||
347 | 64 | raise AttributeError | 66 | raise AttributeError |
348 | 65 | return sum | 67 | return sum |
349 | 66 | 68 | ||
350 | 69 | |||
351 | 67 | def queryset_count(field, qs): | 70 | def queryset_count(field, qs): |
352 | 68 | """ | 71 | """ |
353 | 69 | Returns the number of non-null the values in the given field of the queryset | 72 | Returns the number of non-null the values in the given field of the queryset |
354 | 70 | 73 | ||
355 | === modified file 'loco_directory/common/templatetags/markup.py' | |||
356 | --- loco_directory/common/templatetags/markup.py 2012-02-07 14:36:29 +0000 | |||
357 | +++ loco_directory/common/templatetags/markup.py 2012-06-30 22:09:18 +0000 | |||
358 | @@ -20,6 +20,7 @@ | |||
359 | 20 | 20 | ||
360 | 21 | register = template.Library() | 21 | register = template.Library() |
361 | 22 | 22 | ||
362 | 23 | |||
363 | 23 | @register.filter | 24 | @register.filter |
364 | 24 | def textile(value): | 25 | def textile(value): |
365 | 25 | try: | 26 | try: |
366 | @@ -31,6 +32,7 @@ | |||
367 | 31 | else: | 32 | else: |
368 | 32 | return mark_safe(force_unicode(textile.textile(smart_str(value), encoding='utf-8', output='utf-8'))) | 33 | return mark_safe(force_unicode(textile.textile(smart_str(value), encoding='utf-8', output='utf-8'))) |
369 | 33 | 34 | ||
370 | 35 | |||
371 | 34 | @register.filter | 36 | @register.filter |
372 | 35 | def markdown(value, arg=''): | 37 | def markdown(value, arg=''): |
373 | 36 | """ | 38 | """ |
374 | @@ -68,13 +70,14 @@ | |||
375 | 68 | 70 | ||
376 | 69 | # Unicode support only in markdown v1.7 or above. Version_info | 71 | # Unicode support only in markdown v1.7 or above. Version_info |
377 | 70 | # exist only in markdown v1.6.2rc-2 or above. | 72 | # exist only in markdown v1.6.2rc-2 or above. |
379 | 71 | if getattr(markdown, "version_info", None) < (1,7): | 73 | if getattr(markdown, "version_info", None) < (1, 7): |
380 | 72 | return mark_safe(force_unicode(markdown.markdown(smart_str(value), extensions, safe_mode=safe_mode))) | 74 | return mark_safe(force_unicode(markdown.markdown(smart_str(value), extensions, safe_mode=safe_mode))) |
381 | 73 | else: | 75 | else: |
382 | 74 | return mark_safe(markdown.markdown(force_unicode(value), extensions, safe_mode=safe_mode)) | 76 | return mark_safe(markdown.markdown(force_unicode(value), extensions, safe_mode=safe_mode)) |
383 | 75 | else: | 77 | else: |
384 | 76 | return mark_safe(force_unicode(markdown.markdown(smart_str(value)))) | 78 | return mark_safe(force_unicode(markdown.markdown(smart_str(value)))) |
385 | 77 | 79 | ||
386 | 80 | |||
387 | 78 | @register.filter | 81 | @register.filter |
388 | 79 | def restructuredtext(value): | 82 | def restructuredtext(value): |
389 | 80 | try: | 83 | try: |
390 | 81 | 84 | ||
391 | === modified file 'loco_directory/common/templatetags/teams_tags.py' | |||
392 | --- loco_directory/common/templatetags/teams_tags.py 2011-06-19 13:55:34 +0000 | |||
393 | +++ loco_directory/common/templatetags/teams_tags.py 2012-06-30 22:09:18 +0000 | |||
394 | @@ -3,8 +3,9 @@ | |||
395 | 3 | 3 | ||
396 | 4 | register = template.Library() | 4 | register = template.Library() |
397 | 5 | 5 | ||
398 | 6 | |||
399 | 6 | def irc(nickname): | 7 | def irc(nickname): |
401 | 7 | """ | 8 | """ |
402 | 8 | Replace dots with underscores | 9 | Replace dots with underscores |
403 | 9 | """ | 10 | """ |
404 | 10 | return nickname.replace('.', '_') | 11 | return nickname.replace('.', '_') |
405 | 11 | 12 | ||
406 | === modified file 'loco_directory/common/utils.py' | |||
407 | --- loco_directory/common/utils.py 2011-10-05 00:50:53 +0000 | |||
408 | +++ loco_directory/common/utils.py 2012-06-30 22:09:18 +0000 | |||
409 | @@ -6,6 +6,7 @@ | |||
410 | 6 | 6 | ||
411 | 7 | from django.conf import settings | 7 | from django.conf import settings |
412 | 8 | 8 | ||
413 | 9 | |||
414 | 9 | def write_log(job_name, log): | 10 | def write_log(job_name, log): |
415 | 10 | stamp_dir = os.path.join(settings.PROJECT_PATH, 'data') | 11 | stamp_dir = os.path.join(settings.PROJECT_PATH, 'data') |
416 | 11 | log_file = os.path.join(stamp_dir, "%s.log" % job_name) | 12 | log_file = os.path.join(stamp_dir, "%s.log" % job_name) |
417 | @@ -15,6 +16,7 @@ | |||
418 | 15 | f.write(log) | 16 | f.write(log) |
419 | 16 | f.close() | 17 | f.close() |
420 | 17 | 18 | ||
421 | 19 | |||
422 | 18 | def run_job(which, interval, args=None): | 20 | def run_job(which, interval, args=None): |
423 | 19 | stamp_dir = os.path.join(settings.PROJECT_PATH, 'data') | 21 | stamp_dir = os.path.join(settings.PROJECT_PATH, 'data') |
424 | 20 | if not os.path.exists(stamp_dir): | 22 | if not os.path.exists(stamp_dir): |
425 | @@ -24,7 +26,7 @@ | |||
426 | 24 | datetime.datetime.utcfromtimestamp(os.path.getmtime(stamp_file)) + interval < datetime.datetime.now(): | 26 | datetime.datetime.utcfromtimestamp(os.path.getmtime(stamp_file)) + interval < datetime.datetime.now(): |
427 | 25 | pwd = os.getcwd() | 27 | pwd = os.getcwd() |
428 | 26 | os.chdir(settings.PROJECT_PATH) | 28 | os.chdir(settings.PROJECT_PATH) |
430 | 27 | p = subprocess.Popen(["python", "manage.py", which], stdout=subprocess.PIPE, | 29 | p = subprocess.Popen(["python", "manage.py", which], stdout=subprocess.PIPE, |
431 | 28 | stderr=subprocess.STDOUT, close_fds=True) | 30 | stderr=subprocess.STDOUT, close_fds=True) |
432 | 29 | log = p.stdout.read() | 31 | log = p.stdout.read() |
433 | 30 | p.communicate() | 32 | p.communicate() |
434 | @@ -33,6 +35,7 @@ | |||
435 | 33 | os.utime(stamp_file, None) | 35 | os.utime(stamp_file, None) |
436 | 34 | write_log(which, log) | 36 | write_log(which, log) |
437 | 35 | 37 | ||
438 | 38 | |||
439 | 36 | def flat_list(some_list): | 39 | def flat_list(some_list): |
440 | 37 | """ | 40 | """ |
441 | 38 | >>> reduce(lambda a,b: a.extend(b) or a, [[2,3],[6],[66,34]]) | 41 | >>> reduce(lambda a,b: a.extend(b) or a, [[2,3],[6],[66,34]]) |
442 | @@ -40,9 +43,10 @@ | |||
443 | 40 | """ | 43 | """ |
444 | 41 | if not some_list: | 44 | if not some_list: |
445 | 42 | return [] | 45 | return [] |
449 | 43 | return reduce(lambda a,b: a.extend(b) or a, some_list) | 46 | return reduce(lambda a, b: a.extend(b) or a, some_list) |
450 | 44 | 47 | ||
451 | 45 | 48 | ||
452 | 49 | # pylint: disable-msg=C0103 | ||
453 | 46 | def redirect(to, *args, **kwargs): | 50 | def redirect(to, *args, **kwargs): |
454 | 47 | from distutils.version import LooseVersion as V | 51 | from distutils.version import LooseVersion as V |
455 | 48 | import django | 52 | import django |
456 | @@ -62,10 +66,10 @@ | |||
457 | 62 | if not os.path.exists(version_file): | 66 | if not os.path.exists(version_file): |
458 | 63 | return "version unknown" | 67 | return "version unknown" |
459 | 64 | 68 | ||
464 | 65 | f = email.message_from_file(open(version_file)) | 69 | emai_msg = email.message_from_file(open(version_file)) |
465 | 66 | version = f["version"] | 70 | version = emai_msg["version"] |
466 | 67 | bzr_revno = f["revno"] | 71 | bzr_revno = emai_msg["revno"] |
467 | 68 | 72 | ||
468 | 69 | if debug: | 73 | if debug: |
469 | 70 | try: | 74 | try: |
470 | 71 | from bzrlib.branch import Branch | 75 | from bzrlib.branch import Branch |
471 | @@ -76,6 +80,7 @@ | |||
472 | 76 | 80 | ||
473 | 77 | return "version %s (rev %s)" % (version, bzr_revno) | 81 | return "version %s (rev %s)" % (version, bzr_revno) |
474 | 78 | 82 | ||
475 | 83 | |||
476 | 79 | class simple_iterator(object): | 84 | class simple_iterator(object): |
477 | 80 | 85 | ||
478 | 81 | def __init__(self, *args): | 86 | def __init__(self, *args): |
479 | @@ -85,7 +90,7 @@ | |||
480 | 85 | self.values.extend(deepcopy(args[0])) | 90 | self.values.extend(deepcopy(args[0])) |
481 | 86 | else: | 91 | else: |
482 | 87 | self.values.extend(deepcopy(args)) | 92 | self.values.extend(deepcopy(args)) |
484 | 88 | 93 | ||
485 | 89 | def get_next_index(self): | 94 | def get_next_index(self): |
486 | 90 | if self.index + 1 >= len(self.values): | 95 | if self.index + 1 >= len(self.values): |
487 | 91 | self.index = 0 | 96 | self.index = 0 |
488 | @@ -101,5 +106,3 @@ | |||
489 | 101 | def reset(self): | 106 | def reset(self): |
490 | 102 | self.index = -1 | 107 | self.index = -1 |
491 | 103 | return '' | 108 | return '' |
492 | 104 | |||
493 | 105 | |||
494 | 106 | 109 | ||
495 | === modified file 'loco_directory/common/views.py' | |||
496 | --- loco_directory/common/views.py 2011-10-11 14:03:43 +0000 | |||
497 | +++ loco_directory/common/views.py 2012-06-30 22:09:18 +0000 | |||
498 | @@ -13,6 +13,7 @@ | |||
499 | 13 | MissingUsernameViolation, | 13 | MissingUsernameViolation, |
500 | 14 | ) | 14 | ) |
501 | 15 | except ImportError: | 15 | except ImportError: |
502 | 16 | # pylint: disable-msg=C0103 | ||
503 | 16 | MissingPhysicalMultiFactor = None | 17 | MissingPhysicalMultiFactor = None |
504 | 17 | MissingUsernameViolation = None | 18 | MissingUsernameViolation = None |
505 | 18 | 19 | ||
506 | @@ -25,7 +26,7 @@ | |||
507 | 25 | team_meeting_count = TeamMeeting.objects.next_meetings().count() | 26 | team_meeting_count = TeamMeeting.objects.next_meetings().count() |
508 | 26 | global_event_list = GlobalEvent.objects.next_events()[:5] | 27 | global_event_list = GlobalEvent.objects.next_events()[:5] |
509 | 27 | articles = Article.objects.all()[:5] | 28 | articles = Article.objects.all()[:5] |
511 | 28 | 29 | ||
512 | 29 | context = {'team_event_count': team_event_count, | 30 | context = {'team_event_count': team_event_count, |
513 | 30 | 'team_meeting_count': team_meeting_count, | 31 | 'team_meeting_count': team_meeting_count, |
514 | 31 | 'global_event_list': global_event_list, | 32 | 'global_event_list': global_event_list, |
515 | @@ -35,36 +36,43 @@ | |||
516 | 35 | return render_to_response('index.html', context, | 36 | return render_to_response('index.html', context, |
517 | 36 | RequestContext(request)) | 37 | RequestContext(request)) |
518 | 37 | 38 | ||
519 | 39 | |||
520 | 38 | def loco_council(request): | 40 | def loco_council(request): |
521 | 39 | context = {} | 41 | context = {} |
522 | 40 | return render_to_response('loco_council.html', context, | 42 | return render_to_response('loco_council.html', context, |
523 | 41 | RequestContext(request)) | 43 | RequestContext(request)) |
524 | 42 | 44 | ||
525 | 45 | |||
526 | 43 | def about(request): | 46 | def about(request): |
527 | 44 | context = {} | 47 | context = {} |
528 | 45 | return render_to_response('about.html', context, | 48 | return render_to_response('about.html', context, |
529 | 46 | RequestContext(request)) | 49 | RequestContext(request)) |
530 | 47 | 50 | ||
531 | 51 | |||
532 | 48 | def about_loco(request): | 52 | def about_loco(request): |
533 | 49 | context = {} | 53 | context = {} |
534 | 50 | return render_to_response('about_loco.html', context, | 54 | return render_to_response('about_loco.html', context, |
535 | 51 | RequestContext(request)) | 55 | RequestContext(request)) |
536 | 52 | 56 | ||
537 | 57 | |||
538 | 53 | def loco_setup(request): | 58 | def loco_setup(request): |
539 | 54 | context = {} | 59 | context = {} |
540 | 55 | return render_to_response('loco_setup.html', context, | 60 | return render_to_response('loco_setup.html', context, |
541 | 56 | RequestContext(request)) | 61 | RequestContext(request)) |
542 | 57 | 62 | ||
543 | 63 | |||
544 | 58 | def irc_chat(request): | 64 | def irc_chat(request): |
545 | 59 | context = {} | 65 | context = {} |
546 | 60 | return render_to_response('irc_chat.html', context, | 66 | return render_to_response('irc_chat.html', context, |
547 | 61 | RequestContext(request)) | 67 | RequestContext(request)) |
549 | 62 | 68 | ||
550 | 69 | |||
551 | 63 | def using_locodir(request): | 70 | def using_locodir(request): |
552 | 64 | context = {} | 71 | context = {} |
553 | 65 | return render_to_response('using_locodir.html', context, | 72 | return render_to_response('using_locodir.html', context, |
554 | 66 | RequestContext(request)) | 73 | RequestContext(request)) |
556 | 67 | 74 | ||
557 | 75 | |||
558 | 68 | def site_logout(request): | 76 | def site_logout(request): |
559 | 69 | logout(request) | 77 | logout(request) |
560 | 70 | return HttpResponseRedirect('/') | 78 | return HttpResponseRedirect('/') |
561 | @@ -74,17 +82,19 @@ | |||
562 | 74 | """ | 82 | """ |
563 | 75 | Change the language for a user | 83 | Change the language for a user |
564 | 76 | """ | 84 | """ |
569 | 77 | next = request.META.get('HTTP_REFERER', None) | 85 | next_url = request.META.get('HTTP_REFERER', None) |
570 | 78 | if not next: | 86 | if not next_url: |
571 | 79 | next = '/' | 87 | next_url = '/' |
572 | 80 | response = HttpResponseRedirect(next) | 88 | response = HttpResponseRedirect(next_url) |
573 | 81 | lang = request.GET.get('lang', '') | 89 | lang = request.GET.get('lang', '') |
574 | 82 | if check_for_language(lang): | 90 | if check_for_language(lang): |
575 | 83 | if hasattr(request, 'session'): | 91 | if hasattr(request, 'session'): |
576 | 84 | request.session['django_language'] = lang | 92 | request.session['django_language'] = lang |
578 | 85 | response.set_cookie(settings.LANGUAGE_COOKIE_NAME,lang) | 93 | response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang) |
579 | 86 | return response | 94 | return response |
581 | 87 | 95 | ||
582 | 96 | |||
583 | 97 | # pylint: disable-msg=C0103 | ||
584 | 88 | def site_search(request): | 98 | def site_search(request): |
585 | 89 | from common.forms import SiteSearchForm | 99 | from common.forms import SiteSearchForm |
586 | 90 | from common.utils import simple_iterator | 100 | from common.utils import simple_iterator |
587 | @@ -110,17 +120,24 @@ | |||
588 | 110 | 'venues': venues, | 120 | 'venues': venues, |
589 | 111 | 'meetings': meetings, | 121 | 'meetings': meetings, |
590 | 112 | 'q': q, | 122 | 'q': q, |
592 | 113 | 'colcycle' : simple_iterator('col_left', 'col_right'), | 123 | 'colcycle': simple_iterator('col_left', 'col_right'), |
593 | 114 | } | 124 | } |
594 | 115 | return render_to_response('site_search.html', context, | 125 | return render_to_response('site_search.html', context, |
595 | 116 | RequestContext(request)) | 126 | RequestContext(request)) |
597 | 117 | 127 | ||
598 | 128 | |||
599 | 129 | # pylint: disable-msg=C0103 | ||
600 | 118 | def search_teams(q): | 130 | def search_teams(q): |
601 | 119 | from teams.models import Team | 131 | from teams.models import Team |
602 | 120 | from django.db.models import Q | 132 | from django.db.models import Q |
604 | 121 | team_list = Team.objects.filter(Q(name__icontains=q) | Q(countries__name__icontains=q) | Q(city__icontains=q) | Q(languages__name__icontains=q)).order_by('name').distinct() | 133 | team_list = Team.objects.filter(Q(name__icontains=q) | |
605 | 134 | Q(countries__name__icontains=q) | | ||
606 | 135 | Q(city__icontains=q) | | ||
607 | 136 | Q(languages__name__icontains=q)).order_by('name').distinct() | ||
608 | 122 | return team_list | 137 | return team_list |
610 | 123 | 138 | ||
611 | 139 | |||
612 | 140 | # pylint: disable-msg=C0103 | ||
613 | 124 | def search_global_events(q): | 141 | def search_global_events(q): |
614 | 125 | from events.models import GlobalEvent | 142 | from events.models import GlobalEvent |
615 | 126 | from django.db.models import Q | 143 | from django.db.models import Q |
616 | @@ -128,26 +145,43 @@ | |||
617 | 128 | global_event_list = global_event_list.filter(Q(name__icontains=q)).distinct() | 145 | global_event_list = global_event_list.filter(Q(name__icontains=q)).distinct() |
618 | 129 | return global_event_list | 146 | return global_event_list |
619 | 130 | 147 | ||
620 | 148 | |||
621 | 149 | # pylint: disable-msg=C0103 | ||
622 | 131 | def search_team_events(q): | 150 | def search_team_events(q): |
623 | 132 | from events.models import TeamEvent | 151 | from events.models import TeamEvent |
624 | 133 | from django.db.models import Q | 152 | from django.db.models import Q |
625 | 134 | team_event_list = TeamEvent.objects.next_events() | 153 | team_event_list = TeamEvent.objects.next_events() |
627 | 135 | team_event_list = team_event_list.filter(Q(name__icontains=q) | Q(teams__name__icontains=q) | Q(venue__name__icontains=q) | Q(venue__city__icontains=q) | Q(venue__country__name__icontains=q) | Q(global_event__name__icontains=q)).distinct() | 154 | team_event_list = team_event_list.filter(Q(name__icontains=q) | |
628 | 155 | Q(teams__name__icontains=q) | | ||
629 | 156 | Q(venue__name__icontains=q) | | ||
630 | 157 | Q(venue__city__icontains=q) | | ||
631 | 158 | Q(venue__country__name__icontains=q) | | ||
632 | 159 | Q(global_event__name__icontains=q)).distinct() | ||
633 | 136 | return team_event_list | 160 | return team_event_list |
635 | 137 | 161 | ||
636 | 162 | |||
637 | 163 | # pylint: disable-msg=C0103 | ||
638 | 138 | def search_venues(q): | 164 | def search_venues(q): |
639 | 139 | from venues.models import Venue | 165 | from venues.models import Venue |
640 | 140 | from django.db.models import Q | 166 | from django.db.models import Q |
642 | 141 | venue_list = Venue.objects.filter(Q(name__icontains=q) | Q(country__name__icontains=q) | Q(city__icontains=q) | Q(address__icontains=q)).order_by('name').distinct() | 167 | venue_list = Venue.objects.filter(Q(name__icontains=q) | |
643 | 168 | Q(country__name__icontains=q) | | ||
644 | 169 | Q(city__icontains=q) | | ||
645 | 170 | Q(address__icontains=q)).order_by('name').distinct() | ||
646 | 142 | return venue_list | 171 | return venue_list |
648 | 143 | 172 | ||
649 | 173 | |||
650 | 174 | # pylint: disable-msg=C0103 | ||
651 | 144 | def search_meetings(q): | 175 | def search_meetings(q): |
652 | 145 | from meetings.models import TeamMeeting | 176 | from meetings.models import TeamMeeting |
653 | 146 | from django.db.models import Q | 177 | from django.db.models import Q |
654 | 147 | meeting_list = TeamMeeting.objects.next_meetings() | 178 | meeting_list = TeamMeeting.objects.next_meetings() |
656 | 148 | meeting_list = meeting_list.filter(Q(name__icontains=q) | Q(teams__name__icontains=q) | Q(agenda__title__icontains=q)).distinct() | 179 | meeting_list = meeting_list.filter(Q(name__icontains=q) | |
657 | 180 | Q(teams__name__icontains=q) | | ||
658 | 181 | Q(agenda__title__icontains=q)).distinct() | ||
659 | 149 | return meeting_list | 182 | return meeting_list |
661 | 150 | 183 | ||
662 | 184 | |||
663 | 151 | def login_failure(request, message, status=403, | 185 | def login_failure(request, message, status=403, |
664 | 152 | template_name='login_failure.html', | 186 | template_name='login_failure.html', |
665 | 153 | exception=None): | 187 | exception=None): |
666 | @@ -159,9 +193,10 @@ | |||
667 | 159 | if isinstance(exception, MissingPhysicalMultiFactor): | 193 | if isinstance(exception, MissingPhysicalMultiFactor): |
668 | 160 | context['solution'] = 'Try logging in again using your Yubikey' | 194 | context['solution'] = 'Try logging in again using your Yubikey' |
669 | 161 | elif isinstance(exception, MissingUsernameViolation): | 195 | elif isinstance(exception, MissingUsernameViolation): |
671 | 162 | context['solution'] = 'You will need to create a <a href="https://launchpad.net/people/+me">Launchpad profile</a> to use the LoCo Teams Directory' | 196 | context['solution'] = 'You will need to create a ' \ |
672 | 197 | '<a href="https://launchpad.net/people/+me">' \ | ||
673 | 198 | 'Launchpad profile</a> to use the LoCo Teams Directory' | ||
674 | 163 | 199 | ||
675 | 164 | data = render_to_string(template_name, context, | 200 | data = render_to_string(template_name, context, |
676 | 165 | context_instance=RequestContext(request)) | 201 | context_instance=RequestContext(request)) |
677 | 166 | return HttpResponse(data, status=status) | 202 | return HttpResponse(data, status=status) |
678 | 167 | |||
679 | 168 | 203 | ||
680 | === modified file 'loco_directory/common/widgets.py' | |||
681 | --- loco_directory/common/widgets.py 2010-07-29 12:05:20 +0000 | |||
682 | +++ loco_directory/common/widgets.py 2012-06-30 22:09:18 +0000 | |||
683 | @@ -7,6 +7,7 @@ | |||
684 | 7 | from django.utils.safestring import mark_safe | 7 | from django.utils.safestring import mark_safe |
685 | 8 | import copy | 8 | import copy |
686 | 9 | 9 | ||
687 | 10 | |||
688 | 10 | class PopupRelatedFieldWidgetWrapper(forms.Widget): | 11 | class PopupRelatedFieldWidgetWrapper(forms.Widget): |
689 | 11 | """ | 12 | """ |
690 | 12 | This class is a wrapper to a given widget to add the add icon for the | 13 | This class is a wrapper to a given widget to add the add icon for the |
691 | @@ -29,7 +30,7 @@ | |||
692 | 29 | 30 | ||
693 | 30 | def _media(self): | 31 | def _media(self): |
694 | 31 | wm = self.widget.media | 32 | wm = self.widget.media |
696 | 32 | wm.add_js(['%sjs/admin/RelatedObjectLookups.js'%settings.ADMIN_MEDIA_PREFIX,]) | 33 | wm.add_js(['%sjs/admin/RelatedObjectLookups.js' % settings.ADMIN_MEDIA_PREFIX, ]) |
697 | 33 | return wm | 34 | return wm |
698 | 34 | media = property(_media) | 35 | media = property(_media) |
699 | 35 | 36 | ||
700 | @@ -55,4 +56,3 @@ | |||
701 | 55 | 56 | ||
702 | 56 | def id_for_label(self, id_): | 57 | def id_for_label(self, id_): |
703 | 57 | return self.widget.id_for_label(id_) | 58 | return self.widget.id_for_label(id_) |
704 | 58 |
Text conflict in loco_directory/ common/ launchpad. py