| author | ymh <ymh.work@gmail.com> |
| Wed, 11 Apr 2018 12:19:47 +0200 | |
| branch | documentation |
| changeset 693 | 09e00f38d177 |
| parent 614 | 40e125004a0b |
| permissions | -rw-r--r-- |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
# -*- coding: utf-8 -*- |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
''' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
Created on Jan 27, 2012 |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
@author: ymh |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
''' |
|
353
91c44b3fd11f
Correcterrors on missing dbpedia informations
ymh <ymh.work@gmail.com>
parents:
279
diff
changeset
|
7 |
from hdabo.models import Tag, Datasheet |
|
91c44b3fd11f
Correcterrors on missing dbpedia informations
ymh <ymh.work@gmail.com>
parents:
279
diff
changeset
|
8 |
from hdalab import fields |
|
91c44b3fd11f
Correcterrors on missing dbpedia informations
ymh <ymh.work@gmail.com>
parents:
279
diff
changeset
|
9 |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
from django.db import models |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
class TagYears(models.Model): |
| 693 | 14 |
""" |
15 |
Représente une période (début - fin) associée à un Tag. |
|
16 |
||
17 |
:cvar object tag: Le tag |
|
18 |
:cvar int start_year: L'année de début de la période. |
|
19 |
:cvar int end_year: L'année de fin de période. |
|
20 |
""" |
|
|
614
40e125004a0b
integrate last changes from mcc + finish 1.8 mig + remove some warning
ymh <ymh.work@gmail.com>
parents:
359
diff
changeset
|
21 |
tag = models.OneToOneField(Tag, related_name="years", blank=False, null=False, db_index=True) |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
start_year = models.IntegerField(blank=False, null=False, db_index=True) |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
end_year = models.IntegerField(blank=False, null=False, db_index=True) |
| 693 | 24 |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
class Meta: |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
app_label = 'hdalab' |
| 693 | 27 |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
class TagLinks(models.Model): |
| 693 | 30 |
""" |
31 |
Représente un lien entre tag. |
|
32 |
||
33 |
:cvar object subject: Le tag sujet (source) du lien. |
|
34 |
:cvar object object: Le tag object (cible) du lien. |
|
35 |
""" |
|
36 |
||
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
subject = models.ForeignKey(Tag, blank=False, null=False, db_index=True, related_name="taglinks_subjects") |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
object = models.ForeignKey(Tag, blank=False, null=False, db_index=True, related_name="taglinks_objects") |
| 693 | 39 |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |
class Meta: |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
app_label = 'hdalab' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
|
|
122
fde8335a037c
Added Geographic Inclusion in the Django version (server only)
veltr
parents:
119
diff
changeset
|
43 |
class Country(models.Model): |
| 693 | 44 |
""" |
45 |
Représente un pays. |
|
46 |
||
47 |
:cvar str dbpedia_uri: L'URI DBPedia de ce pays. |
|
48 |
""" |
|
49 |
||
|
279
177b508612f4
add, configure and correct hdalab to installed apps
cavaliet
parents:
272
diff
changeset
|
50 |
dbpedia_uri = models.URLField(max_length=255, blank=False, null=False, db_index=True, unique=True) |
| 693 | 51 |
|
|
122
fde8335a037c
Added Geographic Inclusion in the Django version (server only)
veltr
parents:
119
diff
changeset
|
52 |
class Meta: |
|
fde8335a037c
Added Geographic Inclusion in the Django version (server only)
veltr
parents:
119
diff
changeset
|
53 |
app_label = 'hdalab' |
|
fde8335a037c
Added Geographic Inclusion in the Django version (server only)
veltr
parents:
119
diff
changeset
|
54 |
|
|
fde8335a037c
Added Geographic Inclusion in the Django version (server only)
veltr
parents:
119
diff
changeset
|
55 |
class GeoInclusion(models.Model): |
| 693 | 56 |
""" |
57 |
Représente une relation entre un tag et un pays. (par exemple, le tage "Paris" est inclus dans le pays "France") |
|
58 |
Un tag ne peut être relié qu'a un seul pays. |
|
59 |
||
60 |
:cvar object tag: le tag. |
|
61 |
:cvar object country: Le pays. |
|
62 |
||
63 |
""" |
|
64 |
||
|
122
fde8335a037c
Added Geographic Inclusion in the Django version (server only)
veltr
parents:
119
diff
changeset
|
65 |
tag = models.OneToOneField(Tag, related_name="locatedin", db_index=True) |
|
fde8335a037c
Added Geographic Inclusion in the Django version (server only)
veltr
parents:
119
diff
changeset
|
66 |
country = models.ForeignKey(Country, blank=False, null=False, related_name="includes", db_index=True) |
| 693 | 67 |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
class Meta: |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
69 |
app_label = 'hdalab' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
70 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
71 |
class DbpediaFields(models.Model): |
| 693 | 72 |
""" |
73 |
Informations DBPedia pour un tag. |
|
74 |
Un tag ne peut être lié qu'à une seule instance de cette classe. |
|
75 |
||
76 |
:cvar str dbpedia_uri: L'URI DBPedia. |
|
77 |
:cvar object tag: Le tag. |
|
78 |
:cvar str abstract: Texte résumé du tag issu de DBPedia. |
|
79 |
:cvar str thumbnail: URL d'un thumbnail pour le tag. |
|
80 |
:cvar str label: Label DBPedia pour le tag. |
|
81 |
||
82 |
""" |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
83 |
|
|
279
177b508612f4
add, configure and correct hdalab to installed apps
cavaliet
parents:
272
diff
changeset
|
84 |
dbpedia_uri = models.URLField(max_length=2048, blank=False, null=False, db_index=True, unique=False) |
|
359
46ad324f6fe4
Correct qery_dbpedia and improve model.
ymh <ymh.work@gmail.com>
parents:
353
diff
changeset
|
85 |
tag = fields.OneToOneField(Tag, db_index=True, related_name="dbpedia_fields", related_default=lambda instance: None) |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
abstract = models.TextField(blank=True, null=True) |
| 693 | 87 |
thumbnail = models.URLField(max_length=2048, blank=True, null=True, db_index=False) |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
88 |
label = models.CharField(max_length=2048, unique=False, blank=True, null=True) |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
89 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
90 |
class Meta: |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
91 |
app_label = 'hdalab' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
92 |
|
| 135 | 93 |
|
94 |
class DbpediaFieldsTranslation(models.Model): |
|
| 693 | 95 |
""" |
96 |
Les traductions pour un :class:DbpediaField. |
|
97 |
||
98 |
:cvar object master: Le DBPediafield |
|
99 |
:cvar str language_code: Le code de la langue de la traduction. |
|
100 |
:cvar str label: Le label traduit. Attention si une traduction du label n'a pas été trouvée, on trouvera là le même label que dans "master". |
|
101 |
:cvar str abstract: Le résumé traduit. Attention si une traduction du résumé n'a pas été trouvée, on trouvera là le même label que dans "master". |
|
102 |
:cvar bool is_label_translated: Indique si le label est effectivement traduit. |
|
103 |
:cvar bool is_abstract_translated: Indicque si le résumé est effectivement traduit. |
|
104 |
""" |
|
| 135 | 105 |
|
106 |
master = models.ForeignKey(DbpediaFields, blank=False, null=False, db_index=True, related_name="translations") |
|
107 |
language_code = models.CharField(max_length=15, blank=False, null=False, db_index=True) |
|
108 |
label = models.CharField(max_length=2048, unique=False, blank=True, null=False) |
|
109 |
abstract = models.TextField(blank=True, null=True) |
|
|
240
c8627191f2d7
add indication that the labels has been translated, and use sparql requests instead of full n3 download
ymh <ymh.work@gmail.com>
parents:
135
diff
changeset
|
110 |
is_label_translated = models.BooleanField(default=True) |
|
c8627191f2d7
add indication that the labels has been translated, and use sparql requests instead of full n3 download
ymh <ymh.work@gmail.com>
parents:
135
diff
changeset
|
111 |
is_abstract_translated = models.BooleanField(default=True) |
| 135 | 112 |
class Meta: |
113 |
app_label = 'hdalab' |
|
114 |
unique_together = ('master', 'language_code') |
|
115 |
||
116 |
||
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
class HdaSession(models.Model): |
| 693 | 118 |
""" |
119 |
Classe destinée à sauvagarder des session d'exploration sur HDALab (état de l'interface de recherche par facette). |
|
120 |
Cet objet n'est pas utilisé. |
|
121 |
""" |
|
122 |
||
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
sessionid = models.CharField(max_length=36, unique=True, blank=False, null=False, db_index=True) |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
data = models.TextField(blank=True, null=True) |
| 693 | 125 |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
class Meta: |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
app_label = 'hdalab' |
| 123 | 128 |
|
129 |
class InseeCoords(models.Model): |
|
| 693 | 130 |
""" |
131 |
Coordonnées géographiques et nom de l'entité pour un code INSEE. |
|
132 |
||
133 |
:cvar integer insee: code insee. |
|
134 |
:cvar str city_name: Nom de la commune. |
|
135 |
:cvar float latitude: Latitude. |
|
136 |
:cvar float longitude: Longitude. |
|
137 |
""" |
|
138 |
||
| 123 | 139 |
insee = models.IntegerField(primary_key=True) |
140 |
city_name = models.CharField(max_length=255, blank=False, null=False) |
|
141 |
latitude = models.FloatField(blank=False, null=False) |
|
142 |
longitude = models.FloatField(blank=False, null=False) |
|
| 693 | 143 |
|
| 123 | 144 |
class Meta: |
145 |
app_label = 'hdalab' |
|
146 |
||
147 |
class DatasheetExtras(models.Model): |
|
| 693 | 148 |
""" |
149 |
Information supplémentaire pour und fiche hda. |
|
150 |
||
151 |
:cvar object datasheet: La fiche HDA. |
|
152 |
:cvar object insee: Les information insee (:class:InseeCoords) pour la fiche. |
|
153 |
""" |
|
154 |
||
| 123 | 155 |
datasheet = models.OneToOneField(Datasheet, related_name="extras", db_index=True) |
156 |
insee = models.ForeignKey(InseeCoords, blank=True, null=True, db_index=True) |
|
| 693 | 157 |
|
| 123 | 158 |
class Meta: |
| 693 | 159 |
app_label = 'hdalab' |