|
9
|
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 os.path |
|
|
9 |
import uuid |
|
|
10 |
#from django.core.management.validation import max_length |
|
|
11 |
|
|
|
12 |
|
|
|
13 |
class Annotation(models.Model): |
|
|
14 |
external_id = models.CharField(max_length=1024, null=False, unique=True, default=generate_uuid, verbose_name=_('annotation.external_id')) |
|
|
15 |
uri = models.CharField(max_length=1024, verbose_name=_('annotation.uri')) |
|
|
16 |
tags = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('annotation.tags')) |
|
|
17 |
title = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('annotation.title')) |
|
|
18 |
description = models.TextField(null=True, blank=True, verbose_name=_('annotation.description')) |
|
|
19 |
text = models.TextField(null=True, blank=True, verbose_name=_('annotation.text')) |
|
|
20 |
color = models.CharField(max_length=1024, verbose_name=_('annotation.color')) |
|
|
21 |
creator = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('creator.title')) |
|
|
22 |
contributor = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('contributor.title')) |
|
|
23 |
creation_date = models.DateTimeField(auto_now_add=True, verbose_name=_('annotation.creation_date')) |
|
|
24 |
update_date = models.DateTimeField(auto_now=True, verbose_name=_('annotation.update_date')) |
|
|
25 |
|
|
|
26 |
|
|
|
27 |
def __unicode__(self): |
|
|
28 |
return unicode(self.external_id) + u": " + unicode(self.title) |
|
|
29 |
|
|
|
30 |
@staticmethod |
|
|
31 |
def create_annotation(external_id, uri=None, tags=None, title=None, description=None, text=None, color=None, creator=None, contributor=None, creation_date=None, update_date=None): |
|
|
32 |
annotation = Annotation(external_id=external_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) |
|
|
33 |
annotation.save() |
|
|
34 |
|
|
|
35 |
return annotation |
|
|
36 |
|
|
|
37 |
|