def view_requests(request): if request.method == 'POST': form = DenyRequestForm(request.POST, lecturer_id=request.user.id) if form.is_valid(): PeticionCitaService.cancel(form) messages.success(request, _('Request was rejected successfully.')) else: form = DenyRequestForm(lecturer_id=request.user.id) tutorial_requests = PeticionCitaService.lecturer_requests(request.user.id, 'EC') return render_to_response('tutorial_request/list.html', {'tutorial_requests': tutorial_requests, 'form': form, 'title': _('Tutorial requests')}, context_instance=RequestContext(request))
def view_requests(request): if request.method == "POST": form = DenyRequestForm(request.POST, lecturer_id=request.user.id) if form.is_valid(): PeticionCitaService.cancel(form) messages.success(request, _("Request was rejected successfully.")) else: form = DenyRequestForm(lecturer_id=request.user.id) tutorial_requests = PeticionCitaService.lecturer_requests(request.user.id, "EC") return render_to_response( "tutorial_request/list.html", {"tutorial_requests": tutorial_requests, "form": form, "title": _("Tutorial requests")}, context_instance=RequestContext(request), )
def accepted_requests(request): if request.method == "POST": form = RejectAcceptedTutorialsForm(request.POST, lecturer_id=request.user.id) if form.is_valid(): messages.success(request, _("Tutorials was cancelled successfully.")) PeticionCitaService.cancel_all(form.cleaned_data["tutorial_requests"], form.cleaned_data["motivation"]) return HttpResponseRedirect("/tutorialRequest/accepted") if request.user.has_perm("principal.alumno"): tutorial_requests = PeticionCitaService.student_requests(request.user.id, "AC") form = None else: tutorial_requests = PeticionCitaService.lecturer_requests(request.user.id, "AC") form = None if request.method == "GET": form = RejectAcceptedTutorialsForm(lecturer_id=request.user.id) template_vars = {"tutorial_requests": tutorial_requests, "title": _("Accepted requests"), "reject_form": form} return render_to_response("tutorial_request/list.html", template_vars, context_instance=RequestContext(request))
def accepted_requests(request): if request.method == 'POST': form = RejectAcceptedTutorialsForm(request.POST, lecturer_id=request.user.id) if form.is_valid(): messages.success(request, _('Tutorials was cancelled successfully.')) PeticionCitaService.cancel_all(form.cleaned_data['tutorial_requests'], form.cleaned_data['motivation']) return HttpResponseRedirect('/tutorialRequest/accepted') if request.user.has_perm('principal.alumno'): tutorial_requests = PeticionCitaService.student_requests(request.user.id, 'AC') form = None else: tutorial_requests = PeticionCitaService.lecturer_requests(request.user.id, 'AC') form = None if request.method == 'GET': form = RejectAcceptedTutorialsForm(lecturer_id=request.user.id) template_vars = {'tutorial_requests': tutorial_requests, 'title': _('Accepted requests'), 'reject_form': form} return render_to_response('tutorial_request/list.html', template_vars, context_instance=RequestContext(request))
def __init__(self, *args, **kwargs): lecturer_id = kwargs.pop('lecturer_id') super(RejectAcceptedTutorialsForm, self).__init__(*args, **kwargs) self.fields[ 'tutorial_requests'].queryset = PeticionCitaService.lecturer_requests( lecturer_id, 'AC')
def __init__(self, *args, **kwargs): lecturer_id = kwargs.pop('lecturer_id') super(RejectAcceptedTutorialsForm, self).__init__(*args, **kwargs) self.fields['tutorial_requests'].queryset = PeticionCitaService.lecturer_requests(lecturer_id, 'AC')