src/iconolab/models.py
author Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
Thu, 23 Jun 2016 17:27:44 +0200
changeset 31 e34b70a00488
parent 30 7ff344b4bf6d
child 34 1ede957a6868
permissions -rw-r--r--
adding annotations list
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
     1
from django.db import models, transaction
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     2
from django.contrib.auth.models import User
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     3
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     4
from django.contrib.contenttypes.fields import GenericForeignKey
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     5
from django.contrib.contenttypes.models import ContentType
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
     6
import uuid
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     7
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     8
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     9
class Tag(models.Model):
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    10
	DBPEDIA = 0
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    11
	ICONOLAB = 1
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    12
	TAG_TYPES = (
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    13
		(DBPEDIA, 'dbpedia'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    14
		(ICONOLAB, 'iconolab')
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    15
	)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    16
	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    17
	type = models.IntegerField(choices=TAG_TYPES)
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    18
	label = models.SlugField()
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    19
	link = models.URLField(blank=True, null=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    20
	description = models.CharField(max_length=255)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    21
	collection = models.ForeignKey('Collection', blank=True, null=True)
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    22
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    23
class TaggingInfo(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    24
	revision = models.ForeignKey('AnnotationRevision', on_delete=models.CASCADE)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    25
	tag = models.ForeignKey('Tag', on_delete=models.CASCADE)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    26
	accuracy = models.IntegerField()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    27
	relevancy = models.IntegerField()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    28
	
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    29
13
99224989b67b reorganized settings and static files directories
durandn
parents: 6
diff changeset
    30
# fonds Ingres - Musee de la Poste 
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    31
class Collection(models.Model):
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    32
	name =	models.CharField(max_length=50, unique=True)
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    33
	description = models.CharField(max_length=255)
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    34
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    35
	def __str__(self):
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    36
		return self.name
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    37
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    38
31
e34b70a00488 adding annotations list
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents: 30
diff changeset
    39
class Item(models.Model):
e34b70a00488 adding annotations list
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents: 30
diff changeset
    40
	collection = models.ForeignKey(Collection, related_name="items")
e34b70a00488 adding annotations list
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents: 30
diff changeset
    41
		
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    42
class ItemMetadata(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    43
	item = models.OneToOneField('Item', related_name='metadatas')
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    44
	joconde_ref = models.CharField(max_length=20, null=False, blank=False, unique=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    45
	domain = models.CharField(max_length=255)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    46
	title = models.CharField(max_length=255)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    47
	description = models.CharField(max_length=255)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    48
31
e34b70a00488 adding annotations list
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents: 30
diff changeset
    49
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    50
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    51
class ImageStats(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    52
	image = models.OneToOneField('Image', related_name='stats', blank=False, null=False)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    53
	views_count = models.IntegerField(blank=True, null=True, default=0)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    54
	annotations_count = models.IntegerField(blank=True, null=True, default=0)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    55
	submitted_revisions_count = models.IntegerField(blank=True, null=True, default=0)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    56
	comments_count = models.IntegerField(blank=True, null=True, default=0)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    57
	folders_inclusion_count = models.IntegerField(blank=True, null=True, default=0)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    58
	tag_count = models.IntegerField(blank=True, null=True, default=0)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    59
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    60
class Image(models.Model):
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    61
	name = models.CharField(max_length=200)
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    62
	media = models.ImageField(upload_to='uploads/', height_field='height', width_field='width')
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    63
	image_ref = models.CharField(max_length=255, unique=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    64
	item = models.ForeignKey('Item', related_name='images', null=True, blank=True)
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    65
	height = models.IntegerField(null=False, blank=False)
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    66
	width = models.IntegerField(null=False, blank=False)
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    67
	created = models.DateTimeField(auto_now_add=True, null=True)
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    68
	
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    69
	def __str__(self):
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    70
		return self.name
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    71
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    72
# # Folders
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    73
# class Folder(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    74
# 	label = models.CharField(max_length=255)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    75
# 	owner = models.ForeignKey(User)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    76
# 	images = models.ManyToManyField(Image)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    77
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    78
# 	def __str__(self):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    79
# 		return label
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    80
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    81
class AnnotationManager(models.Manager):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    82
	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    83
	# Call Annotation.objects.create_annotation to initialize a new Annotation with its associated AnnotationStats and initial AnnotationRevision
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    84
	@transaction.atomic
30
7ff344b4bf6d functionality: creation of new annotation from scratch
durandn
parents: 24
diff changeset
    85
	def create_annotation(self, author, image, title='', description='', fragment='', tags=None):
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    86
		# Create annotation object
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    87
		new_annotation = Annotation(
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    88
			image=image, 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    89
			author=author
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    90
		)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    91
		new_annotation.save()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    92
		
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    93
		# Create initial revision
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    94
		initial_revision = AnnotationRevision(
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    95
			annotation=new_annotation, 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    96
			author=author,
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    97
			title=title,
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    98
			description=description,
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
    99
			fragment=fragment,
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   100
			state=AnnotationRevision.ACCEPTED
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   101
		)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   102
		initial_revision.save()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   103
		new_annotation.current_revision = initial_revision
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   104
		new_annotation.save()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   105
		
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   106
		# Create stats object
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   107
		new_annotation_stats = AnnotationStats(annotation=new_annotation)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   108
		new_annotation_stats.save()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   109
		new_annotation.stats = new_annotation_stats
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   110
		new_annotation.save()
30
7ff344b4bf6d functionality: creation of new annotation from scratch
durandn
parents: 24
diff changeset
   111
		return new_annotation
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   112
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   113
class AnnotationStats(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   114
	annotation = models.OneToOneField('Annotation', related_name='stats', blank=False, null=False)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   115
	submitted_revisions_count = models.IntegerField(blank=True, null=True, default=1)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   116
	accepted_revisions_count = models.IntegerField(blank=True, null=True, default=1)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   117
	contributors_count = models.IntegerField(blank=True, null=True, default=1)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   118
	views_count = models.IntegerField(blank=True, null=True, default=0)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   119
	comments_count = models.IntegerField(blank=True, null=True, default=0)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   120
	tag_count = models.IntegerField(blank=True, null=True, default=0)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   121
	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   122
	def contributors(self):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   123
		# returns users that submitted an accepted revision
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   124
		return
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   125
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   126
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   127
class Annotation(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   128
	annotation_guid = models.UUIDField(default=uuid.uuid4, editable=False)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   129
	image = models.ForeignKey('Image', related_name='annotations', on_delete=models.CASCADE)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   130
	source_revision = models.ForeignKey('AnnotationRevision', related_name='source_related_annotation', blank=True, null=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   131
	current_revision = models.OneToOneField('AnnotationRevision', related_name='current_for_annotation', blank=True, null=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   132
	author = models.ForeignKey(User, null=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   133
	created = models.DateTimeField(auto_now_add=True, null=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   134
	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   135
	objects = AnnotationManager()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   136
	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   137
	def update_stats(self):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   138
		pass
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   139
	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   140
	# Call to create a new revision, possibly from a merge
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   141
	@transaction.atomic
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   142
	def make_new_revision(self, author, title, description, fragment, tags):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   143
		if author == self.author:
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   144
			# We're creating an automatically accepted revision
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   145
			new_revision_state = AnnotationRevision.ACCEPTED
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   146
		else:
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   147
			# Revision will require validation
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   148
			new_revision_state = AnnotationRevision.AWAITING
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   149
		new_revision = AnnotationRevision(
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   150
			annotation = self,
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   151
			parent_revision=self.current_revision,
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   152
			title=title,
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   153
			description=description,
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   154
			author=author,
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   155
			fragment=fragment,
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   156
			state=new_revision_state
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   157
		)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   158
		new_revision.save()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   159
		if new_revision.state == AnnotationRevision.ACCEPTED:
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   160
			self.current_revision = new_revision
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   161
			self.save()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   162
		return new_revision
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   163
	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   164
	# Call when we're validating an awaiting revision whose parent is the current revision AS IT WAS CREATED
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   165
	@transaction.atomic
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   166
	def validate_existing_revision(self, revision_to_validate):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   167
		if revision_to_validate.parent_revision == current_revision:
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   168
			self.current_revision = revision_to_validate
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   169
			revision_to_validate.state = AnnotationRevision.ACCEPTED
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   170
			revision_to_validate.save()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   171
			self.save()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   172
			
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   173
	# Call when we're validating an awaiting revision whose parent isn't the current revision OR IF IT WAS CHANGED BY THE ANNOTATION AUTHOR
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   174
	@transaction.atomic
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   175
	def merge_existing_revision(self, title, description, fragment, tags, revision_to_merge):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   176
		merged_revision = self.make_new_revision(author=self.author, title=title, description=description, fragment=fragment, tags=tags)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   177
		merged_revision.merge_parent_revision = revision_to_merge
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   178
		merged_revision.save()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   179
		self.current_revision=merged_revision
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   180
		self.save()
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   181
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   182
class AnnotationRevision(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   183
	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   184
	AWAITING = 0
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   185
	ACCEPTED = 1
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   186
	REJECTED = 2
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   187
	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   188
	REVISION_STATES = (
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   189
		(AWAITING, 'awaiting'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   190
		(ACCEPTED, 'accepted'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   191
		(REJECTED, 'rejected')
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   192
	)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   193
	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   194
	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   195
	revision_guid = models.UUIDField(default=uuid.uuid4)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   196
	annotation = models.ForeignKey('Annotation', related_name='revisions', null=False, blank=False)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   197
	parent_revision = models.ForeignKey('AnnotationRevision', related_name='reverse_parent_revision', blank=True, null=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   198
	merge_parent_revision = models.ForeignKey('AnnotationRevision', related_name='reverse_merge_parent_revision', blank=True, null=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   199
	author = models.ForeignKey(User, null=True)
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   200
	title = models.CharField(max_length=255)
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   201
	description = models.TextField(null=True)
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   202
	fragment = models.TextField() # path string
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   203
	tags = models.ManyToManyField('Tag', through='TaggingInfo', through_fields=('revision', 'tag'), blank=True, null=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   204
	state = models.IntegerField(choices=REVISION_STATES, default=AWAITING)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   205
	created = models.DateTimeField(auto_now_add=True, null=True)
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   206
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   207
24
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   208
#class MetaCategory(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   209
#	collection = models.ForeignKey(Collection)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   210
#	label = models.CharField(max_length=200)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   211
#
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   212
#	def __str__(self):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   213
#		return self.label
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   214
#
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   215
#	class Meta:
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   216
#		verbose_name_plural = 'Metacategories'
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   217
#
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   218
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   219
# class Comment(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   220
# 	author =  models.ForeignKey(User)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   221
# 	created = models.DateTimeField(blank=False, null=False, auto_now_add=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   222
# 	annotation_revision = models.ForeignKey(AnnotationRevision, blank=True, null=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   223
# 	target = models.ForeignKey('Comment', blank=True, null=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   224
# 	content = models.TextField(blank=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   225
# 	metacategories = models.ManyToManyField(MetaCategory) 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   226
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   227
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   228
# class CommentAttachement(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   229
# 	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   230
# 	LINK = 0
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   231
# 	IMAGE = 1
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   232
# 	PDF = 2
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   233
# 	COMMENT_CHOICES = (
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   234
# 		(LINK, 'link'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   235
# 		(IMAGE, 'image'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   236
# 		(PDF, 'pdf')
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   237
# 	)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   238
# 	comment = models.ForeignKey(Comment, on_delete=models.CASCADE, related_name='attachments')
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   239
# 	main_annotation = models.ForeignKey(Annotation)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   240
# 	attachment_type = models.IntegerField(choices=COMMENT_CHOICES, default=0)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   241
# 	created_date = models.DateTimeField(auto_now_add=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   242
# 	data = models.TextField(blank=False)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   243
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   244
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   245
# # Activity & Notification
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   246
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   247
# class Activity(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   248
# 	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   249
# 	NEW_COMMENT = 0
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   250
# 	NEW_REVISION = 1
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   251
# 	NEW_COMMENT_ON_REVISION = 2
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   252
# 	NEW_EXPERT_CALL = 3
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   253
# 	NEW_EXPERT_ANSWER = 4
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   254
# 	NEW_REFERENCE = 5
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   255
# 	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   256
# 	ACTIVITY_VERBS = (
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   257
# 		(NEW_COMMENT, 'New comment'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   258
# 		(NEW_REVISION, 'New revision'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   259
# 		(NEW_COMMENT_ON_REVISION, 'New comment on a revision'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   260
# 		(NEW_EXPERT_CALL, 'New expert call'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   261
# 		(NEW_EXPERT_ANSWER, 'New expert answer'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   262
# 		(NEW_REFERENCE, 'New reference'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   263
# 	) 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   264
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   265
# 	verb = models.IntegerField(choices=ACTIVITY_VERBS)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   266
# 	actor = models.ForeignKey(User)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   267
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   268
# 	target_content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   269
# 	target_object_id = models.PositiveIntegerField()
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   270
# 	target = GenericForeignKey('target_content_type', 'target_object_id')
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   271
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   272
# 	action_content_type = models.ForeignKey(ContentType, related_name='activity_action', on_delete=models.CASCADE, null=True, blank=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   273
# 	action_object_id = models.PositiveIntegerField(null=True, blank=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   274
# 	action_content = GenericForeignKey('action_content_type', 'action_object_id') 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   275
# 	
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   276
# 	created_date = models.DateTimeField(auto_now_add=True)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   277
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   278
# 	def __str__(self):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   279
# 		return '%s:%s' % (author.name, verbe)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   280
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   281
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   282
# class Notification(models.Model):
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   283
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   284
# 	UNREAD = 0
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   285
# 	READ = 1
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   286
# 	DELETED = 2
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   287
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   288
# 	STATUS = (
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   289
# 		(UNREAD, 'Unread'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   290
# 		(READ, 'Read'),
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   291
# 		(DELETED, 'Deleted')
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   292
# 	)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   293
# 
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   294
# 	activity = models.ForeignKey(Activity)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   295
# 	user = models.ForeignKey(User)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   296
# 	status = models.IntegerField(choices=STATUS, default=UNREAD)
6b6b183447a2 work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents: 13
diff changeset
   297
# 	created_date = models.DateTimeField(auto_now_add=True)
6
37baf9d13f32 first commit
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   298