| author | ymh <ymh.work@gmail.com> |
| Sat, 21 Sep 2013 23:49:04 +0200 | |
| changeset 114 | 93b45b4f423c |
| parent 113 | c05567404888 |
| child 126 | a345f1a67bf1 |
| permissions | -rw-r--r-- |
| 0 | 1 |
# -*- coding: utf-8 -*- |
2 |
||
3 |
from django.db import models |
|
|
104
b66ca6275115
add creation + modification fields
ymh <ymh.work@gmail.com>
parents:
102
diff
changeset
|
4 |
|
| 0 | 5 |
from p4l.models.common import P4lModel, P4lModelLang |
|
104
b66ca6275115
add creation + modification fields
ymh <ymh.work@gmail.com>
parents:
102
diff
changeset
|
6 |
from p4l.models.user import User |
| 0 | 7 |
|
8 |
||
9 |
class Imprint(P4lModelLang): |
|
10 |
record = models.ForeignKey('p4l.Record', related_name="imprints") |
|
11 |
imprintCity = models.CharField(max_length=512, blank=True, null=True, db_index=True) |
|
12 |
publisher = models.CharField(max_length=512, blank=True, null=True, db_index=True) |
|
13 |
imprintDate = models.CharField(max_length=512, blank=True, null=True, db_index=True) |
|
14 |
||
15 |
||
|
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
|
16 |
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
|
17 |
record = models.ForeignKey('p4l.Record', related_name="series") |
| 0 | 18 |
title = models.CharField(max_length=2048, blank=False, null=False, db_index=True) |
19 |
volume = models.CharField(max_length=2048, blank=True, null=True, db_index=True) |
|
20 |
||
21 |
||
22 |
class ProjectName(P4lModel): |
|
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
23 |
uri = models.URLField(max_length=2048, unique=True, db_index=True) |
| 0 | 24 |
|
25 |
||
26 |
class CorporateAuthor(P4lModel): |
|
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
27 |
uri = models.URLField(max_length=2048, unique=True, db_index=True) |
| 0 | 28 |
|
29 |
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
|
30 |
record = models.ForeignKey('p4l.Record', related_name="urls", db_index=True) |
| 0 | 31 |
address = models.CharField(max_length=2048, blank=False, null=False, db_index=True) #iiep:address |
32 |
display = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:display |
|
33 |
||
34 |
||
35 |
class Subject(P4lModel): |
|
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
36 |
uri = models.URLField(max_length=2048, unique=True, db_index=True) |
| 0 | 37 |
|
38 |
class Theme(P4lModel): |
|
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
39 |
uri = models.URLField(max_length=2048, unique=True, db_index=True) |
| 0 | 40 |
|
41 |
class Country(P4lModel): |
|
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
42 |
uri = models.URLField(max_length=2048, unique=True, db_index=True) |
| 97 | 43 |
|
44 |
class Audience(P4lModel): |
|
45 |
uri = models.URLField(max_length=2048, unique=True, db_index=True) |
|
| 0 | 46 |
|
47 |
||
48 |
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
|
49 |
record = models.ForeignKey('p4l.Record', related_name="isbns", db_index=True) |
| 0 | 50 |
isbn = models.CharField(max_length=128) #iiep:isbn |
51 |
||
52 |
||
53 |
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
|
54 |
record = models.ForeignKey('p4l.Record', related_name="issns", db_index=True) |
| 0 | 55 |
issn = models.CharField(max_length=128) #iiep:issn |
56 |
||
57 |
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
|
58 |
record = models.ForeignKey('p4l.Record', related_name="documentCodes", db_index=True) |
| 0 | 59 |
documentCode = models.CharField(max_length=128) #iiep:issn |
60 |
||
61 |
class Language(P4lModel): |
|
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
62 |
uri = models.URLField(max_length=2048, unique=True, db_index=True) |
| 0 | 63 |
|
64 |
class BaseTitle(P4lModelLang): |
|
65 |
title = models.CharField(max_length=2048, blank=False, null=False, db_index=True) |
|
66 |
class Meta(P4lModelLang.Meta): |
|
67 |
abstract = True |
|
68 |
||
69 |
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
|
70 |
record = models.ForeignKey('p4l.Record', related_name="titles", db_index=True) |
| 0 | 71 |
|
72 |
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
|
73 |
record = models.ForeignKey('p4l.Record', related_name="addedTitles", db_index=True) |
| 0 | 74 |
|
75 |
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
|
76 |
record = models.ForeignKey('p4l.Record', related_name="titlesMainDocument", db_index=True) |
| 0 | 77 |
|
78 |
||
79 |
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
|
80 |
record = models.ForeignKey('p4l.Record', related_name="abstracts", db_index=True) |
| 0 | 81 |
abstract = models.TextField(blank=True, null=True) |
82 |
||
83 |
||
84 |
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
|
85 |
record = models.ForeignKey('p4l.Record', related_name="collations", db_index=True) |
| 0 | 86 |
collation = models.CharField(max_length=1024, blank=False, null=False, db_index=True) |
87 |
||
88 |
||
89 |
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
|
90 |
record = models.ForeignKey('p4l.Record', related_name="volumeIssues", db_index=True) |
| 0 | 91 |
volume = models.CharField(max_length=1024, blank=True, null=True, db_index=True) #iiep:volume |
92 |
number = models.CharField(max_length=1024, blank=True, null=True, db_index=True) #iiep:number |
|
93 |
||
94 |
||
95 |
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
|
96 |
name = models.CharField(max_length=2048, blank=False, null=False, db_index=True) |
| 0 | 97 |
class Meta(P4lModel.Meta): |
98 |
abstract = True |
|
99 |
||
100 |
||
101 |
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
|
102 |
record = models.ForeignKey('p4l.Record', related_name="authors", db_index=True) |
| 0 | 103 |
|
104 |
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
|
105 |
record = models.ForeignKey('p4l.Record', related_name="subjectPersons", db_index=True) |
| 0 | 106 |
|
|
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 |
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
|
108 |
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
|
109 |
label = models.CharField(max_length=2048, blank=False, null=False, db_index=True) #iiep:periodical |
| 0 | 110 |
|
111 |
||
112 |
class BaseMeeting(P4lModel): |
|
113 |
label = models.CharField(max_length=2048, blank=False, null=False, db_index=True) #rdfs:label |
|
114 |
meetingNumber = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:meetingNumber |
|
115 |
meetingPlace = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:meetingPlace |
|
116 |
meetingDate = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:meetingDate |
|
117 |
meetingYear = models.PositiveSmallIntegerField(blank=True, null=True, db_index=True) #iiep:meetingYear |
|
118 |
class Meta(P4lModel.Meta): |
|
119 |
abstract = True |
|
120 |
||
121 |
||
122 |
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
|
123 |
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
|
124 |
record = models.ForeignKey('p4l.Record', related_name="meetings") |
| 0 | 125 |
|
126 |
||
127 |
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
|
128 |
record = models.ForeignKey('p4l.Record', related_name="subjectMeetings", db_index=True) |
| 0 | 129 |
|
130 |
||
131 |
class Record(P4lModel): |
|
132 |
uri = models.URLField(max_length=2048, unique=True, db_index=True) #subject |
|
| 17 | 133 |
subjects = models.ManyToManyField('p4l.Subject') #dct:subject # <Thesaurus> with no country |
134 |
themes = models.ManyToManyField('p4l.Theme') #iiep:theme # <Themes> |
|
135 |
countries = models.ManyToManyField('p4l.Country') #iiep:country # <Thesaurus> filtered with country only |
|
| 0 | 136 |
identifier = models.CharField(max_length=128, unique=True, db_index=True) #dct:identifier |
137 |
notes = models.TextField(blank=True, null=True) #iiep:notes |
|
138 |
#issns foreign key from Isbn #iiep:issn |
|
139 |
#isbns foreign key from Isbn #iiep:isbn |
|
140 |
#documentCodes foreign key from Isbn #iiep:documentCode |
|
| 17 | 141 |
language = models.ForeignKey('p4l.Language', blank=True, null=True) #dct:language # <Languages> |
142 |
otherLanguages = models.ManyToManyField('p4l.Language', related_name='otherLanguage_record') #iiep:otherLanguage # <Languages> |
|
| 0 | 143 |
#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
|
144 |
#abstracts foreign Key from Abstract #dct:abstract |
| 0 | 145 |
#addedTitles foreign Key from AddedTitle #iiep:addedTitle |
146 |
#titlesMainDocument foreign Key from TitleMainDocument #iiep:titleMainDocument |
|
147 |
editionStatement = models.CharField(max_length=1024, blank=True, null=True) #iiep:editionStatement |
|
148 |
#imprints foreign Key from Imprint #iiep:imprint |
|
149 |
#collations = foreign Key from Collation #iiep:collation |
|
150 |
#volumeIssues = foreign Key from VolumeIssue #iiep:volumeIssue |
|
| 17 | 151 |
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
|
152 |
#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
|
153 |
#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
|
154 |
#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
|
155 |
#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
|
156 |
#subjectPersons = foreign key from 'p4l.SubjectPerson' #iiep:subjectPerson |
| 17 | 157 |
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
|
158 |
#subjectMeetings = foreign key from 'p4l.SubjectMeeting' #iiep:subjectMeeting |
| 17 | 159 |
corporateAuthors = models.ManyToManyField('p4l.CorporateAuthor', related_name='recordsCorporateAuthor') #iiep:subjectCorporateBody # <Organizations> |
| 97 | 160 |
corporateAuthorLabel = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:corporateAuthorLabel |
| 0 | 161 |
#urls foreign Key from Url #iiep:url |
| 100 | 162 |
audiences = models.ManyToManyField('p4l.Audience') #dct:audience # Unknown thesaurus |
| 97 | 163 |
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
|
164 |
|
| 0 | 165 |
isDocumentPart = models.BooleanField() #iiep:isDocumentPart |
| 100 | 166 |
hidden = models.BooleanField(default=False) #iiep:hidden |
167 |
restricted = models.BooleanField(default=False) #iiep:restricted |
|
| 75 | 168 |
|
|
104
b66ca6275115
add creation + modification fields
ymh <ymh.work@gmail.com>
parents:
102
diff
changeset
|
169 |
#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
|
170 |
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
|
171 |
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
|
172 |
modified_by = models.ForeignKey(User, blank=True, null=True) |
|
104
b66ca6275115
add creation + modification fields
ymh <ymh.work@gmail.com>
parents:
102
diff
changeset
|
173 |
|
|
113
c05567404888
First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
108
diff
changeset
|
174 |
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
|
175 |
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
|
176 |
|
|
c05567404888
First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
108
diff
changeset
|
177 |
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
|
178 |
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
|
179 |
|
|
114
93b45b4f423c
add corporate authors and small adjustments
ymh <ymh.work@gmail.com>
parents:
113
diff
changeset
|
180 |
def get_corporate_authors(self): |
|
93b45b4f423c
add corporate authors and small adjustments
ymh <ymh.work@gmail.com>
parents:
113
diff
changeset
|
181 |
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
|
182 |
|
| 75 | 183 |
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
|
184 |
return sorted(set([i.imprintDate for i in self.imprints.all() if i.imprintDate])) |
| 0 | 185 |
|
186 |
def __unicode__(self): |
|
187 |
return "Record id %s { identifier: %s, uri: %s, editionStatement: %s, recordType: %s, isDocumentPart: %s, notes: %s, language : %s}" \ |
|
188 |
% ( |
|
189 |
self.id, |
|
190 |
self.identifier, |
|
191 |
self.uri, |
|
192 |
self.editionStatement, |
|
193 |
self.recordType, |
|
194 |
self.isDocumentPart, |
|
195 |
self.notes[:100] if self.notes else None, |
|
196 |
self.language.id if self.language else None |
|
197 |
) |
|
198 |
||
199 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}issn', 3) |
|
200 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}documentCode', 3) |
|
201 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}country', 44) |
|
202 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}imprint', 5) |
|
203 |
#('{http://purl.org/dc/terms/}title', 4) |
|
204 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}isDocumentPart', 1) |
|
205 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}notes', 1) |
|
206 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}isbn', 8) |
|
207 |
#('{http://purl.org/dc/terms/}identifier', 1) |
|
208 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}meeting', 4) |
|
209 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}projectName', 10) |
|
210 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}addedTitle', 18) |
|
211 |
#('{http://purl.org/dc/terms/}subject', 29) |
|
212 |
#('{http://purl.org/dc/terms/}language', 1) |
|
213 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}serie', 4) |
|
214 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}volumeIssue', 3) |
|
215 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}url', 20) |
|
216 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}titleMainDocument', 3) |
|
217 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}otherLanguage', 13) |
|
218 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}periodical', 3) |
|
219 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}editionStatement', 1) |
|
220 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}collation', 4) |
|
221 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}subjectMeeting', 6) |
|
222 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}corporateAuthor', 7) |
|
223 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}author', 26) |
|
224 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}subjectPerson', 2) |
|
225 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}subjectCorporateBody', 8) |
|
226 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}theme', 6) |
|
227 |
#('{http://purl.org/dc/terms/}abstract', 3) |
|
228 |
#('{http://purl.org/dc/terms/}type', 1) |