From 89db75f602be1ec0407418762d36ace5ad81983e Mon Sep 17 00:00:00 2001 From: 0ssigeno Date: Wed, 25 Oct 2023 15:18:22 +0200 Subject: [PATCH 1/4] Allow the notification to not have `for_user` Signed-off-by: 0ssigeno --- certego_saas/apps/notifications/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/certego_saas/apps/notifications/models.py b/certego_saas/apps/notifications/models.py index bdb21b8..fecfa57 100644 --- a/certego_saas/apps/notifications/models.py +++ b/certego_saas/apps/notifications/models.py @@ -29,6 +29,7 @@ class Notification(TimestampedModel, AppSpecificModel): help_text="If the field is empty, the notification is for everyone; otherwise only for the specified user", null=True, on_delete=models.CASCADE, + blank=True, ) def is_read_by_user(self, user) -> bool: From 453cdd295dd2bc8ff89483bf9ab7f5642bc0cf2a Mon Sep 17 00:00:00 2001 From: 0ssigeno Date: Thu, 26 Oct 2023 12:50:48 +0200 Subject: [PATCH 2/4] Org owner is always admin of the same org --- certego_saas/apps/organization/organization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/certego_saas/apps/organization/organization.py b/certego_saas/apps/organization/organization.py index 8e1d591..6d9f94c 100644 --- a/certego_saas/apps/organization/organization.py +++ b/certego_saas/apps/organization/organization.py @@ -68,7 +68,7 @@ def create(cls, name: str, owner: "User"): org = cls.objects.create(name=name) membership = Membership.objects.create( - user=owner, organization=org, is_owner=True + user=owner, organization=org, is_owner=True, is_admin=True ) org.members.add(membership) org.save() From 7db0b508e9d815831e0bf57c6b53a67cba37c1d0 Mon Sep 17 00:00:00 2001 From: 0ssigeno Date: Thu, 26 Oct 2023 12:51:17 +0200 Subject: [PATCH 3/4] Bump --- certego_saas/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/certego_saas/version.py b/certego_saas/version.py index b90c97e..2400ae8 100644 --- a/certego_saas/version.py +++ b/certego_saas/version.py @@ -1 +1 @@ -VERSION = "0.7.1" +VERSION = "0.7.2" From 36076aaa5ffdd9f88878ebcc1185b973d8bda1f6 Mon Sep 17 00:00:00 2001 From: 0ssigeno Date: Thu, 26 Oct 2023 12:52:58 +0200 Subject: [PATCH 4/4] Added migration --- .../migrations/0004_for_user_blank.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 certego_saas/apps/notifications/migrations/0004_for_user_blank.py diff --git a/certego_saas/apps/notifications/migrations/0004_for_user_blank.py b/certego_saas/apps/notifications/migrations/0004_for_user_blank.py new file mode 100644 index 0000000..a9b6d76 --- /dev/null +++ b/certego_saas/apps/notifications/migrations/0004_for_user_blank.py @@ -0,0 +1,23 @@ +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("certego_saas_notifications", "0003_for_user"), + ] + + operations = [ + migrations.AlterField( + model_name="notification", + name="for_user", + field=models.ForeignKey( + settings.AUTH_USER_MODEL, + related_name="notifications", + help_text="If the field is empty, the notification is for everyone; otherwise only for the specified user", + null=True, + blank=True, + on_delete=models.CASCADE, + ), + ), + ]