Exemplo n.º 1
0
 def add_category(cls, request):
     if request.method == 'POST':
         form = CategoryForm(request.POST)
         if form.is_valid():
             name = request.POST['name']
             new_category = Category(name=name)
             new_category.save()
             return HttpResponseRedirect("/manager/kategorie/")
     else:
         form = CategoryForm()
     return render_to_response('backpanel_new_category.html', 
                               {'form': form}, 
                               context_instance=RequestContext(request))
Exemplo n.º 2
0
 def add_category(cls, request):
     if request.method == 'POST':
         form = CategoryForm(request.POST)
         if form.is_valid():
             name = request.POST['name']
             new_category = Category(name=name)
             new_category.save()
             return HttpResponseRedirect("/manager/kategorie/")
     else:
         form = CategoryForm()
     return render_to_response('backpanel_new_category.html',
                               {'form': form},
                               context_instance=RequestContext(request))
Exemplo n.º 3
0
 def edit_category(cls, request, id):
     if request.method == 'POST':
         form = CategoryForm(request.POST)
         if form.is_valid():
             name = request.POST['name']
             category = Category.objects.get(pk=id)
             category.name=name
             category.save()
             return HttpResponseRedirect("/manager/kategorie/")
     else:
         category=Category.objects.get(pk=id)
         category_name=category.name
         form = CategoryForm(initial={"name":category_name})
     return render_to_response('backpanel_new_category.html', 
                               {'form': form, 'category_name': category_name}, 
                               context_instance=RequestContext(request))        
Exemplo n.º 4
0
 def edit_category(cls, request, id):
     if request.method == 'POST':
         form = CategoryForm(request.POST)
         if form.is_valid():
             name = request.POST['name']
             category = Category.objects.get(pk=id)
             category.name = name
             category.save()
             return HttpResponseRedirect("/manager/kategorie/")
     else:
         category = Category.objects.get(pk=id)
         category_name = category.name
         form = CategoryForm(initial={"name": category_name})
     return render_to_response('backpanel_new_category.html', {
         'form': form,
         'category_name': category_name
     },
                               context_instance=RequestContext(request))