citavi_mapper/frontend/models.py

40 lines
1.7 KiB
Python
Raw Normal View History

2014-07-25 13:53:01 +02:00
# -*- coding: utf-8 -*-
from django.db import models
class Project(models.Model):
""" Model representing a citavi project. """
2014-07-28 13:20:13 +02:00
name = models.CharField(max_length=255)
description = models.TextField()
2014-09-19 11:05:14 +02:00
associated_filename = models.CharField(max_length=255, blank=True, null=True)
2014-07-28 13:20:13 +02:00
def __unicode__(self):
2014-09-29 15:01:35 +02:00
temp = unicode(self.name)
2014-07-28 13:20:13 +02:00
if self.associated_filename:
2014-09-29 15:01:35 +02:00
temp += u" (" + unicode(self.associated_filename) + u")"
else:
2014-09-29 15:01:35 +02:00
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)
2014-09-19 11:05:14 +02:00
# TODO: Extend this for further stuff - maybe vivo external url or something?
def __unicode__(self):
2014-09-29 15:01:35 +02:00
from service.Mapper import PersonMapper
pm = PersonMapper()
return u"<PersonGlobalIdentity repr=" + pm.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)
project = models.ForeignKey(Project, blank=False, null=False)
citavi_uuid = models.CharField(max_length=255, blank=False, null=False)
preferred = models.BooleanField()
2014-09-19 11:05:14 +02:00
def __unicode__(self):
2014-09-29 15:01:35 +02:00
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">"