Repository: svthalia/concrexit

Issue:
Createfixtures: No event where can be payed could be found, creating a new event
### Describe the bug
```
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
No event where can be payed could be found, creating a new event
```

### How to reproduce
No clue, but look at this: https://github.com/svthalia/concrexit/actions/runs/3235115673/jobs/5299102831

### Expected behaviour
The createfixtures command stops at some point


### Screenshots

<img width="728" alt="image" src="https://user-images.githubusercontent.com/1576660/195400401-e476f88f-e19a-4b9b-95af-893daf3745c5.png">





Discussion:

Resolving patch:
diff --git a/website/utils/management/commands/createfixtures.py b/website/utils/management/commands/createfixtures.py
--- a/website/utils/management/commands/createfixtures.py
+++ b/website/utils/management/commands/createfixtures.py
@@ -536,12 +536,17 @@ def create_event_registration(self, event_to_register_for=None):
             if event_to_register_for
             else get_event_to_register_for(registration.member)
         )
-        while not possible_event:
+
+        if not possible_event:
             self.stdout.write("No possible events to register for")
             self.stdout.write("Creating a new event")
             self.create_event()
             possible_event = get_event_to_register_for(registration.member)
 
+        if not possible_event:
+            self.stdout.write("Could not create event")
+            return
+
         registration.event = possible_event
 
         registration.date = registration.event.registration_start
@@ -559,7 +564,7 @@ def create_payment(self):
                 Event.objects.filter(price__gt=0).order_by("?"),
             )
         )
-        while len(possible_events) == 0:
+        if len(possible_events) == 0:
             print("No event where can be payed could be found, creating a new event")
             self.create_event()
             possible_events = list(
@@ -569,6 +574,10 @@ def create_payment(self):
                 )
             )
 
+        if len(possible_events) == 0:
+            print("Could not create the event for an unexpected reason.")
+            return
+
         event = possible_events[0]
         if len(event.registrations) == 0:
             print("No registrations found. Create some more registrations first")


Test patch: