-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supprime notifications forum inaccessible (#6196)
* Supprime code inutile Redondant avec notification/receivers.py remove_group_subscription_on_quitting_groups * Complète les tests * Supprime les notifications caduques qui trainent * Ajout d'un forum réservé au staff dans les fixtures
- Loading branch information
1 parent
44a96f4
commit 915c7d1
Showing
4 changed files
with
132 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
zds/notification/migrations/0017_clean_notifications_new_topic_forums_groups.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.db import migrations | ||
|
||
from zds.notification.models import NewTopicSubscription | ||
from zds.forum.models import Topic, Forum | ||
|
||
|
||
def cleanup(apps, *_): | ||
for forum in Forum.objects.filter(groups__isnull=False).all(): | ||
for subscription in NewTopicSubscription.objects.get_subscriptions(forum): | ||
if not forum.can_read(subscription.user): | ||
subscription.is_active = False | ||
if subscription.last_notification: | ||
subscription.last_notification.is_read = True | ||
subscription.last_notification.save() | ||
subscription.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("notification", "0016_auto_20190114_1301"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(cleanup), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters