src/p4l/models/data.py
author ymh <ymh.work@gmail.com>
Fri, 11 Oct 2013 14:34:20 +0200
changeset 148 a998cf036d15
parent 131 f1854630734f
permissions -rw-r--r--
Merge pull request #8 https://github.com/IRI-Research/plan4learning/pull/8 : Ordre des champs - traduction des libellés - restriction des langues
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
# -*- coding: utf-8 -*-
126
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
     2
#
131
f1854630734f change copyright notice
ymh <ymh.work@gmail.com>
parents: 126
diff changeset
     3
# Copyright IRI (c) 2013
126
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
     4
#
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
     5
# contact@iri.centrepompidou.fr
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
     6
#
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
     7
# This software is governed by the CeCILL-B license under French law and
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
     8
# abiding by the rules of distribution of free software.  You can  use, 
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
     9
# modify and/ or redistribute the software under the terms of the CeCILL-B
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    10
# license as circulated by CEA, CNRS and INRIA at the following URL
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    11
# "http://www.cecill.info". 
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    12
#
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    13
# As a counterpart to the access to the source code and  rights to copy,
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    14
# modify and redistribute granted by the license, users are provided only
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    15
# with a limited warranty  and the software's author,  the holder of the
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    16
# economic rights,  and the successive licensors  have only  limited
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    17
# liability. 
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    18
#
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    19
# In this respect, the user's attention is drawn to the risks associated
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    20
# with loading,  using,  modifying and/or developing or reproducing the
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    21
# software by the user in light of its specific status of free software,
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    22
# that may mean  that it is complicated to manipulate,  and  that  also
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    23
# therefore means  that it is reserved for developers  and  experienced
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    24
# professionals having in-depth computer knowledge. Users are therefore
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    25
# encouraged to load and test the software's suitability as regards their
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    26
# requirements in conditions enabling the security of their systems and/or 
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    27
# data to be ensured and,  more generally, to use and operate it in the 
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    28
# same conditions as regards security. 
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    29
#
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    30
# The fact that you are presently reading this means that you have had
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    31
# knowledge of the CeCILL-B license and that you accept its terms.
a345f1a67bf1 Python licence headers
ymh <ymh.work@gmail.com>
parents: 114
diff changeset
    32
#
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
from django.db import models
104
b66ca6275115 add creation + modification fields
ymh <ymh.work@gmail.com>
parents: 102
diff changeset
    35
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
from p4l.models.common import P4lModel, P4lModelLang
104
b66ca6275115 add creation + modification fields
ymh <ymh.work@gmail.com>
parents: 102
diff changeset
    37
from p4l.models.user import User
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
class Imprint(P4lModelLang):
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
    record = models.ForeignKey('p4l.Record', related_name="imprints")
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
    imprintCity = models.CharField(max_length=512, blank=True, null=True, db_index=True)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
    publisher = models.CharField(max_length=512, blank=True, null=True, db_index=True)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
    imprintDate = models.CharField(max_length=512, blank=True, null=True, db_index=True)    
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
    47
class Serie(P4lModelLang):
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
    48
    record = models.ForeignKey('p4l.Record', related_name="series")
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
    title = models.CharField(max_length=2048, blank=False, null=False, db_index=True)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
    volume = models.CharField(max_length=2048, blank=True, null=True, db_index=True)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
