def _delete(self, id): c.funding_type = FundingType.find_by_id(id) meta.Session.delete(c.funding_type) meta.Session.commit() h.flash("Funding type has been deleted.") redirect_to('index')
def edit(self, id): c.funding_type = FundingType.find_by_id(id) defaults = h.object_to_defaults(c.funding_type, 'funding_type') form = render('/funding_type/edit.mako') return htmlfill.render(form, defaults)
def __before__(self, **kwargs): c.funding_types = FundingType.find_all() c.form_fields = { 'funding.why_attend': 'Why would you like to attend ' + h.lca_info['event_name'], 'funding.how_contribute': 'How do you contribute to the Open Source community', 'funding.male': 'What is your gender', 'funding.financial_circumstances': 'What are your financial circumstances', }
def delete(self, id): """Delete the funding type GET will return a form asking for approval. POST requests will delete the item. """ c.funding_type = FundingType.find_by_id(id) return render('/funding_type/confirm_delete.mako')
def _new(self): results = self.form_result['funding_type'] c.funding_type = FundingType(**results) meta.Session.add(c.funding_type) meta.Session.commit() h.flash("Funding type created") redirect_to(action='view', id=c.funding_type.id)
def _edit(self, id): funding_type = FundingType.find_by_id(id) for key in self.form_result['funding_type']: setattr(funding_type, key, self.form_result['funding_type'][key]) # update the objects with the validated form data meta.Session.commit() h.flash("Funding type has been updated successfully.") redirect_to(action='view', id=id)
def _to_python(self, value, state): funding_type = FundingType.find_by_id(int(value)) if funding_type != None and funding_type.available(): return funding_type else: return False
def index(self): c.funding_type_collection = FundingType.find_all() return render('/funding_type/list.mako')
def view(self, id): c.funding_type = FundingType.find_by_id(id) return render('/funding_type/view.mako')