Esempio n. 1
0
    def edit_student_group(self, id):
        try:
            group = TeacherGroup.get(int(id))
        except ValueError:
            abort(404)

        if group is None or group.teacher != c.user:
            abort(404)

        c.student_group = group
        defaults = {
            'title' : group.title,
            'email' : group.email,
            'group_id' : group.id
            }
        if hasattr(self, 'form_result'):
            group.title = self.form_result['title']
            group.email = self.form_result['email']
            group.update_binding()
            meta.Session.commit()
            message = _(u'Group %(group_title)s (%(group_email)s) updated!') % {
                'group_title': group.title,
                'group_email': group.email}
            h.flash(message)
            redirect(url(controller='profile', action='dashboard'))
        return htmlfill.render(self._edit_student_group(), defaults=defaults)
Esempio n. 2
0
 def _group_teacher_action(self, id=None):
     if id is None:
         redirect(url(controller='search', action='index'))
     group = TeacherGroup.get(id)
     if group is None:
         abort(404)
     c.security_context = group
     c.group = group
     return method(self, group)
Esempio n. 3
0
 def delete_student_group(self):
     if hasattr(self, 'form_result'):
         group = TeacherGroup.get(int(self.form_result['group_id']))
         if group is not None and group.teacher == c.user:
             message = _(u'Group %(group_title)s (%(group_email)s) was deleted.') % {
                 'group_title': group.title,
                 'group_email': group.email}
             meta.Session.delete(group)
             meta.Session.commit()
             h.flash(message)
         else:
             abort(404)
     redirect(url(controller='profile', action='dashboard'))