class ProjectName(P4lModel):
14
52fa6990e0bb adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents: 13
diff changeset
    54
    uri = models.URLField(max_length=2048, unique=True, db_index=True) 
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
class CorporateAuthor(P4lModel):
14
52fa6990e0bb adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents: 13
diff changeset
    58
    uri = models.URLField(max_length=2048, unique=True, db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
class Url(P4lModel):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
    61
    record = models.ForeignKey('p4l.Record', related_name="urls", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
    address = models.CharField(max_length=2048, blank=False, null=False, db_index=True) #iiep:address
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
    display = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:display
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
class Subject(P4lModel):
14
52fa6990e0bb adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents: 13
diff changeset
    67
    uri = models.URLField(max_length=2048, unique=True, db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
class Theme(P4lModel):
14
52fa6990e0bb adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents: 13
diff changeset
    70
    uri = models.URLField(max_length=2048, unique=True, db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
class Country(P4lModel):
14
52fa6990e0bb adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents: 13
diff changeset
    73
    uri = models.URLField(max_length=2048, unique=True, db_index=True)
97
12bbec897e48 model change (again)
cavaliet
parents: 93
diff changeset
    74
12bbec897e48 model change (again)
cavaliet
parents: 93
diff changeset
    75
class Audience(P4lModel):
12bbec897e48 model change (again)
cavaliet
parents: 93
diff changeset
    76
    uri = models.URLField(max_length=2048, unique=True, db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
class Isbn(P4lModelLang):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
    80
    record = models.ForeignKey('p4l.Record', related_name="isbns", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
    isbn = models.CharField(max_length=128) #iiep:isbn
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
class Issn(P4lModelLang):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
    85
    record = models.ForeignKey('p4l.Record', related_name="issns", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
    issn = models.CharField(max_length=128) #iiep:issn
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
class DocumentCode(P4lModelLang):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
    89
    record = models.ForeignKey('p4l.Record', related_name="documentCodes", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
    documentCode = models.CharField(max_length=128) #iiep:issn
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
class Language(P4lModel):
14
52fa6990e0bb adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents: 13
diff changeset
    93
    uri = models.URLField(max_length=2048, unique=True, db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
class BaseTitle(P4lModelLang):
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
    title = models.CharField(max_length=2048, blank=False, null=False, db_index=True)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
    class Meta(P4lModelLang.Meta):
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
        abstract = True
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
class Title(BaseTitle):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   101
    record = models.ForeignKey('p4l.Record', related_name="titles", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
class AddedTitle(BaseTitle):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   104
    record = models.ForeignKey('p4l.Record', related_name="addedTitles", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
class TitleMainDocument(BaseTitle):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   107
    record = models.ForeignKey('p4l.Record', related_name="titlesMainDocument", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
class Abstract(P4lModelLang):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   111
    record = models.ForeignKey('p4l.Record', related_name="abstracts", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
    abstract = models.TextField(blank=True, null=True)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
class Collation(P4lModelLang):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   116
    record = models.ForeignKey('p4l.Record', related_name="collations", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
    collation = models.CharField(max_length=1024, blank=False, null=False, db_index=True)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
class VolumeIssue(P4lModelLang):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   121
    record = models.ForeignKey('p4l.Record', related_name="volumeIssues", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
    volume = models.CharField(max_length=1024, blank=True, null=True, db_index=True) #iiep:volume
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
    number = models.CharField(max_length=1024, blank=True, null=True, db_index=True) #iiep:number
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
class P4lPerson(P4lModel):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   127
    name = models.CharField(max_length=2048, blank=False, null=False, db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
    class Meta(P4lModel.Meta):
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
        abstract = True
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
class Author(P4lPerson):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   133
    record = models.ForeignKey('p4l.Record', related_name="authors", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
    
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
class SubjectPerson(P4lPerson):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   136
    record = models.ForeignKey('p4l.Record', related_name="subjectPersons", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   138
class Periodical(P4lModelLang):
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   139
    record = models.ForeignKey('p4l.Record', related_name="periodicals", db_index=True)
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   140
    label = models.CharField(max_length=2048, blank=False, null=False, db_index=True) #iiep:periodical
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
class BaseMeeting(P4lModel):
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
    label = models.CharField(max_length=2048, blank=False, null=False, db_index=True) #rdfs:label
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
    meetingNumber = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:meetingNumber
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
    meetingPlace = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:meetingPlace
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
    meetingDate = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:meetingDate
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
    meetingYear = models.PositiveSmallIntegerField(blank=True, null=True, db_index=True) #iiep:meetingYear
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
    class Meta(P4lModel.Meta):
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
        abstract = True
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
class Meeting(BaseMeeting):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   154
    lang = models.CharField(max_length=15, blank=True, null=True, db_index=True) #@xml:lang
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   155
    record = models.ForeignKey('p4l.Record', related_name="meetings")
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
class SubjectMeeting(BaseMeeting):
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   159
    record = models.ForeignKey('p4l.Record', related_name="subjectMeetings", db_index=True)
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
class Record(P4lModel):
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
    uri = models.URLField(max_length=2048, unique=True, db_index=True) #subject
17
b31a67614f76 fill labels with sparql request on the go
cavaliet
parents: 14
diff changeset
   164
    subjects = models.ManyToManyField('p4l.Subject') #dct:subject                                                       # <Thesaurus> with no country
b31a67614f76 fill labels with sparql request on the go
cavaliet
parents: 14
diff changeset
   165
    themes = models.ManyToManyField('p4l.Theme') #iiep:theme                                                            # <Themes>
b31a67614f76 fill labels with sparql request on the go
cavaliet
parents: 14
diff changeset
   166
    countries = models.ManyToManyField('p4l.Country') #iiep:country                                                     # <Thesaurus> filtered with country only
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
    identifier = models.CharField(max_length=128, unique=True, db_index=True) #dct:identifier    
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
    notes = models.TextField(blank=True, null=True) #iiep:notes    
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
    #issns foreign key from Isbn #iiep:issn
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
    #isbns foreign key from Isbn #iiep:isbn
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
    #documentCodes foreign key from Isbn #iiep:documentCode
17
b31a67614f76 fill labels with sparql request on the go
cavaliet
parents: 14
diff changeset
   172
    language = models.ForeignKey('p4l.Language', blank=True, null=True) #dct:language                                    # <Languages>
b31a67614f76 fill labels with sparql request on the go
cavaliet
parents: 14
diff changeset
   173
    otherLanguages = models.ManyToManyField('p4l.Language', related_name='otherLanguage_record') #iiep:otherLanguage     # <Languages>
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
    #titles foreign Key from Title #dct:title
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   175
    #abstracts foreign Key from Abstract #dct:abstract
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
    #addedTitles foreign Key from AddedTitle #iiep:addedTitle
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
    #titlesMainDocument foreign Key from TitleMainDocument #iiep:titleMainDocument
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
    editionStatement = models.CharField(max_length=1024, blank=True, null=True) #iiep:editionStatement
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
    #imprints foreign Key from Imprint #iiep:imprint
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
    #collations = foreign Key from Collation #iiep:collation
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
    #volumeIssues = foreign Key from VolumeIssue #iiep:volumeIssue
17
b31a67614f76 fill labels with sparql request on the go
cavaliet
parents: 14
diff changeset
   182
    projectNames = models.ManyToManyField('p4l.ProjectName') #iiep:projectName                                            # <Projects>
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   183
    #periodicals = foreign key from 'p4l.Periodical' #iiep:periodical
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   184
    #meetings = foreign key from 'p4l.Meeting' #iiep:meeting
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   185
    #series = foreign key from 'p4l.Serie'  #iiep:serie
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   186
    #authors = foreign key from 'p4l.Author' #iiep:author
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   187
    #subjectPersons = foreign key from 'p4l.SubjectPerson' #iiep:subjectPerson
17
b31a67614f76 fill labels with sparql request on the go
cavaliet
parents: 14
diff changeset
   188
    subjectCorporateBodies = models.ManyToManyField('p4l.CorporateAuthor', related_name='recordsSubjectCorporateBody') #iiep:subjectCorporateBody # <Organizations>
13
6296aa12fd71 model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents: 10
diff changeset
   189
    #subjectMeetings = foreign key from 'p4l.SubjectMeeting' #iiep:subjectMeeting
17
b31a67614f76 fill labels with sparql request on the go
cavaliet
parents: 14
diff changeset
   190
    corporateAuthors = models.ManyToManyField('p4l.CorporateAuthor', related_name='recordsCorporateAuthor') #iiep:subjectCorporateBody # <Organizations>
97
12bbec897e48 model change (again)
cavaliet
parents: 93
diff changeset
   191
    corporateAuthorLabel = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:corporateAuthorLabel
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
    #urls foreign Key from Url #iiep:url
100
5b076700ac05 Debug and coherent field names
cavaliet
parents: 97
diff changeset
   193
    audiences = models.ManyToManyField('p4l.Audience') #dct:audience                                                      # Unknown thesaurus
97
12bbec897e48 model change (again)
cavaliet
parents: 93
diff changeset
   194
    recordType = models.URLField(max_length=2048, blank=True, null=True) #dct:type                                        # <DocumentType>
14
52fa6990e0bb adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents: 13
diff changeset
   195
    
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
    isDocumentPart = models.BooleanField() #iiep:isDocumentPart
100
5b076700ac05 Debug and coherent field names
cavaliet
parents: 97
diff changeset
   197
    hidden = models.BooleanField(default=False) #iiep:hidden
5b076700ac05 Debug and coherent field names
cavaliet
parents: 97
diff changeset
   198
    restricted = models.BooleanField(default=False) #iiep:restricted
75
eb6530b77b0e Add years in list view
ymh <ymh.work@gmail.com>
parents: 62
diff changeset
   199
    
104
b66ca6275115 add creation + modification fields
ymh <ymh.work@gmail.com>
parents: 102
diff changeset
   200
    #Record import date and modification date
108
c08f9b46a6c5 use PEP8 convention on system fields for Records
ymh <ymh.work@gmail.com>
parents: 104
diff changeset
   201
    creation_date = models.DateTimeField( auto_now_add=True, serialize=False)
c08f9b46a6c5 use PEP8 convention on system fields for Records
ymh <ymh.work@gmail.com>
parents: 104
diff changeset
   202
    modification_date = models.DateTimeField(auto_now=True, serialize=False)
c08f9b46a6c5 use PEP8 convention on system fields for Records
ymh <ymh.work@gmail.com>
parents: 104
diff changeset
   203
    modified_by = models.ForeignKey(User, blank=True, null=True)
104
b66ca6275115 add creation + modification fields
ymh <ymh.work@gmail.com>
parents: 102
diff changeset
   204
    
113
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents: 108
diff changeset
   205
    def get_titles(self):
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents: 108
diff changeset
   206
        return [t.title for t in self.titles.all()]
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents: 108
diff changeset
   207
    
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents: 108
diff changeset
   208
    def get_authors(self):
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents: 108
diff changeset
   209
        return [a.name for a in self.authors.all()]
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents: 108
diff changeset
   210
    
114
93b45b4f423c add corporate authors and small adjustments
ymh <ymh.work@gmail.com>
parents: 113
diff changeset
   211
    def get_corporate_authors(self):
93b45b4f423c add corporate authors and small adjustments
ymh <ymh.work@gmail.com>
parents: 113
diff changeset
   212
        return [c.uri for c in self.corporateAuthors.all()]
93b45b4f423c add corporate authors and small adjustments
ymh <ymh.work@gmail.com>
parents: 113
diff changeset
   213
    
75
eb6530b77b0e Add years in list view
ymh <ymh.work@gmail.com>
parents: 62
diff changeset
   214
    def get_imprints_years(self):
77
15b34232100d Make sure we do not takes null or empty values
ymh <ymh.work@gmail.com>
parents: 76
diff changeset
   215
        return sorted(set([i.imprintDate for i in self.imprints.all() if i.imprintDate]))
0
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
    def __unicode__(self):
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
        return "Record id %s { identifier: %s, uri: %s, editionStatement: %s,  recordType: %s, isDocumentPart: %s, notes: %s, language : %s}" \
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
            % (
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
                self.id,
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
                self.identifier,
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
                self.uri,
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
                self.editionStatement,
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
                self.recordType,
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
                self.isDocumentPart,
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
                self.notes[:100] if self.notes else None,
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
                self.language.id if self.language else None
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
            )
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}issn', 3)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}documentCode', 3)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}country', 44)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}imprint', 5)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
#('{http://purl.org/dc/terms/}title', 4)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}isDocumentPart', 1)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}notes', 1)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}isbn', 8)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
#('{http://purl.org/dc/terms/}identifier', 1)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}meeting', 4)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}projectName', 10)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}addedTitle', 18)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
#('{http://purl.org/dc/terms/}subject', 29)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
#('{http://purl.org/dc/terms/}language', 1)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}serie', 4)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}volumeIssue', 3)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}url', 20)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}titleMainDocument', 3)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}otherLanguage', 13)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}periodical', 3)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}editionStatement', 1)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}collation', 4)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}subjectMeeting', 6)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}corporateAuthor', 7)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}author', 26)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}subjectPerson', 2)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}subjectCorporateBody', 8)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}theme', 6)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
#('{http://purl.org/dc/terms/}abstract', 3)
81e7900b06a7 First import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
#('{http://purl.org/dc/terms/}type', 1)