Beispiel #1
0
    def edit(self, id):
        c.product_category = ProductCategory.find_by_id(id)

        defaults = h.object_to_defaults(c.product_category, 'product_category')

        form = render('/product_category/edit.mako')
        return htmlfill.render(form, defaults)
    def edit(self, id):
        c.product_category = ProductCategory.find_by_id(id)

        defaults = h.object_to_defaults(c.product_category, 'product_category')

        form = render('/product_category/edit.mako')
        return htmlfill.render(form, defaults)
Beispiel #3
0
    def delete(self, id):
        """Delete the product_category

        GET will return a form asking for approval.

        POST requests will delete the item.
        """
        c.product_category = ProductCategory.find_by_id(id)
        return render('/product_category/confirm_delete.mako')
Beispiel #4
0
 def validate_python(self, values, state):
     product_category = ProductCategory.find_by_name(
         values['product_category']['name'])
     if product_category != None and product_category != c.product_category:
         message = "Duplicate product category name"
         error_dict = {
             'product_category.name': "Category name already in use"
         }
         raise Invalid(message, values, state, error_dict=error_dict)
    def delete(self, id):
        """Delete the product_category

        GET will return a form asking for approval.

        POST requests will delete the item.
        """
        c.product_category = ProductCategory.find_by_id(id)
        return render('/product_category/confirm_delete.mako')
Beispiel #6
0
    def _new(self):
        results = self.form_result['product_category']

        c.product_category = ProductCategory(**results)
        meta.Session.add(c.product_category)
        meta.Session.commit()

        h.flash("Category created")
        redirect_to(action='view', id=c.product_category.id)
    def _edit(self, id):
        product_category = ProductCategory.find_by_id(id)

        for key in self.form_result['product_category']:
            setattr(product_category, key, self.form_result['product_category'][key])

        # update the objects with the validated form data
        meta.Session.commit()
        h.flash("The product_category has been updated successfully.")
        redirect_to(action='view', id=id)
Beispiel #8
0
    def _edit(self, id):
        product_category = ProductCategory.find_by_id(id)

        for key in self.form_result['product_category']:
            setattr(product_category, key, self.form_result['product_category'][key])

        # update the objects with the validated form data
        meta.Session.commit()
        h.flash("The product_category has been updated successfully.")
        redirect_to(action='view', id=id)
Beispiel #9
0
 def json(self):
     c.product_categories = ProductCategory.find_all()
     result = []
     for category in c.product_categories:
         for product in category.products:
             product_dict = {
                 'id': product.id,
                  'category': category.name,
                  'category_order': category.display_order,
                  'product_order': product.display_order,
                  'cost': product.cost,
                  'description': product.description
             }
             result.append(product_dict)
     return { 'r': result }
Beispiel #10
0
 def json(self):
     c.product_categories = ProductCategory.find_all()
     result = []
     for category in c.product_categories:
         for product in category.products:
             product_dict = {
                 'id': product.id,
                 'category': category.name,
                 'category_order': category.display_order,
                 'product_order': product.display_order,
                 'cost': product.cost,
                 'description': product.description
             }
             result.append(product_dict)
     return {'r': result}
    def _delete(self, id):
        c.product_category = ProductCategory.find_by_id(id)
        # For some reason cascading isn't working for me. Likely I just don't understand SA so I'll do it this way:
        # first delete all of the products
        for product in c.product_category.products:
            # We also delete all of the productincludes for the products
            for include in ProductInclude.find_by_product(product.id):
                meta.Session.delete(include)
            meta.Session.commit()
            meta.Session.delete(product)
        meta.Session.commit()
        # Also delete any includes of the category
        for include in ProductInclude.find_by_category(id):
            meta.Session.delete(include)
        meta.Session.commit()
        meta.Session.delete(c.product_category)
        meta.Session.commit()

        h.flash("Category has been deleted.")
        redirect_to('index')
Beispiel #12
0
    def _delete(self, id):
        c.product_category = ProductCategory.find_by_id(id)
        # For some reason cascading isn't working for me. Likely I just don't understand SA so I'll do it this way:
        # first delete all of the products
        for product in c.product_category.products:
            # We also delete all of the productincludes for the products
            for include in ProductInclude.find_by_product(product.id):
                meta.Session.delete(include)
            meta.Session.commit()
            meta.Session.delete(product)
        meta.Session.commit()
        # Also delete any includes of the category
        for include in ProductInclude.find_by_category(id):
            meta.Session.delete(include)
        meta.Session.commit()
        meta.Session.delete(c.product_category)
        meta.Session.commit()

        h.flash("Category has been deleted.")
        redirect_to('index')
Beispiel #13
0
 def index(self):
     c.can_edit = True
     c.product_category_collection = ProductCategory.find_all()
     return render('/product_category/list.mako')
Beispiel #14
0
 def stats(self, id):
     c.can_edit = True
     c.product_category = ProductCategory.find_by_id(id)
     c.product_categories = ProductCategory.find_all()
     return render('/product_category/stats.mako')
Beispiel #15
0
 def view(self, id):
     c.product_category = ProductCategory.find_by_id(id)
     return render('/product_category/view.mako')
Beispiel #16
0
 def __before__(self, **kwargs):
     c.product_categories = ProductCategory.find_all()
     c.fulfilment_types = FulfilmentType.find_all()
     c.ceilings = Ceiling.find_all()
 def validate_python(self, values, state):
     product_category = ProductCategory.find_by_name(values['product_category']['name'])
     if product_category != None and product_category != c.product_category:
         message = "Duplicate product category name"
         error_dict = {'product_category.name': "Category name already in use"}
         raise Invalid(message, values, state, error_dict=error_dict)
 def view(self, id):
     c.product_category = ProductCategory.find_by_id(id)
     return render('/product_category/view.mako')
Beispiel #19
0
 def __before__(self, **kwargs):
     c.product_categories = ProductCategory.find_all()
     c.ceilings = Ceiling.find_all()
Beispiel #20
0
 def __before__(self, **kwargs):
     c.product_categories = ProductCategory.find_all()
Beispiel #21
0
 def __before__(self, **kwargs):
     c.product_categories = ProductCategory.find_all()
     c.fulfilment_types = FulfilmentType.find_all()
     c.ceilings = Ceiling.find_all()
 def stats(self, id):
     c.can_edit = True
     c.product_category = ProductCategory.find_by_id(id)
     c.product_categories = ProductCategory.find_all()
     return render('/product_category/stats.mako')
 def index(self):
     c.can_edit = True
     c.product_category_collection = ProductCategory.find_all()
     return render('/product_category/list.mako')