Пример #1
0
    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)
Пример #2
0
    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
Пример #3
0
    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
Пример #4
0
    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)
Пример #5
0
    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')
Пример #6
0
    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)
Пример #7
0
    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')
Пример #8
0
    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)
Пример #9
0
    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)
Пример #10
0
    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)
Пример #11
0
    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)
Пример #12
0
    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)
Пример #13
0
    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')
Пример #14
0
    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')
Пример #15
0
 def index(self):
     c.fulfilment_collection = Fulfilment.find_all()
     return render('/fulfilment/list.mako')
Пример #16
0
 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()
Пример #17
0
 def swag_give(self, id):
     c.fulfilment = Fulfilment.find_by_id(id)
     c.fulfilment.status_id = 6
     meta.Session.commit()
Пример #18
0
 def swag_give(self, id):
     c.fulfilment = Fulfilment.find_by_id(id)
     c.fulfilment.status_id = 6
     meta.Session.commit()
Пример #19
0
 def view(self, id):
     c.fulfilment = Fulfilment.find_by_id(id)
     return render('/fulfilment/view.mako')
Пример #20
0
 def view(self, id):
     c.fulfilment = Fulfilment.find_by_id(id)
     return render('/fulfilment/view.mako')
Пример #21
0
 def index(self):
     c.fulfilment_collection = Fulfilment.find_all()
     return render('/fulfilment/list.mako')
Пример #22
0
 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()