Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add Program.getListDescriptions()

This just moves some code out from Program.getLists(), since it will be
useful in other places.
  • Loading branch information...
commit e2dcba95f2cc9b1c69b54a50b20a33a8bd74491c 1 parent 44575c9
@pricem pricem authored
Showing with 18 additions and 16 deletions.
  1. +18 −16 esp/esp/program/models/__init__.py
View
34 esp/esp/program/models/__init__.py
@@ -461,6 +461,20 @@ def student_counts_by_section_id(self):
return clean_counts
+ @cache_function
+ def getListDescriptions(self):
+ desc = {}
+ modules = self.getModules()
+ desc_functions = ['studentDesc', 'teacherDesc', 'volunteerDesc']
+ for module in modules:
+ for func in desc_functions:
+ if hasattr(module, func):
+ tmpdict = getattr(module, func)()
+ if tmpdict is not None:
+ desc.update(tmpdict)
+ return desc
+ getListDescriptions.depend_on_m2m(lambda: Program, 'program_modules', lambda program, module: {'self': program})
+
def getLists(self, QObjects=False):
from esp.users.models import ESPUser
@@ -475,26 +489,14 @@ def getLists(self, QObjects=False):
lists[k] = {'list': v,
'description':''}
- desc = {}
- for module in learnmodules:
- tmpdict = module.studentDesc()
- if tmpdict is not None:
- desc.update(tmpdict)
- for module in teachmodules:
- tmpdict = module.teacherDesc()
- if tmpdict is not None:
- desc.update(tmpdict)
- for module in teachmodules:
- tmpdict = module.volunteerDesc()
- if tmpdict is not None:
- desc.update(tmpdict)
+ desc = self.getListDescriptions()
for k, v in desc.items():
- lists[k]['description'] = v
+ if k in lists:
+ lists[k]['description'] = v
+
usertypes = ['Student', 'Teacher', 'Guardian', 'Educator', 'Volunteer']
-
-
for usertype in usertypes:
lists['all_'+usertype.lower()+'s'] = {'description':
usertype+'s in all of ESP',
Please sign in to comment.
Something went wrong with that request. Please try again.