Exemplo n.º 1
0
def create_xcty_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + Product.PRODUCT_EXTRA_CITY)
    p.price = 1000
    p.default_count = 1
    p.default = False
    p.possible_counts = range(1, 37)
    p.is_subscription = False
    p.is_subscription_discount = False
    p.is_subscription_extension = True
    p.organization_types = []
    p.product_dependencies = [
        '|'.join([
            '%s%s:-1' % (code_prefix, product_code)
            for product_code in ('MSUP', 'MSSU', 'SSUP', 'SSZP', 'CSUB',
                                 Product.PRODUCT_FREE_PRESENCE,
                                 Product.PRODUCT_FREE_SUBSCRIPTION)
        ])
    ]
    p.picture_url = ""
    p.visible = True
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 2
0
    def handle(self, *args, **options):
        products = settings.BASE_DIR.joinpath('products.json')

        with open(products, encoding='utf-8') as f:
            data = json.load(f)

            for item in data:
                category, created = Category.objects.get_or_create(
                    name=item['category'][0])

                if created:
                    category.save()

                try:
                    product = Product.objects.get(category=category,
                                                  name=item['name'][0])
                except Product.DoesNotExist:
                    product = Product(category=category, name=item['name'][0])

                product.price = float(item['price'][0][1:])
                product.description = item['description'][0]
                product.save()

                photo, created = Photo.objects.get_or_create(
                    product=product, url=item['photo'][1])

                if created:
                    photo.save()

                size, created = Size.objects.get_or_create(product=product)

                if created:
                    size.size = self.random_size()
                    size.save()
Exemplo n.º 3
0
def add_random_product():
    category = Category.objects.first()
    item = Product()
    item.category = category
    item.name = my_random_string(category.slug)
    item.slug = item.name + '_slug'
    item.price = 1
    item.stock = 2
    item.save()
    return item
Exemplo n.º 4
0
 def handle(self, *args, **options):
     try:
         p = Product()
         p.name = u'\"Норка\"'
         p.price = 100500.0
         p.img_url = '/static/bfriday/1.png'
         p.SKU = '-1'
         p.save()
     except Exception, e:
         pass
Exemplo n.º 5
0
def init_products():
    categories = Category.objects.all()
    for category in categories:
        for number in range(4):
            item = Product()
            item.category = category
            item.name = my_random_string(category.slug)
            item.slug = item.name + '_slug'
            item.price = 1
            item.stock = 2
            item.save()
Exemplo n.º 6
0
def create_drc_hefl_product():
    p = Product(key_name='DRC_HEFL')
    p.price = 2000
    p.default_count = 1
    p.possible_counts = [1, 12]
    p.is_subscription = True
    p.visible = True
    p.organization_types = []
    p.module_set = 'ALL'
    p.legal_entity_id = MC_TELECOM_LEGAL_ENTITY_ID
    p.is_multilanguage = False
    p.default_comment_translation_key = u'Abonnement mensuel Ville Connect\xe9e pour les entreprises travaillant \xe0 domicile, entrepreneur ou pigistes'
    p.description_translation_key = u'Abonnement pour les entreprises travaillant \xe0 domicile, entrepreneur ou pigistes'
    return p
Exemplo n.º 7
0
def create_drc_corp_product():
    p = Product(key_name='DRC_CORP')
    p.price = 4166
    p.default_count = 12
    p.possible_counts = [12]
    p.is_subscription = True
    p.visible = True
    p.organization_types = []
    p.module_set = 'ALL'
    p.legal_entity_id = MC_TELECOM_LEGAL_ENTITY_ID
    p.is_multilanguage = False
    p.default_comment_translation_key = u'Abonnement annuel Ville Connect\xe9e pour les entreprises'
    p.description_translation_key = u'Abonnement Ville Connect\xe9e pour entreprises'
    return p
