def task_assign(request, student_pk): marks = 0 marks_get = 0 supervised_info = Supervised.objects.get(pk=student_pk) student_info = get_object_or_404(Student, studentId=supervised_info.s_id) all_basic_info = ProjectPrimaryInfo.objects.filter(s_id=student_info) task_type = DocumentType.objects.all() all_assigned_task = Task.objects.filter(student=student_info) for task_marks in all_assigned_task: marks = task_marks.marks_allowed + marks marks_get = task_marks.marks_allocated + marks_get # if all_assigned_task.marks_allowed is True: # allowed = all_assigned_task.marks_allowed # marks = allowed + marks if request.method == 'POST': assigned_task = request.POST['task_type'] marks_allocated = request.POST['marks_allocated'] deadline = request.POST['deadline'] task_request_type = get_object_or_404( DocumentType, process_product_type=assigned_task) task_save_request = Task(task_name=task_request_type, student=student_info, marks_allocated=marks_allocated, deadline=deadline) task_save_request.save() return render( request, 'supervisor/task_assign.html', { 'supervised_info': supervised_info, 'student_info': student_info, 'task_type': task_type, 'all_basic_info': all_basic_info, 'all_assigned_task': all_assigned_task, 'marks': marks, 'marks_get': marks_get })
def post(self, request): # fields = ['name', 'desc', 'type', 'script', 'project'] name = self.request.POST.get("name") desc = self.request.POST.get("desc") type = self.request.POST.get("type") script = self.request.POST.get("script") project_id = self.request.POST.get("projectId") task = Task() task.name = name task.desc = desc task.type = type task.script = script task.project_id = project_id task.save() print((name, desc, type, script, project_id)) return HttpResponseRedirect("list?projectId=" + project_id)