Esempio n. 1
0
    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
        }
Esempio n. 2
0
    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}
Esempio n. 3
0
    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}
Esempio n. 4
0
def _submit_checklist_item(session,
                           department_id,
                           submitted,
                           csrf_token,
                           slug,
                           custom_message=''):
    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:
        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)
        session.add(item)
        raise HTTPRedirect(
            '../dept_checklist/index?department_id={}&message={}',
            department_id, custom_message
            or 'Thanks for completing the {} form!'.format(
                slug.replace('_', ' ')))

    return {'department': department}
Esempio n. 5
0
    def tech_requirements(self,
                          session,
                          department_id=None,
                          submitted=None,
                          csrf_token=None):
        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 = 'tech_requirements'
            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)
            session.add(item)
            raise HTTPRedirect(
                '../dept_checklist/index?department_id={}&message={}',
                department_id,
                'Thanks for completing the tech requirements form!')

        return {'department': department}
Esempio n. 6
0
    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}
    def mark_item_complete(self, session, slug, department_id):
        attendee = session.admin_attendee()
        department = session.query(Department).options(
            subqueryload(Department.dept_checklist_items)).get(department_id)

        if department.checklist_item_for_slug(slug):
            message = 'Checklist item already marked as complete'
        else:
            item = DeptChecklistItem(attendee=attendee, department=department, slug=slug)
            message = check(item)
            if not message:
                session.add(item)
                message = 'Checklist item marked as complete'
        raise HTTPRedirect(
            'index?department_id={}&message={}', department_id, message)