def before(self, form): """ Populate the form before rendering form The deform form object used in this form view (see parent class in pyramid_deform) """ populate_actionmenu(self.request) auto_need(form) timepicker_fr.need() appstruct = self.context.appstruct() participants = self.context.participants appstruct['participants'] = [p.id for p in participants] trainers = self.context.trainers appstruct['trainers'] = [p.id for p in trainers] timeslots = self.context.timeslots appstruct['timeslots'] = [t.appstruct() for t in timeslots] try: appstruct['owner'] = appstruct['owner'].id except KeyError: pass form.set_appstruct(appstruct) if not self.request.has_permission('edit_owner.event'): form['owner'].widget.readonly = True return form
def before(self, form): """ fill the form before it will be handled """ populate_actionmenu(self.request) self.counter = form.counter appstruct = self.get_appstruct() form.set_appstruct(appstruct) auto_need(form) timepicker_fr.need()
def before(self, form): """ By default the activity is filled with the current user as conseiller """ auto_need(form) timepicker_fr.need() come_from = self.request.referrer current_user = self.request.user appstruct = { 'conseillers': [current_user.id], 'come_from': come_from, } form.set_appstruct(appstruct)
def before(self, form): auto_need(form) timepicker_fr.need() default_timeslots = get_default_timeslots() form.set_appstruct({ 'timeslots': default_timeslots, 'owner': self.request.user.id, }) if not self.request.has_permission('edit_owner.event'): form['owner'].widget.readonly = True # Default to current user if not form['owner'].cstruct: form['owner'].cstruct = self.request.user.id
def record_form(self): """ Return a form for recording the activity informations This form's submission will be handled in the ajax_submission page """ submit_url = self.request.route_path( "activity", id=self.request.context.id, _query=dict(action="record"), ) form = deform.Form( schema=RecordActivitySchema().bind(request=self.request), buttons=(ACTIVITY_RECORD_BUTTON, ACTIVITY_CANCEL_BUTTON,), counter=self.counter, formid="record_form", action=submit_url, ) form.set_appstruct(self.get_appstruct()) auto_need(form) return form.render()
def before(self, form): """ Populate the form before rendering form The deform form object used in this form view (see parent class in pyramid_deform) """ populate_actionmenu(self.request) auto_need(form) timepicker_fr.need() appstruct = self.context.appstruct() participants = self.context.participants appstruct['participants'] = [p.id for p in participants] timeslots = self.context.timeslots appstruct['timeslots'] = [t.appstruct() for t in timeslots] form.set_appstruct(appstruct) return form
def record_form(self): """ Return a form for recording the activity informations This form's submission will be handled in the ajax_submission page """ submit_url = self.request.route_path( "activity", id=self.request.context.id, _query=dict(action="record"), ) form = deform.Form( schema=RecordActivitySchema().bind(request=self.request), buttons=( ACTIVITY_RECORD_BUTTON, ACTIVITY_CANCEL_BUTTON, ACTIVITY_PDF_BUTTON, ), counter=self.counter, formid="record_form", action=submit_url, ) form.set_appstruct(self.get_appstruct()) auto_need(form) return form.render()
def before(self, form): auto_need(form) timepicker_fr.need() default_timeslots = get_default_timeslots() form.set_appstruct({'timeslots': default_timeslots})
def before(self, form): BaseEditView.before(self, form) auto_need(form) form.widget = AccordionFormWidget(named_grids=FORM_GRID)
def before(self, form): auto_need(form) form.widget = AccordionFormWidget(named_grids=USERDATAS_FORM_GRIDS) self.populate_actionmenu()