39 lines
1.7 KiB
Python
39 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from django.db import models
|
|
|
|
class Project(models.Model):
|
|
""" Model representing a citavi project. """
|
|
name = models.CharField(max_length=255)
|
|
description = models.TextField()
|
|
associated_filename = models.CharField(max_length=255, blank=True, null=True)
|
|
|
|
def __unicode__(self):
|
|
temp = unicode(self.name)
|
|
if self.associated_filename:
|
|
temp += u" (" + unicode(self.associated_filename) + u")"
|
|
else:
|
|
temp += u" (empty)"
|
|
return temp
|
|
|
|
|
|
class PersonGlobalIdentity(models.Model):
|
|
""" Model representing a global person identity in django. Can be used to link any foreign identity to it. """
|
|
type = models.CharField(max_length=255)
|
|
# TODO: Extend this for further stuff - maybe vivo external url or something?
|
|
|
|
def __unicode__(self):
|
|
from service.Mapper import person_mapper
|
|
return u"<PersonGlobalIdentity repr='" + person_mapper.get_representation_for_global_identity(self) + u"', ID=" + unicode(self.id) + u", type=" + unicode(self.type) + u">"
|
|
|
|
|
|
class CitaviProjectIdentity(models.Model):
|
|
""" Model representing an identity from a citavi project. """
|
|
global_identity = models.ForeignKey(PersonGlobalIdentity, blank=True, null=True, db_index=True)
|
|
project = models.ForeignKey(Project, blank=False, null=False, db_index=True)
|
|
citavi_uuid = models.CharField(max_length=255, blank=False, null=False, db_index=True)
|
|
preferred = models.BooleanField()
|
|
|
|
def __unicode__(self):
|
|
return u"<CitaviProjectIdentity project=" + unicode(self.project) + u", citavi_uuid=" + unicode(self.citavi_uuid) + u", global_identity=" + unicode(self.global_identity) + u", preferred=" + unicode(self.preferred) + u">"
|