Repository: svthalia/concrexit

Issue:
Allow event registering for open events
From https://gitlab.science.ru.nl/thalia/concrexit/-/issues/711

### One-sentence description
Allow event registering for open events

### Motivation
So that the personal calendar can contain these events, notifications only get send to these people and open events have an indication how many people are going to go to the event.

### Desired functionality
The normal registration functionality. But it is not registration, more like Facebooks

### Suggested implementation
We should be able to add an option that if there is no registration required that you can still register.



Discussion:

Resolving patch:
diff --git a/website/events/models/event_registration.py b/website/events/models/event_registration.py
--- a/website/events/models/event_registration.py
+++ b/website/events/models/event_registration.py
@@ -107,6 +107,8 @@ def is_paid(self):
 
     def would_cancel_after_deadline(self):
         now = timezone.now()
+        if not self.event.registration_required:
+            return False
         return not self.queue_position and now >= self.event.cancel_deadline
 
     def clean(self):
diff --git a/website/events/services.py b/website/events/services.py
--- a/website/events/services.py
+++ b/website/events/services.py
@@ -66,20 +66,20 @@ def event_permissions(member, event, name=None):
 
     perms["create_registration"] = (
         (registration is None or registration.date_cancelled is not None)
-        and event.registration_allowed
+        and (event.registration_allowed or not event.registration_required)
         and (name or member.can_attend_events)
     )
     perms["cancel_registration"] = (
         registration is not None
         and registration.date_cancelled is None
-        and (event.cancellation_allowed or name)
+        and (event.cancellation_allowed or name or not event.registration_required)
         and registration.payment is None
     )
     perms["update_registration"] = (
         registration is not None
         and registration.date_cancelled is None
         and event.has_fields
-        and event.registration_allowed
+        and (event.registration_allowed or not event.registration_required)
         and (name or member.can_attend_events)
     )
     return perms


Test patch:
diff --git a/website/events/tests/test_api.py b/website/events/tests/test_api.py
--- a/website/events/tests/test_api.py
+++ b/website/events/tests/test_api.py
@@ -45,8 +45,8 @@ def setUp(self):
 
     def test_registration_register_not_required(self):
         response = self.client.post("/api/v1/events/1/registrations/", follow=True)
-        self.assertEqual(response.status_code, 403)
-        self.assertEqual(self.event.participants.count(), 0)
+        self.assertEqual(response.status_code, 201)
+        self.assertEqual(self.event.participants.count(), 1)
 
     def test_registration_register(self):
         self.event.registration_start = timezone.now() - datetime.timedelta(hours=1)
diff --git a/website/events/tests/test_views.py b/website/events/tests/test_views.py
--- a/website/events/tests/test_views.py
+++ b/website/events/tests/test_views.py
@@ -158,7 +158,7 @@ def setUp(self):
     def test_registration_register_not_required(self):
         response = self.client.post("/events/1/registration/register/", follow=True)
         self.assertEqual(response.status_code, 200)
-        self.assertEqual(self.event.participants.count(), 0)
+        self.assertEqual(self.event.participants.count(), 1)
 
     def test_registration_register(self):
         self.event.registration_start = timezone.now() - datetime.timedelta(hours=1)