Esempio n. 1
0
 def edit(self, id):
     # A person can only volunteer once
     c.form = 'edit'
     c.volunteer = Volunteer.find_by_id(id)
     defaults = h.object_to_defaults(c.volunteer, 'volunteer')
     form = render('/volunteer/edit.mako')
     return htmlfill.render(form, defaults)
Esempio n. 2
0
 def pending(self, id):
     volunteer = Volunteer.find_by_id(id)
     volunteer.accepted = None
     volunteer.ticket_type = None
     meta.Session.commit()
     h.flash("Status Updated")
     redirect_to(action="index", id=None)
Esempio n. 3
0
    def index(self):
        # Check access and redirect
        if not h.auth.authorized(h.auth.has_organiser_role):
            redirect_to(action="new")

        c.volunteer_collection = Volunteer.find_all()
        return render("volunteer/list.mako")
Esempio n. 4
0
 def pending(self, id):
     volunteer = Volunteer.find_by_id(id)
     volunteer.accepted = None
     volunteer.ticket_type = None
     meta.Session.commit()
     h.flash('Status Updated')
     redirect_to(action='index', id=None)
Esempio n. 5
0
 def edit(self, id):
     # A person can only volunteer once
     c.form = "edit"
     c.volunteer = Volunteer.find_by_id(id)
     defaults = h.object_to_defaults(c.volunteer, "volunteer")
     form = render("/volunteer/edit.mako")
     return htmlfill.render(form, defaults)
Esempio n. 6
0
 def _edit(self, id):
     results = self.form_result["volunteer"]
     c.volunteer = Volunteer.find_by_id(id)
     for key in self.form_result["volunteer"]:
         setattr(c.volunteer, key, self.form_result["volunteer"][key])
     meta.Session.commit()
     redirect_to(action="view", id=c.volunteer.id)
Esempio n. 7
0
    def index(self):
        # Check access and redirect
        if not h.auth.authorized(h.auth.has_organiser_role):
            redirect_to(action='new')

        c.volunteer_collection = Volunteer.find_all()
        return render('volunteer/list.mako')
Esempio n. 8
0
 def _edit(self, id):
     results = self.form_result['volunteer']
     c.volunteer = Volunteer.find_by_id(id)
     for key in self.form_result['volunteer']:
         setattr(c.volunteer, key, self.form_result['volunteer'][key])
     meta.Session.commit()
     redirect_to(action='view', id=c.volunteer.id)
Esempio n. 9
0
    def view(self, id):
        c.volunteer = Volunteer.find_by_id(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(c.volunteer.person.id), h.auth.has_organiser_role)
        ):
            # Raise a no_auth error
            h.auth.no_role()

        c.can_edit = h.auth.is_same_zookeepr_user(c.volunteer.person.id)

        c.volunteer = Volunteer.find_by_id(id)
        if c.volunteer is None:
            abort(404, "No such object")

        return render("volunteer/view.mako")
Esempio n. 10
0
    def view(self, id):
        c.volunteer = Volunteer.find_by_id(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(c.volunteer.person.id),
                          h.auth.has_organiser_role)):
            # Raise a no_auth error
            h.auth.no_role()

        c.can_edit = h.auth.is_same_zookeepr_user(c.volunteer.person.id)

        c.volunteer = Volunteer.find_by_id(id)
        if c.volunteer is None:
            abort(404, "No such object")

        return render('volunteer/view.mako')
Esempio n. 11
0
 def reject(self, id):
     volunteer = Volunteer.find_by_id(id)
     volunteer.accepted = False
     volunteer.ticket_type = None
     meta.Session.commit()
     c.volunteer = volunteer
     c.person = volunteer.person
     email(c.person.email_address, render("volunteer/response.mako"))
     h.flash("Status Updated and Rejection Email Sent")
     redirect_to(action="index", id=None)
Esempio n. 12
0
 def reject(self, id):
     volunteer = Volunteer.find_by_id(id)
     volunteer.accepted = False
     volunteer.ticket_type = None
     meta.Session.commit()
     c.volunteer = volunteer
     c.person = volunteer.person
     email(c.person.email_address, render('volunteer/response.mako'))
     h.flash('Status Updated and Rejection Email Sent')
     redirect_to(action='index', id=None)
Esempio n. 13
0
 def _accept(self, id):
     results = self.form_result
     volunteer = Volunteer.find_by_id(id)
     volunteer.ticket_type = results['ticket_type']
     volunteer.accepted = True
     meta.Session.commit()
     c.volunteer = volunteer
     c.person = volunteer.person
     email(c.person.email_address, render('volunteer/response.mako'))
     h.flash('Status Updated and Acceptance Email Sent')
     redirect_to(action='index', id=None)
Esempio n. 14
0
 def _accept(self, id):
     results = self.form_result
     volunteer = Volunteer.find_by_id(id)
     volunteer.ticket_type = results["ticket_type"]
     volunteer.accepted = True
     meta.Session.commit()
     c.volunteer = volunteer
     c.person = volunteer.person
     email(c.person.email_address, render("volunteer/response.mako"))
     h.flash("Status Updated and Acceptance Email Sent")
     redirect_to(action="index", id=None)
Esempio n. 15
0
 def accept(self, id):
     volunteer = Volunteer.find_by_id(id)
     category = ProductCategory.find_by_name("Ticket")
     products = Product.find_by_category(category.id)
     defaults = {}
     if volunteer.ticket_type:
         defaults["ticket_type"] = volunteer.ticket_type.id
     c.products_select = []
     c.products_select.append(["", "No Ticket"])
     for p in products:
         if "Volunteer" in p.description:
             c.products_select.append([p.id, p.description + " - " + h.number_to_currency(p.cost / 100)])
     form = render("volunteer/accept.mako")
     return htmlfill.render(form, defaults)
Esempio n. 16
0
    def _new(self):
        results = self.form_result['volunteer']

        c.volunteer = Volunteer(**results)
        c.volunteer.person = h.signed_in_person()
        c.person = c.volunteer.person
        meta.Session.add(c.volunteer)
        meta.Session.commit()

        h.flash(
            "Thank you for volunteering. We will contact you shortly regarding your application"
        )
        email(c.person.email_address, render('volunteer/response.mako'))
        redirect_to(action='view', id=c.volunteer.id)
Esempio n. 17
0
 def accept(self, id):
     volunteer = Volunteer.find_by_id(id)
     category = ProductCategory.find_by_name('Ticket')
     products = Product.find_by_category(category.id)
     defaults = {}
     if volunteer.ticket_type:
         defaults['ticket_type'] = volunteer.ticket_type.id
     c.products_select = []
     c.products_select.append(['', 'No Ticket'])
     for p in products:
         if 'Volunteer' in p.description:
             c.products_select.append([
                 p.id,
                 p.description + ' - ' + h.number_to_currency(p.cost / 100)
             ])
     form = render('volunteer/accept.mako')
     return htmlfill.render(form, defaults)