예제 #1
0
 def __init__(self, *args, **kwargs):
     cohort = kwargs.pop("cohort")
     specialty_id = kwargs.pop("specialty_id")
     super(SpecialityForm, self).__init__(*args, **kwargs)
     self.fields["speciality"].queryset = internship_speciality.find_by_cohort(cohort)
     if specialty_id:
         self.fields["speciality"].initial = internship_speciality.get_by_id(specialty_id)
예제 #2
0
def _copy_specialties(cohort_from, cohort_to):
    specialities = internship_speciality.find_by_cohort(cohort_from)
    for speciality in specialities:
        speciality.pk = None
        speciality.uuid = uuid.uuid4()
        speciality.cohort = cohort_to
        speciality.save()
예제 #3
0
def view_student_resume(request, cohort_id):
    cohort = mdl_internship_cohort.Cohort.objects.get(pk=cohort_id)
    student = mdl_student.find_by_user(request.user)
    internships = mdl_internship.Internship.objects.filter(
        cohort=cohort).order_by('speciality', 'name')

    student_information = mdl_student_information.find_by_user_in_cohort(
        request.user, cohort=cohort)
    periods = mdl_period.Period.objects.filter(cohort=cohort)
    period_ids = periods.values_list("pk", flat=True)
    student_affectations = mdl_student_affectation.InternshipStudentAffectationStat.objects.filter(
        student=student, period_id__in=period_ids).order_by("period__name")
    specialities = mdl_internship_speciality.find_by_cohort(cohort)
    student_choices = mdl_internship_choice.search(student=student,
                                                   specialities=specialities)
    cohort = mdl_internship_cohort.Cohort.objects.get(pk=cohort_id)
    publication_allowed = cohort.publication_start_date <= datetime.date.today(
    )
    offers = {}
    for affectation in student_affectations:
        score = InternshipAPIService.get_affectation(
            person=request.user.person,
            affectation_uuid=str(affectation.uuid)).score
        if score and score.validated:
            score.comments = _replace_comments_keys_with_translations(
                score.comments)
            setattr(affectation, 'score', score)
        offer = mdl_internship_offer.find_offer(
            cohort=cohort,
            speciality=affectation.speciality,
            organization=affectation.organization).first()
        offer.master = _get_internship_masters_repr(request.user.person,
                                                    affectation)
        try:
            offers[affectation.organization].update(
                {affectation.speciality: offer})
        except KeyError:
            offers.update(
                {affectation.organization: {
                    affectation.speciality: offer
                }})
    return layout.render(
        request, "student_resume.html", {
            "student": student,
            "student_information": student_information,
            "student_affectations": student_affectations,
            "student_choices": student_choices,
            "internships": internships,
            "publication_allowed": publication_allowed,
            "cohort": cohort,
            "offers": offers,
            "current_date": date.today(),
            "apds": APDS,
        })
예제 #4
0
def masters(request, cohort_id):
    current_cohort = shortcuts.get_object_or_404(cohort.Cohort, pk=cohort_id)
    filter_specialty = int(request.GET.get('specialty', 0))
    filter_hospital = int(request.GET.get('hospital', 0))

    allocations = master_allocation.search(current_cohort, filter_specialty,
                                           filter_hospital)
    if not filter_specialty and not filter_hospital:
        unallocated_masters = master_allocation.find_unallocated_masters()

    specialties = internship_speciality.find_by_cohort(current_cohort)
    hospitals = organization.find_by_cohort(current_cohort)

    return shortcuts.render(request, "masters.html", locals())
예제 #5
0
def master_form(request, cohort_id, master_id=None):
    current_cohort = shortcuts.get_object_or_404(cohort.Cohort, pk=cohort_id)
    if master_id:
        allocated_master = internship_master.get_by_id(master_id)
        allocations = master_allocation.find_by_master(current_cohort,
                                                       allocated_master)
        doctor_selected = 'selected' if allocated_master.civility == Civility.DOCTOR.value else ''
        professor_selected = 'selected' if allocated_master.civility == Civility.PROFESSOR.value else ''
        female_selected = 'selected' if allocated_master.gender == Gender.FEMALE.value else ''
        male_selected = 'selected' if allocated_master.gender == Gender.MALE.value else ''
        generalist_selected = 'selected' if allocated_master.type_mastery == Mastery.GENERALIST.value else ''
        specialist_selected = 'selected' if allocated_master.type_mastery == Mastery.SPECIALIST.value else ''

    countries = country.find_all()
    specialties = internship_speciality.find_by_cohort(current_cohort)
    hospitals = organization.find_by_cohort(current_cohort)
    return shortcuts.render(request, "master_form.html", locals())
예제 #6
0
def masters(request, cohort_id):
    current_cohort = shortcuts.get_object_or_404(cohort.Cohort, pk=cohort_id)
    filter_specialty = int(request.GET.get('specialty', 0))
    filter_hospital = int(request.GET.get('hospital', 0))
    filter_name = request.GET.get('name', '')
    filter_role = request.GET.get('role', Role.MASTER.name)

    allocations = master_allocation.search(current_cohort, filter_specialty,
                                           filter_hospital, filter_role)
    if filter_name:
        allocations = allocations.filter(master__person__last_name__unaccent__icontains=filter_name) | \
                      allocations.filter(master__person__first_name__unaccent__icontains=filter_name)
    specialties = internship_speciality.find_by_cohort(current_cohort)
    hospitals = organization.find_by_cohort(current_cohort)
    allocations = get_object_list(request, allocations)
    account_status = user_account_status.UserAccountStatus.__members__
    return render(request, "masters.html", locals())
예제 #7
0
def master_form(request, cohort_id, master_id=None, allocated_master=None):
    current_cohort = shortcuts.get_object_or_404(cohort.Cohort, pk=cohort_id)
    if master_id:
        allocated_master = internship_master.get_by_id(master_id)
        allocations = master_allocation.find_by_master(current_cohort,
                                                       allocated_master)

    master_form = MasterForm(request.POST or None, instance=allocated_master)
    person = allocated_master.person if allocated_master else None
    if request.POST.get('existing-person-id'):
        person = Person.objects.get(pk=request.POST.get('existing-person-id'))
    person_form = InternshipPersonForm(request.POST or None, instance=person)
    person_address = person.personaddress_set.first() if person else None
    person_address_form = InternshipPersonAddressForm(request.POST or None,
                                                      instance=person_address)
    specialties = internship_speciality.find_by_cohort(current_cohort)
    hospitals = organization.find_by_cohort(current_cohort)
    roles = Role.choices()

    dynamic_fields = json.dumps(
        list(person_form.fields.keys()) +
        list(person_address_form.fields.keys()))

    return render(request, "master_form.html", locals())
예제 #8
0
 def __init__(self, *args, **kwargs):
     cohort = kwargs.pop("cohort")
     super(SpecialityForm, self).__init__(*args, **kwargs)
     self.fields["speciality"] = forms.ModelChoiceField(
         queryset=internship_speciality.find_by_cohort(cohort),
         empty_label=None)
예제 #9
0
 def __init__(self, *args, **kwargs):
     super(InternshipForm, self).__init__(*args, **kwargs)
     cohort_id = kwargs['instance'].cohort_id
     self.fields[
         'speciality'].queryset = internship_speciality.find_by_cohort(
             cohort_id)