예제 #1
0
def item_create_admin(request):
    category_form = AbstractFactory.upsert(request, CategoryAdminForm)
    item_form = AbstractFactory.upsert(request, ItemAdminForm)
    if item_form.is_valid():
        messages.success(request, _("You have create a new item"))
        return redirect('wishlist:item_list_admin')
    return render(request, 'wishlist/admin/item/form.html', {'form': item_form, 'category_form': category_form, 'action': _("Create")})
예제 #2
0
def item_clone_admin(request, item_id):
    item = get_object_or_404(Item, id=item_id)
    item_form = AbstractFactory.upsert(request, ItemAdminForm, item)
    category_form = AbstractFactory.upsert(request, CategoryAdminForm)
    if item_form.is_valid():
        messages.success(request, _("You have clone item : " + item.title))
        return redirect('wishlist:item_list_admin')

    return render(request, 'wishlist/admin/item/form.html', {'form': item_form, 'category_form': category_form, 'action': _("Clone")})
예제 #3
0
def item_update_admin(request, item_id):
    item = get_object_or_404(Item, id=item_id)
    item_form = AbstractFactory.upsert(request, ItemAdminForm, item)
    category_form = AbstractFactory.upsert(request, CategoryAdminForm)
    if item_form.is_valid():
        messages.success(request, _("You have update item : " + item.title))
        return redirect('wishlist:item_list_admin')

    historical_items = Item.history.filter(id=item_id).order_by('-history_id')
    return render(request, 'wishlist/admin/item/form.html', {'form': item_form, 'category_form': category_form, 'historical_items': historical_items, 'action': _("Update")})
예제 #4
0
def category_revert_admin(request, item_id, history_id):
    category = get_object_or_404(Category, id=item_id)
    historical_category = Category.history.get(history_id=history_id)
    category_form = AbstractFactory.upsert(request, CategoryAdminForm, category, historical_category)
    if category_form.is_valid():
        messages.success(request, _("You have revert category : " + category.title))
        return redirect('wishlist:category_list_admin')

    return render(request, 'wishlist/admin/item/form.html', {'form': category_form, 'action': _("Revert")})
예제 #5
0
def category_update_admin(request, category_id):
    category = get_object_or_404(Category, id=category_id)
    category_form = AbstractFactory.upsert(request, CategoryAdminForm, category)
    if category_form.is_valid():
        messages.success(request, _("You have update category : " + category.title))
        return redirect('wishlist:category_list_admin')

    historical_items = Category.history.filter(id=category_id).order_by('-history_id')
    return render(request, 'wishlist/admin/category/form.html', {'form': category_form, 'historical_items': historical_items, 'action': _("Update")})