How to use the result.decorators.lecturer_required function in result

To help you get started, we’ve selected a few result examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Abdoulrasheed / django-school-management / result / views.py View on Github external
@lecturer_required 
def add_score(request):
    """ 
    Shows a page where a lecturer will select a course allocated to him for score entry.
    in a specific semester and session 

    """
    current_session = Session.objects.get(is_current_session=True)
    current_semester = get_object_or_404(Semester, is_current_semester=True, session=current_session)
    semester = Course.objects.filter(allocated_course__lecturer__pk=request.user.id, semester=current_semester)
    courses = Course.objects.filter(allocated_course__lecturer__pk=request.user.id).filter(semester=current_semester)
    context = {
    "courses": courses,
    }
    return render(request, 'result/add_score.html', context)
github Abdoulrasheed / django-school-management / result / views.py View on Github external
@lecturer_required
def delete_staff(request, pk):
    staff = get_object_or_404(User, pk=pk)
    staff.delete()
    return redirect('staff_list')
github Abdoulrasheed / django-school-management / result / views.py View on Github external
@lecturer_required
def delete_student(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.delete()
    return redirect('student_list')
github Abdoulrasheed / django-school-management / result / views.py View on Github external
@lecturer_required 
def add_score_for(request, id):
    """ 
    Shows a page where a lecturer will add score for studens that are taking courses allocated to him
    in a specific semester and session 
    """
    current_semester = Semester.objects.get(is_current_semester=True)
    if request.method == 'GET':
        courses = Course.objects.filter(allocated_course__lecturer__pk=request.user.id).filter(semester=current_semester)
        course = Course.objects.get(pk=id)
        students = TakenCourse.objects.filter(course__allocated_course__lecturer__pk=request.user.id).filter(course__id=id).filter(course__semester=current_semester)
        context = {
        "courses":courses, 
        "course": course, 
        "students":students,
        }
        return render(request, 'result/add_score_for.html', context)
github Abdoulrasheed / django-school-management / result / views.py View on Github external
@lecturer_required
def semester_delete_view(request, pk):
    semester = get_object_or_404(Semester, pk=pk)
    if semester.is_current_semester == True:
    	messages.info(request, "You cannot delete current semester")
    	return redirect('manage_semester')
    else:
    	semester.delete()
    	messages.success(request, "Semester successfully deleted")
    return redirect('manage_semester')
github Abdoulrasheed / django-school-management / result / views.py View on Github external
@lecturer_required
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)
github Abdoulrasheed / django-school-management / result / views.py View on Github external
@lecturer_required
def course_allocation_view(request):
    allocated_courses = CourseAllocation.objects.all()
    return render(request, 'course/course_allocation_view.html', {"allocated_courses": allocated_courses})
github Abdoulrasheed / django-school-management / result / views.py View on Github external
@lecturer_required
def student_list(request):
    """ Show list of all registered students in the system """
    students = Student.objects.all()
    user_type = "Student"
    context = {
        "students": students, 
        "user_type": user_type,
        }
    return render(request, 'students/student_list.html', context)
github Abdoulrasheed / django-school-management / result / views.py View on Github external
@lecturer_required
def delete_course(request, pk):
    course = get_object_or_404(Course, pk=pk)
    course.delete()
    messages.success(request, 'Deleted successfully!')
    return redirect('course_list')
github Abdoulrasheed / django-school-management / result / views.py View on Github external
@lecturer_required
def edit_student(request, pk):
	student = get_object_or_404(Student, pk=pk)
	if request.method == "POST":
		form = StudentAddForm(request.POST, instance=student)
		if form.is_valid():
			form.save()
			return redirect('student_list')
	else:
		form = StudentAddForm(instance=student)
	return render(request, 'registration/edit_student.html', {'form': form})