FusionIIIT/applications/hostel_management/views.py
def generate_worker_report(request):
    """
    This function is used to read uploaded worker report spreadsheet(.xls) and generate WorkerReport instance and save it in the database.
    @param:
      request - HttpRequest object containing metadata about the user request.

    @variables:
      files - stores uploaded worker report file 
      excel - stores the opened spreadsheet file raedy for data extraction.
      user_id - stores user id of the current user.
      sheet - stores a sheet from the uploaded spreadsheet.
    """
    if request.method == "POST":
      try:
        files = request.FILES['upload_report']
        excel = xlrd.open_workbook(file_contents=files.read())
        user_id = request.user.extrainfo.id
        if str(excel.sheets()[0].cell(0,0).value)[:5].lower() == str(HallCaretaker.objects.get(staff__id=user_id).hall):
            for sheet in excel.sheets():
                save_worker_report_sheet(excel,sheet,user_id)
                return HttpResponseRedirect(reverse("hostelmanagement:hostel_view"))

        return HttpResponseRedirect(reverse("hostelmanagement:hostel_view"))
      except: 
          messages.error(request,"Please upload a file in valid format before submitting")
          return HttpResponseRedirect(reverse("hostelmanagement:hostel_view"))

    This function is used to read uploaded worker report spreadsheet(.xls) and generate WorkerReport instance and save it in the database.
    @param:
      request - HttpRequest object containing metadata about the user request.

    @variables:
      files - stores uploaded worker report file 
      excel - stores the opened spreadsheet file raedy for data extraction.
      user_id - stores user id of the current user.
      sheet - stores a sheet from the uploaded spreadsheet.
    
This function is used to read uploaded worker report spreadsheet(.xls) and generate WorkerReport instance and save it in the database.
@param:
request - HttpRequest object containing metadata about the user request.

@variables:
files - stores uploaded worker report file
excel - stores the opened spreadsheet file raedy for data extraction.
user_id - stores user id of the current user.
sheet - stores a sheet from the uploaded spreadsheet.
This function is used to read uploaded worker report spreadsheet ( . xls ) and generate WorkerReport instance and save it in the database . @param : request - HttpRequest object containing metadata about the user request . @variables : files - stores uploaded worker report file excel - stores the opened spreadsheet file raedy for data extraction . user_id - stores user id of the current user . sheet - stores a sheet from the uploaded spreadsheet .
def generate_worker_report(request):
    if request.method == "POST":
      try:
        files = request.FILES['upload_report']
        excel = xlrd.open_workbook(file_contents=files.read())
        user_id = request.user.extrainfo.id
        if str(excel.sheets()[0].cell(0,0).value)[:5].lower() == str(HallCaretaker.objects.get(staff__id=user_id).hall):
            for sheet in excel.sheets():
                save_worker_report_sheet(excel,sheet,user_id)
                return HttpResponseRedirect(reverse("hostelmanagement:hostel_view"))
        return HttpResponseRedirect(reverse("hostelmanagement:hostel_view"))
      except: 
          messages.error(request,"Please upload a file in valid format before submitting")
          return HttpResponseRedirect(reverse("hostelmanagement:hostel_view"))
def generate_worker_report ( request ) : if request . method == "POST" : try : files = request . FILES [ 'upload_report' ] excel = xlrd . open_workbook ( file_contents = files . read ( ) ) user_id = request . user . extrainfo . id if str ( excel . sheets ( ) [ 0 ] . cell ( 0 , 0 ) . value ) [ : 5 ] . lower ( ) == str ( HallCaretaker . objects . get ( staff__id = user_id ) . hall ) : for sheet in excel . sheets ( ) : save_worker_report_sheet ( excel , sheet , user_id ) return HttpResponseRedirect ( reverse ( "hostelmanagement:hostel_view" ) ) return HttpResponseRedirect ( reverse ( "hostelmanagement:hostel_view" ) ) except : messages . error ( request , "Please upload a file in valid format before submitting" ) return HttpResponseRedirect ( reverse ( "hostelmanagement:hostel_view" ) )
This function is used to read uploaded worker report spreadsheet(.xls) and generate WorkerReport instance and save it in the database.
This function is used to read uploaded worker report spreadsheet ( . xls ) and generate WorkerReport instance and save it in the database .
"""
    This function is used to read uploaded worker report spreadsheet(.xls) and generate WorkerReport instance and save it in the database.
    @param:
      request - HttpRequest object containing metadata about the user request.

    @variables:
      files - stores uploaded worker report file 
      excel - stores the opened spreadsheet file raedy for data extraction.
      user_id - stores user id of the current user.
      sheet - stores a sheet from the uploaded spreadsheet.
    """
request