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)
示例#2
0
 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'))
示例#3
0
    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})
示例#4
0
    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'))
示例#5
0
 def get(self, request):
     project_from = ProjectForm()
     return render(request, 'project.html', {"obj_form": project_from})