def form(self, session, slug, department_id, csrf_token=None, comments=None): attendee = session.admin_attendee() department = session.query(Department).options( subqueryload(Department.dept_checklist_items)).get(department_id) conf = DeptChecklistConf.instances[slug] item = department.checklist_item_for_slug(slug) if not item: item = DeptChecklistItem(attendee=attendee, department=department, slug=slug) if comments is not None: # since this form doesn't use our normal utility methods, we need to check the csrf_token manually check_csrf(csrf_token) item.comments = comments message = check(item) if not message: session.add(item) message = conf.name + ' checklist data uploaded' raise HTTPRedirect('index?department_id={}&message={}', department_id, message) return {'item': item, 'conf': conf, 'department': department}
def form(self, session, slug, department_id, csrf_token=None, comments=None): attendee = session.admin_attendee() department = session.query(Department).options( subqueryload(Department.dept_checklist_items)).get(department_id) conf = DeptChecklistConf.instances[slug] item = department.checklist_item_for_slug(slug) if not item: item = DeptChecklistItem( attendee=attendee, department=department, slug=slug) if comments is not None: # since this form doesn't use our normal utility methods, we need to check the csrf_token manually check_csrf(csrf_token) item.comments = comments message = check(item) if not message: session.add(item) message = conf.name + ' checklist data uploaded' raise HTTPRedirect( 'index?department_id={}&message={}', department_id, message) return { 'item': item, 'conf': conf, 'department': department }
def allotments(self, session, department_id=None, submitted=None, csrf_token=None, **params): if not department_id: raise HTTPRedirect('../dept_checklist/index') attendee = session.admin_attendee() department = session.query(Department).options( subqueryload(Department.dept_checklist_items)).get(department_id) if submitted: slug = 'allotments' item = department.checklist_item_for_slug(slug) if not item: item = DeptChecklistItem(attendee=attendee, department=department, slug=slug) # since this form doesn't use our normal utility methods, we need to do this manually check_csrf(csrf_token) item.comments = render('dept_checklist/allotments.txt', params).decode('utf-8') session.add(item) raise HTTPRedirect( '../dept_checklist/index?department_id={}&message={}', department_id, 'Treasury checklist data uploaded') return {'department': department}