Merge lp:~elachuni/ubuntu-webcatalog/department-icons into lp:ubuntu-webcatalog
- department-icons
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Ricardo Kirkner |
Approved revision: | 14 |
Merged at revision: | 12 |
Proposed branch: | lp:~elachuni/ubuntu-webcatalog/department-icons |
Merge into: | lp:ubuntu-webcatalog |
Diff against target: |
330 lines (+73/-21) 11 files modified
django_project/settings.py (+8/-1) django_project/urls.py (+7/-0) src/webcatalog/department_filters.py (+0/-1) src/webcatalog/fixtures/initial_data.json (+9/-9) src/webcatalog/models.py (+5/-0) src/webcatalog/static/css/webcatalog.css (+18/-2) src/webcatalog/templates/webcatalog/department_overview.html (+2/-4) src/webcatalog/templates/webcatalog/department_overview_snippet.html (+8/-0) src/webcatalog/templates/webcatalog/index.html (+1/-3) src/webcatalog/tests/test_models.py (+14/-0) src/webcatalog/urls.py (+1/-1) |
To merge this branch: | bzr merge lp:~elachuni/ubuntu-webcatalog/department-icons |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ricardo Kirkner (community) | Approve | ||
Review via email: mp+58477@code.launchpad.net |
Commit message
Add department icons as static media files.
Description of the change
Overview
========
This branch adds department icons as static media files.
Details
=======
Importing department icons proved to be quite tricky, as it seems they don't all come from the same package, and are sometimes quite hard to locate.
Instead this branch uploads a sane set of icons as simple static files, that can be updated when needed through code.
Department icons shouldn't change nearly as often as application icons and data in general, so having them in static files shouldn't be that bad.
- 14. By Anthony Lenton
-
Tidied up inline style into the css file.
Anthony Lenton (elachuni) wrote : | # |
Hi Ricardo,
Thanks for your review.
> I think you need to escape special characters when calling re.sub (according
> to python docs), like - and .
>
> The same applies for URLs with -, . and + as those are regular expressions.
In these cases it's unnecessary, as in both cases (line 115 and line 327 of the diff) the added special characters are used within character sets ([]). Special characters like + and . lose their special meaning within character sets, and - can be used as long as it's used at the beginning of the set, so that it's not confused with a character span.
Unless I'm missing something?
Ricardo Kirkner (ricardokirkner) wrote : | # |
Ok, thanks for the clarification. Better safe than sorry.
Preview Diff
1 | === modified file 'django_project/settings.py' |
2 | --- django_project/settings.py 2011-04-13 09:28:55 +0000 |
3 | +++ django_project/settings.py 2011-04-20 19:46:11 +0000 |
4 | @@ -50,7 +50,7 @@ |
5 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a |
6 | # trailing slash. |
7 | # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" |
8 | -MEDIA_URL = '' |
9 | +MEDIA_URL = '/site_media/' |
10 | |
11 | # Absolute path to the directory static files should be collected to. |
12 | # Don't put anything in this directory yourself; store your static files |
13 | @@ -141,6 +141,13 @@ |
14 | } |
15 | } |
16 | |
17 | +######################## |
18 | +# Ubuntu Web Catalog specific settings: |
19 | +######################## |
20 | + |
21 | +# Strictly for use in our dev environment: |
22 | +SERVE_SITE_MEDIA = True |
23 | + |
24 | try: |
25 | from local_settings import * |
26 | except ImportError: |
27 | |
28 | === modified file 'django_project/urls.py' |
29 | --- django_project/urls.py 2011-04-07 10:09:53 +0000 |
30 | +++ django_project/urls.py 2011-04-20 19:46:11 +0000 |
31 | @@ -16,6 +16,7 @@ |
32 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
33 | |
34 | from django.conf.urls.defaults import patterns, include, url |
35 | +from django.conf import settings |
36 | from django.contrib import admin |
37 | |
38 | admin.autodiscover() |
39 | @@ -24,3 +25,9 @@ |
40 | url(r'^cat/', include('webcatalog.urls')), |
41 | url(r'^admin/', include(admin.site.urls)), |
42 | ) |
43 | + |
44 | +if settings.SERVE_SITE_MEDIA: |
45 | + urlpatterns += patterns('', |
46 | + (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', |
47 | + {'document_root': settings.MEDIA_ROOT}), |
48 | + ) |
49 | |
50 | === modified file 'src/webcatalog/department_filters.py' |
51 | --- src/webcatalog/department_filters.py 2011-04-13 01:46:00 +0000 |
52 | +++ src/webcatalog/department_filters.py 2011-04-20 19:46:11 +0000 |
53 | @@ -89,7 +89,6 @@ |
54 | 'Geology': [category_filter(set(['Geology', 'Geoscience']))], |
55 | 'Mathematics': [category_filter(set(['DataVisualization', 'Math', |
56 | 'NumericalAnalysis'])), section_filter(['math', 'gnu-r'])], |
57 | - 'Medicine': [category_filter(set(['MedicalSoftware']))], |
58 | 'Physics': [category_filter(set(['Electricity', 'Physics']))], |
59 | 'Sound & Video': [category_filter(set(['AudioVideo', 'Audio', 'Video']))], |
60 | 'Themes & Tweaks': [category_filter(set(['Settings']))], |
61 | |
62 | === modified file 'src/webcatalog/fixtures/initial_data.json' |
63 | --- src/webcatalog/fixtures/initial_data.json 2011-04-13 15:00:07 +0000 |
64 | +++ src/webcatalog/fixtures/initial_data.json 2011-04-20 19:46:11 +0000 |
65 | @@ -80,14 +80,6 @@ |
66 | } |
67 | }, |
68 | { |
69 | - "pk": 11, |
70 | - "model": "webcatalog.department", |
71 | - "fields": { |
72 | - "name": "Medicine", |
73 | - "parent": 5 |
74 | - } |
75 | - }, |
76 | - { |
77 | "pk": 12, |
78 | "model": "webcatalog.department", |
79 | "fields": { |
80 | @@ -358,5 +350,13 @@ |
81 | "name": "Card Games", |
82 | "parent": 1 |
83 | } |
84 | - } |
85 | + }, |
86 | + { |
87 | + "pk": 47, |
88 | + "model": "webcatalog.department", |
89 | + "fields": { |
90 | + "name": "Fonts", |
91 | + "parent": null |
92 | + } |
93 | + } |
94 | ] |
95 | \ No newline at end of file |
96 | |
97 | === modified file 'src/webcatalog/models.py' |
98 | --- src/webcatalog/models.py 2011-04-13 09:28:55 +0000 |
99 | +++ src/webcatalog/models.py 2011-04-20 19:46:11 +0000 |
100 | @@ -23,6 +23,7 @@ |
101 | ) |
102 | |
103 | import logging |
104 | +import re |
105 | |
106 | from django.db import models |
107 | |
108 | @@ -99,3 +100,7 @@ |
109 | |
110 | def __unicode__(self): |
111 | return self.name |
112 | + |
113 | + @property |
114 | + def normalized_name(self): |
115 | + return re.sub(r'[-&.,;" \']', '', self.name) |
116 | |
117 | === modified file 'src/webcatalog/static/css/webcatalog.css' |
118 | --- src/webcatalog/static/css/webcatalog.css 2011-04-13 15:00:07 +0000 |
119 | +++ src/webcatalog/static/css/webcatalog.css 2011-04-20 19:46:11 +0000 |
120 | @@ -84,10 +84,21 @@ |
121 | } |
122 | |
123 | .department { |
124 | - width: 250px; |
125 | - height: 40px; |
126 | + width: 300px; |
127 | + height: 56px; |
128 | float: left; |
129 | } |
130 | + |
131 | +.department h3 { |
132 | + margin-bottom: 8px; |
133 | + padding-top: 8px; |
134 | + line-height: 32px; |
135 | +} |
136 | + |
137 | +.department h3 a { |
138 | + line-height: 32px; |
139 | +} |
140 | + |
141 | #search-box.main { |
142 | margin-left: 270px; |
143 | width: 350px; |
144 | @@ -97,3 +108,8 @@ |
145 | width: 300px; |
146 | } |
147 | |
148 | +.dept-icon { |
149 | + float:left; |
150 | + width:56px; |
151 | + height:48px; |
152 | +} |
153 | |
154 | === added directory 'src/webcatalog/static/images/dept_icons' |
155 | === added file 'src/webcatalog/static/images/dept_icons/3D.png' |
156 | Binary files src/webcatalog/static/images/dept_icons/3D.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/3D.png 2011-04-20 19:46:11 +0000 differ |
157 | === added file 'src/webcatalog/static/images/dept_icons/Accessories.png' |
158 | Binary files src/webcatalog/static/images/dept_icons/Accessories.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Accessories.png 2011-04-20 19:46:11 +0000 differ |
159 | === added file 'src/webcatalog/static/images/dept_icons/Astronomy.png' |
160 | Binary files src/webcatalog/static/images/dept_icons/Astronomy.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Astronomy.png 2011-04-20 19:46:11 +0000 differ |
161 | === added file 'src/webcatalog/static/images/dept_icons/Biology.png' |
162 | Binary files src/webcatalog/static/images/dept_icons/Biology.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Biology.png 2011-04-20 19:46:11 +0000 differ |
163 | === added file 'src/webcatalog/static/images/dept_icons/BoardGames.png' |
164 | Binary files src/webcatalog/static/images/dept_icons/BoardGames.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/BoardGames.png 2011-04-20 19:46:11 +0000 differ |
165 | === added file 'src/webcatalog/static/images/dept_icons/CardGames.png' |
166 | Binary files src/webcatalog/static/images/dept_icons/CardGames.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/CardGames.png 2011-04-20 19:46:11 +0000 differ |
167 | === added file 'src/webcatalog/static/images/dept_icons/Chat.png' |
168 | Binary files src/webcatalog/static/images/dept_icons/Chat.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Chat.png 2011-04-20 19:46:11 +0000 differ |
169 | === added file 'src/webcatalog/static/images/dept_icons/Chemistry.png' |
170 | Binary files src/webcatalog/static/images/dept_icons/Chemistry.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Chemistry.png 2011-04-20 19:46:11 +0000 differ |
171 | === added file 'src/webcatalog/static/images/dept_icons/ComputingRobotics.png' |
172 | Binary files src/webcatalog/static/images/dept_icons/ComputingRobotics.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/ComputingRobotics.png 2011-04-20 19:46:11 +0000 differ |
173 | === added file 'src/webcatalog/static/images/dept_icons/Debugging.png' |
174 | Binary files src/webcatalog/static/images/dept_icons/Debugging.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Debugging.png 2011-04-20 19:46:11 +0000 differ |
175 | === added file 'src/webcatalog/static/images/dept_icons/DeveloperTools.png' |
176 | Binary files src/webcatalog/static/images/dept_icons/DeveloperTools.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/DeveloperTools.png 2011-04-20 19:46:11 +0000 differ |
177 | === added file 'src/webcatalog/static/images/dept_icons/Drawing.png' |
178 | Binary files src/webcatalog/static/images/dept_icons/Drawing.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Drawing.png 2011-04-20 19:46:11 +0000 differ |
179 | === added file 'src/webcatalog/static/images/dept_icons/Education.png' |
180 | Binary files src/webcatalog/static/images/dept_icons/Education.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Education.png 2011-04-20 19:46:11 +0000 differ |
181 | === added file 'src/webcatalog/static/images/dept_icons/Electronics.png' |
182 | Binary files src/webcatalog/static/images/dept_icons/Electronics.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Electronics.png 2011-04-20 19:46:11 +0000 differ |
183 | === added file 'src/webcatalog/static/images/dept_icons/Engineering.png' |
184 | Binary files src/webcatalog/static/images/dept_icons/Engineering.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Engineering.png 2011-04-20 19:46:11 +0000 differ |
185 | === added file 'src/webcatalog/static/images/dept_icons/FileSharing.png' |
186 | Binary files src/webcatalog/static/images/dept_icons/FileSharing.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/FileSharing.png 2011-04-20 19:46:11 +0000 differ |
187 | === added file 'src/webcatalog/static/images/dept_icons/Fonts.png' |
188 | Binary files src/webcatalog/static/images/dept_icons/Fonts.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Fonts.png 2011-04-20 19:46:11 +0000 differ |
189 | === added file 'src/webcatalog/static/images/dept_icons/Games.png' |
190 | Binary files src/webcatalog/static/images/dept_icons/Games.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Games.png 2011-04-20 19:46:11 +0000 differ |
191 | === added file 'src/webcatalog/static/images/dept_icons/Geography.png' |
192 | Binary files src/webcatalog/static/images/dept_icons/Geography.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Geography.png 2011-04-20 19:46:11 +0000 differ |
193 | === added file 'src/webcatalog/static/images/dept_icons/Geology.png' |
194 | Binary files src/webcatalog/static/images/dept_icons/Geology.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Geology.png 2011-04-20 19:46:11 +0000 differ |
195 | === added file 'src/webcatalog/static/images/dept_icons/GraphicInterfaceDesign.png' |
196 | Binary files src/webcatalog/static/images/dept_icons/GraphicInterfaceDesign.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/GraphicInterfaceDesign.png 2011-04-20 19:46:11 +0000 differ |
197 | === added file 'src/webcatalog/static/images/dept_icons/Graphics.png' |
198 | Binary files src/webcatalog/static/images/dept_icons/Graphics.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Graphics.png 2011-04-20 19:46:11 +0000 differ |
199 | === added file 'src/webcatalog/static/images/dept_icons/IDEs.png' |
200 | Binary files src/webcatalog/static/images/dept_icons/IDEs.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/IDEs.png 2011-04-20 19:46:11 +0000 differ |
201 | === added file 'src/webcatalog/static/images/dept_icons/Internet.png' |
202 | Binary files src/webcatalog/static/images/dept_icons/Internet.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Internet.png 2011-04-20 19:46:11 +0000 differ |
203 | === added file 'src/webcatalog/static/images/dept_icons/Localization.png' |
204 | Binary files src/webcatalog/static/images/dept_icons/Localization.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Localization.png 2011-04-20 19:46:11 +0000 differ |
205 | === added file 'src/webcatalog/static/images/dept_icons/Mail.png' |
206 | Binary files src/webcatalog/static/images/dept_icons/Mail.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Mail.png 2011-04-20 19:46:11 +0000 differ |
207 | === added file 'src/webcatalog/static/images/dept_icons/Mathematics.png' |
208 | Binary files src/webcatalog/static/images/dept_icons/Mathematics.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Mathematics.png 2011-04-20 19:46:11 +0000 differ |
209 | === added file 'src/webcatalog/static/images/dept_icons/Office.png' |
210 | Binary files src/webcatalog/static/images/dept_icons/Office.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Office.png 2011-04-20 19:46:11 +0000 differ |
211 | === added file 'src/webcatalog/static/images/dept_icons/Painting.png' |
212 | Binary files src/webcatalog/static/images/dept_icons/Painting.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Painting.png 2011-04-20 19:46:11 +0000 differ |
213 | === added file 'src/webcatalog/static/images/dept_icons/Photography.png' |
214 | Binary files src/webcatalog/static/images/dept_icons/Photography.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Photography.png 2011-04-20 19:46:11 +0000 differ |
215 | === added file 'src/webcatalog/static/images/dept_icons/Physics.png' |
216 | Binary files src/webcatalog/static/images/dept_icons/Physics.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Physics.png 2011-04-20 19:46:11 +0000 differ |
217 | === added file 'src/webcatalog/static/images/dept_icons/Profiling.png' |
218 | Binary files src/webcatalog/static/images/dept_icons/Profiling.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Profiling.png 2011-04-20 19:46:11 +0000 differ |
219 | === added file 'src/webcatalog/static/images/dept_icons/Publishing.png' |
220 | Binary files src/webcatalog/static/images/dept_icons/Publishing.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Publishing.png 2011-04-20 19:46:11 +0000 differ |
221 | === added file 'src/webcatalog/static/images/dept_icons/Puzzles.png' |
222 | Binary files src/webcatalog/static/images/dept_icons/Puzzles.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Puzzles.png 2011-04-20 19:46:11 +0000 differ |
223 | === added file 'src/webcatalog/static/images/dept_icons/RolePlaying.png' |
224 | Binary files src/webcatalog/static/images/dept_icons/RolePlaying.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/RolePlaying.png 2011-04-20 19:46:11 +0000 differ |
225 | === added file 'src/webcatalog/static/images/dept_icons/ScanningOCR.png' |
226 | Binary files src/webcatalog/static/images/dept_icons/ScanningOCR.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/ScanningOCR.png 2011-04-20 19:46:11 +0000 differ |
227 | === added file 'src/webcatalog/static/images/dept_icons/ScienceEngineering.png' |
228 | Binary files src/webcatalog/static/images/dept_icons/ScienceEngineering.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/ScienceEngineering.png 2011-04-20 19:46:11 +0000 differ |
229 | === added file 'src/webcatalog/static/images/dept_icons/SoundVideo.png' |
230 | Binary files src/webcatalog/static/images/dept_icons/SoundVideo.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/SoundVideo.png 2011-04-20 19:46:11 +0000 differ |
231 | === added file 'src/webcatalog/static/images/dept_icons/Sports.png' |
232 | Binary files src/webcatalog/static/images/dept_icons/Sports.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Sports.png 2011-04-20 19:46:11 +0000 differ |
233 | === added file 'src/webcatalog/static/images/dept_icons/ThemesTweaks.png' |
234 | Binary files src/webcatalog/static/images/dept_icons/ThemesTweaks.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/ThemesTweaks.png 2011-04-20 19:46:11 +0000 differ |
235 | === added file 'src/webcatalog/static/images/dept_icons/UniversalAccess.png' |
236 | Binary files src/webcatalog/static/images/dept_icons/UniversalAccess.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/UniversalAccess.png 2011-04-20 19:46:11 +0000 differ |
237 | === added file 'src/webcatalog/static/images/dept_icons/VersionControl.png' |
238 | Binary files src/webcatalog/static/images/dept_icons/VersionControl.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/VersionControl.png 2011-04-20 19:46:11 +0000 differ |
239 | === added file 'src/webcatalog/static/images/dept_icons/Viewers.png' |
240 | Binary files src/webcatalog/static/images/dept_icons/Viewers.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/Viewers.png 2011-04-20 19:46:11 +0000 differ |
241 | === added file 'src/webcatalog/static/images/dept_icons/WebBrowsers.png' |
242 | Binary files src/webcatalog/static/images/dept_icons/WebBrowsers.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/WebBrowsers.png 2011-04-20 19:46:11 +0000 differ |
243 | === added file 'src/webcatalog/static/images/dept_icons/WebDevelopment.png' |
244 | Binary files src/webcatalog/static/images/dept_icons/WebDevelopment.png 1970-01-01 00:00:00 +0000 and src/webcatalog/static/images/dept_icons/WebDevelopment.png 2011-04-20 19:46:11 +0000 differ |
245 | === modified file 'src/webcatalog/templates/webcatalog/department_overview.html' |
246 | --- src/webcatalog/templates/webcatalog/department_overview.html 2011-04-13 15:00:07 +0000 |
247 | +++ src/webcatalog/templates/webcatalog/department_overview.html 2011-04-20 19:46:11 +0000 |
248 | @@ -9,9 +9,7 @@ |
249 | <h3>{% trans "Subsections" %}:</h3> |
250 | |
251 | {% for dept in subdepts %} |
252 | - <div class="department"> |
253 | - <h3><a href="{% url wc-department dept.id %}">{{ dept.name }}</a></h3> |
254 | - </div> |
255 | + {% include "webcatalog/department_overview_snippet.html" %} |
256 | {% endfor %} |
257 | {% endif %} |
258 | |
259 | @@ -22,7 +20,7 @@ |
260 | {% for app in apps %} |
261 | <div class="app-overview-row"> |
262 | {% if app.icon %} |
263 | - <img src="{{ app.icon.url }}"/> |
264 | + <img src="{{ app.icon.url }}" width="32" height="32" /> |
265 | {% else %} |
266 | <img src="{{ STATIC_URL }}images/noicon_32.png"/> |
267 | {% endif %} |
268 | |
269 | === added file 'src/webcatalog/templates/webcatalog/department_overview_snippet.html' |
270 | --- src/webcatalog/templates/webcatalog/department_overview_snippet.html 1970-01-01 00:00:00 +0000 |
271 | +++ src/webcatalog/templates/webcatalog/department_overview_snippet.html 2011-04-20 19:46:11 +0000 |
272 | @@ -0,0 +1,8 @@ |
273 | + <div class="department"> |
274 | + <div class="dept-icon"> |
275 | + <a href="{% url wc-department dept.id %}"> |
276 | + <img width="48" height="48" |
277 | + src="{{ STATIC_URL }}images/dept_icons/{{ dept.normalized_name }}.png"/> |
278 | + </a></div> |
279 | + <h3><a href="{% url wc-department dept.id %}">{{ dept.name }}</a></h3> |
280 | + </div> |
281 | |
282 | === modified file 'src/webcatalog/templates/webcatalog/index.html' |
283 | --- src/webcatalog/templates/webcatalog/index.html 2011-04-13 19:52:23 +0000 |
284 | +++ src/webcatalog/templates/webcatalog/index.html 2011-04-20 19:46:11 +0000 |
285 | @@ -9,9 +9,7 @@ |
286 | <h3>{% trans "Browse application departments" %}:</h3> |
287 | |
288 | {% for dept in depts %} |
289 | - <div class="department"> |
290 | - <h3><a href="{% url wc-department dept.id %}">{{ dept.name }}</a></h3> |
291 | - </div> |
292 | + {% include "webcatalog/department_overview_snippet.html" %} |
293 | {% endfor %} |
294 | |
295 | <p style="clear:both"/> |
296 | |
297 | === modified file 'src/webcatalog/tests/test_models.py' |
298 | --- src/webcatalog/tests/test_models.py 2011-04-13 02:24:17 +0000 |
299 | +++ src/webcatalog/tests/test_models.py 2011-04-20 19:46:11 +0000 |
300 | @@ -58,3 +58,17 @@ |
301 | |
302 | self.assertEqual(1, app.departments.count()) |
303 | self.assertEqual('Games', app.departments.get().name) |
304 | + |
305 | + |
306 | +def DepartmentTestCse(TestCaseWithFactory): |
307 | + def test_normalized_name(self): |
308 | + cases = { |
309 | + 'Foo': 'Foo', |
310 | + 'Foo & Bar': 'FooBar', |
311 | + ' Foo, Bar ': 'FooBar', |
312 | + ' && , ': '', |
313 | + '': '' |
314 | + } |
315 | + for case, expected in cases.items(): |
316 | + dept = self.factory.make_department(case) |
317 | + self.assertEquals(dept.normalized_name, expected) |
318 | |
319 | === modified file 'src/webcatalog/urls.py' |
320 | --- src/webcatalog/urls.py 2011-04-13 15:00:07 +0000 |
321 | +++ src/webcatalog/urls.py 2011-04-20 19:46:11 +0000 |
322 | @@ -36,7 +36,7 @@ |
323 | url(r'^$', 'index', name='wc-index'), |
324 | url(r'^department/(?P<dept_id>\d+)/$', 'department_overview', |
325 | name='wc-department'), |
326 | - url(r'^applications/(?P<slug>[-.\w]+)/$', DetailView.as_view( |
327 | + url(r'^applications/(?P<slug>[-.+\w]+)/$', DetailView.as_view( |
328 | model=Application, slug_field='package_name', |
329 | context_object_name='application'), name="wc-package-detail"), |
330 | url(r'^search/$', 'search', name="wc-search"), |
I think you need to escape special characters when calling re.sub (according to python docs), like - and .
The same applies for URLs with -, . and + as those are regular expressions.