|
1 from django.conf import settings |
|
2 from django.db import models |
|
3 from django.utils.translation import ugettext_lazy as _ |
|
4 from ldt.core.models import Document, Owner |
|
5 from django.contrib.auth.models import User |
|
6 import tagging.fields |
|
7 from utils import generate_uuid |
|
8 import lxml.etree |
|
9 import os.path |
|
10 import uuid |
|
11 import lucene |
|
12 from ldt.ldt_utils import STORE, ANALYZER |
|
13 #from django.core.management.validation import max_length |
|
14 |
|
15 |
|
16 |
|
17 class Annotation(models.Model): |
|
18 id = models.CharField(max_length=1024, primary_key=True, unique=True, default=generate_uuid, verbose_name=_('annotation.id')) |
|
19 uri = models.CharField(max_length=1024, verbose_name=_('annotation.uri')) |
|
20 tags = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('annotation.tags')) |
|
21 title = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('annotation.title')) |
|
22 description = models.TextField(null=True, blank=True, verbose_name=_('annotation.description')) |
|
23 text = models.TextField(null=True, blank=True, verbose_name=_('annotation.text')) |
|
24 color = models.CharField(max_length=1024, verbose_name=_('annotation.color')) |
|
25 creator = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('creator.title')) |
|
26 contributor = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('contributor.title')) |
|
27 creation_date = models.DateTimeField(auto_now_add=True, verbose_name=_('annotation.creation_date')) |
|
28 update_date = models.DateTimeField(auto_now=True, verbose_name=_('annotation.update_date')) |
|
29 |
|
30 |
|
31 def __unicode__(self): |
|
32 return unicode(self.id) + u": " + unicode(self.title) |
|
33 |
|
34 @staticmethod |
|
35 def create_annotation(id, uri=None, tags=None, title=None, description=None, text=None, color=None, creator=None, contributor=None, creation_date=None, update_date=None): |
|
36 annotation = Annotation(id=id, uri=uri, tags=tags, title=title, description=description, text=text, color=color, creator=creator, contributor=contributor, creation_date=creation_date, update_date=update_date) |
|
37 annotation.save() |
|
38 |
|
39 return annotation |
|
40 |
|
41 |
|
42 #class Author(models.Model): |
|
43 # |
|
44 # handle = models.CharField(max_length=512, unique=True, blank=True, null=True) |
|
45 # email = models.EmailField(unique=False, blank=True, null=True) |
|
46 # firstname = models.CharField(max_length=512, blank=True, null=True) |
|
47 # lastname = models.CharField(max_length=512, blank=True, null=True) |
|
48 # |
|
49 # def __unicode__(self): |
|
50 # return unicode(self.id) + " - " + self.handle + ", " + self.email + ", " + self.firstname + " " + self.lastname |
|
51 |