def _edit(self, id): """UPDATE PERSON""" # 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_zookeepr_user(id), h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.person = Person.find_by_id(id) for key in self.form_result['person']: setattr(c.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']: c.person.social_networks[network] = sn['account_name'] elif network in c.person.social_networks: del c.person.social_networks[network] # update the objects with the validated form data meta.Session.commit() redirect_to(action='view', id=id)
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_zookeepr_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') defaults['person.email_address2'] = c.person.email_address form = render('/person/edit.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_zookeepr_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') defaults['person.email_address2'] = c.person.email_address form = render('/person/edit.mako') return htmlfill.render(form, defaults)
def new(self): # Do we allow account creation? if lca_info['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 h.lca_rego['personal_info']['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 _edit(self, id): """UPDATE PERSON""" # 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_zookeepr_user(id), h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.person = Person.find_by_id(id) for key in self.form_result['person']: setattr(c.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']: c.person.social_networks[network] = sn['account_name'] elif network in c.person.social_networks: del c.person.social_networks[network] # update the objects with the validated form data meta.Session.commit() redirect_to(action='view', id=id)
def _to_python(self, value, state): return SocialNetwork.find_by_id(value)