def arsiv_location_update(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') categori = CategoryItem.objects.get(pk=pk) category_item_form = AcategoriForm(request.POST or None, instance=categori) if request.method == 'POST': if category_item_form.is_valid(): category_item_form.save() return redirect('sbs:arsiv-konumEkle') categoryitem = CategoryItem.objects.filter(forWhichClazz='location') return render(request, 'arsiv/locationUpdate.html', {'category_item_form': category_item_form, 'categoryitem': categoryitem})
def arsiv_location_add(request): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') if request.method == 'POST': category_item_form = AcategoriForm(request.POST) if category_item_form.is_valid(): categori = category_item_form.save(commit=False) categori.forWhichClazz = "location" categori.save() category_item_form = AcategoriForm() categoryitem = CategoryItem.objects.filter(forWhichClazz='location') return render(request, 'arsiv/location.html', {'category_item_form': category_item_form, 'categoryitem': categoryitem})