Merge lp:~widelands-dev/widelands-website/better_notification_mail into lp:widelands-website

Proposed by kaputtnik
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
Reviewer Review Type Date Requested Status
kaputtnik (community) Needs Resubmitting
SirVer Approve
Review via email: mp+335028@code.launchpad.net

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://wl.widelands.org/wiki/history/Main%20Page/changeset/94/. This will fix bug 340920

Removed filter 'custom_date' from wiki feeds, to get a normal date format.

This should may be tested on the alpha site.

To post a comment you must log in.
493. By kaputtnik

small css fix for the documentation

Revision history for this message
kaputtnik (franku) wrote :

I found a bug in this code which needs fixing.

review: Needs Fixing
494. By kaputtnik

fixed a failure in wlmaps; removed django-messages related templates because those are self handled by django-messages

Revision history for this message
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/notification/messages_*.txt) are obsolete and i have removed them in this branch.

django messages uses this template:

http://bazaar.launchpad.net/~widelands-dev/widelands-website/trunk/view/head:/templates/django_messages/new_message.html

review: Needs Resubmitting
Revision history for this message
GunChleoc (gunchleoc) wrote :

Code LGTM as far as I can tell.

I might be available sometime next week to do some testing.

495. By kaputtnik

reverted latest changes

496. By kaputtnik

fixed a failure in wlmaps

497. By kaputtnik

merged with trunk

Revision history for this message
kaputtnik (franku) wrote :

I've made a failure recently by updating django-messages to a wrong version.

https://wl.widelands.org/forum/topic/4196/

I fixed it in trunk and also in this branch, which means we need to keep the templates in

templates/notification/messages_*/full_text

Revision history for this message
SirVer (sirver) wrote :

lgtm. not tested though.

review: Approve
Revision history for this message
kaputtnik (franku) wrote :

Some parts aren't fine. E.g. the email subject when replying to a pm.

review: Needs Fixing
498. By kaputtnik

unified email messsages

Revision history for this message
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.

review: Needs Resubmitting
499. By kaputtnik

reduced upper space for email of observed article changed

Revision history for this message
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

500. By kaputtnik

remove leading newlines from email body

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have added a few posts to the alpha site and uploaded a map.

Revision history for this message
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.

501. By kaputtnik

Added files to overwrite default short.txt

Revision history for this message
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.

Revision history for this message
GunChleoc (gunchleoc) wrote :

There's a typo in the subject now: was send -> was sent

I got the 2 notifications for the messages.

502. By kaputtnik

fixed a typo

503. By kaputtnik

merged with trunk

Revision history for this message
kaputtnik (franku) wrote :

