Esempio n. 1
0
def save_group_modifier_item(form, venue):
    if form.cleaned_data['group_modifier_item_id']:
        modifier = GroupModifierItem.objects.get(id=form.cleaned_data['group_modifier_item_id'])
        modifier.name = form.cleaned_data['name']
        if form.cleaned_data['image']:
            modifier.image_url = upload_image(form.cleaned_data['image'])
        modifier.save()
    else:
        modifier = GroupModifierItem(name=form.cleaned_data['name'], min_price=form.cleaned_data['min_price'])
        modifier.group_modifier = GroupModifier.objects.get(id=form.cleaned_data['group_modifier_id'])
        modifier.save()
        if form.cleaned_data['image']:
            modifier.image_url = upload_image(form.cleaned_data['image'])
            modifier.save()
Esempio n. 2
0
def save_group_modifier(form, venue):
    if form.cleaned_data['group_modifier_id']:
        modifier = GroupModifier.objects.get(id=form.cleaned_data['group_modifier_id'])
        modifier.name = form.cleaned_data['name']
        if form.cleaned_data['image']:
            modifier.image_url = upload_image(form.cleaned_data['image'])
        modifier.save()
    else:
        modifier = GroupModifier(name=form.cleaned_data['name'])
        modifier.save()
        if form.cleaned_data['image']:
            modifier.image_url = upload_image(form.cleaned_data['image'])
            modifier.save()
        modifier.save_in_venues(venue)
Esempio n. 3
0
def save_single_modifier(form, venue):
    if form.cleaned_data['single_modifier_id']:
        modifier = SingleModifier.objects.get(id=form.cleaned_data['single_modifier_id'])
        modifier.name = form.cleaned_data['name']
        if form.cleaned_data['image']:
            modifier.image_url = upload_image(form.cleaned_data['image'])
        modifier.save()
    else:
        modifier = SingleModifier(name=form.cleaned_data['name'], min_price=form.cleaned_data['min_price'])
        modifier.save()
        if form.cleaned_data['image']:
            modifier.image_url = upload_image(form.cleaned_data['image'])
            modifier.save()
        modifier.save_in_venues(venue)
Esempio n. 4
0
def save_category(form, venue):
    if form.cleaned_data['category_id']:
        category = Category.objects.get(id=form.cleaned_data['category_id'])
        category.name = form.cleaned_data['name']
        category.description = form.cleaned_data['description']
        if form.cleaned_data['image']:
            category.image_url = upload_image(form.cleaned_data['image'])
        category.save()
    else:
        category = Category(name=form.cleaned_data['name'], description=form.cleaned_data['description'],
                            parent=Category.objects.get(id=form.cleaned_data['parent_category_id']))
        category.save()
        if form.cleaned_data['image']:
            category.image_url = upload_image(form.cleaned_data['image'])
        category.save()
    category.get_first_category().save()
Esempio n. 5
0
def save_product(form, venue):
    if form.cleaned_data['product_id']:
        product = Product.objects.get(id=form.cleaned_data['product_id'])
        product.name = form.cleaned_data['name']
        product.description = form.cleaned_data['description']
        if form.cleaned_data['image']:
            product.image_url = upload_image(form.cleaned_data['image'])
        product.save()
    else:
        product = Product(name=form.cleaned_data['name'], description=form.cleaned_data['description'],
                          min_price=form.cleaned_data['min_price'],
                          category=Category.objects.get(id=form.cleaned_data['category_id']))
        product.save()
        if form.cleaned_data['image']:
            product.image_url = upload_image(form.cleaned_data['image'])
            product.save()
        product.save_in_venues(venue)
    product.category.get_first_category().save()
 def create(cls, company_name, user, image):
     company = cls(chief_username=user.username, name=company_name)
     company.image_url = upload_image(image)
     company.save()
     return company