Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
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/')
Example #5
0
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/')
Example #6
0
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
Example #7
0
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
Example #8
0
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
Example #9
0
def professor_detail(request, idProfessor):
    professor = Professor.pickById(idProfessor)
    rendered_page = render(request, 'professor_detail.html',
                           {'professor': professor})
    return rendered_page
Example #10
0
def professor_detail(request, idProfessor):
    professor = Professor.pickById(idProfessor)
    rendered_page = render(request, 'professor_detail.html', {'professor': professor})
    return rendered_page