def _copy_organizations(cohort_from, cohort_to): organizations = organization.find_by_cohort(cohort_from) for org in organizations: org.pk = None org.uuid = uuid.uuid4() org.cohort = cohort_to org.save()
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())
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())
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())
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())
def test_find_by_cohort(self): cohort = CohortFactory() OrganizationFactory(cohort=cohort) an_organization = organization.find_by_cohort(cohort) self.assertEquals(cohort, an_organization[0].cohort)