citavi_mapper/service/Django.py

25 lines
881 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
from frontend.models import PersonGlobalIdentity, CitaviProjectIdentity
class PersonIdentityManager():
def create_identity(self, project, uuid):
pgi = PersonGlobalIdentity(type='citavi')
pgi.save()
cpi = CitaviProjectIdentity(global_identity=pgi, project=project, citavi_uuid=uuid, preferred=True)
cpi.save()
return cpi
def add_identity_to_global_identity(self, global_identity, project, uuid, preferred):
cpi = CitaviProjectIdentity(global_identity=global_identity, project=project, citavi_uuid=uuid, preferred=True)
cpi.save()
return cpi
def get_global_identities(self):
return PersonGlobalIdentity.objects.all()
def get_mapped_identities_for_project(self, project_instance):
return CitaviProjectIdentity.objects.filter(project=project_instance).all()