FusionIIIT/applications/hostel_management/views.py
def edit_attendance(request):
    """
    This function is used to edit the attendance of a student.
    @param:
      request - HttpRequest object containing metadata about the user request.
    
    @variables:
      student_id = The student whose attendance has to be updated.
      hall = The hall of the concerned student.
      date = The date on which attendance has to be marked.
    """
    if request.method == "POST":
        roll_no = request.POST["roll_no"]
        
        student = Student.objects.get(id=roll_no)
        hall = Hall.objects.get(hall_id='hall'+str(student.hall_no))
        date = datetime.datetime.today().strftime('%Y-%m-%d')

        if HostelStudentAttendence.objects.filter(student_id=student,date=date).exists() == True:
            messages.error(request, f'{student.id.id} is already marked present on {date}')
            return HttpResponseRedirect(reverse("hostelmanagement:hostel_view"))

        record = HostelStudentAttendence.objects.create(student_id=student, \
            hall=hall, date=date, present=True)
        record.save()

        messages.success(request, f'Attendance of {student.id.id} recorded.')

        return HttpResponseRedirect(reverse("hostelmanagement:hostel_view"))

    This function is used to edit the attendance of a student.
    @param:
      request - HttpRequest object containing metadata about the user request.
    
    @variables:
      student_id = The student whose attendance has to be updated.
      hall = The hall of the concerned student.
      date = The date on which attendance has to be marked.
    
This function is used to edit the attendance of a student.
@param:
request - HttpRequest object containing metadata about the user request.

@variables:
student_id = The student whose attendance has to be updated.
hall = The hall of the concerned student.
date = The date on which attendance has to be marked.
This function is used to edit the attendance of a student . @param : request - HttpRequest object containing metadata about the user request . @variables : student_id = The student whose attendance has to be updated . hall = The hall of the concerned student . date = The date on which attendance has to be marked .
def edit_attendance(request):
    if request.method == "POST":
        roll_no = request.POST["roll_no"]
        student = Student.objects.get(id=roll_no)
        hall = Hall.objects.get(hall_id='hall'+str(student.hall_no))
        date = datetime.datetime.today().strftime('%Y-%m-%d')
        if HostelStudentAttendence.objects.filter(student_id=student,date=date).exists() == True:
            messages.error(request, f'{student.id.id} is already marked present on {date}')
            return HttpResponseRedirect(reverse("hostelmanagement:hostel_view"))
        record = HostelStudentAttendence.objects.create(student_id=student, \
            hall=hall, date=date, present=True)
        record.save()
        messages.success(request, f'Attendance of {student.id.id} recorded.')
        return HttpResponseRedirect(reverse("hostelmanagement:hostel_view"))
def edit_attendance ( request ) : if request . method == "POST" : roll_no = request . POST [ "roll_no" ] student = Student . objects . get ( id = roll_no ) hall = Hall . objects . get ( hall_id = 'hall' + str ( student . hall_no ) ) date = datetime . datetime . today ( ) . strftime ( '%Y-%m-%d' ) if HostelStudentAttendence . objects . filter ( student_id = student , date = date ) . exists ( ) == True : messages . error ( request , f'{student.id.id} is already marked present on {date}' ) return HttpResponseRedirect ( reverse ( "hostelmanagement:hostel_view" ) ) record = HostelStudentAttendence . objects . create ( student_id = student , hall = hall , date = date , present = True ) record . save ( ) messages . success ( request , f'Attendance of {student.id.id} recorded.' ) return HttpResponseRedirect ( reverse ( "hostelmanagement:hostel_view" ) )
This function is used to edit the attendance of a student.
This function is used to edit the attendance of a student .
"""
    This function is used to edit the attendance of a student.
    @param:
      request - HttpRequest object containing metadata about the user request.
    
    @variables:
      student_id = The student whose attendance has to be updated.
      hall = The hall of the concerned student.
      date = The date on which attendance has to be marked.
    """
request