def professor_create(request): if request.method == 'POST': form = ProfessorForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] memberId = form.cleaned_data['memberId'] office = form.cleaned_data['office'] email = form.cleaned_data['email'] phoneNumber = form.cleaned_data['phoneNumber'] cellphoneNumber = form.cleaned_data['cellphoneNumber'] idDepartment = form.cleaned_data['idDepartment'] professor = Professor(name) professor.setMemberId(memberId) if office: professor.setOffice(office) if email: professor.setEmail(email) if phoneNumber: professor.setPhoneNumber(phoneNumber) if cellphoneNumber: professor.setCellphoneNumber(cellphoneNumber) if idDepartment: professor.setDepartment(Department.pickById(idDepartment)) user= request.user user_name = request.user.username time = get_time() action = u"Usuário " + user_name + u" criou o professor " + name professor_create_log = Log(user=user, action=action, time=time) professor_create_log.save() professor.store() return HttpResponseRedirect('/interface/professor/' + str(professor.idProfessor)) else: form = ProfessorForm() rendered_page = render(request, 'professor_create.html', {'form': form}) return rendered_page
def generateCourses(request): data = request.GET idCourses = json.loads(data['idCourses']) #Do something with this list idCourses = [int(idCourse) for idCourse in idCourses] if int(data['useProfessorsName']) == 1: useProfessorsName = True else: useProfessorsName = False if int(data['byOffer']) == 1: byOffer = 1 elif int(data['byOffer']) == 2: byOffer = 2 elif int(data['byOffer']) == 0: byOffer = 0 idTimePeriod = int(data['idTimePeriod']) idFaculty = int(data['idFaculty']) assessmentNumber = int(data['assessmentNumber']) user= request.user user_name = request.user.username time = get_time() timePeriod = str(TimePeriod.pickById(idTimePeriod)) courses = [str(Course.pickById(idCourse).courseCode) for idCourse in idCourses] cycle = Cycle.pickById(int(data['idCycle'])).name action = u"Usuário " + str(user_name) + u" gerou relatório: " \ + u"{ Curso: " + cycle \ + u"; Semestre: " + data['term'] \ + u"; Matérias: " + str(courses) \ + u"; Período: " + timePeriod \ + u"; Avaliação: " + data['assessmentNumber'] + " }" report_generate_log = Log(user=user, action=action, time=time) report_generate_log.save() CourseReportGenerator(idTimePeriod, idCourses, useProfessorsName, byOffer, idFaculty, assessmentNumber) return HttpResponse('Relatórios Gerados')
def professor_edit(request, idProfessor): professor = Professor.pickById(idProfessor) if request.method == 'POST': form = ProfessorForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] memberId = form.cleaned_data['memberId'] office = form.cleaned_data['office'] email = form.cleaned_data['email'] phoneNumber = form.cleaned_data['phoneNumber'] cellphoneNumber = form.cleaned_data['cellphoneNumber'] idDepartment = form.cleaned_data['idDepartment'] professor_name_old = professor.name professor_memberId_old = professor.memberId professor_office_old = professor.office professor_email_old = professor.email professor_phoneNumber_old = professor.phoneNumber professor_cellphoneNumber_old = professor.cellphoneNumber professor_idDepartment_old = professor.idDepartment professor.name = name professor.memberId = memberId office = None if not office else office email = None if not email else email professor.office = office professor.email = email professor.phoneNumber = phoneNumber professor.cellphoneNumber = cellphoneNumber professor.idDepartment = idDepartment user = request.user user_name = request.user.username time = get_time() action = u"Usuário " + user_name + u" alterou as informações do professor " + professor_name_old \ + u" { name: " + professor_name_old + " => " + professor.name \ + u"; memberId: " + str(professor_memberId_old) + " => " + str(professor.memberId) \ + u"; office: " + str(professor_office_old) + " => " + str(professor.office) \ + u"; email: " + str(professor_email_old) + " => " + str(professor.email) \ + u"; phoneNumber: " + str(professor_phoneNumber_old) + " => " + str(professor.phoneNumber) \ + u"; cellphoneNumber: " + str(professor_cellphoneNumber_old) + " => " + str(professor.cellphoneNumber) \ + u"; idDepartment: " + str(professor_idDepartment_old) + " => " + str(professor.idDepartment) + " }" professor_edit_log = Log(user=user, action=action, time=time) professor_edit_log.save() professor.store() return HttpResponseRedirect('/interface/professor/' + str(idProfessor)) else: form = ProfessorForm( initial={ 'name': professor.name, 'idDepartment': professor.idDepartment, 'memberId': professor.memberId, 'office': professor.office, 'email': professor.email, 'phoneNumber': professor.phoneNumber, 'cellphoneNumber': professor.cellphoneNumber }) rendered_page = render(request, 'professor_edit.html', { 'professor': professor, 'form': form }) return rendered_page
def offer_edit(request, idOffer): offer = Offer.pickById(idOffer) if request.method == 'POST': form = OfferForm(request.POST) form.updateForm() if form.is_valid(): idProfessor = form.cleaned_data['dropDownProfessor'] classNumber = form.cleaned_data['classNumber'] practical = form.cleaned_data['dropDownTeoricaPratica'] numberOfRegistrations = form.cleaned_data['numberOfRegistrations'] schedulesIds = form.cleaned_data['listSchedules'] schedules = [ Schedule.pickById(int(schedule)) for schedule in schedulesIds ] schedules_string_old = '[ ' schedules_string = '[ ' for schedule in offer.schedules: schedules_string_old += str(schedule).replace('ç', 'c') + " " for schedule in schedules: schedules_string += str(schedule).replace('ç', 'c') + " " schedules_string_old += ']' schedules_string += ']' user = request.user user_name = request.user.username time = get_time() action = u"Usuário " + user_name + u" editou o oferecimento id: " + str(offer.idOffer) + " {" \ + u" Código do Curso: " + str(offer.course.courseCode) \ + u"; Periodo: " + str(offer.timePeriod) \ + u"; Turma: T" + str(offer.classNumber) + " => T" + str(classNumber) \ + u"; Professor: " + offer.professor.name + " => " + Professor.pickById(idProfessor).name \ + u"; Horários: " + schedules_string_old + " => " + schedules_string + " }" offer_edit_log = Log(user=user, action=action, time=time) offer_edit_log.save() offer.setProfessor(Professor.pickById(idProfessor)) offer.classNumber = classNumber offer.practical = practical numberOfRegistrations = None if not numberOfRegistrations else numberOfRegistrations offer.setNumberOfRegistrations(numberOfRegistrations) offer.setSchedules(schedules) offer.store() return HttpResponseRedirect('/interface/offer/' + str(idOffer)) else: form = OfferForm( initial={ 'dropDownProfessor': offer.professor.idProfessor, 'classNumber': offer.classNumber, 'dropDownTeoricaPratica': offer.practical, 'numberOfRegistrations': offer.numberOfRegistrations }) form.updateForm() form.fields['listSchedules'].initial = [ schedule.idSchedule for schedule in offer.schedules ] rendered_page = render(request, 'offer_edit.html', { 'offer': offer, 'form': form }) return rendered_page
def professor_delete(request, idProfessor): professor = Professor.pickById(idProfessor) user = request.user user_name = request.user.username time = get_time() action = u"Usuário " + user_name + u" deletou o professor " + professor.name professor_delete_log = Log(user=user, action=action, time=time) professor_delete_log.save() professor.delete() return HttpResponseRedirect('/interface/professor/')
def professor_delete(request, idProfessor): professor = Professor.pickById(idProfessor) user= request.user user_name = request.user.username time = get_time() action = u"Usuário " + user_name + u" deletou o professor " + professor.name professor_delete_log = Log(user=user, action=action, time=time) professor_delete_log.save() professor.delete() return HttpResponseRedirect('/interface/professor/')
def professor_edit(request, idProfessor): professor = Professor.pickById(idProfessor) if request.method == 'POST': form = ProfessorForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] memberId = form.cleaned_data['memberId'] office = form.cleaned_data['office'] email = form.cleaned_data['email'] phoneNumber = form.cleaned_data['phoneNumber'] cellphoneNumber = form.cleaned_data['cellphoneNumber'] idDepartment = form.cleaned_data['idDepartment'] professor_name_old = professor.name professor_memberId_old = professor.memberId professor_office_old = professor.office professor_email_old = professor.email professor_phoneNumber_old = professor.phoneNumber professor_cellphoneNumber_old = professor.cellphoneNumber professor_idDepartment_old = professor.idDepartment professor.name = name professor.memberId = memberId office = None if not office else office email = None if not email else email professor.office = office professor.email = email professor.phoneNumber = phoneNumber professor.cellphoneNumber = cellphoneNumber professor.idDepartment = idDepartment user= request.user user_name = request.user.username time = get_time() action = u"Usuário " + user_name + u" alterou as informações do professor " + professor_name_old \ + u" { name: " + professor_name_old + " => " + professor.name \ + u"; memberId: " + str(professor_memberId_old) + " => " + str(professor.memberId) \ + u"; office: " + str(professor_office_old) + " => " + str(professor.office) \ + u"; email: " + str(professor_email_old) + " => " + str(professor.email) \ + u"; phoneNumber: " + str(professor_phoneNumber_old) + " => " + str(professor.phoneNumber) \ + u"; cellphoneNumber: " + str(professor_cellphoneNumber_old) + " => " + str(professor.cellphoneNumber) \ + u"; idDepartment: " + str(professor_idDepartment_old) + " => " + str(professor.idDepartment) + " }" professor_edit_log = Log(user=user, action=action, time=time) professor_edit_log.save() professor.store() return HttpResponseRedirect('/interface/professor/' + str(idProfessor)) else: form = ProfessorForm(initial={'name': professor.name, 'idDepartment': professor.idDepartment, 'memberId': professor.memberId, 'office': professor.office, 'email': professor.email, 'phoneNumber': professor.phoneNumber, 'cellphoneNumber': professor.cellphoneNumber}) rendered_page = render(request, 'professor_edit.html', {'professor': professor, 'form': form}) return rendered_page
def deleteEncoding(request): data = request.GET opticalSheet = OpticalSheet.pickById(int(data['idOpticalSheet'])) user= request.user user_name = request.user.username time = get_time() timePeriod = str(TimePeriod.pickById(int(data['idTimePeriod']))) action = u"Usuário " + str(user_name) + u" deletou codificação " + opticalSheet.encodingName \ + u" { Periodo: " + timePeriod + " }" encoding_delete_log = Log(user=user, action=action, time=time) encoding_delete_log.save() opticalSheet.delete() return HttpResponseRedirect('/encoder/')
def offer_create(request, idTimePeriod, idCourse): timePeriod = TimePeriod.pickById(idTimePeriod) course = Course.pickById(idCourse) if request.method == 'POST': form = OfferForm(request.POST) form.updateForm() if form.is_valid(): idProfessor = form.cleaned_data['dropDownProfessor'] classNumber = form.cleaned_data['classNumber'] practical = form.cleaned_data['dropDownTeoricaPratica'] numberOfRegistrations = form.cleaned_data['numberOfRegistrations'] schedulesIds = form.cleaned_data['listSchedules'] schedules = [ Schedule.pickById(schedule) for schedule in schedulesIds ] professor = Professor.pickById(idProfessor) practical = (practical == 1) offer = Offer(timePeriod, course, classNumber, practical, professor) offer.setSchedules(schedules) offer.setNumberOfRegistrations(numberOfRegistrations) offer.store() user = request.user user_name = request.user.username time = get_time() schedules_string = '[ ' for schedule in schedules: schedules_string += str(schedule).replace('ç', 'c') + " " schedules_string += ']' action = u"Usuário " + user_name + u" criou o oferecimento id: " + str(offer.idOffer) + " {" \ + u" Código do Curso: " + str(course.courseCode) \ + u"; Turma: T" + str(classNumber) \ + u"; Professor: " + professor.name \ + u"; Periodo: " + str(timePeriod) \ + u"; Horários: " + schedules_string + " }" offer_create_log = Log(user=user, action=action, time=time) offer_create_log.save() return HttpResponseRedirect('/interface/offer/' + str(offer.idOffer)) else: form = OfferForm() form.updateForm() rendered_page = render(request, 'offer_create.html', { 'form': form, 'timePeriod': timePeriod, 'course': course }) return rendered_page
def offer_edit(request, idOffer): offer = Offer.pickById(idOffer) if request.method == 'POST': form = OfferForm(request.POST) form.updateForm() if form.is_valid(): idProfessor = form.cleaned_data['dropDownProfessor'] classNumber = form.cleaned_data['classNumber'] practical = form.cleaned_data['dropDownTeoricaPratica'] numberOfRegistrations = form.cleaned_data['numberOfRegistrations'] schedulesIds = form.cleaned_data['listSchedules'] schedules = [Schedule.pickById(int(schedule)) for schedule in schedulesIds] schedules_string_old = '[ ' schedules_string = '[ ' for schedule in offer.schedules: schedules_string_old += str(schedule).replace('ç','c') + " " for schedule in schedules: schedules_string += str(schedule).replace('ç','c') + " " schedules_string_old += ']' schedules_string += ']' user= request.user user_name = request.user.username time = get_time() action = u"Usuário " + user_name + u" editou o oferecimento id: " + str(offer.idOffer) + " {" \ + u" Código do Curso: " + str(offer.course.courseCode) \ + u"; Periodo: " + str(offer.timePeriod) \ + u"; Turma: T" + str(offer.classNumber) + " => T" + str(classNumber) \ + u"; Professor: " + offer.professor.name + " => " + Professor.pickById(idProfessor).name \ + u"; Horários: " + schedules_string_old + " => " + schedules_string + " }" offer_edit_log = Log(user=user, action=action, time=time) offer_edit_log.save() offer.setProfessor(Professor.pickById(idProfessor)) offer.classNumber = classNumber offer.practical = practical numberOfRegistrations = None if not numberOfRegistrations else numberOfRegistrations offer.setNumberOfRegistrations(numberOfRegistrations) offer.setSchedules(schedules) offer.store() return HttpResponseRedirect('/interface/offer/' + str(idOffer)) else: form = OfferForm(initial={'dropDownProfessor': offer.professor.idProfessor, 'classNumber': offer.classNumber, 'dropDownTeoricaPratica': offer.practical, 'numberOfRegistrations': offer.numberOfRegistrations}) form.updateForm() form.fields['listSchedules'].initial = [schedule.idSchedule for schedule in offer.schedules] rendered_page = render(request, 'offer_edit.html', {'offer': offer, 'form': form}) return rendered_page
def store(request): data = request.POST data = json.loads(data['json']) user= request.user user_name = request.user.username time = get_time() cycle_name = Cycle.pickById(int(data['idCycle'])).name timePeriod = str(TimePeriod.pickById(int(data['idTimePeriod']))) response = OpticalSheetController.storeOpticalSheet(data['idOpticalSheet'], data['surveyType'], data['idCycle'], data['term'], data['idTimePeriod'], data['fields'], data['surveys'], data['encoded']) action = u"Usuário " + str(user_name) + u" salvou idOpticalSheet " + str(data['idOpticalSheet']) \ + u" { Periodo: " + timePeriod \ + u"; Curso: " + cycle_name \ + u"; Semestre: " + str(data['term']) + " }" opticalSheet_store_log = Log(user=user, action=action, time=time) opticalSheet_store_log.save() return HttpResponse(json.dumps(response))
def offer_delete(request, idOffer): offer = Offer.pickById(idOffer) user = request.user user_name = request.user.username time = get_time() schedules_string = '[ ' for schedule in offer.schedules: schedules_string += str(schedule).replace('ç', 'c') + " " schedules_string += ']' action = u"Usuário " + user_name + u" deletou o oferecimento id: " + str(offer.idOffer) + " {" \ + u" Código do Curso: " + str(offer.course.courseCode) \ + u"; Turma: T" + str(offer.classNumber) \ + u"; Professor: " + offer.professor.name \ + u"; Periodo: " + str(offer.timePeriod) \ + u"; Horários: " + schedules_string + " }" offer_delete_log = Log(user=user, action=action, time=time) offer_delete_log.save() offer.delete() return HttpResponseRedirect('/interface/offer/')
def offer_delete(request, idOffer): offer = Offer.pickById(idOffer) user= request.user user_name = request.user.username time = get_time() schedules_string = '[ ' for schedule in offer.schedules: schedules_string += str(schedule).replace('ç','c') + " " schedules_string += ']' action = u"Usuário " + user_name + u" deletou o oferecimento id: " + str(offer.idOffer) + " {" \ + u" Código do Curso: " + str(offer.course.courseCode) \ + u"; Turma: T" + str(offer.classNumber) \ + u"; Professor: " + offer.professor.name \ + u"; Periodo: " + str(offer.timePeriod) \ + u"; Horários: " + schedules_string + " }" offer_delete_log = Log(user=user, action=action, time=time) offer_delete_log.save() offer.delete() return HttpResponseRedirect('/interface/offer/')
def store(request): data = request.POST data = json.loads(data['json']) user = request.user user_name = request.user.username time = get_time() cycle_name = Cycle.pickById(int(data['idCycle'])).name timePeriod = str(TimePeriod.pickById(int(data['idTimePeriod']))) response = OpticalSheetController.storeOpticalSheet( data['idOpticalSheet'], data['surveyType'], data['idCycle'], data['term'], data['idTimePeriod'], data['fields'], data['surveys'], data['encoded']) action = u"Usuário " + str(user_name) + u" salvou idOpticalSheet " + str(data['idOpticalSheet']) \ + u" { Periodo: " + timePeriod \ + u"; Curso: " + cycle_name \ + u"; Semestre: " + str(data['term']) + " }" opticalSheet_store_log = Log(user=user, action=action, time=time) opticalSheet_store_log.save() return HttpResponse(json.dumps(response))
def openSite(request): header = Header() header.setTermFunction('$("#file").show()') if request.method == 'POST': data = request.POST NoteReader.readNote(request.FILES['arq'].name, request.FILES['arq'].file.getvalue(),int(data['headerCycle']), int(data['headerTerm']), int(data['headerTimePeriod']), int(data['bSheet']), int(data['assessmentNumber'])) user= request.user user_name = request.user.username time = get_time() cycle_name = Cycle.pickById(int(data['headerCycle'])).name timePeriod = str(TimePeriod.pickById(int(data['headerTimePeriod']))) b_sheet = "A" if int(data['bSheet']) == 0 else "B" action = u"Usuário " + str(user_name) + " inseriu datafile " + request.FILES['arq'].name \ + u" { Curso: " + cycle_name \ + u"; Semestre: " + data['headerTerm'] \ + u"; Período: " + timePeriod \ + u"; Folha(A ou B): " + b_sheet \ + u"; Avaliação: " + data['assessmentNumber'] + " }" datafile_insert_log = Log(user=user, action=action, time=time) datafile_insert_log.save() return render_to_response('datafile.html',{'divs':header.getHtml()},context_instance=RequestContext(request))
def offer_create(request, idTimePeriod, idCourse): timePeriod = TimePeriod.pickById(idTimePeriod) course = Course.pickById(idCourse) if request.method == 'POST': form = OfferForm(request.POST) form.updateForm() if form.is_valid(): idProfessor = form.cleaned_data['dropDownProfessor'] classNumber = form.cleaned_data['classNumber'] practical = form.cleaned_data['dropDownTeoricaPratica'] numberOfRegistrations = form.cleaned_data['numberOfRegistrations'] schedulesIds = form.cleaned_data['listSchedules'] schedules = [Schedule.pickById(schedule) for schedule in schedulesIds] professor = Professor.pickById(idProfessor) practical = (practical == 1) offer = Offer(timePeriod, course, classNumber, practical, professor) offer.setSchedules(schedules) offer.setNumberOfRegistrations(numberOfRegistrations) offer.store() user= request.user user_name = request.user.username time = get_time() schedules_string = '[ ' for schedule in schedules: schedules_string += str(schedule).replace('ç','c') + " " schedules_string += ']' action = u"Usuário " + user_name + u" criou o oferecimento id: " + str(offer.idOffer) + " {" \ + u" Código do Curso: " + str(course.courseCode) \ + u"; Turma: T" + str(classNumber) \ + u"; Professor: " + professor.name \ + u"; Periodo: " + str(timePeriod) \ + u"; Horários: " + schedules_string + " }" offer_create_log = Log(user=user, action=action, time=time) offer_create_log.save() return HttpResponseRedirect('/interface/offer/' + str(offer.idOffer)) else: form = OfferForm() form.updateForm() rendered_page = render(request, 'offer_create.html', {'form': form, 'timePeriod': timePeriod, 'course': course}) return rendered_page
def professor_create(request): if request.method == 'POST': form = ProfessorForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] memberId = form.cleaned_data['memberId'] office = form.cleaned_data['office'] email = form.cleaned_data['email'] phoneNumber = form.cleaned_data['phoneNumber'] cellphoneNumber = form.cleaned_data['cellphoneNumber'] idDepartment = form.cleaned_data['idDepartment'] professor = Professor(name) professor.setMemberId(memberId) if office: professor.setOffice(office) if email: professor.setEmail(email) if phoneNumber: professor.setPhoneNumber(phoneNumber) if cellphoneNumber: professor.setCellphoneNumber(cellphoneNumber) if idDepartment: professor.setDepartment(Department.pickById(idDepartment)) user = request.user user_name = request.user.username time = get_time() action = u"Usuário " + user_name + u" criou o professor " + name professor_create_log = Log(user=user, action=action, time=time) professor_create_log.save() professor.store() return HttpResponseRedirect('/interface/professor/' + str(professor.idProfessor)) else: form = ProfessorForm() rendered_page = render(request, 'professor_create.html', {'form': form}) return rendered_page
def generateCourses(request): data = request.GET idCourses = json.loads(data['idCourses']) #Do something with this list idCourses = [int(idCourse) for idCourse in idCourses] if int(data['useProfessorsName']) == 1: useProfessorsName = True else: useProfessorsName = False if int(data['byOffer']) == 1: byOffer = 1 elif int(data['byOffer']) == 2: byOffer = 2 elif int(data['byOffer']) == 0: byOffer = 0 idTimePeriod = int(data['idTimePeriod']) idFaculty = int(data['idFaculty']) assessmentNumber = int(data['assessmentNumber']) user = request.user user_name = request.user.username time = get_time() timePeriod = str(TimePeriod.pickById(idTimePeriod)) courses = [ str(Course.pickById(idCourse).courseCode) for idCourse in idCourses ] cycle = Cycle.pickById(int(data['idCycle'])).name action = u"Usuário " + str(user_name) + u" gerou relatório: " \ + u"{ Curso: " + cycle \ + u"; Semestre: " + data['term'] \ + u"; Matérias: " + str(courses) \ + u"; Período: " + timePeriod \ + u"; Avaliação: " + data['assessmentNumber'] + " }" report_generate_log = Log(user=user, action=action, time=time) report_generate_log.save() CourseReportGenerator(idTimePeriod, idCourses, useProfessorsName, byOffer, idFaculty, assessmentNumber) return HttpResponse('Relatórios Gerados')