def new_blog_category(request): if request.method == 'POST': validate_blogcategory = BlogCategoryForm(request.POST) if validate_blogcategory.is_valid(): validate_blogcategory.save() data = {'error':False,'response':'Blog category created'} else: data = {'error':True,'response':validate_blogcategory.errors} return HttpResponse(json.dumps(data)) c = {} c.update(csrf(request)) return render_to_response('admin/blog/blog-category.html',{'csrf_token':c['csrf_token']})
def edit_category(request,category_slug): if request.method == 'POST': category = Category.objects.get(slug = category_slug) validate_blogcategory = BlogCategoryForm(request.POST,instance = category) if validate_blogcategory.is_valid(): validate_blogcategory.save() data = {'error':False,'response':'Blog category updated'} else: data = {'error':True,'response':validate_blogcategory.errors} return HttpResponse(json.dumps(data)) blog_category = Category.objects.get(slug=category_slug) c = {} c.update(csrf(request)) return render_to_response('admin/blog/blog-category-edit.html',{'blog_category':blog_category, 'csrf_token':c['csrf_token']})
def new_blog_category(request): if request.method == 'POST': validate_blogcategory = BlogCategoryForm(request.POST) if validate_blogcategory.is_valid(): validate_blogcategory.save() data = {'error': False, 'response': 'Blog category created'} else: data = {'error': True, 'response': validate_blogcategory.errors} return HttpResponse(json.dumps(data), content_type='application/json; charset=utf-8') if request.user.is_superuser: c = {} c.update(csrf(request)) return render(request, 'admin/blog/blog-category.html', {'csrf_token': c['csrf_token']}) else: return render_to_response('admin/accessdenied.html')
def new_blog_category(request): if request.method == "POST": validate_blogcategory = BlogCategoryForm(request.POST) if validate_blogcategory.is_valid(): validate_blogcategory.save() data = {"error": False, "response": "Blog category created"} else: data = {"error": True, "response": validate_blogcategory.errors} return HttpResponse(json.dumps(data), content_type="application/json; charset=utf-8") if request.user.is_superuser: c = {} c.update(csrf(request)) return render(request, "admin/blog/blog-category.html", {"csrf_token": c["csrf_token"]}) else: return render_to_response("admin/accessdenied.html")
def edit_category(request, category_slug): blog_category = get_object_or_404(Category, slug=category_slug) if request.method == 'POST': validate_blogcategory = BlogCategoryForm(request.POST, instance=blog_category) if validate_blogcategory.is_valid(): validate_blogcategory.save() data = {'error': False, 'response': 'Blog category updated'} else: data = {'error': True, 'response': validate_blogcategory.errors} return HttpResponse(json.dumps(data), content_type='application/json; charset=utf-8') if request.user.is_superuser: c = {} c.update(csrf(request)) return render(request, 'admin/blog/blog-category-edit.html', {'blog_category': blog_category, 'csrf_token': c['csrf_token']}) else: return render_to_response('admin/accessdenied.html')
def new_blog_category(request): if request.method == 'POST': validate_blogcategory = BlogCategoryForm(request.POST) if validate_blogcategory.is_valid(): validate_blogcategory.save() cache._cache.flush_all() data = {'error': False, 'response': 'Blog category created'} else: data = {'error': True, 'response': validate_blogcategory.errors} return HttpResponse(json.dumps(data), content_type='application/json; charset=utf-8') if request.user.is_superuser: c = {} c.update(csrf(request)) return render(request, 'admin/blog/blog-category.html', {'csrf_token': c['csrf_token']}) else: return render_to_response('admin/accessdenied.html')
def edit_category(request, category_slug): blog_category = get_object_or_404(Category, slug=category_slug) if request.method == 'POST': validate_blogcategory = BlogCategoryForm( request.POST, instance=blog_category) if validate_blogcategory.is_valid(): validate_blogcategory.save() cache._cache.flush_all() data = {'error': False, 'response': 'Blog category updated'} else: data = {'error': True, 'response': validate_blogcategory.errors} return HttpResponse(json.dumps(data), content_type='application/json; charset=utf-8') if request.user.is_superuser: c = {} c.update(csrf(request)) return render(request, 'admin/blog/blog-category-edit.html', {'blog_category': blog_category, 'csrf_token': c['csrf_token']}) else: return render_to_response('admin/accessdenied.html')
def edit_category(request, category_slug): blog_category = get_object_or_404(Category, slug=category_slug) if request.method == "POST": validate_blogcategory = BlogCategoryForm(request.POST, instance=blog_category) if validate_blogcategory.is_valid(): validate_blogcategory.save() data = {"error": False, "response": "Blog category updated"} else: data = {"error": True, "response": validate_blogcategory.errors} return HttpResponse(json.dumps(data), content_type="application/json; charset=utf-8") if request.user.is_superuser: c = {} c.update(csrf(request)) return render( request, "admin/blog/blog-category-edit.html", {"blog_category": blog_category, "csrf_token": c["csrf_token"]}, ) else: return render_to_response("admin/accessdenied.html")