Commit Graph

24 Commits

Author SHA1 Message Date
2f969bff76 Make documentation purges use xkey 2021-05-18 09:54:18 +02:00
c2d58d6f78 Include title of modified object in change notification emails
Should make the notifications a lot more useful without clicking
through.
2020-11-23 12:15:52 +01:00
5ffe6c389c Re-work moderation of submitted items
This includes a number of new features:

* Move some moderation functionality into shared places, so we don't
  keep re-inventing the wheel.
* Implement three-state moderation, where the submitter can edit their
  item and then explicitly say "i'm done, please moderate this now".
  This is currently only implemented for News, but done in a reusable
  way.
* Move moderation workflow to it's own set of URLs instead of
  overloading it on the general admin interface. Admin interface remains
  for editing things, but these are now separated out into separate
  things.
* Do proper stylesheet clearing for moderation of markdown fields, using
  a dynamic sandboxed iframe, so it's not ruined by the /admin/ css.
* Move moderation email notification into dedicated moderation code,
  thereby simplifying the admin subclassing we did which was in some
  places quite fragile.
* Reset date of news postings to the date of their approval, when
  approved. This avoids some annoying ordering issues.
2020-09-10 14:52:41 +02:00
5c838c57ea Fix up some incorrect imports 2020-07-04 15:52:36 +02:00
6db3da412c Fix typo in comments
s/tring/string/
2019-11-20 10:05:24 +01:00
5d0b64a5ab Re-implement modification notifications in simple_form
The way signals are sent for many2many apparently changed completely
between the python2 and python3 versions of the same Django version,
which broke the way we did this before. And it was always a bit of a
hack...

Instead, reimplement notifications in the simple_form handler. This now
also consolidates regular field notificationss and many2many
notifications in a much cleaner way.

This will, however, *only* have an effect on changes made through
simple_form. Luckily that's the most common way we handle forms, with
the exception being /admin/. So leave the old code in place to handle
the changes through /admin/, as well as the deletion of objects.

In the end the only thing lost is the ability to get m2m differences
when an admin makes changes, and that's the least important of all
notification. And as a bonus, the regular change notifications and in
particular "new item" notifications look a lot nicer.
2019-01-26 16:19:26 +01:00
a10eb6420b More generic changes from 2to3 2019-01-26 16:19:26 +01:00
a156829375 Generic unicode updates 2019-01-26 16:19:26 +01:00
00ab822ea8 Fix deprecated comparison structs 2019-01-17 21:19:57 +01:00
e3ec36b50c Remove multi-statement lines, per pep8 2019-01-17 20:52:17 +01:00
0883ac6423 Fix whitespace and indentation, per pep8 2019-01-17 20:47:43 +01:00
87237f6536 Tabs, meet your new overlords: spaces
In a quest to reach pep8, use spaces to indent rather than tabs.
2019-01-17 15:35:39 +01:00
d8889fd37d Don't send notifications generated internally in the system
Django 1.11 fires the save signals in more cases than 1.8 did it seems,
so we can generate extra notifications for example when the twitter
script posts a news item to twitter.

To avoid this, just don't send notification if the user is unknown
(=None).

Per discussion with Jonathan
2018-03-29 12:00:05 +02:00
9fdaaab726 Fix model diffing to be compatible with both 1.8 and 1.11 2018-03-10 10:58:47 -05:00
65d0854f83 Don't crash when adding models with optional m2m fields
If the m2m field is optional, there will be no "pre" data available, not
even an empty one. Don't crash in this case, just assume it's empty
(which it is).

This could happen when adding a new Organisation, which currently is the
only model we have with optional m2m fields
2017-12-28 16:09:31 +01:00
2cbf0bf048 Add support for notification emails on m2m changes
Unfortunately, we'll send one email for each m2m field, instead of
collecting them to a single one. That's because there is no signal
delivered at the end of them all, there will be one sent for each field.

Luckily we don't have a lot of m2m fields at this point, and no model
has more than one, so at this point that part is not a problem.

It also means that if a regular field *and* an m2m field is changed,
then we will get two notifications.

Finally, enable these notifications for the Organisation fields, meaning
we will get a notification when an Organisation changes managers, which
was not working before.
2017-12-13 20:49:52 +01:00
ef83f8c841 Fix spelling error
Pointed out by Stephen
2017-05-27 14:43:34 -04:00
59bb64f409 Fix notifications for ForeignKey fields
Instead of reporting the integer value of the foreign key, we should
report the text value from the related object. This makes the new
submissions more readable, and also makes the system not throw an
exception when trying to diff (as integers cannot be diffed).

THis seems to have broken around the time of the 1.8 upgrade, just went
unnoticed for a long time probably because changing things like which
organization owns a news item doesn't happen very often.
2016-12-17 14:28:01 +01:00
cb8fd07fd7 Don't pretend that notifications for m2m works
They don't... And there is no easy way to make them work either, given
the way that signals are called for m2ms.
2016-12-17 14:25:55 +01:00
d9c8c089cb Handle migrated records with NULL in them when building diff 2016-11-07 20:17:58 +01:00
6a65f96476 Fix(ish) notifications for new objects with Unicode in value
Previous code triggered a conversion from unicode to ascii inside the
django framework, which would throw an exception when the object itself
returned unicode in the name.

The new version will work around that by actually checking the primary
key first.

This still doesn't work insofar that any changes to a many2many fields
are now lost. This did not work properly before either, but this
probably made it a bit work. We definitely need to fix this properly at
some point, probably by using the m2m_changed signal handler (but it's
not straight forward as this is now a separate signal and we'll somehow
want to track this indepdendently)
2016-08-22 11:50:21 +02:00
fd689e01c9 module_name has been renamed to model_name 2016-05-14 19:49:12 +02:00
10656c603f Use difflib to show differences when an object is edited
This makes for a much easier-to-read output, especially when the
modified field is more than one line.
2016-03-07 22:02:24 +01:00
8058accee0 Get rid of PgModel, replacing it with simple signals
We were already using signals for everything except delete, and even
in our old version of django the delete signal exists (it didn't exist
when this code was first written).

Django doesn't really like models to be OOP like this, so keeping PgModel
would cause issues with upcoming changes in django 1.8. Using simple functions
is easier, and the actual functionality is replicated straight off.
2016-03-07 21:41:45 +01:00