-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #472 from elixir-luxembourg/implement-notification…
…-models Updating notification models for new notification system;
- Loading branch information
Showing
8 changed files
with
145 additions
and
269 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Generated by Django 3.2.20 on 2023-10-25 09:00 | ||
|
||
from django.db import migrations, models, connection | ||
import enumchoicefield.fields | ||
import notification.models | ||
|
||
|
||
def empty_notification_table(apps, schema_editor): | ||
with connection.cursor() as cursor: | ||
cursor.execute("TRUNCATE TABLE notification_notification;") | ||
|
||
|
||
def rollback_empty_notification_table(apps, schema_editor): | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("notification", "0003_auto_20220726_1343"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
empty_notification_table, rollback_empty_notification_table | ||
), | ||
migrations.RenameField( | ||
model_name="notification", | ||
old_name="actor", | ||
new_name="recipient", | ||
), | ||
migrations.RemoveField( | ||
model_name="notificationsetting", | ||
name="style", | ||
), | ||
migrations.AddField( | ||
model_name="notification", | ||
name="dismissed", | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name="notification", | ||
name="dispatch_by_email", | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name="notification", | ||
name="dispatch_in_app", | ||
field=models.BooleanField(default=True), | ||
), | ||
migrations.AddField( | ||
model_name="notification", | ||
name="message", | ||
field=models.TextField(default=""), | ||
), | ||
migrations.AddField( | ||
model_name="notification", | ||
name="on", | ||
field=models.DateTimeField(blank=True, default=None, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="notification", | ||
name="processing_date", | ||
field=models.DateField(blank=True, default=None, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="notificationsetting", | ||
name="notification_offset", | ||
field=models.PositiveSmallIntegerField( | ||
default=90, | ||
help_text="Define how many days before the actual event you want to receive the notification", | ||
verbose_name="Notification time", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="notificationsetting", | ||
name="send_email", | ||
field=models.BooleanField( | ||
default=False, | ||
help_text="Notifications will be send directly to your email. See your [profile page] for more detail.", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="notificationsetting", | ||
name="send_in_app", | ||
field=models.BooleanField( | ||
default=True, | ||
help_text="Notification will be displayed in DAISY interface", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="notification", | ||
name="verb", | ||
field=enumchoicefield.fields.EnumChoiceField( | ||
enum_class=notification.models.NotificationVerb, max_length=13 | ||
), | ||
), | ||
] |
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 was deleted.
Oops, something went wrong.
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,14 @@ | ||
import pytest | ||
|
||
from test.factories import DatasetFactory, DatasetNotificationFactory | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"factory, object_factory", [(DatasetNotificationFactory, DatasetFactory)] | ||
) | ||
def test_notification_urls(user_normal, factory, object_factory): | ||
notification = factory(recipient=user_normal, content_object=object_factory()) | ||
assert ( | ||
notification.get_absolute_url() | ||
== notification.content_object.get_absolute_url() | ||
) |
Oops, something went wrong.