def finish_edit(self, person): for key in self.form_result['person']: setattr(person, key, self.form_result['person'][key]) for sn in self.form_result['social_network']: network = SocialNetwork.find_by_name(sn['name']) if sn['account_name']: person.social_networks[network] = sn['account_name'] elif network in person.social_networks: del person.social_networks[network] # update the objects with the validated form data meta.Session.commit()
def finish_signup(self): c.form = 'finish_signup' c.person = h.signed_in_person() c.social_networks = SocialNetwork.find_all() c.person.fetch_social_networks() defaults = h.object_to_defaults(c.person, 'person') if not defaults['person.country']: defaults['person.country'] = 'AUSTRALIA' form = render('/person/finish_signup.mako') return htmlfill.render(form, defaults)
def edit(self, id): # We need to recheck auth in here so we can pass in the id if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_user(id), h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.form = 'edit' c.person = Person.find_by_id(id) c.social_networks = SocialNetwork.find_all() c.person.fetch_social_networks() defaults = h.object_to_defaults(c.person, 'person') if not defaults['person.country']: defaults['person.country'] = 'AUSTRALIA' form = render('/person/edit.mako') return htmlfill.render(form, defaults)
def new(self): # Do we allow account creation? if Config.get('account_creation'): """Create a new person form. """ if h.signed_in_person(): h.flash("You're already logged in") redirect_to('home') defaults = { 'person.country': 'AUSTRALIA', } if Config.get('personal_info', category='rego')['home_address'] == 'no': defaults['person.address1'] = 'not available' defaults['person.city'] = 'not available' defaults['person.postcode'] = 'not available' c.social_networks = SocialNetwork.find_all() form = render('/person/new.mako') return htmlfill.render(form, defaults) else: return render('/not_allowed.mako')
def _to_python(self, value, state): return SocialNetwork.find_by_id(value)