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