Ejemplo n.º 1
0
    def __init__(self, product_id, sql_conn):
        self.sql_conn = sql_conn
        self.product = sql_conn.get_product_by_id(product_id)[0]
        self.has_options = False

        try:
            self.product[
                'manufacturer_name'] = sql_conn.get_manufacturer_by_id(
                    self.product['manufacturer_id'])[0]['name']
        except:
            self.product['manufacturer_name'] = "None"
        self.product['categories'] = [
            a['name']
            for a in self.sql_conn.get_categories_by_product_id(product_id)
        ]
        self.product['display_description'] = Markup.unescape(
            Markup(self.product['display_description']))

        if self.sql_conn.has_product_options(product_id):
            self.has_options = True
            self.options = self.sql_conn.get_options_by_product(product_id)
            self.option_number = len(self.options)
            self.product['has_options'] = True
        else:
            self.options = dict()
            self.options['product_option_id'] = 0
            self.options['option_value_id'] = 0
            self.product['has_options'] = False
        self.product['options'] = self.options
Ejemplo n.º 2
0
    def __init__(self, product_id, sql_conn):
        self.sql_conn = sql_conn
        self.product = sql_conn.get_product_by_id(product_id)[0]
        self.has_options = False

        try:
            self.product['manufacturer_name'] = sql_conn.get_manufacturer_by_id(self.product['manufacturer_id'])[0][
                'name']
        except:
            self.product['manufacturer_name'] = "None"
        self.product['categories'] = [a['name'] for a in self.sql_conn.get_categories_by_product_id(product_id)]
        self.product['display_description'] = Markup.unescape(Markup(self.product['display_description']))

        if self.sql_conn.has_product_options(product_id):
            self.has_options = True
            self.options = self.sql_conn.get_options_by_product(product_id)
            self.option_number = len(self.options)
            self.product['has_options'] = True
        else:
            self.options = dict()
            self.options['product_option_id'] = 0
            self.options['option_value_id'] = 0
            self.product['has_options'] = False
        self.product['options'] = self.options