Mark Lavin  committed d57cf6c

Move page cleaning logic to the form.

  • Participants
  • Parent commits 2ebb8a3
  • Branches result-refactor

Comments (0)

Files changed (1)

File selectable/forms/

 class BaseLookupForm(forms.Form):
     term = forms.CharField(required=False)
     limit = forms.IntegerField(required=False, min_value=1)
+    page = forms.IntegerField(required=False, min_value=1)
     def clean_limit(self):
         "Ensure given limit is less than default if defined"
             (not limit or limit > settings.SELECTABLE_MAX_LIMIT)):
             limit = settings.SELECTABLE_MAX_LIMIT
         return limit
+    def clean_page(self):
+        "Return the first page if no page or invalid number is given."
+        return self.cleaned_data.get('page', 1) or 1