Exemplo n.º 8
0
def create_drc_stud_product():
    p = Product(key_name='DRC_STUD')
    p.price = 1000
    p.default_count = 1
    p.possible_counts = [1, 12]
    p.is_subscription = True
    p.visible = True
    p.organization_types = []
    p.module_set = 'ALL'
    p.legal_entity_id = MC_TELECOM_LEGAL_ENTITY_ID
    p.is_multilanguage = False
    p.default_comment_translation_key = u'Abonnement mensuel Ville Connect\xe9e pour \xe9tudiants'
    p.description_translation_key = u'Abonnement Ville Connect\xe9e pour \xe9tudiants'
    return p
Exemplo n.º 9
0
Arquivo: views.py Projeto: wooshe/Shop
def main_product(author, category, name, description, material, model, color):
    pr = Product()
    pr.author = author
    pr.category = category
    pr.name = name
    pr.description = description
    pr.material = material
    pr.model = model
    pr.color = color
    pr.price = random.uniform(100, 2000)
    pr.like = random.randint(0, 1000)
    pr.rating = random.uniform(1, 5)
    pr.rating_count = 500
    pr.rating_sum = int(pr.rating * 500)
    pr.save()
Exemplo n.º 10
0
def create_klup_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'KLUP')
    p.price = -18000
    p.default_count = 1
    p.default = False
    p.possible_counts = [1]
    p.is_subscription = False
    p.is_subscription_discount = False
    p.organization_types = []
    p.product_dependencies = [code_prefix + 'LSUP', code_prefix + 'KSUP:-1']
    p.visible = False
    p.legal_entity_id = legal_entity_id
    p.default_comment_translation_key = ''
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
    return p
Exemplo n.º 11
0
def create_msub_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'MSUB')
    p.price = 25000
    p.default_count = 12
    p.default = False
    p.possible_counts = [1, 12, 24, 36]
    p.is_subscription = True
    p.is_subscription_discount = False
    p.module_set = 'ALL'
    p.organization_types = []
    p.product_dependencies = []
    p.visible = bool(
        code_prefix)  # only for legal entities other than mobicage
    p.legal_entity_id = legal_entity_id
    p.description_translation_key = 'MSUP.description'
    p.default_comment_translation_key = 'MSSU.default_comment'
    return p
Exemplo n.º 12
0
def create_xtrb_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'XTRB')
    p.price = 10000
    p.default_count = 1
    p.default = False
    p.possible_counts = range(1, 101)
    p.is_subscription = False
    p.is_subscription_discount = False
    p.module_set = 'ALL'
    p.organization_types = []
    p.product_dependencies = []
    p.visible = bool(
        code_prefix)  # only for legal entities other than mobicage
    p.legal_entity_id = legal_entity_id
    p.description_translation_key = 'XTRA.description'
    p.default_comment_translation_key = 'XTRA.default_comment'
    return p
Exemplo n.º 13
0
def create_news_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + Product.PRODUCT_NEWS_PROMOTION)
    p.price = 1
    p.default_count = 1
    p.default = False
    p.possible_counts = []
    p.is_subscription = False
    p.organization_types = []
    p.product_dependencies = []
    p.visible = False  # Only orderable via dashboard when creating a newsfeed item
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 14
0
def create_loya_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'LOYA')
    p.price = 30000
    p.default_count = 1
    p.default = False
    p.possible_counts = [1, 2, 3, 4]
    p.is_subscription = False
    p.is_subscription_discount = False
    p.organization_types = []
    p.product_dependencies = [code_prefix + 'MSUP:-1']
    p.visible = False
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 15
0
def create_visi_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'VISI')
    p.price = 30
    p.default_count = 250
    p.default = False
    p.possible_counts = [250, 500, 750]
    p.is_subscription = False
    p.is_subscription_discount = False
    p.organization_types = []
    p.product_dependencies = []
    p.visible = False
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 16
0
def create_pres_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'PRES')
    p.price = 30000
    p.default_count = 4
    p.default = False
    p.possible_counts = range(1, 101)
    p.is_subscription = False
    p.is_subscription_discount = False
    p.module_set = 'ALL'
    p.organization_types = [ServiceProfile.ORGANIZATION_TYPE_CITY]
    p.product_dependencies = []
    p.visible = True
    p.legal_entity_id = legal_entity_id
    p.default_comment_translation_key = ''
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
    return p
