コード例 #1
0
ファイル: workshop.py プロジェクト: w3bcr4ft/autonomie
def record_attendances_view(context, request):
    """
    Record attendances for the given context (workshop)

    Special Note : Since we need a special layout in the form (with tabs and
        lines with the username as header, we can't render it with deform.  We
        use peppercorn's parser and we build an appropriate form in the template
    """
    schema = AttendanceSchema().bind(request=request)
    if 'submit' in request.params:
        controls = request.params.items()
        values = peppercorn.parse(controls)
        try:
            appstruct = schema.deserialize(values)
        except colander.Invalid as e:
            log.error(u"Error while validating workshop attendance")
            log.error(e)
        else:
            for datas in appstruct['attendances']:
                account_id = datas['account_id']
                timeslot_id = datas['timeslot_id']
                obj = Attendance.get((account_id, timeslot_id))
                obj.status = datas['status']
                request.dbsession.merge(obj)
            request.session.flash(u"L'émargement a bien été enregistré")

    url = request.route_path(
        'workshop',
        id=context.id,
        _query=dict(action="edit"),
        )

    return HTTPFound(url)
コード例 #2
0
ファイル: workshop.py プロジェクト: Swannbm/autonomie
def record_attendances_view(context, request):
    """
    Record attendances for the given context (workshop)

    Special Note : Since we need a special layout in the form (with tabs and
        lines with the username as header, we can't render it with deform.  We
        use peppercorn's parser and we build an appropriate form in the template
    """
    schema = AttendanceSchema().bind(request=request)
    if 'submit' in request.params:
        controls = request.params.items()
        values = peppercorn.parse(controls)
        try:
            appstruct = schema.deserialize(values)
        except colander.Invalid as e:
            log.error(u"Error while validating workshop attendance")
            log.error(e)
        else:
            for datas in appstruct['attendances']:
                account_id = datas['account_id']
                timeslot_id = datas['timeslot_id']
                obj = Attendance.get((account_id, timeslot_id))
                obj.status = datas['status']
                request.dbsession.merge(obj)
            request.session.flash(u"L'émargement a bien été enregistré")

    url = request.route_path(
        'workshop',
        id=context.id,
        _query=dict(action="edit"),
    )

    return HTTPFound(url)
コード例 #3
0
    def record_attendance(self, appstruct):
        """
        Record the attendances status in both cancelled and closed activity
        """
        for datas in appstruct.pop('attendances', []):
            account_id = datas['account_id']
            event_id = datas['event_id']

            obj = Attendance.get((account_id, event_id))
            if obj is not None:
                obj.status = datas['status']
                self.dbsession.merge(obj)
コード例 #4
0
ファイル: activity.py プロジェクト: yledoare/autonomie
    def record_attendance(self, appstruct):
        """
        Record the attendances status in both cancelled and closed activity
        """
        for datas in appstruct.pop('attendances', []):
            account_id = datas['account_id']
            event_id = datas['event_id']

            obj = Attendance.get((account_id, event_id))
            if obj is not None:
                obj.status = datas['status']
                self.dbsession.merge(obj)