diff --git a/src/api/serializers.py b/src/api/serializers.py index ac19fd91ecf768c599b909d875f1ddd9c119dbc3..f6a5ef970628ac7ce536c1bfb077dd660f40aad3 100644 --- a/src/api/serializers.py +++ b/src/api/serializers.py @@ -114,6 +114,7 @@ class ConferenceSerializer(HubModelSerializer): 'is_public', 'start', 'end', + 'publication_date', 'registration_start', 'registration_deadline', 'tracks', @@ -121,6 +122,7 @@ class ConferenceSerializer(HubModelSerializer): staff_only_fields = [ 'is_public', 'publication_date', + 'registration_start', ] diff --git a/src/core/locale/de/LC_MESSAGES/django.po b/src/core/locale/de/LC_MESSAGES/django.po index 6ab69f2a63e0abac805fc2a150ce71e84b5a4b05..f8d30d14df38b2a2cc43cec052fb73370a02683f 100644 --- a/src/core/locale/de/LC_MESSAGES/django.po +++ b/src/core/locale/de/LC_MESSAGES/django.po @@ -673,6 +673,12 @@ msgstr "Konferenz öffentlich anzeigen" msgid "Conference__is_public" msgstr "veröffentlicht" +msgid "Conference__publication_date__help" +msgstr "Veröffentlichungszeitpunkt für Inhalte für die Öffentlichkeit" + +msgid "Conference__publication_date" +msgstr "Veröffentlichungszeitpunkt" + msgid "Conference__registration_start__help" msgstr "Start der Registrierung für Assemblies." diff --git a/src/core/locale/en/LC_MESSAGES/django.po b/src/core/locale/en/LC_MESSAGES/django.po index d6ff37c1671277eb264cab8e52e803c4a14ff235..dc6c5f67a6bffb415ae8c584ee2124dd4578726a 100644 --- a/src/core/locale/en/LC_MESSAGES/django.po +++ b/src/core/locale/en/LC_MESSAGES/django.po @@ -673,6 +673,12 @@ msgstr "show this conference publically" msgid "Conference__is_public" msgstr "is public" +msgid "Conference__publication_date__help" +msgstr "From this point in time the content will be displayed to the public." + +msgid "Conference__publication_date" +msgstr "publication start" + msgid "Conference__registration_start__help" msgstr "from this point in time registration will be available" diff --git a/src/core/migrations/0151_conference_publication_date.py b/src/core/migrations/0151_conference_publication_date.py new file mode 100644 index 0000000000000000000000000000000000000000..89763a07b6f8e2ba78ba4831d101b3fff67a3197 --- /dev/null +++ b/src/core/migrations/0151_conference_publication_date.py @@ -0,0 +1,23 @@ +# Generated by Django 5.1.2 on 2024-10-20 17:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0150_conference_registration_start"), + ] + + operations = [ + migrations.AddField( + model_name="conference", + name="publication_date", + field=models.DateTimeField( + blank=True, + help_text="Conference__publication_date__help", + null=True, + verbose_name="Conference__publication_date", + ), + ), + ] diff --git a/src/core/models/base_managers.py b/src/core/models/base_managers.py index 651ba1c3bf0315b2a57647d3c30a82cb5bf2a8fc..aa2ff05a5a2e27911d2baaf3814e7dc75b484f4c 100644 --- a/src/core/models/base_managers.py +++ b/src/core/models/base_managers.py @@ -157,6 +157,8 @@ class ConferenceManagerMixin(models.Manager, Generic[_ModelType]): Returns: QuerySet[_ModelType]: A Queryset of objects that are accessible for the given conference. """ + if not conference.is_published: + return self.get_queryset().none() if isinstance(member, ConferenceMember): return self.apply_public_filter(self.get_conference_queryset(conference), member) return self.apply_public_filter(self.get_conference_queryset(conference)) diff --git a/src/core/models/conference.py b/src/core/models/conference.py index c65edfe5ebe18fc1b04ed6f96d0d4ea2ca50ca16..0b8be5714120146fe5d6d130bfbb1d53cdcc2abd 100644 --- a/src/core/models/conference.py +++ b/src/core/models/conference.py @@ -230,6 +230,9 @@ class Conference(models.Model): name = models.CharField(max_length=200, help_text=_('Conference__name__help'), verbose_name=_('Conference__name')) is_public = models.BooleanField(default=False, help_text=_('Conference__is_public__help'), verbose_name=_('Conference__is_public')) + publication_date = models.DateTimeField( + blank=True, null=True, help_text=_('Conference__publication_date__help'), verbose_name=_('Conference__publication_date') + ) registration_start = models.DateTimeField( blank=True, null=True, help_text=_('Conference__registration_start__help'), verbose_name=_('Conference__registration_start') ) @@ -378,6 +381,10 @@ class Conference(models.Model): return self.start <= timezone.now() return self.start <= timezone.now() <= self.end + @cached_property + def is_published(self): + return self.is_public and (self.publication_date is None or self.publication_date < timezone.now()) + @cached_property def has_ended(self): return self.end is not None and timezone.now() > self.end diff --git a/src/core/tests/assemblies.py b/src/core/tests/assemblies.py index 3150f0ef24c39295ac73c28555c7798bfd3f9e9f..052e0e1934dc967143472ca9695bc829a7d99f8b 100644 --- a/src/core/tests/assemblies.py +++ b/src/core/tests/assemblies.py @@ -9,7 +9,7 @@ from core.models.users import PlatformUser, UserCommunicationChannel class AssembliesTestsMixin(TestCase): def setUp(self): - self.conference = Conference(slug='foo', name='Foo Conference', mail_footer='This is serious business w/ legal stuff.') + self.conference = Conference(slug='foo', name='Foo Conference', mail_footer='This is serious business w/ legal stuff.', is_public=True) self.conference.save() self.user_mgmt = PlatformUser(username='manager')