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 | +table.field-list{ |
6 | + border-collapse: separate; |
7 | +} |
8 | + |
9 | .sphinx a.headerlink { |
10 | padding: 0 4px 0 4px; |
11 | visibility: hidden; |
12 | |
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 | class NoticeType(models.Model): |
18 | |
19 | label = models.CharField(_('label'), max_length=40) |
20 | - display = models.CharField(_('display'), max_length=50) |
21 | + display = models.CharField(_('display'), |
22 | + max_length=50, |
23 | + help_text=_('Used as subject when sending emails.')) |
24 | description = models.CharField(_('description'), max_length=100) |
25 | |
26 | # by default only on for media with sensitivity less than or equal to this |
27 | @@ -101,14 +103,22 @@ |
28 | setting.save() |
29 | return setting |
30 | |
31 | + |
32 | def should_send(user, notice_type, medium): |
33 | return get_notification_setting(user, notice_type, medium).send |
34 | |
35 | -def get_observers_for(notice_type): |
36 | - """ Returns the list of users which wants to get a message (email) for this |
37 | + |
38 | +def get_observers_for(notice_type, excl_user=None): |
39 | + """Returns the list of users which wants to get a message (email) for this |
40 | type of notice.""" |
41 | - settings = NoticeSetting.objects.filter(notice_type__label=notice_type).filter(send=True) |
42 | - return [s.user for s in NoticeSetting.objects.filter(notice_type__label=notice_type).filter(send=True)] |
43 | + query = NoticeSetting.objects.filter( |
44 | + notice_type__label=notice_type, send=True) |
45 | + |
46 | + if excl_user: |
47 | + query = query.exclude(user=excl_user) |
48 | + |
49 | + return [notice_setting.user for notice_setting in query] |
50 | + |
51 | |
52 | class NoticeQueueBatch(models.Model): |
53 | """A queued notice. |
54 | @@ -244,6 +254,8 @@ |
55 | 'user': user, |
56 | 'notices_url': notices_url, |
57 | 'current_site': current_site, |
58 | + 'subject': notice_type.display, |
59 | + 'description': notice_type.description, |
60 | }) |
61 | context.update(extra_context) |
62 | |
63 | @@ -254,10 +266,14 @@ |
64 | subject = ''.join(render_to_string('notification/email_subject.txt', { |
65 | 'message': messages['short.txt'], |
66 | }, context).splitlines()) |
67 | - |
68 | + |
69 | + # Strip leading newlines. Make writing the email templates easier: |
70 | + # Each linebreak in the templates results in a linebreak in the emails |
71 | + # If the first line in a template contains only template tags the |
72 | + # email will contain an empty line at the top. |
73 | body = render_to_string('notification/email_body.txt', { |
74 | 'message': messages['full.txt'], |
75 | - }, context) |
76 | + }, context).lstrip() |
77 | |
78 | if should_send(user, notice_type, '1') and user.email: # Email |
79 | recipients.append(user.email) |
80 | |
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 | if notification: |
86 | if not topic: |
87 | # Inform subscribers of a new topic |
88 | - notification.send(notification.get_observers_for('forum_new_topic'), 'forum_new_topic', |
89 | - {'topic': post.topic, 'post': post, 'user': post.topic.user}, queue = True) |
90 | + subscribers = notification.get_observers_for('forum_new_topic', |
91 | + excl_user=request.user) |
92 | + notification.send(subscribers, 'forum_new_topic', |
93 | + {'topic': post.topic, |
94 | + 'post': post, |
95 | + 'user': post.topic.user |
96 | + }, |
97 | + queue = True) |
98 | # Topics author is subscriber for all new posts in his topic |
99 | post.topic.subscribers.add(request.user) |
100 | |
101 | else: |
102 | # Send mails about a new post to topic subscribers |
103 | - notification.send(post.topic.subscribers.all(), 'forum_new_post', |
104 | + notification.send(post.topic.subscribers.exclude(username=post.user), 'forum_new_post', |
105 | {'post': post, 'topic': topic, 'user': post.user}, queue = True) |
106 | |
107 | return HttpResponseRedirect(post.get_absolute_url()) |
108 | |
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 @@ |
113 | -{% load i18n %}{% blocktrans %}You have received the following notice from {{ current_site }}: |
114 | - |
115 | +{% load i18n %}{% blocktrans %} |
116 | {{ message }} |
117 | To change how you receive notifications, please go to {{ notices_url }}. |
118 | {% endblocktrans %} |
119 | |
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 @@ |
124 | -{% load i18n %}{% blocktrans %}[Widelands.org] {{ message }}{% endblocktrans %} |
125 | +{% load i18n %} |
126 | +{% if message|length > 1 %} |
127 | +{% blocktrans %}{{ message }}{% endblocktrans %} |
128 | +{% else %} |
129 | +{% blocktrans %}{{ subject }}{% endblocktrans %} |
130 | +{% endif %} |
131 | |
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 | |
137 | "{{ user }}" wrote: |
138 | |
139 | -{{ post.body_text }} |
140 | +{{ post.body }} |
141 | {% blocktrans with post.get_absolute_url as post_url and topic.get_absolute_url as topic_url %} |
142 | -––––––––––– |
143 | +------------------------- |
144 | Link to post: http://{{ current_site }}{{ post_url }} |
145 | Link to topic: http://{{ current_site }}{{ topic_url }} |
146 | {% endblocktrans %} |
147 | \ No newline at end of file |
148 | |
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 @@ |
153 | -{% load i18n %}{% blocktrans with topic.get_absolute_url as topic_url %}The Forum topic {{ topic }} has been created by {{ user }}. |
154 | - |
155 | -http://{{ current_site }}{{ topic_url }} |
156 | +{% 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 | + |
158 | +{{ user }} wrote: |
159 | + |
160 | +{{ txt }} |
161 | {% endblocktrans %} |
162 | -{{ topic }}: |
163 | |
164 | -{{ post.body_text }} |
165 | +------------------------- |
166 | +Link to topic: http://{{ current_site }}{{ topic_url }} |
167 | \ No newline at end of file |
168 | |
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 @@ |
173 | -{% load i18n %}A new map was uploaded to the Website by {{ user }}: |
174 | +{% load i18n %}A new map has been uploaded to the Website by {{ user }}: |
175 | {% blocktrans %} |
176 | Mapname: {{ mapname }} |
177 | Description: {{ uploader_comment }} |
178 | -––––––––––– |
179 | + |
180 | +------------------------- |
181 | Link to map: http://{{ current_site }}{{ url }} |
182 | -{% endblocktrans %} |
183 | \ No newline at end of file |
184 | +{% endblocktrans %} |
185 | |
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 | |
191 | {{ message_body }} |
192 | |
193 | -http://{{ current_site }}{{ message_url }} |
194 | - |
195 | -reply directly: |
196 | -http://{{ current_site }}/messages/reply/{{ message_id }}/{% endblocktrans %} |
197 | +------------------------- |
198 | +Link to Message: http://{{ current_site }}{{ message_url }} |
199 | +Reply directly: http://{{ current_site }}/messages/reply/{{ message_id }}/{% endblocktrans %} |
200 | |
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 | +{% load i18n %}{% blocktrans with message.sender as message_sender %}User {{ message_sender }} has sent you a message{% endblocktrans %} |
206 | \ No newline at end of file |
207 | |
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 | -{% load i18n %}{% blocktrans with message.sender as message_sender %}{{ notice }} by {{ message_sender }}{% endblocktrans %} |
213 | \ No newline at end of file |
214 | |
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 | |
220 | {{ message_body }} |
221 | |
222 | -http://{{ current_site }}{{ message_url }} |
223 | - |
224 | -reply directly: |
225 | -http://{{ current_site }}/messages/reply/{{ message_id }}/{% endblocktrans %} |
226 | +------------------------- |
227 | +Link to message: http://{{ current_site }}{{ message_url }} |
228 | +Reply directly: http://{{ current_site }}/messages/reply/{{ message_id }}/ |
229 | +{% endblocktrans %} |
230 | |
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 | +{% load i18n %}{% blocktrans with message.sender as message_sender %}{{ message_sender }} has replied to a message{% endblocktrans %} |
236 | \ No newline at end of file |
237 | |
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 | -{% load i18n %}{% blocktrans with message.sender as message_sender %}{{ notice }} by {{ message_sender }}{% endblocktrans %} |
243 | \ No newline at end of file |
244 | |
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 | -{% load i18n %}{% blocktrans %}{{ notice }}{% endblocktrans %} |
250 | \ No newline at end of file |
251 | +{% load i18n %}{% blocktrans %}{{ notice }}{% endblocktrans %} |
252 | |
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 | -{% load i18n %}{% blocktrans with article.get_absolute_url as article_url %}The wiki article {{ article }} has been edited by {{ user }}. |
259 | - |
260 | -http://{{ current_site }}{{ article_url }} |
261 | -{% endblocktrans %} |
262 | |
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 @@ |
267 | -{% load i18n %}{% blocktrans with observed.get_absolute_url as article_url %}The article {{ observed }} that you observe has changed. |
268 | +{% load i18n %}{% url 'wiki_changeset' article rev as diff_url %}{% url 'wiki_article' article as article_url %}{% blocktrans %} |
269 | +The article "{{ article }}" that you observe has been edited by {{ editor }}. |
270 | +Comment for this revision: "{{ rev_comment }}" |
271 | |
272 | -http://{{ current_site }}{{ article_url }} |
273 | +------------------------- |
274 | +A diff is available at: http://{{ current_site }}{{ diff_url }} |
275 | +Link to article: http://{{ current_site }}{{ article_url }} |
276 | {% endblocktrans %} |
277 | \ No newline at end of file |
278 | |
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 | {% load i18n %} |
284 | -{% blocktrans with article.get_absolute_url as article_url %}Your revision {{ revision }} on {{ article }} has been reverted. |
285 | +{% blocktrans with article.get_absolute_url as article_url %}Your revision {{ revision }} on "{{ article }}" has been reverted. |
286 | |
287 | -http://{{ current_site }}{{ article_url }} |
288 | -{% endblocktrans %} |
289 | \ No newline at end of file |
290 | +-------------------------------------- |
291 | +Link to article: http://{{ current_site }}{{ article_url }} |
292 | +{% endblocktrans %} |
293 | |
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 @@ |
298 | -{% load i18n custom_date %} |
299 | +{% load i18n %} |
300 | |
301 | -{% trans "edited by user" %} {{ obj.editor.username }} {% trans "at"%} {{ obj.modified|custom_date:obj.editor }}<br> |
302 | +{% trans "edited by user" %} {{ obj.editor.username }} {% trans "at"%} {{ obj.modified }}<br> |
303 | {{ obj.comment }} |
304 | |
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 | -{%load custom_date %} |
310 | |
311 | -{{ obj.article.title }} - {{ obj.modified|custom_date:obj.editor }} |
312 | +{{ obj.article.title }} - {{ obj.modified }} |
313 | |
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 | return self.filter(revision__gt=int(revision)) |
319 | |
320 | |
321 | -class NonRevertedChangeSetManager(ChangeSetManager): |
322 | - |
323 | - def get_default_queryset(self): |
324 | - super(PublishedBookManager, self).get_queryset().filter( |
325 | - reverted=False) |
326 | - |
327 | - |
328 | class ChangeSet(models.Model): |
329 | """A report of an older version of some Article.""" |
330 | |
331 | @@ -165,7 +158,6 @@ |
332 | reverted = models.BooleanField(_(u"Reverted Revision"), default=False) |
333 | |
334 | objects = ChangeSetManager() |
335 | - non_reverted_objects = NonRevertedChangeSetManager() |
336 | |
337 | class Meta: |
338 | verbose_name = _(u'Change set') |
339 | @@ -177,16 +169,17 @@ |
340 | def __unicode__(self): |
341 | return u'#%s' % self.revision |
342 | |
343 | - @models.permalink |
344 | def get_absolute_url(self): |
345 | if self.article.group is None: |
346 | - return ('wiki_changeset', (), |
347 | - {'title': self.article.title, |
348 | - 'revision': self.revision}) |
349 | - return ('wiki_changeset', (), |
350 | - {'group_slug': self.article.group.slug, |
351 | - 'title': self.article.title, |
352 | - 'revision': self.revision}) |
353 | + return reverse('wiki_changeset', kwargs={ |
354 | + 'title': self.article.title, |
355 | + 'revision': self.revision |
356 | + }) |
357 | + return reverse('wiki_changeset', kwargs={ |
358 | + 'group_slug': self.article.group.slug, |
359 | + 'title': self.article.title, |
360 | + 'revision': self.revision, |
361 | + }) |
362 | |
363 | def is_anonymous_change(self): |
364 | return self.editor is None |
365 | @@ -240,31 +233,9 @@ |
366 | article=self.article).latest().revision + 1 |
367 | except self.DoesNotExist: |
368 | self.revision = 1 |
369 | + |
370 | super(ChangeSet, self).save(*args, **kwargs) |
371 | |
372 | - def display_diff(self): |
373 | - """Returns a HTML representation of the diff.""" |
374 | - |
375 | - # well, it *will* be the old content |
376 | - old_content = self.article.content |
377 | - |
378 | - # newer non-reverted revisions of this article, starting from this |
379 | - newer_changesets = ChangeSet.non_reverted_objects.filter( |
380 | - article=self.article, |
381 | - revision__gte=self.revision) |
382 | - |
383 | - # apply all patches to get the content of this revision |
384 | - for i, changeset in enumerate(newer_changesets): |
385 | - patches = dmp.patch_fromText(changeset.content_diff) |
386 | - if len(newer_changesets) == i + 1: |
387 | - # we need to compare with the next revision after the change |
388 | - next_rev_content = old_content |
389 | - old_content = dmp.patch_apply(patches, old_content)[0] |
390 | - |
391 | - diffs = dmp.diff_main(old_content, next_rev_content) |
392 | - dmp.diff_cleanupSemantic(diffs) |
393 | - return dmp.diff_prettyHtml(diffs) |
394 | - |
395 | def get_content(self): |
396 | """Returns the content of this revision.""" |
397 | content = self.article.content |
398 | @@ -283,6 +254,3 @@ |
399 | diffs = dmp.diff_main(other_content, self.get_content()) |
400 | dmp.diff_cleanupSemantic(diffs) |
401 | return dmp.diff_prettyHtml(diffs) |
402 | - |
403 | -if notification is not None: |
404 | - signals.post_save.connect(notification.handle_observations, sender=Article) |
405 | |
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 | form.group = group |
411 | |
412 | new_article, changeset = form.save() |
413 | + |
414 | + if notification and not changeset.reverted: |
415 | + # Get observers for this article and exclude current editor |
416 | + items = notification.ObservedItem.objects.all_for( |
417 | + new_article, 'post_save').exclude(user=request.user).iterator() |
418 | + users = [o.user for o in items] |
419 | + notification.send(users, 'wiki_observed_article_changed', |
420 | + {'editor': request.user, |
421 | + 'rev': changeset.revision, |
422 | + 'rev_comment': changeset.comment, |
423 | + 'article': new_article}) |
424 | + |
425 | |
426 | return redirect(new_article) |
427 | |
428 | |
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 | |
434 | map = super(Map, self).save(*args, **kwargs) |
435 | |
436 | - # Send notifications only on new maps, not when updating fields, e.g. nr_downloads |
437 | + # Send notifications only on new maps, not when updating fields, e.g. |
438 | + # nr_downloads |
439 | if notification and is_new: |
440 | - notification.send(notification.get_observers_for('maps_new_map'), 'maps_new_map', |
441 | - {'mapname': self.name, 'url': self.get_absolute_url(), 'user': self.uploader, 'uploader_comment': self.uploader_comment}, queue=True) |
442 | + notification.send(notification.get_observers_for('maps_new_map', excl_user=self.uploader), 'maps_new_map', |
443 | + {'mapname': self.name, |
444 | + 'url': self.get_absolute_url(), |
445 | + 'user': self.uploader, |
446 | + 'uploader_comment': self.uploader_comment |
447 | + }, |
448 | + queue=True) |
449 | |
450 | - return map |
451 | + return map |
I found a bug in this code which needs fixing.