Luke Plant avatar Luke Plant committed a361608

Split long method

Comments (0)

Files changed (1)

cciw/bookings/models.py

         If 'booking_sec', it shows the problems as they should be seen by the
         booking secretary.
         """
-        errors = []
-        warnings = []
-
         if self.state == BOOKING_APPROVED and not booking_sec:
             return ([], [])
 
+        return (self.get_booking_errors(booking_sec=booking_sec),
+                self.get_booking_warnings(booking_sec=booking_sec))
+
+    def get_booking_errors(self, booking_sec=False):
+        errors = []
+
         # Custom price - not auto bookable
         if self.price_type == PRICE_CUSTOM:
             errors.append(u"A custom discount needs to be arranged by the booking secretary")
                                   u"for the campers in this set of bookings.")
                     places_available = False
 
-        ### Warnings ###
+        if booking_sec and self.price_type != PRICE_CUSTOM:
+            expected_amount = self.expected_amount_due()
+            if self.amount_due != expected_amount:
+                errors.append(u"The 'amount due' is not the expected value of £%s." % expected_amount)
+        return errors
+
+    def get_booking_warnings(self, booking_sec=False):
+        warnings = []
 
         if self.account.bookings.filter(name=self.name, camp=self.camp).exclude(id=self.id):
             warnings.append(u"You have entered another set of place details for a camper "
 
                 warnings.append(warning)
 
-        if booking_sec and self.price_type != PRICE_CUSTOM:
-            expected_amount = self.expected_amount_due()
-            if self.amount_due != expected_amount:
-                errors.append(u"The 'amount due' is not the expected value of £%s." % expected_amount)
-
-        return (errors, warnings)
+        return warnings
 
     def confirm(self):
         self.booking_expires = None
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.