Repository: svthalia/concrexit

Issue:
Use a different colour for waiting list events
### Is your feature request related to a problem? Please describe.
In the event overview calendar, the dot in front of the event is colored as if you are registered. And this is confusing.

### Describe the solution you'd like
Use a different colour for events you're on the waiting list for.

### Motivation
Better user experience.

### Describe alternatives you've considered
There is not really any alternative

### Additional context
Created based on #1007



Discussion:
This can probably be found in https://github.com/svthalia/concrexit/tree/master/website/events/templates/events
No, the colour is retrieved from the API.
I'm wondering about what would be a proper design for this. What color would be nice in this case? And do we maybe want a coloured dot for events someone is registered for as well?

Also, from what I can find, the colors are added using CSS classes, which are in turn received from the API.

Resolving patch:
diff --git a/website/events/api/calendarjs/serializers.py b/website/events/api/calendarjs/serializers.py
--- a/website/events/api/calendarjs/serializers.py
+++ b/website/events/api/calendarjs/serializers.py
@@ -13,12 +13,18 @@ def _url(self, instance):
         return reverse("events:event", kwargs={"pk": instance.id})
 
     def _class_names(self, instance):
-        class_names = ["regular-event"]
         if self.context["member"] and services.is_user_registered(
             self.context["member"], instance
         ):
-            class_names.append("has-registration")
-        return class_names
+            if services.user_registration_pending(self.context["member"], instance):
+                return ["regular-event-pending-registration"]
+            else:
+                return ["regular-event-has-registration"]
+        elif (not instance.registration_required) or instance.registration_allowed:
+            return ["regular-event-registration-open"]
+        else:
+            # I think this handles the case that registration is needed, but not yet possible
+            return ["regular-event-registration-closed"]
 
 
 class UnpublishedEventsCalenderJSSerializer(CalenderJSSerializer):
diff --git a/website/events/services.py b/website/events/services.py
--- a/website/events/services.py
+++ b/website/events/services.py
@@ -19,12 +19,28 @@ def is_user_registered(member, event):
     :param event: the event
     :return: None if registration is not required or no member else True/False
     """
-    if not event.registration_required or not member.is_authenticated:
+    if not member.is_authenticated:
         return None
 
     return event.registrations.filter(member=member, date_cancelled=None).count() > 0
 
 
+def user_registration_pending(member, event):
+    """Return if the user is in the queue, but not yet registered for, the specific event.
+
+    :param member: the user
+    :param event: the event
+    :return: None if registration is not required or no member else True/False
+    """
+    if not event.registration_required:
+        return False
+    if not member.is_authenticated:
+        return None
+
+    reg = event.registrations.filter(member=member, date_cancelled=None)
+    return len(list(filter(lambda r: r.queue_position, reg))) > 0
+
+
 def is_user_present(member, event):
     if not event.registration_required or not member.is_authenticated:
         return None


Test patch: