Exemplo n.º 1
0
def students(request):

    profile = UserProfile.get_profile_by_user_id(request.user.id)

    students_info = []

    if profile.type == 'a' or request.user.is_superuser:
        students_info = UserProfile.objects.filter(type='s')

    return render(request, 'students.html', {
        'students': students_info,
        'profile': profile
    })
Exemplo n.º 2
0
def currentPlan(request):
    year = int(datetime.datetime.now().year)
    month = int(datetime.datetime.now().month)
    user_profile = UserProfile.get_profile_by_user(request.user)
    plan=None
    try:
        if month < 8:
            plan = TeacherPlan.objects.get(person_profile = user_profile, start_date = (year - 1))[0]
        else :
            plan = TeacherPlan.objects.get(person_profile = user_profile, start_date = year)[0]
    except :
        return HttpResponseRedirect('/teacherPlan/plan/add/')
    return render(request, 'teacherPlan/plan.html',{'plan':plan,'user_profile':user_profile})
Exemplo n.º 3
0
def login_teacher_required(function=None,
                           redirect_field_name=REDIRECT_FIELD_NAME,
                           login_url=None):
    """
  Decorator for views that checks that the user is logged in, redirecting
  to the log-in page if necessary.
  """

    actual_decorator = user_passes_test(
        lambda u: u.is_authenticated() and
        (UserProfile.check_teacher(u) or u.is_superuser),
        login_url=login_url,
        redirect_field_name=redirect_field_name)
    if function:
        return actual_decorator(function)
    return actual_decorator
Exemplo n.º 4
0
def group_list(request):

    profile = UserProfile.get_profile_by_user_id(request.user.id)

    group_list_info = []

    if profile.type == 'a' or profile.type == 't' or request.user.is_superuser:
        group_list_info = GroupListHelper.get_all_group_lists()

    if profile.type == 'h' or profile.type == 's':
        group_list_info = GroupListHelper.get_this_group_list(
            profile.study_group)

    return render(request, 'group-list.html', {
        'grouplist': group_list_info,
        'profile': profile
    })
Exemplo n.º 5
0
def term_projects(request):

    profile = UserProfile.get_profile_by_user_id(request.user.id)

    term_projects_info = []

    if profile.type == 'a' or profile.type == 't' or request.user.is_superuser:
        term_projects_info = TermProjectsHelper.get_all_term_projects()

    if profile.type == 'h' or profile.type == 's':
        term_projects_info = TermProjectsHelper.get_group_term_projects(
            profile.study_group)

    return render(request, 'term-projects.html', {
        'projectlist': term_projects_info,
        'profile': profile
    })
Exemplo n.º 6
0
def grades(request):

    profile = UserProfile.get_profile_by_user_id(request.user.id)

    grades_info = []

    if profile.type == 'a' or profile.type == 't' or request.user.is_superuser:
        grades_info = GradesHelper.get_all_grades()

    if profile.type == 'h':
        grades_info = GradesHelper.get_grades_by_group(profile.study_group)

    if profile.type == 's':
        grades_info = GradesHelper.get_grades_by_student(profile.id)

    return render(request, 'grades.html', {
        'grades': grades_info,
        'profile': profile
    })
Exemplo n.º 7
0
def attendance(request):

    profile = UserProfile.get_profile_by_user_id(request.user.id)

    attendance_info = []

    if profile.type == 'a' or profile.type == 't' or request.user.is_superuser:
        attendance_info = AttendanceHelper.get_all_attendance()

    if profile.type == 's':
        attendance_info = AttendanceHelper.get_attendance_by_student(
            profile.id)

    if profile.type == 'h':
        attendance_info = AttendanceHelper.get_attendance_by_group(
            profile.study_group)

    return render(request, 'attendance.html', {
        'attendance': attendance_info,
        'profile': profile
    })
Exemplo n.º 8
0
def listOfPlans(request):
    up = UserProfile.get_profile_by_user(request.user)
    list = TeacherPlan.objects.all().filter(person_profile=up)
    return render(request, 'teacherPlan/plan_list.html',{'list':list})
Exemplo n.º 9
0
def makeNewPlan(request):
    user_profile = UserProfile.get_profile_by_user(request.user)
    form = MakeTeacherPlanFrom()
    if request.method == 'POST':
        form = MakeTeacherPlanFrom(request.POST)
        if form.is_valid():
            election_date = datetime.datetime(
                int(request.POST['election_date_year']),
                int(request.POST['election_date_month']),
                int(request.POST['election_date_day'])
            )
            contract_date = datetime.datetime(
                int(request.POST['contract_date_year']),
                int(request.POST['contract_date_month']),
                int(request.POST['contract_date_day'])
            )
            plan = TeacherPlan.objects.create(
                person_profile=user_profile,
                start_date=int(request.POST["start_date"]),
                first_name=request.POST["first_name"],
                last_name=request.POST["last_name"],
                patronymic=request.POST["patronymic"],
                department_name=request.POST["department_name"],
                organisation_name=request.POST["organisation_name"],
                department_head=request.POST["department_head"],
                organisation_head=request.POST["organisation_head"],
                election_date=election_date,
                position=request.POST["position"],
                contract_date=contract_date,
                academic_degree=request.POST["academic_degree"],
                year_of_academic_degree=request.POST["year_of_academic_degree"],
                academic_status=request.POST["academic_status"],
                year_of_academic_status=request.POST["year_of_academic_status"],
                rate=str(request.POST["rate"]),
            )
            return HttpResponseRedirect('/teacherPlan/plan/' + plan.id)

    form.fields["start_date"].initial = str(datetime.datetime.now().year)
    if user_profile.first_name == None : user_profile.first_name=""
    form.fields["first_name"].initial =unicode(user_profile.first_name)
    if user_profile.last_name == None: user_profile.last_name = ""
    form.fields["last_name"].initial = unicode(user_profile.last_name)
    if user_profile.patronymic == None: user_profile.patronymic = ""
    form.fields["patronymic"].initial = unicode(user_profile.patronymic)

    if user_profile.position == None: user_profile.position = ""
    form.fields["position"].initial = unicode(user_profile.position)
    if user_profile.election_date == None: user_profile.election_date = ""
    form.fields["election_date"].initial = unicode(user_profile.election_date)
    if user_profile.academic_degree == None: user_profile.academic_degree = ""
    form.fields["academic_degree"].initial = unicode(user_profile.academic_degree)

    if user_profile.year_of_academic_degree == None: user_profile.year_of_academic_degree = 2000
    form.fields["year_of_academic_degree"].initial = unicode(user_profile.year_of_academic_degree)
    if user_profile.academic_status == None: user_profile.academic_status = ""
    form.fields["academic_status"].initial = unicode(user_profile.academic_status)
    if user_profile.year_of_academic_status == None: user_profile.year_of_academic_status = 2000
    form.fields["year_of_academic_status"].initial = unicode(user_profile.year_of_academic_status)
    if user_profile.rate == None: user_profile.rate = "1"
    form.fields["rate"].initial = unicode(user_profile.rate)

    departmentInfo = TeacherSettings.get()
    form.fields["department_name"].initial = departmentInfo.department_name
    form.fields["organisation_name"].initial = departmentInfo.organisation_name
    form.fields["department_head"].initial = departmentInfo.department_head
    form.fields["organisation_head"].initial = departmentInfo.organisation_head

    return render(request, 'teacherPlan/forms/make_plan.html', {
        'form': form,
        'user_profile':user_profile.id,
    })