updated indexes
authorHarris Baptiste <harris.baptiste@iri.centrepompidou.fr>
Fri, 12 Aug 2016 16:02:23 +0200
changeset 116 1e2caa72bf2f
parent 114 f0ce0058c09b
child 117 e4e85c5c0830
updated indexes
src/iconolab/models.py
src/iconolab/search_indexes/forms.py
src/iconolab/search_indexes/indexes.py
src/iconolab/templates/partials/header_search_form.html
src/iconolab/templates/search/indexes/iconolab/image_text.txt
--- a/src/iconolab/models.py	Fri Aug 12 11:10:42 2016 +0200
+++ b/src/iconolab/models.py	Fri Aug 12 16:02:23 2016 +0200
@@ -103,22 +103,51 @@
     height = models.IntegerField(null=False, blank=False)
     width = models.IntegerField(null=False, blank=False)
     created = models.DateTimeField(auto_now_add=True, null=True)
-    
-    def __str__(self):
-        return self.name
-    
+
     @property
     def collection(self):
         return self.item.collection.name
 
     @property
     def title(self):
-        return self.item.metadatas.title
+        return self.item.metadatas.designation
+
+    @property
+    def authors(self):
+        return self.item.metadatas.authors
+
+    @property
+    def school(self):
+        return self.item.metadatas.school
+        
+    @property
+    def designation(self):
+        return self.item.metadatas.designation
+
+    @property
+    def datation(self):
+        return self.item.metadatas.datation
     
     @property
-    def description(self):
-        return self.item.metadatas.description
+    def technics(self):
+        return self.item.metadatas.technics
+
+    @property
+    def measurements(self):
+        return self.item.metadatas.measurements
+
+    def __str__(self):
+        return self.name
 
+    @property
+    def tags(self):
+        tag_list = []
+        for annotation in self.annotations.all():
+            revision_tags = annotation.current_revision.tags.all()
+            tag_list = [tag.label for tag in revision_tags] 
+            print("tags")
+            print(tag_list)
+        return tag_list
 
 class AnnotationManager(models.Manager):
     
--- a/src/iconolab/search_indexes/forms.py	Fri Aug 12 11:10:42 2016 +0200
+++ b/src/iconolab/search_indexes/forms.py	Fri Aug 12 16:02:23 2016 +0200
@@ -29,7 +29,6 @@
 		
 		if realm == 'image':
 			qs = qs.models(Image).load_all_queryset(Image, Image.objects.select_related('item', 'item__metadatas'))
-			qs = qs.filter(collection='stdie')
 		if realm == 'annotation':
 			qs = qs.models(Annotation).load_all_queryset(Annotation, Annotation.objects.select_related('image', 'stats', 'current_revision', 'author'))
 		return qs
--- a/src/iconolab/search_indexes/indexes.py	Fri Aug 12 11:10:42 2016 +0200
+++ b/src/iconolab/search_indexes/indexes.py	Fri Aug 12 16:02:23 2016 +0200
@@ -3,35 +3,41 @@
 from iconolab.models import Annotation, Image
 
 class ImageIndex(indexes.SearchIndex, indexes.Indexable):
-	text = indexes.CharField(document=True, use_template=True)
+    text = indexes.CharField(document=True, use_template=True)
 
-	title = indexes.CharField(model_attr='item__metadatas__title')
-	description = indexes.CharField(model_attr='item__metadatas__description')
-	collection = indexes.CharField(model_attr='item__collection__name')
-	tags = indexes.MultiValueField()
+    collection = indexes.CharField(model_attr='collection')
+    authors = indexes.CharField(model_attr="authors")
+    school = indexes.CharField(model_attr="school")
+    designation = indexes.CharField(model_attr="designation")
+    datation = indexes.CharField(model_attr="datation")
+    technics = indexes.CharField(model_attr="technics")
+    measurements = indexes.CharField(model_attr="measurements")
 
-	def get_model(self):
-		return Image
+    create_or_usage_location = indexes.CharField(model_attr="item__metadatas__create_or_usage_location")
+    discovery_context = indexes.CharField(model_attr="item__metadatas__discovery_context")
+    conservation_location = indexes.CharField(model_attr="item__metadatas__conservation_location")
+    
+    tags = indexes.MultiValueField(model_attr="tags")
 
-	def prepare_tags(self, object):
-		return ["radical", "you better", "yes"]
+    def get_model(self):
+        return Image
 
-	def index_queryset(self, using=None):
-		return self.get_model().objects.filter(created__lte=datetime.datetime.now())
+    def index_queryset(self, using=None):
+        return self.get_model().objects.filter(created__lte=datetime.datetime.now())
 
 
 class AnnotationIndex(indexes.SearchIndex, indexes.Indexable):
 
-	##indexed field
-	text = indexes.CharField(document=True, use_template=True)
+    ##indexed field
+    text = indexes.CharField(document=True, use_template=True)
 
-	title = indexes.CharField(model_attr='current_revision__title')
-	description = indexes.CharField(model_attr='current_revision__description')
-	tags = indexes.MultiValueField(model_attr='tags')
+    title = indexes.CharField(model_attr='current_revision__title')
+    description = indexes.CharField(model_attr='current_revision__description')
+    tags = indexes.MultiValueField(model_attr='tags')
 
-	## tags
-	def get_model(self):
-		return Annotation
+    ## tags
+    def get_model(self):
+        return Annotation
 
-	def index_queryset(self, using=None):
-		return self.get_model().objects.filter(created__lte=datetime.datetime.now())
\ No newline at end of file
+    def index_queryset(self, using=None):
+        return self.get_model().objects.filter(created__lte=datetime.datetime.now())
\ No newline at end of file
--- a/src/iconolab/templates/partials/header_search_form.html	Fri Aug 12 11:10:42 2016 +0200
+++ b/src/iconolab/templates/partials/header_search_form.html	Fri Aug 12 16:02:23 2016 +0200
@@ -7,7 +7,7 @@
 	<div class="form-group">
 		<select name="realm" class="form-control">
 			<option value="image">Images</option>
-			<option value="innotation">Annotations</option>
+			<option value="annotation">Annotations</option>
 		</select>
 	</div>
 
--- a/src/iconolab/templates/search/indexes/iconolab/image_text.txt	Fri Aug 12 11:10:42 2016 +0200
+++ b/src/iconolab/templates/search/indexes/iconolab/image_text.txt	Fri Aug 12 16:02:23 2016 +0200
@@ -1,7 +1,12 @@
-{{ object.item.metadatas.title }}
+{{ object.school }}
+{{ object.authors }}
+{{ object.designation }}
+{{ object.datation }}
+{{ object.technics }}
+{{ object.measurements }}
 
-{{ object.item.metadatas.description }}
+{{ object.item.metadatas.create_or_usage_location }}
+{{ object.item.metadatas.discovery_context }}
+{{ object.item.metadatas.conservation_location }}
 
 {{ object.tags }}
-
-samedi
\ No newline at end of file