aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/caf/managers.py
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack/caf/managers.py')
-rw-r--r--ctrack/caf/managers.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/ctrack/caf/managers.py b/ctrack/caf/managers.py
index 3aea117..1323e38 100644
--- a/ctrack/caf/managers.py
+++ b/ctrack/caf/managers.py
@@ -1,6 +1,7 @@
from django.db import models
-from ctrack.organisations.models import Organisation, Person
+from ctrack.organisations.models import Organisation, Person, Submode
+import ctrack.caf.models # to deal with circular import
class ApplicableSystemManager(models.Manager):
@@ -12,14 +13,15 @@ class ApplicableSystemManager(models.Manager):
from django.db import connection
with connection.cursor() as cursor:
cursor.execute("""
- SELECT a.id, a.name, o.id, c.id, sm.descriptor, p.id, o.name
+ SELECT a.id, a.name, o.id, c.id, sm.id, p.id, o.name
FROM caf_applicablesystem a, organisations_organisation o, organisations_person p, caf_caf c, organisations_submode sm
WHERE a.organisation_id = o.id AND a.caf_id = c.id AND p.organisation_id = o.id AND o.submode_id = sm.id AND p.primary_nis_contact = False;
""")
result_list = []
for row in cursor.fetchall():
org = Organisation.objects.get(pk=row[2])
- ass = self.model(id=row[0], name=row[1], organisation=org)
+ caf = ctrack.caf.models.CAF.objects.get(pk=row[3])
+ ass = self.model(id=row[0], name=row[1], organisation=org, caf=caf)
ass.nis_contact = Person.objects.get(pk=row[5])
result_list.append(ass)
return result_list