def manager_informations_add_person(request): if request.method == "POST": form = ManagerAddAdviserPerson(request.POST) if form.is_valid(): person = Person(**form.cleaned_data, source=person_source_type.DISSERTATION) person.save() adv = adviser.add(person, 'PRF', False, False, False, '') return redirect('manager_informations_detail', pk=adv.pk) else: form = ManagerAddAdviserPerson() return render(request, 'manager_information_add_person.html', {'form': form})
def _create_update_person(user, person, user_infos): if not person: person = find_by_user(user) if not person: person = Person(user=user, global_id=user_infos.get('USER_FGS'), first_name=user_infos.get('USER_FIRST_NAME'), last_name=user_infos.get('USER_LAST_NAME'), email=user_infos.get('USER_EMAIL')) person.save() person_created.send(sender=None, person=person) else: updated, person = _update_person_if_necessary( person, user, user_infos.get('USER_FGS')) return person
def get_or_create_person(user=None, first_name=None, global_id=None): person = None created = False if user: person = mdl_person.find_by_user(user) if not person and global_id: person = mdl_person.find_by_global_id(global_id) if not person: person = Person(user=user, first_name=first_name, global_id=global_id) created = True if created: person.user = user person.first_name = first_name person.global_id = global_id person.save() return person