Esempio n. 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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)
Esempio n. 4
0
    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')
Esempio n. 5
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)
Esempio n. 6
0
    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')
Esempio n. 7
0
 def _to_python(self, value, state):
     return SocialNetwork.find_by_id(value)
Esempio n. 8
0
 def _to_python(self, value, state):
     return SocialNetwork.find_by_id(value)