Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get(self, request, hash):
from result.models import Result
ptask = get_object_or_404(ProcessTask, hash=hash)
if not (
request.user == ptask.process.executioner
or ptask.process.workflow.workflowpermission.public
):
raise Http404
users = ptask.users().values_list('id', flat=True)
results = Result.objects.filter(removed=False, processtaskuser__in=users).select_subclasses()
tasktype = ptask.task.subclass()
schema=None
if tasktype.type() == 'form.FormTask':
schema = tasktype.form.schema
context = {
'STATIC_URL': settings.STATIC_URL,
'processtask': ptask,
'schema' : schema,
'results': results,
'status': ProcessTask.statusCode(ptask.status)
}
def get(self, request, hash):
from result.models import Result
ptask = get_object_or_404(ProcessTask, hash=hash)
if not (
request.user == ptask.process.executioner
or ptask.process.workflow.workflowpermission.public
):
raise Http404
users = ptask.users().values_list('id', flat=True)
results = Result.objects.filter(removed=False, processtaskuser__in=users).select_subclasses()
tasktype = ptask.task.subclass()
schema=None
if tasktype.type() == 'form.FormTask':
schema = tasktype.form.schema
context = {
'STATIC_URL': settings.STATIC_URL,
'processtask': ptask,
'schema' : schema,
'results': results,
'status': ProcessTask.statusCode(ptask.status)
}
def calculate_cgpa(self):
current_semester = Semester.objects.get(is_current_semester=True)
previousResult = Result.objects.filter(student__id=self.student.id, level__lt=self.student.level)
previousCGPA = 0
for i in previousResult:
if i.cgpa is not None:
previousCGPA += i.cgpa
cgpa = 0
if str(current_semester) == SECOND:
try:
first_sem_gpa = Result.objects.get(student=self.student.id, semester=FIRST, level=self.student.level)
first_sem_gpa += first_sem_gpa.gpa.gpa
except:
first_sem_gpa = 0
try:
sec_sem_gpa = Result.objects.get(student=self.student.id, semester=SECOND, level=self.student.level)
sec_sem_gpa += sec_sem_gpa.gpa
except: