Example #1
0
    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)
Example #2
0
    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)