def list_formations(request): formation_list = [] search_form = FormationFilterForm(request.GET) if search_form.is_valid(): formation_list = search_form.get_formations() if request.GET.get('xls_status') == "xls_formations": return create_xls(request.user, formation_list, search_form) continuing_education_training_manager = is_continuing_education_training_manager(request.user) trainings_managing = list( ContinuingEducationTrainingManager.objects.filter( person=request.user.person ).values_list('training', flat=True).distinct( 'training') ) if continuing_education_training_manager else None return render( request, "formations.html", { 'formations': get_object_list(request, formation_list), 'formations_number': len(formation_list), 'search_form': search_form, 'continuing_education_training_manager': continuing_education_training_manager, 'trainings_managing': trainings_managing } )
def list_prospects(request): prospects_list = list(Prospect.objects.all()) return render( request, "prospects.html", { 'prospects': get_object_list(request, prospects_list), 'prospects_count': len(prospects_list) })
def list_registrations(request): search_form = RegistrationFilterForm(request.GET, user=request.user) user_is_continuing_education_student_worker = is_continuing_education_student_worker( request.user) admission_list = [] if search_form.is_valid(): admission_list = search_form.get_registrations() if not user_is_continuing_education_student_worker: admission_list = filter_authorized_admissions(request.user, admission_list) if request.GET.get('xls_status') == "xls_registrations": return create_xls_registration(request.user, admission_list, search_form) return render( request, "registrations.html", { 'admissions': get_object_list(request, admission_list), 'admissions_number': len(admission_list), 'search_form': search_form, 'user_is_continuing_education_student_worker': user_is_continuing_education_student_worker, 'ucl_registration_state_choices': UCLRegistrationState.__members__ })
def list_prospects(request): prospects_list = get_prospects_by_user(request.user) return render( request, "prospects.html", { 'prospects': get_object_list(request, prospects_list), 'prospects_count': len(prospects_list) })
def list_cancelled(request): admission_list = Admission.objects.filter(state__in=[ admission_state_choices.CANCELLED, admission_state_choices.CANCELLED_NO_REGISTRATION_REQUIRED ]) admission_list = filter_authorized_admissions(request.user, admission_list) return render(request, "cancellations.html", {'admissions': get_object_list(request, admission_list)})
def list_admissions(request): search_form = AdmissionFilterForm(request.GET) admission_list = [] if search_form.is_valid(): admission_list = search_form.get_admissions() admission_list = filter_authorized_admissions(request.user, admission_list) if request.GET.get('xls_status') == "xls_admissions": return create_xls(request.user, admission_list, search_form) return render(request, "admissions.html", { 'admissions': get_object_list(request, admission_list), 'admissions_number': len(admission_list), 'search_form': search_form, })
def list_archives(request): search_form = ArchiveFilterForm(data=request.GET, user=request.user) archive_list = [] if search_form.is_valid(): archive_list = search_form.get_archives() archive_list = filter_authorized_admissions(request.user, archive_list) if request.GET.get('xls_status') == "xls_archives": return export_archives(request, archive_list, search_form) return render( request, "archives.html", { 'archives': get_object_list(request, archive_list), 'archives_number': len(archive_list), 'search_form': search_form })
def list_admissions(request): search_form = AdmissionFilterForm(request.GET) if search_form.is_valid(): admission_list = search_form.get_admissions() admission_list = filter_authorized_admissions(request.user, admission_list) else: admission_list = Admission.objects.none() if request.GET.get('xls_status') == "xls_admissions": return export_admissions(request, admission_list, search_form) return render( request, "admissions.html", { 'admissions': get_object_list(request, admission_list), 'admissions_number': admission_list.count(), 'search_form': search_form, })
def list_managers(request): search_form = ManagerFilterForm(data=request.GET) trainings = ContinuingEducationTraining.objects.all().select_related( 'education_group') person_training_form = PersonTrainingForm() if search_form.is_valid(): managers = search_form.get_managers() else: managers = Person.objects.filter( user__groups__name=TRAINING_MANAGERS_GROUP).order_by('last_name') for manager in managers: manager.trainings = trainings.filter(managers=manager).distinct() return render( request, "managers.html", { 'managers': get_object_list(request, managers), 'search_form': search_form, 'person_training_form': person_training_form })
def list_managers(request): search_form = ManagerFilterForm(data=request.GET) person_training_form = PersonTrainingForm(request.POST or None) trainings = ContinuingEducationTraining.objects.all().select_related( 'education_group') if search_form.is_valid(): managers = search_form.get_managers() else: managers = Person.objects.filter( user__groups__name=TRAINING_MANAGERS_GROUP).order_by('last_name') errors = [] if person_training_form.is_valid(): person = person_training_form.cleaned_data['person'] _append_user_to_training_managers(person.user) person_training_form.save() success_msg = _( 'Successfully assigned %(manager)s to the training %(training)s' ) % { "manager": person, "training": person_training_form.cleaned_data['training'].acronym } display_success_messages(request, success_msg) else: errors.append(person_training_form.errors) display_errors(request, errors) for manager in managers: manager.trainings = trainings.filter(managers=manager).distinct() return render( request, "managers.html", { 'managers': get_object_list(request, managers), 'search_form': search_form, 'person_training_form': person_training_form })