2014-09-19 11:52:56 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from frontend.models import PersonGlobalIdentity, CitaviProjectIdentity
|
|
|
|
|
|
|
|
|
|
|
|
class PersonIdentityManager():
|
|
|
|
|
|
|
|
def create_identity(self, project, uuid):
|
|
|
|
pgi = PersonGlobalIdentity(type='citavi')
|
|
|
|
pgi.save()
|
2014-09-19 16:22:11 +02:00
|
|
|
cpi = CitaviProjectIdentity(global_identity=pgi, project=project, citavi_uuid=uuid, preferred=True)
|
2014-09-19 11:52:56 +02:00
|
|
|
cpi.save()
|
|
|
|
return cpi
|
|
|
|
|
|
|
|
def add_identity_to_global_identity(self, global_identity, project, uuid, preferred):
|
2014-09-19 16:22:11 +02:00
|
|
|
cpi = CitaviProjectIdentity(global_identity=global_identity, project=project, citavi_uuid=uuid, preferred=True)
|
2014-09-19 11:52:56 +02:00
|
|
|
cpi.save()
|
|
|
|
return cpi
|
|
|
|
|
|
|
|
def get_global_identities(self):
|
|
|
|
return PersonGlobalIdentity.objects.all()
|
|
|
|
|
|
|
|
def get_mapped_identities_for_project(self, project):
|
|
|
|
return CitaviProjectIdentity.objects.filter(project=project).all()
|