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_zkpylons_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_zkpylons_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')
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)
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')
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)
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)
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)
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)
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)
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)
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.integer_to_currency(p.cost)]) form = render('volunteer/accept.mako') return htmlfill.render(form, defaults)