Merged and deployed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'media/css/documentation.css'
--- media/css/documentation.css 2016-10-18 09:43:58 +0000
+++ media/css/documentation.css 2018-02-22 06:34:38 +0000
@@ -1,3 +1,7 @@
1table.field-list{
2 border-collapse: separate;
3}
4
1.sphinx a.headerlink {5.sphinx a.headerlink {
2 padding: 0 4px 0 4px;6 padding: 0 4px 0 4px;
3 visibility: hidden;7 visibility: hidden;
48
=== modified file 'notification/models.py'
--- notification/models.py 2017-05-07 09:51:15 +0000
+++ notification/models.py 2018-02-22 06:34:38 +0000
@@ -40,7 +40,9 @@
40class NoticeType(models.Model):40class NoticeType(models.Model):
4141
42 label = models.CharField(_('label'), max_length=40)42 label = models.CharField(_('label'), max_length=40)
43 display = models.CharField(_('display'), max_length=50)43 display = models.CharField(_('display'),
44 max_length=50,
45 help_text=_('Used as subject when sending emails.'))
44 description = models.CharField(_('description'), max_length=100)46 description = models.CharField(_('description'), max_length=100)
4547
46 # by default only on for media with sensitivity less than or equal to this48 # by default only on for media with sensitivity less than or equal to this
@@ -101,14 +103,22 @@
101 setting.save()103 setting.save()
102 return setting104 return setting
103105
106
104def should_send(user, notice_type, medium):107def should_send(user, notice_type, medium):
105 return get_notification_setting(user, notice_type, medium).send108 return get_notification_setting(user, notice_type, medium).send
106109
107def get_observers_for(notice_type):110
108 """ Returns the list of users which wants to get a message (email) for this111def get_observers_for(notice_type, excl_user=None):
112 """Returns the list of users which wants to get a message (email) for this
109 type of notice."""113 type of notice."""
110 settings = NoticeSetting.objects.filter(notice_type__label=notice_type).filter(send=True)114 query = NoticeSetting.objects.filter(
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)
116
117 if excl_user:
118 query = query.exclude(user=excl_user)
119
120 return [notice_setting.user for notice_setting in query]
121
112122
113class NoticeQueueBatch(models.Model):123class NoticeQueueBatch(models.Model):
114 """A queued notice.124 """A queued notice.
@@ -244,6 +254,8 @@
244 'user': user,254 'user': user,
245 'notices_url': notices_url,255 'notices_url': notices_url,
246 'current_site': current_site,256 'current_site': current_site,
257 'subject': notice_type.display,
258 'description': notice_type.description,
247 })259 })
248 context.update(extra_context)260 context.update(extra_context)
249261
@@ -254,10 +266,14 @@
254 subject = ''.join(render_to_string('notification/email_subject.txt', {266 subject = ''.join(render_to_string('notification/email_subject.txt', {
255 'message': messages['short.txt'],267 'message': messages['short.txt'],
256 }, context).splitlines())268 }, context).splitlines())
257269
270 # Strip leading newlines. Make writing the email templates easier:
271 # Each linebreak in the templates results in a linebreak in the emails
272 # If the first line in a template contains only template tags the
273 # email will contain an empty line at the top.
258 body = render_to_string('notification/email_body.txt', {274 body = render_to_string('notification/email_body.txt', {
259 'message': messages['full.txt'],275 'message': messages['full.txt'],
260 }, context)276 }, context).lstrip()
261277
262 if should_send(user, notice_type, '1') and user.email: # Email278 if should_send(user, notice_type, '1') and user.email: # Email
263 recipients.append(user.email)279 recipients.append(user.email)
264280
=== modified file 'pybb/views.py'
--- pybb/views.py 2017-11-26 10:57:35 +0000
+++ pybb/views.py 2018-02-22 06:34:38 +0000
@@ -178,14 +178,20 @@
178 if notification:178 if notification:
179 if not topic:179 if not topic:
180 # Inform subscribers of a new topic180 # Inform subscribers of a new topic
181 notification.send(notification.get_observers_for('forum_new_topic'), 'forum_new_topic',181 subscribers = notification.get_observers_for('forum_new_topic',
182 {'topic': post.topic, 'post': post, 'user': post.topic.user}, queue = True)182 excl_user=request.user)
183 notification.send(subscribers, 'forum_new_topic',
184 {'topic': post.topic,
185 'post': post,
186 'user': post.topic.user
187 },
188 queue = True)
183 # Topics author is subscriber for all new posts in his topic189 # Topics author is subscriber for all new posts in his topic
184 post.topic.subscribers.add(request.user)190 post.topic.subscribers.add(request.user)
185191
186 else:192 else:
187 # Send mails about a new post to topic subscribers193 # Send mails about a new post to topic subscribers
188 notification.send(post.topic.subscribers.all(), 'forum_new_post',194 notification.send(post.topic.subscribers.exclude(username=post.user), 'forum_new_post',
189 {'post': post, 'topic': topic, 'user': post.user}, queue = True)195 {'post': post, 'topic': topic, 'user': post.user}, queue = True)
190196
191 return HttpResponseRedirect(post.get_absolute_url())197 return HttpResponseRedirect(post.get_absolute_url())
192198
=== modified file 'templates/notification/email_body.txt'
--- templates/notification/email_body.txt 2017-04-17 14:34:48 +0000
+++ templates/notification/email_body.txt 2018-02-22 06:34:38 +0000
@@ -1,5 +1,4 @@
1{% load i18n %}{% blocktrans %}You have received the following notice from {{ current_site }}:1{% load i18n %}{% blocktrans %}
2
3{{ message }}2{{ message }}
4To change how you receive notifications, please go to {{ notices_url }}.3To change how you receive notifications, please go to {{ notices_url }}.
5{% endblocktrans %}4{% endblocktrans %}
65
=== modified file 'templates/notification/email_subject.txt'
--- templates/notification/email_subject.txt 2009-02-20 16:46:21 +0000
+++ templates/notification/email_subject.txt 2018-02-22 06:34:38 +0000
@@ -1,1 +1,6 @@
1{% load i18n %}{% blocktrans %}[Widelands.org] {{ message }}{% endblocktrans %}1{% load i18n %}
2{% if message|length > 1 %}
3{% blocktrans %}{{ message }}{% endblocktrans %}
4{% else %}
5{% blocktrans %}{{ subject }}{% endblocktrans %}
6{% endif %}
27
=== modified file 'templates/notification/forum_new_post/full.txt'
--- templates/notification/forum_new_post/full.txt 2015-03-16 07:00:43 +0000
+++ templates/notification/forum_new_post/full.txt 2018-02-22 06:34:38 +0000
@@ -2,9 +2,9 @@
22
3"{{ user }}" wrote:3"{{ user }}" wrote:
44
5{{ post.body_text }}5{{ post.body }}
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 %}
7–––––––––––7-------------------------
8Link to post: http://{{ current_site }}{{ post_url }}8Link to post: http://{{ current_site }}{{ post_url }}
9Link to topic: http://{{ current_site }}{{ topic_url }}9Link to topic: http://{{ current_site }}{{ topic_url }}
10{% endblocktrans %}10{% endblocktrans %}
11\ No newline at end of file11\ No newline at end of file
1212
=== modified file 'templates/notification/forum_new_topic/full.txt'
--- templates/notification/forum_new_topic/full.txt 2010-06-10 12:13:43 +0000
+++ templates/notification/forum_new_topic/full.txt 2018-02-22 06:34:38 +0000
@@ -1,7 +1,9 @@
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 }}.
22
3http://{{ current_site }}{{ topic_url }}3{{ user }} wrote:
4
5{{ txt }}
4{% endblocktrans %}6{% endblocktrans %}
5{{ topic }}:
67
7{{ post.body_text }}8-------------------------
9Link to topic: http://{{ current_site }}{{ topic_url }}
8\ No newline at end of file10\ No newline at end of file
911
=== modified file 'templates/notification/maps_new_map/full.txt'
--- templates/notification/maps_new_map/full.txt 2017-04-23 21:00:01 +0000
+++ templates/notification/maps_new_map/full.txt 2018-02-22 06:34:38 +0000
@@ -1,7 +1,8 @@
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 }}:
2{% blocktrans %}2{% blocktrans %}
3Mapname: {{ mapname }}3Mapname: {{ mapname }}
4Description: {{ uploader_comment }}4Description: {{ uploader_comment }}
5–––––––––––5
6-------------------------
6Link to map: http://{{ current_site }}{{ url }}7Link to map: http://{{ current_site }}{{ url }}
7{% endblocktrans %}
8\ No newline at end of file8\ No newline at end of file
9{% endblocktrans %}
910
=== modified file 'templates/notification/messages_received/full.txt'
--- templates/notification/messages_received/full.txt 2009-03-17 12:57:21 +0000
+++ templates/notification/messages_received/full.txt 2018-02-22 06:34:38 +0000
@@ -4,7 +4,6 @@
44
5{{ message_body }}5{{ message_body }}
66
7http://{{ current_site }}{{ message_url }}7-------------------------
88Link to Message: http://{{ current_site }}{{ message_url }}
9reply directly: 9Reply directly: http://{{ current_site }}/messages/reply/{{ message_id }}/{% endblocktrans %}
10http://{{ current_site }}/messages/reply/{{ message_id }}/{% endblocktrans %}
1110
=== added file 'templates/notification/messages_received/short.txt'
--- templates/notification/messages_received/short.txt 1970-01-01 00:00:00 +0000
+++ templates/notification/messages_received/short.txt 2018-02-22 06:34:38 +0000
@@ -0,0 +1,1 @@
1{% load i18n %}{% blocktrans with message.sender as message_sender %}User {{ message_sender }} has sent you a message{% endblocktrans %}
0\ No newline at end of file2\ No newline at end of file
13
=== removed file 'templates/notification/messages_received/short.txt'
--- templates/notification/messages_received/short.txt 2009-02-26 11:32:18 +0000
+++ templates/notification/messages_received/short.txt 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{% load i18n %}{% blocktrans with message.sender as message_sender %}{{ notice }} by {{ message_sender }}{% endblocktrans %}
2\ No newline at end of file0\ No newline at end of file
31
=== modified file 'templates/notification/messages_reply_received/full.txt'
--- templates/notification/messages_reply_received/full.txt 2009-03-17 12:57:21 +0000
+++ templates/notification/messages_reply_received/full.txt 2018-02-22 06:34:38 +0000
@@ -4,7 +4,7 @@
44
5{{ message_body }}5{{ message_body }}
66
7http://{{ current_site }}{{ message_url }}7-------------------------
88Link to message: http://{{ current_site }}{{ message_url }}
9reply directly: 9Reply directly: http://{{ current_site }}/messages/reply/{{ message_id }}/
10http://{{ current_site }}/messages/reply/{{ message_id }}/{% endblocktrans %}10{% endblocktrans %}
1111
=== added file 'templates/notification/messages_reply_received/short.txt'
--- templates/notification/messages_reply_received/short.txt 1970-01-01 00:00:00 +0000
+++ templates/notification/messages_reply_received/short.txt 2018-02-22 06:34:38 +0000
@@ -0,0 +1,1 @@
1{% load i18n %}{% blocktrans with message.sender as message_sender %}{{ message_sender }} has replied to a message{% endblocktrans %}
0\ No newline at end of file2\ No newline at end of file
13
=== removed file 'templates/notification/messages_reply_received/short.txt'
--- templates/notification/messages_reply_received/short.txt 2009-02-26 11:32:18 +0000
+++ templates/notification/messages_reply_received/short.txt 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{% load i18n %}{% blocktrans with message.sender as message_sender %}{{ notice }} by {{ message_sender }}{% endblocktrans %}
2\ No newline at end of file0\ No newline at end of file
31
=== modified file 'templates/notification/short.txt'
--- templates/notification/short.txt 2009-02-20 16:46:21 +0000
+++ templates/notification/short.txt 2018-02-22 06:34:38 +0000
@@ -1,1 +1,1 @@
1{% load i18n %}{% blocktrans %}{{ notice }}{% endblocktrans %}
2\ No newline at end of file1\ No newline at end of file
2{% load i18n %}{% blocktrans %}{{ notice }}{% endblocktrans %}
33
=== removed directory 'templates/notification/wiki_article_edited'
=== removed file 'templates/notification/wiki_article_edited/full.txt'
--- templates/notification/wiki_article_edited/full.txt 2009-02-20 10:11:49 +0000
+++ templates/notification/wiki_article_edited/full.txt 1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
1{% load i18n %}{% blocktrans with article.get_absolute_url as article_url %}The wiki article {{ article }} has been edited by {{ user }}.
2
3http://{{ current_site }}{{ article_url }}
4{% endblocktrans %}
50
=== modified file 'templates/notification/wiki_observed_article_changed/full.txt'
--- templates/notification/wiki_observed_article_changed/full.txt 2009-02-20 10:11:49 +0000
+++ templates/notification/wiki_observed_article_changed/full.txt 2018-02-22 06:34:38 +0000
@@ -1,4 +1,8 @@
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 %}
2The article "{{ article }}" that you observe has been edited by {{ editor }}.
3Comment for this revision: "{{ rev_comment }}"
24
3http://{{ current_site }}{{ article_url }}5-------------------------
6A diff is available at: http://{{ current_site }}{{ diff_url }}
7Link to article: http://{{ current_site }}{{ article_url }}
4{% endblocktrans %}8{% endblocktrans %}
5\ No newline at end of file9\ No newline at end of file
610
=== modified file 'templates/notification/wiki_revision_reverted/full.txt'
--- templates/notification/wiki_revision_reverted/full.txt 2009-02-20 10:11:49 +0000
+++ templates/notification/wiki_revision_reverted/full.txt 2018-02-22 06:34:38 +0000
@@ -1,5 +1,6 @@
1{% load i18n %}1{% load i18n %}
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.
33
4http://{{ current_site }}{{ article_url }}
5{% endblocktrans %}
6\ No newline at end of file4\ No newline at end of file
5--------------------------------------
6Link to article: http://{{ current_site }}{{ article_url }}
7{% endblocktrans %}
78
=== modified file 'templates/wiki/feeds/history_description.html'
--- templates/wiki/feeds/history_description.html 2016-04-30 09:43:53 +0000
+++ templates/wiki/feeds/history_description.html 2018-02-22 06:34:38 +0000
@@ -1,4 +1,4 @@
1{% load i18n custom_date %}1{% load i18n %}
22
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>
4{{ obj.comment }}4{{ obj.comment }}
55
=== modified file 'templates/wiki/feeds/history_title.html'
--- templates/wiki/feeds/history_title.html 2016-04-30 09:43:53 +0000
+++ templates/wiki/feeds/history_title.html 2018-02-22 06:34:38 +0000
@@ -1,3 +1,2 @@
1{%load custom_date %}
21
3{{ obj.article.title }} - {{ obj.modified|custom_date:obj.editor }}2{{ obj.article.title }} - {{ obj.modified }}
43
=== modified file 'wiki/models.py'
--- wiki/models.py 2017-12-01 14:06:15 +0000
+++ wiki/models.py 2018-02-22 06:34:38 +0000
@@ -133,13 +133,6 @@
133 return self.filter(revision__gt=int(revision))133 return self.filter(revision__gt=int(revision))
134134
135135
136class NonRevertedChangeSetManager(ChangeSetManager):
137
138 def get_default_queryset(self):
139 super(PublishedBookManager, self).get_queryset().filter(
140 reverted=False)
141
142
143class ChangeSet(models.Model):136class ChangeSet(models.Model):
144 """A report of an older version of some Article."""137 """A report of an older version of some Article."""
145138
@@ -165,7 +158,6 @@
165 reverted = models.BooleanField(_(u"Reverted Revision"), default=False)158 reverted = models.BooleanField(_(u"Reverted Revision"), default=False)
166159
167 objects = ChangeSetManager()160 objects = ChangeSetManager()
168 non_reverted_objects = NonRevertedChangeSetManager()
169161
170 class Meta:162 class Meta:
171 verbose_name = _(u'Change set')163 verbose_name = _(u'Change set')
@@ -177,16 +169,17 @@
177 def __unicode__(self):169 def __unicode__(self):
178 return u'#%s' % self.revision170 return u'#%s' % self.revision
179171
180 @models.permalink
181 def get_absolute_url(self):172 def get_absolute_url(self):
182 if self.article.group is None:173 if self.article.group is None:
183 return ('wiki_changeset', (),174 return reverse('wiki_changeset', kwargs={
184 {'title': self.article.title,175 'title': self.article.title,
185 'revision': self.revision})176 'revision': self.revision
186 return ('wiki_changeset', (),177 })
187 {'group_slug': self.article.group.slug,178 return reverse('wiki_changeset', kwargs={
188 'title': self.article.title,179 'group_slug': self.article.group.slug,
189 'revision': self.revision})180 'title': self.article.title,
181 'revision': self.revision,
182 })
190183
191 def is_anonymous_change(self):184 def is_anonymous_change(self):
192 return self.editor is None185 return self.editor is None
@@ -240,31 +233,9 @@
240 article=self.article).latest().revision + 1233 article=self.article).latest().revision + 1
241 except self.DoesNotExist:234 except self.DoesNotExist:
242 self.revision = 1235 self.revision = 1
236
243 super(ChangeSet, self).save(*args, **kwargs)237 super(ChangeSet, self).save(*args, **kwargs)
244238
245 def display_diff(self):
246 """Returns a HTML representation of the diff."""
247
248 # well, it *will* be the old content
249 old_content = self.article.content
250
251 # newer non-reverted revisions of this article, starting from this
252 newer_changesets = ChangeSet.non_reverted_objects.filter(
253 article=self.article,
254 revision__gte=self.revision)
255
256 # apply all patches to get the content of this revision
257 for i, changeset in enumerate(newer_changesets):
258 patches = dmp.patch_fromText(changeset.content_diff)
259 if len(newer_changesets) == i + 1:
260 # we need to compare with the next revision after the change
261 next_rev_content = old_content
262 old_content = dmp.patch_apply(patches, old_content)[0]
263
264 diffs = dmp.diff_main(old_content, next_rev_content)
265 dmp.diff_cleanupSemantic(diffs)
266 return dmp.diff_prettyHtml(diffs)
267
268 def get_content(self):239 def get_content(self):
269 """Returns the content of this revision."""240 """Returns the content of this revision."""
270 content = self.article.content241 content = self.article.content
@@ -283,6 +254,3 @@
283 diffs = dmp.diff_main(other_content, self.get_content())254 diffs = dmp.diff_main(other_content, self.get_content())
284 dmp.diff_cleanupSemantic(diffs)255 dmp.diff_cleanupSemantic(diffs)
285 return dmp.diff_prettyHtml(diffs)256 return dmp.diff_prettyHtml(diffs)
286
287if notification is not None:
288 signals.post_save.connect(notification.handle_observations, sender=Article)
289257
=== modified file 'wiki/views.py'
--- wiki/views.py 2017-12-03 11:43:47 +0000
+++ wiki/views.py 2018-02-22 06:34:38 +0000
@@ -286,6 +286,18 @@
286 form.group = group286 form.group = group
287287
288 new_article, changeset = form.save()288 new_article, changeset = form.save()
289
290 if notification and not changeset.reverted:
291 # Get observers for this article and exclude current editor
292 items = notification.ObservedItem.objects.all_for(
293 new_article, 'post_save').exclude(user=request.user).iterator()
294 users = [o.user for o in items]
295 notification.send(users, 'wiki_observed_article_changed',
296 {'editor': request.user,
297 'rev': changeset.revision,
298 'rev_comment': changeset.comment,
299 'article': new_article})
300
289301
290 return redirect(new_article)302 return redirect(new_article)
291303
292304
=== modified file 'wlmaps/models.py'
--- wlmaps/models.py 2017-09-12 18:04:34 +0000
+++ wlmaps/models.py 2018-02-22 06:34:38 +0000
@@ -63,9 +63,15 @@
6363
64 map = super(Map, self).save(*args, **kwargs)64 map = super(Map, self).save(*args, **kwargs)
6565
66 # Send notifications only on new maps, not when updating fields, e.g. nr_downloads66 # Send notifications only on new maps, not when updating fields, e.g.
67 # nr_downloads
67 if notification and is_new:68 if notification and is_new:
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',
69 {'mapname': self.name, 'url': self.get_absolute_url(), 'user': self.uploader, 'uploader_comment': self.uploader_comment}, queue=True)70 {'mapname': self.name,
71 'url': self.get_absolute_url(),
72 'user': self.uploader,
73 'uploader_comment': self.uploader_comment
74 },
75 queue=True)
7076
71 return map 77 return map

Subscribers

People subscribed via source and target branches