Exemplo n.º 17
0
def create_xtra_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'XTRA')
    p.price = 7500
    p.default_count = 1
    p.default = False
    p.possible_counts = range(1, 101)
    p.is_subscription = False
    p.is_subscription_discount = False
    p.module_set = 'ALL'
    p.organization_types = []
    p.product_dependencies = []
    p.visible = True
    p.legal_entity_id = legal_entity_id
    p.default_comment_translation_key = ''
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
    return p
Exemplo n.º 18
0
def create_msud_product(legal_entity_id, code_prefix='', default_count=12):
    p = Product(key_name=code_prefix + 'MSUD')
    p.price = -5000
    p.default_count = default_count
    p.default = True
    p.possible_counts = [1, 12, 24, 36]
    p.is_subscription = True
    p.is_subscription_discount = False
    p.module_set = 'ALL'
    p.organization_types = []
    p.product_dependencies = [code_prefix + 'MSUP']
    p.visible = True
    p.legal_entity_id = legal_entity_id
    p.default_comment_translation_key = ''
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
    return p
Exemplo n.º 19
0
def create_free_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + Product.PRODUCT_FREE_SUBSCRIPTION)
    p.price = 0
    p.default_count = 1
    p.default = False
    p.possible_counts = []
    p.is_subscription = True
    p.organization_types = []
    p.product_dependencies = []
    p.visible = True
    p.legal_entity_id = legal_entity_id
    p.module_set = 'ALL'
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 20
0
def create_ssup_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'SSUP')
    p.price = 1000
    p.default_count = 12
    p.default = False
    p.possible_counts = [12, 24, 36]
    p.is_subscription = True
    p.is_subscription_discount = False
    p.module_set = 'ALL'
    p.organization_types = [ServiceProfile.ORGANIZATION_TYPE_NON_PROFIT]
    p.product_dependencies = []
    p.visible = False
    p.legal_entity_id = legal_entity_id
    p.default_comment_translation_key = 'MSSU.default_comment'
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
    return p
Exemplo n.º 21
0
def create_csux_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'CSUX')
    p.price = 0
    p.default_count = 12
    p.default = False
    p.possible_counts = [12]
    p.is_subscription = True
    p.is_subscription_discount = False
    p.module_set = 'ALL'
    p.organization_types = [ServiceProfile.ORGANIZATION_TYPE_CITY]
    p.product_dependencies = []
    p.visible = bool(
        code_prefix)  # only for legal entities other than mobicage
    p.legal_entity_id = legal_entity_id
    p.default_comment_translation_key = 'CSUB.default_comment'
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
    return p
