51 return self.description_pertimm.split(",") |
51 return self.description_pertimm.split(",") |
52 |
52 |
53 @property |
53 @property |
54 def thesaurus_pertimm_list(self): |
54 def thesaurus_pertimm_list(self): |
55 return self.thesaurus_pertimm.replace("|", ",").split(",") |
55 return self.thesaurus_pertimm.replace("|", ",").split(",") |
|
56 |
|
57 @property |
|
58 def tags(self): |
|
59 # all keywords mots_cles + titre_pertimm+ description_pertimm + thesaurus_pertimmreturn |
|
60 # merged into one sorted list |
|
61 moc = self.mots_cles.split(",") |
|
62 tip = self.titre_pertimm.split(",") |
|
63 dep = self.description_pertimm.split(",") |
|
64 thp = self.thesaurus_pertimm.replace("|", ",").split(",") |
|
65 # sort by alphabetical order (sorted) and remove duplicates (set) |
|
66 l = sorted(list(set(moc + tip + dep + thp)), key=unicode.lower) |
|
67 return l |
56 |
68 |
57 |
69 |
58 class ImageInfo(models.Model): |
70 class ImageInfo(models.Model): |
59 |
71 |
60 id = models.CharField(null=False, blank=False, max_length=15, primary_key=True) |
72 id = models.CharField(null=False, blank=False, max_length=15, primary_key=True) |
139 # If fragment w > h, we center the fragment on y ... |
151 # If fragment w > h, we center the fragment on y ... |
140 vb_y = max(0, vb_y - (((vb_w * img_ratio) - vb_h) / 2)) |
152 vb_y = max(0, vb_y - (((vb_w * img_ratio) - vb_h) / 2)) |
141 # ... and resize the viewbox's h with image's ratio |
153 # ... and resize the viewbox's h with image's ratio |
142 vb_h = vb_w * img_ratio |
154 vb_h = vb_w * img_ratio |
143 else: |
155 else: |
144 # If fragment w > h, we center the fragment on x ... |
156 # If fragment w <= h, we center the fragment on x ... |
145 vb_x = max(0, vb_x - (((vb_h / img_ratio) - vb_w) / 2)) |
157 vb_x = max(0, vb_x - (((vb_h / img_ratio) - vb_w) / 2)) |
146 # ... and we resize the viewbox's w with image's ratio |
158 # ... and we resize the viewbox's w with image's ratio |
147 vb_w = vb_h / img_ratio |
159 vb_w = vb_h / img_ratio |
148 vb = str(vb_x) + " " + str(vb_y) + " " + str(vb_w) + " " + str(vb_h) |
160 vb = str(vb_x) + " " + str(vb_y) + " " + str(vb_w) + " " + str(vb_h) |
149 |
161 |
150 return vb |
162 return vb |
|
163 |
151 |
164 |
|
165 class Collection(models.Model): |
|
166 |
|
167 SLIDESHOW = 1 |
|
168 MOSAIC = 2 |
|
169 GEOGRAPHICAL = 3 |
|
170 |
|
171 STATE_CHOICES = ( |
|
172 (SLIDESHOW, 'slideshow'), |
|
173 (MOSAIC, 'mosaic'), |
|
174 (GEOGRAPHICAL, 'geographical') |
|
175 ) |
|
176 |
|
177 |
|
178 title = models.CharField(max_length=2048, blank=True, null=True) |
|
179 description = models.TextField(blank=True, null=True) |
|
180 author = models.ForeignKey(User, blank=False, null=False) |
|
181 creation = models.DateTimeField(auto_now_add=True) |
|
182 modification = models.DateTimeField(auto_now=True) |
|
183 public = models.BooleanField(null=False, default=True) # Collection is published or not, always published by default |
|
184 |
|
185 |
|
186 |
|
187 |