Example #1
0
def name_attendance_sunday_school(request):

    if not request.user.is_authenticated:
        return redirect('config:login')
    if request.user.username != 'admin':
        return HttpResponse('Unauthorized', status=401)

    err, student = '', ''
    full_name = request.POST['full_name']
    student_names = StudentSelector().get_all_student_names()

    try:
        student = StudentSelector.get_student_by_full_name(full_name)
        AttendanceService().add_attendance_by_student(student,
                                                      for_sunday_school=True)
    except ObjectDoesNotExist:
        err = 'Name does not exist.'
    except IntegrityError:
        err = f'{str(student)} has already been recorded.'

    context = {
        'err':
        err,
        'student_names':
        student_names,
        'attendance_count':
        AttendanceSelector.get_attendance_count_by_day(for_sunday_school=True),
    }
    return render(request, 'attendance/sunday_school.html', context)
Example #2
0
    def test_new_alumni_no_longer_student(self):
        student_count = StudentSelector.get_all_student_count()
        alumni_count = AlumniSelector.get_all_alumni_count()

        AlumniService().student_to_alumni(student=self.student)

        new_student_count = StudentSelector.get_all_student_count()
        new_alumni_count = AlumniSelector.get_all_alumni_count()

        self.assertEqual(student_count, new_student_count + 1)
        self.assertEqual(alumni_count + 1, new_alumni_count)
Example #3
0
def card_attendance_summer_club(request):

    if not request.user.is_authenticated:
        return redirect('config:login')
    if request.user.username != 'admin':
        return HttpResponse('Unauthorized', status=401)

    err, card = '', ''
    card_number = request.POST['card_number']
    student_names = StudentSelector().get_all_student_names()

    try:
        card = CardSelector().get_card_by_number(card_number)
        AttendanceService().add_attendance_by_card(card=card)
    except ObjectDoesNotExist:
        err = 'Card does not exist.'
    except IntegrityError:
        err = f'{str(card.holder)} has already been recorded.'

    context = {
        'err': err,
        'student_names': student_names,
        'attendance_count': AttendanceSelector.get_attendance_count_by_day(),
    }
    return render(request, 'attendance/summer_club.html', context)
Example #4
0
    def get_unattended_students_by_day(day: datetime.date) -> set:
        attendence_objs = Attendance.objects.filter(
            day=day).select_related('student')
        attended_students = {
            attendance.student
            for attendance in attendence_objs
        }

        return StudentSelector.get_all_students() - attended_students
Example #5
0
 def test_adding_user_with_birth_day_less_than_12_years_returns_validation_error(
         self):
     user_count = StudentSelector.get_all_student_count()
     with self.assertRaisesMessage(ValidationError,
                                   'Year cannot be less than 12 years.'):
         date = str(datetime.date.today() - relativedelta(years=11))
         StudentService().create_student(first_name='Mark',
                                         middle_name='Smithy',
                                         last_name='Smith',
                                         birth_day=date,
                                         phone=12345678,
                                         grade=9,
                                         school='asdavfs',
                                         mothers_number=113123,
                                         fathers_number=123123,
                                         father_of_confession='Father',
                                         servant=self.servant,
                                         residency_area='Prague')
     new_user_count = StudentSelector.get_all_student_count()
     self.assertEqual(user_count, new_user_count)
Example #6
0
def summer_club(request):

    if not request.user.is_authenticated:
        return redirect('config:login')
    if request.user.username != 'admin':
        return HttpResponse('Unauthorized', status=401)

    context = {
        'title': "Summer Club",
        'student_names': StudentSelector().get_all_student_names(),
        'attendance_count': AttendanceSelector.get_attendance_count_by_day(),
    }
    return render(request, 'attendance/summer_club.html', context)
Example #7
0
def bible_study(request):

    if not request.user.is_authenticated:
        return redirect('config:login')
    if request.user.username != 'admin':
        return HttpResponse('Unauthorized', status=401)

    context = {
        'title':
        "Bible Study",
        'student_names':
        StudentSelector().get_all_student_names(),
        'attendance_count':
        AttendanceSelector.get_attendance_count_by_day(for_bible_study=True),
    }
    return render(request, 'attendance/bible_study.html', context)
Example #8
0
import sys
from attendance.selectors.day import DaySelector, Day
from attendance.selectors.attendance import AttendanceSelector
from attendance.services import MultiplierService
from config.selectors.student import StudentSelector

yesterday: Day = DaySelector.get_yesterday_or_none()
if not yesterday:
    sys.exit(1)

all_students = StudentSelector.get_all_student_count()
unattended_students = AttendanceSelector.get_unattended_students_by_day(
    yesterday)
attended_students = all_students - unattended_students

report = f'''{yesterday.date} - {yesterday.get_service()}: Attendance Report

Unattended students : {len(unattended_students)}
Total students      : {len(all_students)}
% Attendance        : {(attended_students/all_students) * 100}%   

'''


def get_multiplier(student, day):
    multiplier = MultiplierService.get_or_create_multiplier(student)
    if day.for_sunday_school:
        return multiplier.sunday_school
    elif day.for_bible_study:
        return multiplier.bible_study
    return multiplier.summer_club