server/ammico/models.py
author rougeronj
Fri, 22 May 2015 12:37:37 +0200
changeset 90 faf2cdb47813
parent 71 a5dedc11ba8f
child 102 622f5d1955b6
permissions -rw-r--r--
remove "comment" from the model. Copy the 'comment' field of Jamespot in the 'description' field of the model instead
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45
19f3f0a7fbd7 add idInventory for slides saved from a research and not coming from Jamespot
rougeronj
parents: 21
diff changeset
     1
import datetime
19f3f0a7fbd7 add idInventory for slides saved from a research and not coming from Jamespot
rougeronj
parents: 21
diff changeset
     2
13
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
     3
from django.db import models
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
     4
from taggit.managers import TaggableManager
21
4e9e005bce90 update ammico user attribute to OnetoOneField instead of foreign key
rougeronj
parents: 20
diff changeset
     5
51
032280909e65 add authentication module using Token Auth
rougeronj
parents: 45
diff changeset
     6
from authentication.models import AmmicoUser
13
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
     7
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
     8
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
     9
class Book(models.Model):
51
032280909e65 add authentication module using Token Auth
rougeronj
parents: 45
diff changeset
    10
    user = models.ForeignKey(AmmicoUser, related_name = "books")
71
a5dedc11ba8f add parent_visit attribute to model to identify a book created by user and a book from Jamespot
rougeronj
parents: 63
diff changeset
    11
    idArticle = models.CharField(max_length=512, null=True)
13
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
    12
    title = models.CharField(max_length=512, blank=True)
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
    13
    description = models.CharField(max_length=512, blank=True, null=True)
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
    14
    image = models.URLField(max_length=2048, blank=True)
51
032280909e65 add authentication module using Token Auth
rougeronj
parents: 45
diff changeset
    15
    date = models.DateTimeField(default=datetime.datetime.now)
71
a5dedc11ba8f add parent_visit attribute to model to identify a book created by user and a book from Jamespot
rougeronj
parents: 63
diff changeset
    16
    parent_visit = models.ForeignKey('Book', related_name = "books_copy", null=True)
13
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
    17
    
14
4d27fbc3f9df Succed to get the books from our api server and print them dynamically
rougeronj
parents: 13
diff changeset
    18
    def __str__(self):
4d27fbc3f9df Succed to get the books from our api server and print them dynamically
rougeronj
parents: 13
diff changeset
    19
        return self.title
13
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
    20
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
    21
class Slide(models.Model):
16
f0f0f29395d5 add related_name keyword fro easy access to the slides of a book
rougeronj
parents: 14
diff changeset
    22
    book = models.ForeignKey(Book, related_name = "slides")
45
19f3f0a7fbd7 add idInventory for slides saved from a research and not coming from Jamespot
rougeronj
parents: 21
diff changeset
    23
    idStop = models.CharField(max_length=512, blank=True)
19f3f0a7fbd7 add idInventory for slides saved from a research and not coming from Jamespot
rougeronj
parents: 21
diff changeset
    24
    idInventory = models.CharField(max_length=512, blank=True)
20
a84fce1b1a98 dd some fields to slide model
rougeronj
parents: 16
diff changeset
    25
    title = models.CharField(max_length=512, blank=True)
a84fce1b1a98 dd some fields to slide model
rougeronj
parents: 16
diff changeset
    26
    description = models.CharField(max_length=1024, blank=True)
a84fce1b1a98 dd some fields to slide model
rougeronj
parents: 16
diff changeset
    27
    image = models.URLField(max_length=2048, blank=True)
45
19f3f0a7fbd7 add idInventory for slides saved from a research and not coming from Jamespot
rougeronj
parents: 21
diff changeset
    28
    date = models.DateTimeField(default=datetime.datetime.now)
13
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
    29
    favorite = models.BooleanField(default=False, db_index=True)
71
a5dedc11ba8f add parent_visit attribute to model to identify a book created by user and a book from Jamespot
rougeronj
parents: 63
diff changeset
    30
    tags = TaggableManager()
13
08f34bbc70ee set up django rest framework
rougeronj
parents:
diff changeset
    31
    
14
4d27fbc3f9df Succed to get the books from our api server and print them dynamically
rougeronj
parents: 13
diff changeset
    32
    def __str__(self):
20
a84fce1b1a98 dd some fields to slide model
rougeronj
parents: 16
diff changeset
    33
        return self.idStop
a84fce1b1a98 dd some fields to slide model
rougeronj
parents: 16
diff changeset
    34
    
a84fce1b1a98 dd some fields to slide model
rougeronj
parents: 16
diff changeset
    35
    class Meta:
a84fce1b1a98 dd some fields to slide model
rougeronj
parents: 16
diff changeset
    36
        order_with_respect_to = 'book'