コード例 #1
0
ファイル: shop.py プロジェクト: vovkd/django-lfs
def save_order_numbers_tab(request):
    """Saves the order number tab of the default shop.
    """
    shop = lfs.core.utils.get_default_shop()

    ong = import_symbol(settings.LFS_ORDER_NUMBER_GENERATOR)
    order_number = ong.objects.get(id="order_number")
    form = order_number.get_form(instance=order_number, data=request.POST)

    if form.is_valid():
        form.save()
        shop_changed.send(shop)
        message = _(u"Order numbers has been saved.")
    else:
        message = _(u"Please correct the indicated errors.")

    result = simplejson.dumps(
        {
            "html":
            [["#order_numbers",
              order_numbers_tab(request, shop, form)]],
            "message": message,
        },
        cls=LazyEncoder)

    return HttpResponse(result)
コード例 #2
0
ファイル: shop.py プロジェクト: diefenbach/django-lfs
def save_data_tab(request):
    """Saves the data tab of the default shop.
    """
    shop = lfs.core.utils.get_default_shop()

    form = ShopDataForm(instance=shop, data=request.POST, files=request.FILES)
    if form.is_valid():
        form.save()

        # Delete image
        if request.POST.get("delete_image"):
            shop.image.delete()

        # reinitialize form in order to properly display uploaded image
        form = ShopDataForm(instance=shop)
        shop_changed.send(shop)
        message = _(u"Shop data has been saved.")
    else:
        message = _(u"Please correct the indicated errors.")

    result = json.dumps({
        "html": [["#data", data_tab(request, shop, form)]],
        "message": message,
    }, cls=LazyEncoder)

    return HttpResponse(result, content_type='application/json')
コード例 #3
0
ファイル: shop.py プロジェクト: vovkd/django-lfs
def save_data_tab(request):
    """Saves the data tab of the default shop.
    """
    shop = lfs.core.utils.get_default_shop()

    form = ShopDataForm(instance=shop, data=request.POST, files=request.FILES)
    if form.is_valid():
        form.save()

        # Delete image
        if request.POST.get("delete_image"):
            shop.image.delete()

        # reinitialize form in order to properly display uploaded image
        form = ShopDataForm(instance=shop)
        shop_changed.send(shop)
        message = _(u"Shop data has been saved.")
    else:
        message = _(u"Please correct the indicated errors.")

    result = simplejson.dumps(
        {
            "html": [["#data", data_tab(request, shop, form)]],
            "message": message,
        },
        cls=LazyEncoder)

    return HttpResponse(result)
コード例 #4
0
ファイル: shop.py プロジェクト: ranjithtenz/django-lfs
def save_default_values_tab(request):
    """Saves the default value part
    """
    shop = lfs_get_object_or_404(Shop, pk=1)
    form = ShopDefaultValuesForm(instance=shop, data=request.POST)

    if form.is_valid():
        shop = form.save()
        shop_changed.send(shop)
        message = _(u"Shop default values have been saved.")
    else:
        message = _(u"Please correct the indicated errors.")

    result = simplejson.dumps(
        {"html": [["#default_values", default_values_tab(request, shop, form)]], "message": message}, cls=LazyEncoder
    )

    return HttpResponse(result)
コード例 #5
0
ファイル: shop.py プロジェクト: cocox/django-lfs
def save_seo_tab(request):
    """Saves the seo tab of the default shop.
    """
    shop = lfs.core.utils.get_default_shop()

    form = ShopSEOForm(instance=shop, data=request.POST)
    if form.is_valid():
        form.save()
        shop_changed.send(shop)
        message = _(u"Shop SEO data has been saved.")
    else:
        message = _(u"Please correct the indicated errors.")

    result = simplejson.dumps({
        "html": [["#seo", seo_tab(request, shop, form)]],
        "message": message,
    }, cls=LazyEncoder)

    return HttpResponse(result)
コード例 #6
0
def save_default_values_tab(request):
    """Saves the default value part
    """
    shop = lfs_get_object_or_404(Shop, pk=1)
    form = ShopDefaultValuesForm(instance=shop, data=request.POST)

    if form.is_valid():
        shop = form.save()
        shop_changed.send(shop)
        message = _(u"Shop default values have been saved.")
    else:
        message = _(u"Please correct the indicated errors.")

    result = simplejson.dumps({
        "html": [["#default_values", default_values_tab(request, shop, form)]],
        "message": message
    }, cls=LazyEncoder)

    return HttpResponse(result, mimetype='application/json')
コード例 #7
0
def save_seo_tab(request):
    """Saves the seo tab of the default shop.
    """
    shop = lfs.core.utils.get_default_shop()

    form = ShopSEOForm(instance=shop, data=request.POST)
    if form.is_valid():
        form.save()
        shop_changed.send(shop)
        message = _(u"Shop SEO data has been saved.")
    else:
        message = _(u"Please correct the indicated errors.")

    result = simplejson.dumps({
        "html": [["#seo", seo_tab(request, shop, form)]],
        "message": message,
    }, cls=LazyEncoder)

    return HttpResponse(result)
コード例 #8
0
ファイル: shop.py プロジェクト: ranjithtenz/django-lfs
def save_order_numbers_tab(request):
    """Saves the order number tab of the default shop.
    """
    shop = lfs.core.utils.get_default_shop()

    ong = import_symbol(settings.LFS_ORDER_NUMBER_GENERATOR)
    order_number = ong.objects.get(id="order_number")
    form = order_number.get_form(instance=order_number, data=request.POST)

    if form.is_valid():
        form.save()
        shop_changed.send(shop)
        message = _(u"Order numbers has been saved.")
    else:
        message = _(u"Please correct the indicated errors.")

    result = simplejson.dumps(
        {"html": [["#order_numbers", order_numbers_tab(request, shop, form)]], "message": message}, cls=LazyEncoder
    )

    return HttpResponse(result)
コード例 #9
0
def save_order_numbers_tab(request):
    """Saves the order number tab of the default shop.
    """
    shop = lfs.core.utils.get_default_shop()

    order_number = MODELS.OrderNumberGenerator.objects.get(id="order_number")
    form = FORMS.OrderNumberGeneratorForm(instance=order_number, data=request.POST)

    if form.is_valid():
        form.save()
        shop_changed.send(shop)
        message = _(u"Order numbers has been saved.")
    else:
        message = _(u"Please correct the indicated errors.")

    result = simplejson.dumps({
        "html": [["#order_numbers", order_numbers_tab(request, shop, form)]],
        "message": message,
    }, cls=LazyEncoder)

    return HttpResponse(result)
コード例 #10
0
ファイル: shop.py プロジェクト: vovkd/django-lfs
 def form_valid(self, form):
     res = super(ShopSEOView, self).form_valid(form)
     shop_changed.send(form.instance)
     return res
コード例 #11
0
ファイル: shop.py プロジェクト: diefenbach/django-lfs
 def form_valid(self, form):
     res = super(ShopSEOView, self).form_valid(form)
     shop_changed.send(form.instance)
     return res