[TASK] Perform validation in mapping wizard, polish model representations.
This commit is contained in:
@@ -15,6 +15,9 @@ class PersonIdentityManager():
|
||||
|
||||
def add_identity_to_global_identity(self, global_identity, project, uuid, preferred):
|
||||
""" Maps given citavi project identity to existing global identity. """
|
||||
# First, fetch all involved CitaviProjectIdentities and set them to preferred=False
|
||||
CitaviProjectIdentity.objects.filter(global_identity=global_identity).update(preferred=False)
|
||||
# Then add the new primary ProjectIdentity.
|
||||
cpi = CitaviProjectIdentity(global_identity=global_identity, project=project, citavi_uuid=uuid, preferred=preferred)
|
||||
cpi.save()
|
||||
return cpi
|
||||
|
||||
+6
-2
@@ -60,14 +60,18 @@ class PersonMapper():
|
||||
if global_identity.type == 'citavi':
|
||||
citavi_identity = self._person_identity_manager.get_citavi_identity_by_global_identity(global_identity)
|
||||
citavi_person = self._citavi_project_manager.get_person_by_uuid(citavi_identity.project_id, citavi_identity.citavi_uuid)
|
||||
return unicode(citavi_person.ID) + u" " + unicode(citavi_person.FirstName) + u" " + unicode(citavi_person.LastName)
|
||||
return self._representation_for_citavi_person(citavi_person)
|
||||
else:
|
||||
return u'Not implemented yet!'
|
||||
|
||||
def get_representation_for_citavi_identity(self, citavi_identity):
|
||||
""" Returns a unicode representation for a citavi project identiy. """
|
||||
citavi_person = self._citavi_project_manager.get_person_by_uuid(citavi_identity.project_id, citavi_identity.citavi_uuid)
|
||||
return unicode(citavi_person.ID) + u" " + unicode(citavi_person.FirstName) + u" " + unicode(citavi_person.LastName)
|
||||
return self._representation_for_citavi_person(citavi_person)
|
||||
|
||||
def _representation_for_citavi_person(self, citavi_person):
|
||||
p = citavi_person
|
||||
return u"<" + unicode(p.FirstName) + u" " + unicode(p.LastName) + u">"
|
||||
|
||||
|
||||
# Create a PersonMapper instance for public use, so ressources are not wasted.
|
||||
|
||||
Reference in New Issue
Block a user