Luke Plant avatar Luke Plant committed c992ecc

Rewrote some utility functions using new 'Camp.officers' attribute

Comments (0)

Files changed (3)


 from cciw.officers.tests.references import *
 from cciw.officers.tests.officer_list import *
 from cciw.officers.tests.applicationform import *
+from cciw.officers.tests.utils import *


+from cciw.cciwmain.models import Camp
+from cciw.officers import utils
+from django.test import TestCase
+class UtilsTests(TestCase):
+    fixtures = ['basic.yaml', 'officers_users.yaml', 'references.yaml']
+    def test_camp_officer_list(self):
+        c = Camp.objects.get(pk=1)
+        self.assertEqual(repr(utils.camp_officer_list(c)), "[<User: davestott>, <User: mrofficer2>, <User: officer3>]")
+    def test_camp_slacker_list(self):
+        c = Camp.objects.get(pk=1)
+        self.assertEqual(repr(utils.camp_slacker_list(c)), "[<User: davestott>]")


     Returns complete list of officers for a camp
-    return [i.officer for i in camp.invitation_set.all().select_related('officer')]
+    return list(camp.officers.all())
 def camp_slacker_list(camp):
     finished_apps_off_ids = [o['officer__id']
                              for o in camp.application_set.filter(finished=True).values('officer__id')]
-    return [i.officer for i in camp.invitation_set.exclude(officer__in=finished_apps_off_ids).select_related('officer')]
+    return list(camp.officers.exclude(id__in=finished_apps_off_ids))
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
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.