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_total_unit(self):
t = 0
total = Course.objects.all()
for i in total:
t +=i
return i
def home(request):
"""
Shows our dashboard containing number of students, courses, lecturers, repating students,
carry over students and 1st class students in an interactive graph
"""
students = Student.objects.all().count()
staff = User.objects.filter(is_lecturer=True).count()
courses = Course.objects.all().count()
current_semester = Semester.objects.get(is_current_semester=True)
no_of_1st_class_students = Result.objects.filter(cgpa__gte=4.5).count()
no_of_carry_over_students = CarryOverStudent.objects.all().count()
no_of_students_to_repeat = RepeatingStudent.objects.all().count()
context = {
"no_of_students": students,
"no_of_staff":staff,
"no_of_courses": courses,
"no_of_1st_class_students": no_of_1st_class_students,
"no_of_students_to_repeat": no_of_students_to_repeat,
"no_of_carry_over_students": no_of_carry_over_students,
}
return render(request, 'result/home.html', context)
def course_list(request):
""" Show list of all registered courses in the system """
courses = Course.objects.all()
context = {
"courses":courses,
}
return render(request, 'course/course_list.html', context)
def carry_over(request):
if request.method == "POST":
value = ()
data = request.POST.copy()
data.pop('csrfmiddlewaretoken', None) # remove csrf_token
for val in data.values():
value += (val,)
course = value[0]
session = value[1]
courses = CarryOverStudent.objects.filter(course__courseCode=course, session=session)
all_courses = Course.objects.all()
sessions = Session.objects.all()
signal_template = True
context = {
"all_courses": all_courses,
"courses": courses,
"signal_template": signal_template,
"sessions":sessions
}
return render(request, 'course/carry_over.html', context)
else:
all_courses = Course.objects.all()
sessions = Session.objects.all()
return render(request, 'course/carry_over.html', { "all_courses": all_courses, "sessions":sessions })