Merge lp:~widelands-dev/widelands-website/better_notification_mail into lp:widelands-website
- better_notification_mail
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 482 | ||||||||
Proposed branch: | lp:~widelands-dev/widelands-website/better_notification_mail | ||||||||
Merge into: | lp:widelands-website | ||||||||
Diff against target: |
451 lines (+109/-93) 21 files modified
media/css/documentation.css (+4/-0) notification/models.py (+23/-7) pybb/views.py (+9/-3) templates/notification/email_body.txt (+1/-2) templates/notification/email_subject.txt (+6/-1) templates/notification/forum_new_post/full.txt (+2/-2) templates/notification/forum_new_topic/full.txt (+7/-5) templates/notification/maps_new_map/full.txt (+4/-3) templates/notification/messages_received/full.txt (+3/-4) templates/notification/messages_received/short.txt (+0/-1) templates/notification/messages_reply_received/full.txt (+4/-4) templates/notification/messages_reply_received/short.txt (+0/-1) templates/notification/short.txt (+1/-1) templates/notification/wiki_article_edited/full.txt (+0/-4) templates/notification/wiki_observed_article_changed/full.txt (+6/-2) templates/notification/wiki_revision_reverted/full.txt (+4/-3) templates/wiki/feeds/history_description.html (+2/-2) templates/wiki/feeds/history_title.html (+1/-2) wiki/models.py (+10/-42) wiki/views.py (+12/-0) wlmaps/models.py (+10/-4) |
||||||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands-website/better_notification_mail | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
kaputtnik (community) | Needs Resubmitting | ||
SirVer | Approve | ||
Review via email: mp+335028@code.launchpad.net |
Commit message
Description of the change
Fixes bug 1736263
Do not send emails to the one who
- creates a new topic
- replied to a topic
- uploaded a new map
Reworked the content of send emails. For the wiki it contains now the user who edited an article and a link to the last changeset, which shows the changes, e.g. https:/
Removed filter 'custom_date' from wiki feeds, to get a normal date format.
This should may be tested on the alpha site.
kaputtnik (franku) wrote : | # |
I had forgotten to update the packages of the virtual environment the last time. Did this now. The content of email send by django-messages are defined by django-messages itself, so the old templates (templates/
django messages uses this template:
GunChleoc (gunchleoc) wrote : | # |
Code LGTM as far as I can tell.
I might be available sometime next week to do some testing.
kaputtnik (franku) wrote : | # |
I've made a failure recently by updating django-messages to a wrong version.
https:/
I fixed it in trunk and also in this branch, which means we need to keep the templates in
templates/
SirVer (sirver) wrote : | # |
lgtm. not tested though.
kaputtnik (franku) wrote : | # |
Some parts aren't fine. E.g. the email subject when replying to a pm.
kaputtnik (franku) wrote : | # |
alpha site is running with database django_18 now, so only the 8 registered people in this database may get emails and not the people from the old alpha database.
kaputtnik (franku) wrote : | # |
Ooops, sorry for spamming you with emails. I just forgot that ./manage.py emit_notices must be called by hand on the alpha site and wrote post after post, wondering that no emails get send :-S
GunChleoc (gunchleoc) wrote : | # |
I have added a few posts to the alpha site and uploaded a map.
GunChleoc (gunchleoc) wrote : | # |
PM to myself just says "by GunChleoc" in the subject. It should read "X sent you a message on Widelands" or something.
kaputtnik (franku) wrote : | # |
Thanks for testing :-)
The subject on private messages should work now. I forgot that django_messages ships his own short.txt (used for the subject).
I send you a PM reply and a new PM. If this is ok it can go in, imho.
Shut off the alpha site for now.
GunChleoc (gunchleoc) wrote : | # |
There's a typo in the subject now: was send -> was sent
I got the 2 notifications for the messages.
kaputtnik (franku) wrote : | # |
Merged and deployed
Preview Diff
1 | === modified file 'media/css/documentation.css' | |||
2 | --- media/css/documentation.css 2016-10-18 09:43:58 +0000 | |||
3 | +++ media/css/documentation.css 2018-02-22 06:34:38 +0000 | |||
4 | @@ -1,3 +1,7 @@ | |||
5 | 1 | table.field-list{ | ||
6 | 2 | border-collapse: separate; | ||
7 | 3 | } | ||
8 | 4 | |||
9 | 1 | .sphinx a.headerlink { | 5 | .sphinx a.headerlink { |
10 | 2 | padding: 0 4px 0 4px; | 6 | padding: 0 4px 0 4px; |
11 | 3 | visibility: hidden; | 7 | visibility: hidden; |
12 | 4 | 8 | ||
13 | === modified file 'notification/models.py' | |||
14 | --- notification/models.py 2017-05-07 09:51:15 +0000 | |||
15 | +++ notification/models.py 2018-02-22 06:34:38 +0000 | |||
16 | @@ -40,7 +40,9 @@ | |||
17 | 40 | class NoticeType(models.Model): | 40 | class NoticeType(models.Model): |
18 | 41 | 41 | ||
19 | 42 | label = models.CharField(_('label'), max_length=40) | 42 | label = models.CharField(_('label'), max_length=40) |
21 | 43 | display = models.CharField(_('display'), max_length=50) | 43 | display = models.CharField(_('display'), |
22 | 44 | max_length=50, | ||
23 | 45 | help_text=_('Used as subject when sending emails.')) | ||
24 | 44 | description = models.CharField(_('description'), max_length=100) | 46 | description = models.CharField(_('description'), max_length=100) |
25 | 45 | 47 | ||
26 | 46 | # by default only on for media with sensitivity less than or equal to this | 48 | # by default only on for media with sensitivity less than or equal to this |
27 | @@ -101,14 +103,22 @@ | |||
28 | 101 | setting.save() | 103 | setting.save() |
29 | 102 | return setting | 104 | return setting |
30 | 103 | 105 | ||
31 | 106 | |||
32 | 104 | def should_send(user, notice_type, medium): | 107 | def should_send(user, notice_type, medium): |
33 | 105 | return get_notification_setting(user, notice_type, medium).send | 108 | return get_notification_setting(user, notice_type, medium).send |
34 | 106 | 109 | ||
37 | 107 | def get_observers_for(notice_type): | 110 | |
38 | 108 | """ Returns the list of users which wants to get a message (email) for this | 111 | def get_observers_for(notice_type, excl_user=None): |
39 | 112 | """Returns the list of users which wants to get a message (email) for this | ||
40 | 109 | type of notice.""" | 113 | type of notice.""" |
43 | 110 | settings = NoticeSetting.objects.filter(notice_type__label=notice_type).filter(send=True) | 114 | query = NoticeSetting.objects.filter( |
44 | 111 | return [s.user for s in NoticeSetting.objects.filter(notice_type__label=notice_type).filter(send=True)] | 115 | notice_type__label=notice_type, send=True) |
45 | 116 | |||
46 | 117 | if excl_user: | ||
47 | 118 | query = query.exclude(user=excl_user) | ||
48 | 119 | |||
49 | 120 | return [notice_setting.user for notice_setting in query] | ||
50 | 121 | |||
51 | 112 | 122 | ||
52 | 113 | class NoticeQueueBatch(models.Model): | 123 | class NoticeQueueBatch(models.Model): |
53 | 114 | """A queued notice. | 124 | """A queued notice. |
54 | @@ -244,6 +254,8 @@ | |||
55 | 244 | 'user': user, | 254 | 'user': user, |
56 | 245 | 'notices_url': notices_url, | 255 | 'notices_url': notices_url, |
57 | 246 | 'current_site': current_site, | 256 | 'current_site': current_site, |
58 | 257 | 'subject': notice_type.display, | ||
59 | 258 | 'description': notice_type.description, | ||
60 | 247 | }) | 259 | }) |
61 | 248 | context.update(extra_context) | 260 | context.update(extra_context) |
62 | 249 | 261 | ||
63 | @@ -254,10 +266,14 @@ | |||
64 | 254 | subject = ''.join(render_to_string('notification/email_subject.txt', { | 266 | subject = ''.join(render_to_string('notification/email_subject.txt', { |
65 | 255 | 'message': messages['short.txt'], | 267 | 'message': messages['short.txt'], |
66 | 256 | }, context).splitlines()) | 268 | }, context).splitlines()) |
68 | 257 | 269 | ||
69 | 270 | # Strip leading newlines. Make writing the email templates easier: | ||
70 | 271 | # Each linebreak in the templates results in a linebreak in the emails | ||
71 | 272 | # If the first line in a template contains only template tags the | ||
72 | 273 | # email will contain an empty line at the top. | ||
73 | 258 | body = render_to_string('notification/email_body.txt', { | 274 | body = render_to_string('notification/email_body.txt', { |
74 | 259 | 'message': messages['full.txt'], | 275 | 'message': messages['full.txt'], |
76 | 260 | }, context) | 276 | }, context).lstrip() |
77 | 261 | 277 | ||
78 | 262 | if should_send(user, notice_type, '1') and user.email: # Email | 278 | if should_send(user, notice_type, '1') and user.email: # Email |
79 | 263 | recipients.append(user.email) | 279 | recipients.append(user.email) |
80 | 264 | 280 | ||
81 | === modified file 'pybb/views.py' | |||
82 | --- pybb/views.py 2017-11-26 10:57:35 +0000 | |||
83 | +++ pybb/views.py 2018-02-22 06:34:38 +0000 | |||
84 | @@ -178,14 +178,20 @@ | |||
85 | 178 | if notification: | 178 | if notification: |
86 | 179 | if not topic: | 179 | if not topic: |
87 | 180 | # Inform subscribers of a new topic | 180 | # Inform subscribers of a new topic |
90 | 181 | notification.send(notification.get_observers_for('forum_new_topic'), 'forum_new_topic', | 181 | subscribers = notification.get_observers_for('forum_new_topic', |
91 | 182 | {'topic': post.topic, 'post': post, 'user': post.topic.user}, queue = True) | 182 | excl_user=request.user) |
92 | 183 | notification.send(subscribers, 'forum_new_topic', | ||
93 | 184 | {'topic': post.topic, | ||
94 | 185 | 'post': post, | ||
95 | 186 | 'user': post.topic.user | ||
96 | 187 | }, | ||
97 | 188 | queue = True) | ||
98 | 183 | # Topics author is subscriber for all new posts in his topic | 189 | # Topics author is subscriber for all new posts in his topic |
99 | 184 | post.topic.subscribers.add(request.user) | 190 | post.topic.subscribers.add(request.user) |
100 | 185 | 191 | ||
101 | 186 | else: | 192 | else: |
102 | 187 | # Send mails about a new post to topic subscribers | 193 | # Send mails about a new post to topic subscribers |
104 | 188 | notification.send(post.topic.subscribers.all(), 'forum_new_post', | 194 | notification.send(post.topic.subscribers.exclude(username=post.user), 'forum_new_post', |
105 | 189 | {'post': post, 'topic': topic, 'user': post.user}, queue = True) | 195 | {'post': post, 'topic': topic, 'user': post.user}, queue = True) |
106 | 190 | 196 | ||
107 | 191 | return HttpResponseRedirect(post.get_absolute_url()) | 197 | return HttpResponseRedirect(post.get_absolute_url()) |
108 | 192 | 198 | ||
109 | === modified file 'templates/notification/email_body.txt' | |||
110 | --- templates/notification/email_body.txt 2017-04-17 14:34:48 +0000 | |||
111 | +++ templates/notification/email_body.txt 2018-02-22 06:34:38 +0000 | |||
112 | @@ -1,5 +1,4 @@ | |||
115 | 1 | {% load i18n %}{% blocktrans %}You have received the following notice from {{ current_site }}: | 1 | {% load i18n %}{% blocktrans %} |
114 | 2 | |||
116 | 3 | {{ message }} | 2 | {{ message }} |
117 | 4 | To change how you receive notifications, please go to {{ notices_url }}. | 3 | To change how you receive notifications, please go to {{ notices_url }}. |
118 | 5 | {% endblocktrans %} | 4 | {% endblocktrans %} |
119 | 6 | 5 | ||
120 | === modified file 'templates/notification/email_subject.txt' | |||
121 | --- templates/notification/email_subject.txt 2009-02-20 16:46:21 +0000 | |||
122 | +++ templates/notification/email_subject.txt 2018-02-22 06:34:38 +0000 | |||
123 | @@ -1,1 +1,6 @@ | |||
125 | 1 | {% load i18n %}{% blocktrans %}[Widelands.org] {{ message }}{% endblocktrans %} | 1 | {% load i18n %} |
126 | 2 | {% if message|length > 1 %} | ||
127 | 3 | {% blocktrans %}{{ message }}{% endblocktrans %} | ||
128 | 4 | {% else %} | ||
129 | 5 | {% blocktrans %}{{ subject }}{% endblocktrans %} | ||
130 | 6 | {% endif %} | ||
131 | 2 | 7 | ||
132 | === modified file 'templates/notification/forum_new_post/full.txt' | |||
133 | --- templates/notification/forum_new_post/full.txt 2015-03-16 07:00:43 +0000 | |||
134 | +++ templates/notification/forum_new_post/full.txt 2018-02-22 06:34:38 +0000 | |||
135 | @@ -2,9 +2,9 @@ | |||
136 | 2 | 2 | ||
137 | 3 | "{{ user }}" wrote: | 3 | "{{ user }}" wrote: |
138 | 4 | 4 | ||
140 | 5 | {{ post.body_text }} | 5 | {{ post.body }} |
141 | 6 | {% blocktrans with post.get_absolute_url as post_url and topic.get_absolute_url as topic_url %} | 6 | {% blocktrans with post.get_absolute_url as post_url and topic.get_absolute_url as topic_url %} |
143 | 7 | ––––––––––– | 7 | ------------------------- |
144 | 8 | Link to post: http://{{ current_site }}{{ post_url }} | 8 | Link to post: http://{{ current_site }}{{ post_url }} |
145 | 9 | Link to topic: http://{{ current_site }}{{ topic_url }} | 9 | Link to topic: http://{{ current_site }}{{ topic_url }} |
146 | 10 | {% endblocktrans %} | 10 | {% endblocktrans %} |
147 | 11 | \ No newline at end of file | 11 | \ No newline at end of file |
148 | 12 | 12 | ||
149 | === modified file 'templates/notification/forum_new_topic/full.txt' | |||
150 | --- templates/notification/forum_new_topic/full.txt 2010-06-10 12:13:43 +0000 | |||
151 | +++ templates/notification/forum_new_topic/full.txt 2018-02-22 06:34:38 +0000 | |||
152 | @@ -1,7 +1,9 @@ | |||
156 | 1 | {% load i18n %}{% blocktrans with topic.get_absolute_url as topic_url %}The Forum topic {{ topic }} has been created by {{ user }}. | 1 | {% load i18n %}{% blocktrans with topic.get_absolute_url as topic_url and post.body as txt %}The Forum topic "{{ topic }}" has been created by {{ user }}. |
157 | 2 | 2 | ||
158 | 3 | http://{{ current_site }}{{ topic_url }} | 3 | {{ user }} wrote: |
159 | 4 | |||
160 | 5 | {{ txt }} | ||
161 | 4 | {% endblocktrans %} | 6 | {% endblocktrans %} |
162 | 5 | {{ topic }}: | ||
163 | 6 | 7 | ||
165 | 7 | {{ post.body_text }} | 8 | ------------------------- |
166 | 9 | Link to topic: http://{{ current_site }}{{ topic_url }} | ||
167 | 8 | \ No newline at end of file | 10 | \ No newline at end of file |
168 | 9 | 11 | ||
169 | === modified file 'templates/notification/maps_new_map/full.txt' | |||
170 | --- templates/notification/maps_new_map/full.txt 2017-04-23 21:00:01 +0000 | |||
171 | +++ templates/notification/maps_new_map/full.txt 2018-02-22 06:34:38 +0000 | |||
172 | @@ -1,7 +1,8 @@ | |||
174 | 1 | {% load i18n %}A new map was uploaded to the Website by {{ user }}: | 1 | {% load i18n %}A new map has been uploaded to the Website by {{ user }}: |
175 | 2 | {% blocktrans %} | 2 | {% blocktrans %} |
176 | 3 | Mapname: {{ mapname }} | 3 | Mapname: {{ mapname }} |
177 | 4 | Description: {{ uploader_comment }} | 4 | Description: {{ uploader_comment }} |
179 | 5 | ––––––––––– | 5 | |
180 | 6 | ------------------------- | ||
181 | 6 | Link to map: http://{{ current_site }}{{ url }} | 7 | Link to map: http://{{ current_site }}{{ url }} |
182 | 7 | {% endblocktrans %} | ||
183 | 8 | \ No newline at end of file | 8 | \ No newline at end of file |
184 | 9 | {% endblocktrans %} | ||
185 | 9 | 10 | ||
186 | === modified file 'templates/notification/messages_received/full.txt' | |||
187 | --- templates/notification/messages_received/full.txt 2009-03-17 12:57:21 +0000 | |||
188 | +++ templates/notification/messages_received/full.txt 2018-02-22 06:34:38 +0000 | |||
189 | @@ -4,7 +4,6 @@ | |||
190 | 4 | 4 | ||
191 | 5 | {{ message_body }} | 5 | {{ message_body }} |
192 | 6 | 6 | ||
197 | 7 | http://{{ current_site }}{{ message_url }} | 7 | ------------------------- |
198 | 8 | 8 | Link to Message: http://{{ current_site }}{{ message_url }} | |
199 | 9 | reply directly: | 9 | Reply directly: http://{{ current_site }}/messages/reply/{{ message_id }}/{% endblocktrans %} |
196 | 10 | http://{{ current_site }}/messages/reply/{{ message_id }}/{% endblocktrans %} | ||
200 | 11 | 10 | ||
201 | === added file 'templates/notification/messages_received/short.txt' | |||
202 | --- templates/notification/messages_received/short.txt 1970-01-01 00:00:00 +0000 | |||
203 | +++ templates/notification/messages_received/short.txt 2018-02-22 06:34:38 +0000 | |||
204 | @@ -0,0 +1,1 @@ | |||
205 | 1 | {% load i18n %}{% blocktrans with message.sender as message_sender %}User {{ message_sender }} has sent you a message{% endblocktrans %} | ||
206 | 0 | \ No newline at end of file | 2 | \ No newline at end of file |
207 | 1 | 3 | ||
208 | === removed file 'templates/notification/messages_received/short.txt' | |||
209 | --- templates/notification/messages_received/short.txt 2009-02-26 11:32:18 +0000 | |||
210 | +++ templates/notification/messages_received/short.txt 1970-01-01 00:00:00 +0000 | |||
211 | @@ -1,1 +0,0 @@ | |||
212 | 1 | {% load i18n %}{% blocktrans with message.sender as message_sender %}{{ notice }} by {{ message_sender }}{% endblocktrans %} | ||
213 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
214 | 3 | 1 | ||
215 | === modified file 'templates/notification/messages_reply_received/full.txt' | |||
216 | --- templates/notification/messages_reply_received/full.txt 2009-03-17 12:57:21 +0000 | |||
217 | +++ templates/notification/messages_reply_received/full.txt 2018-02-22 06:34:38 +0000 | |||
218 | @@ -4,7 +4,7 @@ | |||
219 | 4 | 4 | ||
220 | 5 | {{ message_body }} | 5 | {{ message_body }} |
221 | 6 | 6 | ||
226 | 7 | http://{{ current_site }}{{ message_url }} | 7 | ------------------------- |
227 | 8 | 8 | Link to message: http://{{ current_site }}{{ message_url }} | |
228 | 9 | reply directly: | 9 | Reply directly: http://{{ current_site }}/messages/reply/{{ message_id }}/ |
229 | 10 | http://{{ current_site }}/messages/reply/{{ message_id }}/{% endblocktrans %} | 10 | {% endblocktrans %} |
230 | 11 | 11 | ||
231 | === added file 'templates/notification/messages_reply_received/short.txt' | |||
232 | --- templates/notification/messages_reply_received/short.txt 1970-01-01 00:00:00 +0000 | |||
233 | +++ templates/notification/messages_reply_received/short.txt 2018-02-22 06:34:38 +0000 | |||
234 | @@ -0,0 +1,1 @@ | |||
235 | 1 | {% load i18n %}{% blocktrans with message.sender as message_sender %}{{ message_sender }} has replied to a message{% endblocktrans %} | ||
236 | 0 | \ No newline at end of file | 2 | \ No newline at end of file |
237 | 1 | 3 | ||
238 | === removed file 'templates/notification/messages_reply_received/short.txt' | |||
239 | --- templates/notification/messages_reply_received/short.txt 2009-02-26 11:32:18 +0000 | |||
240 | +++ templates/notification/messages_reply_received/short.txt 1970-01-01 00:00:00 +0000 | |||
241 | @@ -1,1 +0,0 @@ | |||
242 | 1 | {% load i18n %}{% blocktrans with message.sender as message_sender %}{{ notice }} by {{ message_sender }}{% endblocktrans %} | ||
243 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
244 | 3 | 1 | ||
245 | === modified file 'templates/notification/short.txt' | |||
246 | --- templates/notification/short.txt 2009-02-20 16:46:21 +0000 | |||
247 | +++ templates/notification/short.txt 2018-02-22 06:34:38 +0000 | |||
248 | @@ -1,1 +1,1 @@ | |||
249 | 1 | {% load i18n %}{% blocktrans %}{{ notice }}{% endblocktrans %} | ||
250 | 2 | \ No newline at end of file | 1 | \ No newline at end of file |
251 | 2 | {% load i18n %}{% blocktrans %}{{ notice }}{% endblocktrans %} | ||
252 | 3 | 3 | ||
253 | === removed directory 'templates/notification/wiki_article_edited' | |||
254 | === removed file 'templates/notification/wiki_article_edited/full.txt' | |||
255 | --- templates/notification/wiki_article_edited/full.txt 2009-02-20 10:11:49 +0000 | |||
256 | +++ templates/notification/wiki_article_edited/full.txt 1970-01-01 00:00:00 +0000 | |||
257 | @@ -1,4 +0,0 @@ | |||
258 | 1 | {% load i18n %}{% blocktrans with article.get_absolute_url as article_url %}The wiki article {{ article }} has been edited by {{ user }}. | ||
259 | 2 | |||
260 | 3 | http://{{ current_site }}{{ article_url }} | ||
261 | 4 | {% endblocktrans %} | ||
262 | 5 | 0 | ||
263 | === modified file 'templates/notification/wiki_observed_article_changed/full.txt' | |||
264 | --- templates/notification/wiki_observed_article_changed/full.txt 2009-02-20 10:11:49 +0000 | |||
265 | +++ templates/notification/wiki_observed_article_changed/full.txt 2018-02-22 06:34:38 +0000 | |||
266 | @@ -1,4 +1,8 @@ | |||
268 | 1 | {% load i18n %}{% blocktrans with observed.get_absolute_url as article_url %}The article {{ observed }} that you observe has changed. | 1 | {% load i18n %}{% url 'wiki_changeset' article rev as diff_url %}{% url 'wiki_article' article as article_url %}{% blocktrans %} |
269 | 2 | The article "{{ article }}" that you observe has been edited by {{ editor }}. | ||
270 | 3 | Comment for this revision: "{{ rev_comment }}" | ||
271 | 2 | 4 | ||
273 | 3 | http://{{ current_site }}{{ article_url }} | 5 | ------------------------- |
274 | 6 | A diff is available at: http://{{ current_site }}{{ diff_url }} | ||
275 | 7 | Link to article: http://{{ current_site }}{{ article_url }} | ||
276 | 4 | {% endblocktrans %} | 8 | {% endblocktrans %} |
277 | 5 | \ No newline at end of file | 9 | \ No newline at end of file |
278 | 6 | 10 | ||
279 | === modified file 'templates/notification/wiki_revision_reverted/full.txt' | |||
280 | --- templates/notification/wiki_revision_reverted/full.txt 2009-02-20 10:11:49 +0000 | |||
281 | +++ templates/notification/wiki_revision_reverted/full.txt 2018-02-22 06:34:38 +0000 | |||
282 | @@ -1,5 +1,6 @@ | |||
283 | 1 | {% load i18n %} | 1 | {% load i18n %} |
285 | 2 | {% blocktrans with article.get_absolute_url as article_url %}Your revision {{ revision }} on {{ article }} has been reverted. | 2 | {% blocktrans with article.get_absolute_url as article_url %}Your revision {{ revision }} on "{{ article }}" has been reverted. |
286 | 3 | 3 | ||
287 | 4 | http://{{ current_site }}{{ article_url }} | ||
288 | 5 | {% endblocktrans %} | ||
289 | 6 | \ No newline at end of file | 4 | \ No newline at end of file |
290 | 5 | -------------------------------------- | ||
291 | 6 | Link to article: http://{{ current_site }}{{ article_url }} | ||
292 | 7 | {% endblocktrans %} | ||
293 | 7 | 8 | ||
294 | === modified file 'templates/wiki/feeds/history_description.html' | |||
295 | --- templates/wiki/feeds/history_description.html 2016-04-30 09:43:53 +0000 | |||
296 | +++ templates/wiki/feeds/history_description.html 2018-02-22 06:34:38 +0000 | |||
297 | @@ -1,4 +1,4 @@ | |||
299 | 1 | {% load i18n custom_date %} | 1 | {% load i18n %} |
300 | 2 | 2 | ||
302 | 3 | {% trans "edited by user" %} {{ obj.editor.username }} {% trans "at"%} {{ obj.modified|custom_date:obj.editor }}<br> | 3 | {% trans "edited by user" %} {{ obj.editor.username }} {% trans "at"%} {{ obj.modified }}<br> |
303 | 4 | {{ obj.comment }} | 4 | {{ obj.comment }} |
304 | 5 | 5 | ||
305 | === modified file 'templates/wiki/feeds/history_title.html' | |||
306 | --- templates/wiki/feeds/history_title.html 2016-04-30 09:43:53 +0000 | |||
307 | +++ templates/wiki/feeds/history_title.html 2018-02-22 06:34:38 +0000 | |||
308 | @@ -1,3 +1,2 @@ | |||
309 | 1 | {%load custom_date %} | ||
310 | 2 | 1 | ||
312 | 3 | {{ obj.article.title }} - {{ obj.modified|custom_date:obj.editor }} | 2 | {{ obj.article.title }} - {{ obj.modified }} |
313 | 4 | 3 | ||
314 | === modified file 'wiki/models.py' | |||
315 | --- wiki/models.py 2017-12-01 14:06:15 +0000 | |||
316 | +++ wiki/models.py 2018-02-22 06:34:38 +0000 | |||
317 | @@ -133,13 +133,6 @@ | |||
318 | 133 | return self.filter(revision__gt=int(revision)) | 133 | return self.filter(revision__gt=int(revision)) |
319 | 134 | 134 | ||
320 | 135 | 135 | ||
321 | 136 | class NonRevertedChangeSetManager(ChangeSetManager): | ||
322 | 137 | |||
323 | 138 | def get_default_queryset(self): | ||
324 | 139 | super(PublishedBookManager, self).get_queryset().filter( | ||
325 | 140 | reverted=False) | ||
326 | 141 | |||
327 | 142 | |||
328 | 143 | class ChangeSet(models.Model): | 136 | class ChangeSet(models.Model): |
329 | 144 | """A report of an older version of some Article.""" | 137 | """A report of an older version of some Article.""" |
330 | 145 | 138 | ||
331 | @@ -165,7 +158,6 @@ | |||
332 | 165 | reverted = models.BooleanField(_(u"Reverted Revision"), default=False) | 158 | reverted = models.BooleanField(_(u"Reverted Revision"), default=False) |
333 | 166 | 159 | ||
334 | 167 | objects = ChangeSetManager() | 160 | objects = ChangeSetManager() |
335 | 168 | non_reverted_objects = NonRevertedChangeSetManager() | ||
336 | 169 | 161 | ||
337 | 170 | class Meta: | 162 | class Meta: |
338 | 171 | verbose_name = _(u'Change set') | 163 | verbose_name = _(u'Change set') |
339 | @@ -177,16 +169,17 @@ | |||
340 | 177 | def __unicode__(self): | 169 | def __unicode__(self): |
341 | 178 | return u'#%s' % self.revision | 170 | return u'#%s' % self.revision |
342 | 179 | 171 | ||
343 | 180 | @models.permalink | ||
344 | 181 | def get_absolute_url(self): | 172 | def get_absolute_url(self): |
345 | 182 | if self.article.group is None: | 173 | if self.article.group is None: |
353 | 183 | return ('wiki_changeset', (), | 174 | return reverse('wiki_changeset', kwargs={ |
354 | 184 | {'title': self.article.title, | 175 | 'title': self.article.title, |
355 | 185 | 'revision': self.revision}) | 176 | 'revision': self.revision |
356 | 186 | return ('wiki_changeset', (), | 177 | }) |
357 | 187 | {'group_slug': self.article.group.slug, | 178 | return reverse('wiki_changeset', kwargs={ |
358 | 188 | 'title': self.article.title, | 179 | 'group_slug': self.article.group.slug, |
359 | 189 | 'revision': self.revision}) | 180 | 'title': self.article.title, |
360 | 181 | 'revision': self.revision, | ||
361 | 182 | }) | ||
362 | 190 | 183 | ||
363 | 191 | def is_anonymous_change(self): | 184 | def is_anonymous_change(self): |
364 | 192 | return self.editor is None | 185 | return self.editor is None |
365 | @@ -240,31 +233,9 @@ | |||
366 | 240 | article=self.article).latest().revision + 1 | 233 | article=self.article).latest().revision + 1 |
367 | 241 | except self.DoesNotExist: | 234 | except self.DoesNotExist: |
368 | 242 | self.revision = 1 | 235 | self.revision = 1 |
369 | 236 | |||
370 | 243 | super(ChangeSet, self).save(*args, **kwargs) | 237 | super(ChangeSet, self).save(*args, **kwargs) |
371 | 244 | 238 | ||
372 | 245 | def display_diff(self): | ||
373 | 246 | """Returns a HTML representation of the diff.""" | ||
374 | 247 | |||
375 | 248 | # well, it *will* be the old content | ||
376 | 249 | old_content = self.article.content | ||
377 | 250 | |||
378 | 251 | # newer non-reverted revisions of this article, starting from this | ||
379 | 252 | newer_changesets = ChangeSet.non_reverted_objects.filter( | ||
380 | 253 | article=self.article, | ||
381 | 254 | revision__gte=self.revision) | ||
382 | 255 | |||
383 | 256 | # apply all patches to get the content of this revision | ||
384 | 257 | for i, changeset in enumerate(newer_changesets): | ||
385 | 258 | patches = dmp.patch_fromText(changeset.content_diff) | ||
386 | 259 | if len(newer_changesets) == i + 1: | ||
387 | 260 | # we need to compare with the next revision after the change | ||
388 | 261 | next_rev_content = old_content | ||
389 | 262 | old_content = dmp.patch_apply(patches, old_content)[0] | ||
390 | 263 | |||
391 | 264 | diffs = dmp.diff_main(old_content, next_rev_content) | ||
392 | 265 | dmp.diff_cleanupSemantic(diffs) | ||
393 | 266 | return dmp.diff_prettyHtml(diffs) | ||
394 | 267 | |||
395 | 268 | def get_content(self): | 239 | def get_content(self): |
396 | 269 | """Returns the content of this revision.""" | 240 | """Returns the content of this revision.""" |
397 | 270 | content = self.article.content | 241 | content = self.article.content |
398 | @@ -283,6 +254,3 @@ | |||
399 | 283 | diffs = dmp.diff_main(other_content, self.get_content()) | 254 | diffs = dmp.diff_main(other_content, self.get_content()) |
400 | 284 | dmp.diff_cleanupSemantic(diffs) | 255 | dmp.diff_cleanupSemantic(diffs) |
401 | 285 | return dmp.diff_prettyHtml(diffs) | 256 | return dmp.diff_prettyHtml(diffs) |
402 | 286 | |||
403 | 287 | if notification is not None: | ||
404 | 288 | signals.post_save.connect(notification.handle_observations, sender=Article) | ||
405 | 289 | 257 | ||
406 | === modified file 'wiki/views.py' | |||
407 | --- wiki/views.py 2017-12-03 11:43:47 +0000 | |||
408 | +++ wiki/views.py 2018-02-22 06:34:38 +0000 | |||
409 | @@ -286,6 +286,18 @@ | |||
410 | 286 | form.group = group | 286 | form.group = group |
411 | 287 | 287 | ||
412 | 288 | new_article, changeset = form.save() | 288 | new_article, changeset = form.save() |
413 | 289 | |||
414 | 290 | if notification and not changeset.reverted: | ||
415 | 291 | # Get observers for this article and exclude current editor | ||
416 | 292 | items = notification.ObservedItem.objects.all_for( | ||
417 | 293 | new_article, 'post_save').exclude(user=request.user).iterator() | ||
418 | 294 | users = [o.user for o in items] | ||
419 | 295 | notification.send(users, 'wiki_observed_article_changed', | ||
420 | 296 | {'editor': request.user, | ||
421 | 297 | 'rev': changeset.revision, | ||
422 | 298 | 'rev_comment': changeset.comment, | ||
423 | 299 | 'article': new_article}) | ||
424 | 300 | |||
425 | 289 | 301 | ||
426 | 290 | return redirect(new_article) | 302 | return redirect(new_article) |
427 | 291 | 303 | ||
428 | 292 | 304 | ||
429 | === modified file 'wlmaps/models.py' | |||
430 | --- wlmaps/models.py 2017-09-12 18:04:34 +0000 | |||
431 | +++ wlmaps/models.py 2018-02-22 06:34:38 +0000 | |||
432 | @@ -63,9 +63,15 @@ | |||
433 | 63 | 63 | ||
434 | 64 | map = super(Map, self).save(*args, **kwargs) | 64 | map = super(Map, self).save(*args, **kwargs) |
435 | 65 | 65 | ||
437 | 66 | # Send notifications only on new maps, not when updating fields, e.g. nr_downloads | 66 | # Send notifications only on new maps, not when updating fields, e.g. |
438 | 67 | # nr_downloads | ||
439 | 67 | if notification and is_new: | 68 | if notification and is_new: |
442 | 68 | notification.send(notification.get_observers_for('maps_new_map'), 'maps_new_map', | 69 | notification.send(notification.get_observers_for('maps_new_map', excl_user=self.uploader), 'maps_new_map', |
443 | 69 | {'mapname': self.name, 'url': self.get_absolute_url(), 'user': self.uploader, 'uploader_comment': self.uploader_comment}, queue=True) | 70 | {'mapname': self.name, |
444 | 71 | 'url': self.get_absolute_url(), | ||
445 | 72 | 'user': self.uploader, | ||
446 | 73 | 'uploader_comment': self.uploader_comment | ||
447 | 74 | }, | ||
448 | 75 | queue=True) | ||
449 | 70 | 76 | ||
451 | 71 | return map | 77 | return map |
I found a bug in this code which needs fixing.