Exemplo n.º 22
0
def create_demo_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'DEMO')
    p.price = 0
    p.default_count = 3
    p.default = False
    p.possible_counts = [3]
    p.is_subscription = True
    p.is_subscription_discount = False
    p.module_set = 'ALL'
    p.organization_types = []
    p.product_dependencies = []
    p.visible = False
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 23
0
def create_kspp_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'KSPP')
    p.price = -1500
    p.default_count = 36
    p.default = True
    p.possible_counts = [12, 24, 36]
    p.is_subscription = False
    p.is_subscription_discount = True
    p.organization_types = []
    p.product_dependencies = [code_prefix + 'MSUP']
    p.visible = bool(
        code_prefix)  # only for legal entities other than mobicage
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 24
0
def create_beac_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + Product.PRODUCT_BEACON)
    p.price = 3500
    p.default_count = 1
    p.default = False
    p.possible_counts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    p.is_subscription = False
    p.is_subscription_discount = False
    p.organization_types = []
    p.product_dependencies = []
    p.visible = True
    p.picture_url = "/static/images/solutions/flex/BEACON_PRESENTATIE.jpg"
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 25
0
def create_updi_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'UPDI')
    p.price = -1000
    p.default_count = 1
    p.default = False
    p.possible_counts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
    p.is_subscription = False
    p.is_subscription_discount = False
    p.organization_types = []
    p.product_dependencies = []
    p.visible = bool(
        code_prefix)  # only for legal entities other than mobicage
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 26
0
def create_setd_product(legal_entity_id, code_prefix='', price=-7500):
    p = Product(key_name=code_prefix + 'SETD')
    p.price = price
    p.default_count = 1
    p.default = True
    p.possible_counts = [1]
    p.is_subscription = False
    p.is_subscription_discount = False
    p.module_set = 'ALL'
    p.organization_types = []
    p.product_dependencies = [code_prefix + 'SETU']
    p.visible = True
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 27
0
def create_appl_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'APPL')
    p.price = 10000
    p.default_count = 1
    p.default = False
    p.possible_counts = [1]
    p.is_subscription = False
    p.is_subscription_discount = False
    p.is_subscription_extension = True
    p.organization_types = [ServiceProfile.ORGANIZATION_TYPE_CITY]
    p.product_dependencies = []
    p.visible = True
    p.legal_entity_id = legal_entity_id
    p.default_comment_translation_key = ''
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
    p.charge_interval = 12
    return p
Exemplo n.º 28
0
def create_suby_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'SUBY')
    p.price = 12000
    p.default_count = 1
    p.default = False
    p.possible_counts = [1]
    p.is_subscription = False
    p.is_subscription_extension = True
    p.extra_subscription_months = 12
    p.organization_types = []
    p.product_dependencies = []
    p.visible = bool(
        code_prefix)  # only for legal entities other than mobicage
    p.legal_entity_id = legal_entity_id
    p.default_comment_translation_key = u'SUBX.default_comment'
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
    return p
Exemplo n.º 29
0
def create_otrm_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + 'OTRM')
    p.price = 19900
    p.default_count = 1
    p.default = False
    p.possible_counts = range(1, 50)
    p.is_subscription = False
    p.is_subscription_discount = False
    p.is_subscription_extension = False
    p.organization_types = []
    p.product_dependencies = []
    p.visible = bool(
        code_prefix)  # only for legal entities other than mobicage
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 30
0
def create_kkrt_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + Product.PRODUCT_CARDS)
    p.price = 1750
    p.default_count = 2
    p.default = False
    p.possible_counts = range(1, 6)
    p.is_subscription = False
    p.is_subscription_extension = False
    p.organization_types = []
    p.product_dependencies = []
    p.visible = bool(
        code_prefix)  # only for legal entities other than mobicage
    p.picture_url = "/static/images/solutions/flex/loyalty_cards.jpg"
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p
Exemplo n.º 31
0
def create_bnnr_product(legal_entity_id, code_prefix=''):
    p = Product(key_name=code_prefix + Product.PRODUCT_ROLLUP_BANNER)
    p.price = 10000
    p.default_count = 1
    p.default = False
    p.possible_counts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    p.is_subscription = False
    p.is_subscription_discount = False
    p.organization_types = [ServiceProfile.ORGANIZATION_TYPE_CITY]
    p.product_dependencies = []
    p.visible = bool(
        code_prefix)  # only for legal entities other than mobicage
    p.picture_url = "/static/images/solutions/flex/rollup_banner.jpg"
    p.legal_entity_id = legal_entity_id
    if code_prefix:
        p.description_translation_key = p.code[len(code_prefix
                                                   ):] + '.description'
        p.default_comment_translation_key = p.code[len(code_prefix
                                                       ):] + '.default_comment'
    return p