def get(self, request, *args, **kwargs): return JsonResponse( { 'task_queue_choice_form': TaskQueueChoiceForm().as_p(), 'task_queue_create_form': TaskQueueForm().as_p(), 'project_choice_form': ProjectChoiceForm().as_p(), 'project_create_form': ProjectForm().as_p() }, encoder=DjangoJSONEncoder, safe=False)
def post(self, request, id): project_form = ProjectForm(request.POST) if project_form.is_valid(): project = Project.objects.get(id=id) project.name = request.POST['name'] project.type = request.POST['type'] project.detail = request.POST['detail'] project.creator = UserProfile.objects.get(username=request.user) project.save() return HttpResponseRedirect(reverse('project_list'))
def get(self, request, id): project = Project.objects.get(id=id) user = UserProfile.objects.get(username=project.creator) project_form = ProjectForm({ 'name': project.name, 'type': project.type, 'creator': user.username, 'detail': project.detail }) return render(request, 'project_edit.html', {'obj_form': project_form})
def post(self, request): project_form = ProjectForm(request.POST) if project_form.is_valid(): name = request.POST['name'] type = request.POST['type'] detail = request.POST['detail'] creator = UserProfile.objects.get(username=request.user) project = Project(name=name, type=type, detail=detail, creator=creator) project.save() else: return render(request, 'project_add.html', {'error': project_form.errors}) return HttpResponseRedirect(reverse('project_list'))
def get(self, request): project_from = ProjectForm() return render(request, 'project.html', {"obj_form": project_from})