def _delete(self, id): c.fulfilment = Fulfilment.find_by_id(id) meta.Session.delete(c.fulfilment) meta.Session.commit() h.flash("Fulfilment has been deleted.") redirect_to('index', id=None)
def _badge(self, id): c.fulfilment = Fulfilment.find_by_id(id) xml_s = render('/fulfilment/badge.mako') xsl_f = app_globals.mako_lookup.get_template('/fulfilment/badge.xsl').filename pdf_data = pdfgen.generate_pdf(xml_s, xsl_f) return pdf_data
def delete(self, id): """Delete the fulfilment GET will return a form asking for approval. POST requests will delete the item. """ c.fulfilment = Fulfilment.find_by_id(id) return render('/fulfilment/confirm_delete.mako')
def _new(self): results = self.form_result['fulfilment'] c.fulfilment = Fulfilment(**results) meta.Session.add(c.fulfilment) meta.Session.commit() h.flash("Fulfilment created") redirect_to(action='index', id=None)
def _edit(self, id): fulfilment = Fulfilment.find_by_id(id) for key in self.form_result['fulfilment']: setattr(fulfilment, key, self.form_result['fulfilment'][key]) # update the objects with the validated form data meta.Session.commit() h.flash("The Fulfilment has been updated successfully.") redirect_to(action='index', id=None)
def edit(self, id): c.fulfilment = Fulfilment.find_by_id(id) defaults = h.object_to_defaults(c.fulfilment, 'fulfilment') defaults['fulfilment.person'] = c.fulfilment.person_id defaults['fulfilment.type'] = c.fulfilment.type_id defaults['fulfilment.status'] = c.fulfilment.status_id form = render('/fulfilment/edit.mako') return htmlfill.render(form, defaults)
def edit(self, id): c.fulfilment = Fulfilment.find_by_id(id) defaults = h.object_to_defaults(c.fulfilment, "fulfilment") defaults["fulfilment.person"] = c.fulfilment.person_id defaults["fulfilment.type"] = c.fulfilment.type_id defaults["fulfilment.status"] = c.fulfilment.status_id form = render("/fulfilment/edit.mako") return htmlfill.render(form, defaults)
def update_fulfilments(self): """ Allow the updating of fulfilment data via json. Only allow a subset of the columns in the tables to be updated. In particular do not allow the primary keys or the fulfilment_id on the fulfilmment_item table to be changed. TODO: If we don't get all of the fulfilment_items for a fulfilment then throw an error If qty for an item is zero then we should delete it. """ import json debug = "" data = request.params['data'] data = json.loads(data) for fulfilment in data['fulfilments']: db_fulfilment = Fulfilment.find_by_id(int(fulfilment['id']), abort_404=False) db_fulfilment.type_id = fulfilment['type_id'] db_fulfilment.status_id = fulfilment['status_id'] db_fulfilment.code = fulfilment['code'] meta.Session.add(db_fulfilment) for fulfilment_item in fulfilment['fulfilment_items']: db_fulfilment_item = FulfilmentItem.find_by_id( fulfilment_item['id'], abort_404=False) db_fulfilment_item.product_id = fulfilment_item['product_id'] db_fulfilment_item.product_text = fulfilment_item[ 'product_text'] db_fulfilment_item.qty = int(fulfilment_item['qty']) meta.Session.add(db_fulfilment_item) meta.Session.commit() debug += "Committed changes\n" return debug raise Exception('Success')
def update_fulfilments(self): """ Allow the updating of fulfilment data via json. Only allow a subset of the columns in the tables to be updated. In particular do not allow the primary keys or the fulfilment_id on the fulfilmment_item table to be changed. TODO: If we don't get all of the fulfilment_items for a fulfilment then throw an error If qty for an item is zero then we should delete it. """ import json debug = "" data = request.params['data'] data = json.loads(data) for fulfilment in data['fulfilments']: db_fulfilment = Fulfilment.find_by_id(int(fulfilment['id']), abort_404=False) db_fulfilment.type_id = fulfilment['type_id'] db_fulfilment.status_id = fulfilment['status_id'] db_fulfilment.code = fulfilment['code'] meta.Session.add(db_fulfilment) for fulfilment_item in fulfilment['fulfilment_items']: db_fulfilment_item = FulfilmentItem.find_by_id(fulfilment_item['id'], abort_404=False) db_fulfilment_item.product_id = fulfilment_item['product_id'] db_fulfilment_item.product_text = fulfilment_item['product_text'] db_fulfilment_item.qty = int(fulfilment_item['qty']) meta.Session.add(db_fulfilment_item) meta.Session.commit() debug += "Committed changes\n" return debug raise Exception( 'Success')
def index(self): c.fulfilment_collection = Fulfilment.find_all() return render('/fulfilment/list.mako')
def swag_give(self, id): c.fulfilment = Fulfilment.find_by_id(id) # TODO: This needs be unhardcoded c.fulfilment.status_id = 6 meta.Session.commit()
def swag_give(self, id): c.fulfilment = Fulfilment.find_by_id(id) c.fulfilment.status_id = 6 meta.Session.commit()
def view(self, id): c.fulfilment = Fulfilment.find_by_id(id) return render('/fulfilment/view.mako')