def __call__(self, context): try: section = ISection(context) except (TypeError,): linked_activity = proxy.removeSecurityProxy(context) section = ISection(linked_activity.__parent__) return ExternalActivitiesSource(section)
def contains(self, principal): setting = ConfigurableScheduleEditors(self.context) if not setting.contains(principal): return False section = ISection(self.context, None) if section is None: return False contains = InstructorsCrowd(section).contains(principal) return contains
def enabled(self): gradebook = removeSecurityProxy(self.context) worksheet = gradebook.context if worksheet.hidden: return False courses = list(ISection(gradebook).courses) if not courses: return False for course in courses: if not flourish.canEdit(course): return False return super(DeployAsCourseWorksheetLinkViewlet, self).enabled
def courses(self): courses = [] request_courses = self.request.get('courses', []) for course in ISection(self.context).courses: if not flourish.canEdit(course): continue checked = ('SUBMIT' not in self.request or course.__name__ in request_courses) courses.append({ 'name': course.__name__, 'title': course.title, 'checked': checked and 'checked' or '', 'obj': course, }) return courses
def schoolyear(self): return ISchoolYear(ISection(self.context))