Пример #1
0
 def update(self):
     self.collator = ICollator(self.request.locale)
     relationships = Membership.bind(member=self.context).all().relationships
     group_states = self.app_states('group-membership')
     student_states = self.app_states('student-enrollment')
     schoolyears_data = {}
     for link_info in relationships:
         group = removeSecurityProxy(link_info.target)
         if ISection.providedBy(group) or not canAccess(group, 'title'):
             continue
         sy = ISchoolYear(group.__parent__)
         if sy not in schoolyears_data:
             schoolyears_data[sy] = []
         schoolyears_data[sy].append((group, link_info))
     self.schoolyears = []
     for sy in sorted(schoolyears_data, key=lambda x:x.first, reverse=True):
         sy_info = {
             'obj': sy,
             'css_class': 'active' if sy is self.schoolyear else 'inactive',
             'groups': [],
             }
         for group, link_info in sorted(schoolyears_data[sy],
                                        key=lambda x:self.collator.key(
                                            x[0].title)):
             is_students = group.__name__ == 'students'
             app_states = student_states if is_students else group_states
             states = self.group_current_states(link_info, app_states)
             group_info = {
                 'obj': group,
                 'title': group.title,
                 'states': states,
                 }
             sy_info['groups'].append(group_info)
         self.schoolyears.append(sy_info)
Пример #2
0
 def update(self):
     self.collator = ICollator(self.request.locale)
     relationships = Membership.bind(
         member=self.context).all().relationships
     group_states = self.app_states('group-membership')
     student_states = self.app_states('student-enrollment')
     schoolyears_data = {}
     for link_info in relationships:
         group = removeSecurityProxy(link_info.target)
         if ISection.providedBy(group) or not canAccess(group, 'title'):
             continue
         sy = ISchoolYear(group.__parent__)
         if sy not in schoolyears_data:
             schoolyears_data[sy] = []
         schoolyears_data[sy].append((group, link_info))
     self.schoolyears = []
     for sy in sorted(schoolyears_data, key=lambda x: x.first,
                      reverse=True):
         sy_info = {
             'obj': sy,
             'css_class': 'active' if sy is self.schoolyear else 'inactive',
             'groups': [],
         }
         for group, link_info in sorted(
                 schoolyears_data[sy],
                 key=lambda x: self.collator.key(x[0].title)):
             is_students = group.__name__ == 'students'
             app_states = student_states if is_students else group_states
             states = self.group_current_states(link_info, app_states)
             group_info = {
                 'obj': group,
                 'title': group.title,
                 'states': states,
             }
             sy_info['groups'].append(group_info)
         self.schoolyears.append(sy_info)
Пример #3
0
 def sectionsAsLearner(self):
     """Get the sections the person is a member of."""
     app_states = self.app_states('section-membership')
     relationships = Membership.bind(member=self.context).all().relationships
     return self.sectionsAs(app_states, relationships)