def seek_tutorial(request, lecturer_id):
    lecturer = get_object_or_404(Profesor, id=lecturer_id)

    if request.method == "POST":
        form = TutorialRequestForm(request.POST)
        if form.is_valid():
            tutorial_request = PeticionCitaService.create(form, request.user.id)

            if PeticionCitaService.can_request(tutorial_request):
                tutorial_request.save()
                EmailViews.send_tutorial_request_mail(request, tutorial_request)
                messages.add_message(request, messages.SUCCESS, _("The request has been sent successfully."))

                return HttpResponseRedirect("/student/tutorial/seek/%s" % lecturer_id)
            else:
                messages.add_message(
                    request,
                    messages.ERROR,
                    _("Sorry, but you cannot request more than two appointments for the same teacher in the same day."),
                )

    else:
        form = TutorialRequestForm(initial={"lecturer": lecturer.id})

    return render_to_response(
        "tutorial_request/calendar.html", {"lecturer": lecturer, "form": form}, context_instance=RequestContext(request)
    )
Exemplo n.º 2
0
def cancel_all(tutorial_request_list, motivation):
    for t in tutorial_request_list:
        t.motivocancelacion = motivation
        t.estado = 'DE'
        t.save()

        EmailViews.send_tutorial_rejected_mail(t)
Exemplo n.º 3
0
def auto_cancel(request_to_cancel):
    request_to_cancel.estado = 'CA'
    request_to_cancel.motivocancelacion = 'There is another accepted request for this date.'

    request_to_cancel.save()

    EmailViews.send_tutorial_rejected_mail(request_to_cancel)
Exemplo n.º 4
0
def cancel(deny_form):
    tutorial_request = Peticioncita.objects.get(
        idcita=deny_form.cleaned_data['request_id'])
    tutorial_request.motivocancelacion = deny_form.cleaned_data['motivation']
    tutorial_request.estado = 'DE'
    tutorial_request.save()

    EmailViews.send_tutorial_rejected_mail(tutorial_request)
def accept_request(request, tutorial_request_id):
    tutorial_request = Peticioncita.objects.get(idcita=tutorial_request_id)
    lecturer = Profesor.objects.get(id=request.user.id)

    assert lecturer == tutorial_request.profesor

    if PeticionCitaService.can_accept(tutorial_request):
        PeticionCitaService.accept(tutorial_request)
        EmailViews.send_tutorial_accepted_mail(tutorial_request)
        messages.success(request, _('Request was accepted successfully.'))
    else:
        messages.warning(request, _('There is another accepted request for this date. The request was not accepted.'))

    return HttpResponseRedirect('/lecturer/tutorialRequest/list')
def accept_request(request, tutorial_request_id):
    tutorial_request = Peticioncita.objects.get(idcita=tutorial_request_id)
    lecturer = Profesor.objects.get(id=request.user.id)

    assert lecturer == tutorial_request.profesor

    if PeticionCitaService.can_accept(tutorial_request):
        PeticionCitaService.accept(tutorial_request)
        EmailViews.send_tutorial_accepted_mail(tutorial_request)
        messages.success(request, _("Request was accepted successfully."))
    else:
        messages.warning(request, _("There is another accepted request for this date. The request was not accepted."))

    return HttpResponseRedirect("/lecturer/tutorialRequest/list")
def seek_tutorial(request, lecturer_id):
    lecturer = get_object_or_404(Profesor, id=lecturer_id)

    if request.method == 'POST':
        form = TutorialRequestForm(request.POST)
        if form.is_valid():
            tutorial_request = PeticionCitaService.create(form, request.user.id)

            if PeticionCitaService.can_request(tutorial_request):
                tutorial_request.save()
                EmailViews.send_tutorial_request_mail(request, tutorial_request)
                messages.add_message(request, messages.SUCCESS, _('The request has been sent successfully.'))

                return HttpResponseRedirect('/student/tutorial/seek/%s' % lecturer_id)
            else:
                messages.add_message(request, messages.ERROR, _(
                    'Sorry, but you cannot request more than two appointments for the same teacher in the same day.'))

    else:
        form = TutorialRequestForm(initial={'lecturer': lecturer.id})

    return render_to_response('tutorial_request/calendar.html', {'lecturer': lecturer, 'form': form},
                              context_instance=RequestContext(request))
Exemplo n.º 8
0
def send_email_create_user(user_create, request):

    for user in list(user_create.keys()):
        EmailViews.send_email_create_user(user, user_create[user], request)