]> git.parisson.com Git - telemeta.git/commitdiff
cosmetic fixes
authorGuillaume Pellerin <yomguy@parisson.com>
Wed, 1 Jul 2015 09:17:24 +0000 (11:17 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Wed, 1 Jul 2015 09:17:34 +0000 (11:17 +0200)
telemeta/forms/haystack_form.py
telemeta/models/query.py
telemeta/views/haystack_search.py

index b857e169e1258933279b96bb41503f32e893c79e..945509e82be34c5e312c0240a72318432aec2eec 100644 (file)
@@ -1,12 +1,50 @@
 # -*- coding: utf-8 -*-
+# Copyright (C) 2015 Parisson SARL
+
+# This software is a computer program whose purpose is to backup, analyse,
+# transcode and stream any audio content with its metadata over a web frontend.
+
+# This software is governed by the CeCILL  license under French law and
+# abiding by the rules of distribution of free software.  You can  use,
+# modify and/ or redistribute the software under the terms of the CeCILL
+# license as circulated by CEA, CNRS and INRIA at the following URL
+# "http://www.cecill.info".
+
+# As a counterpart to the access to the source code and  rights to copy,
+# modify and redistribute granted by the license, users are provided only
+# with a limited warranty  and the software's author,  the holder of the
+# economic rights,  and the successive licensors  have only  limited
+# liability.
+
+# In this respect, the user's attention is drawn to the risks associated
+# with loading,  using,  modifying and/or developing or reproducing the
+# software by the user in light of its specific status of free software,
+# that may mean  that it is complicated to manipulate,  and  that  also
+# therefore means  that it is reserved for developers  and  experienced
+# professionals having in-depth computer knowledge. Users are therefore
+# encouraged to load and test the software's suitability as regards their
+# requirements in conditions enabling the security of their systems and/or
+# data to be ensured and,  more generally, to use and operate it in the
+# same conditions as regards security.
+
+# The fact that you are presently reading this means that you have had
+# knowledge of the CeCILL license and that you accept its terms.
+#
+# Authors: Angy Fil-Aimé
+#          Killian Mary
+
+
 from telemeta.models import *
 from haystack.forms import *
 from haystack.query import SearchQuerySet
 from datetime import date
 from django.utils.translation import ugettext_lazy as _
 
+
 class HaySearchForm(FacetedSearchForm):
+
     q = forms.CharField(required=False, widget=forms.TextInput(attrs={'class': 'form-control', 'type' : 'text'}))
+
     def search(self):
         sqs = SearchQuerySet().load_all()
 
@@ -32,7 +70,6 @@ class HaySearchForm(FacetedSearchForm):
 
 
 class HayAdvanceForm(SearchForm):
-#begin create field
 
     #to replace de basic search form field
     q = forms.CharField(required=False, label=(_('title')), widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'search'}))
@@ -49,11 +86,10 @@ class HayAdvanceForm(SearchForm):
         return type_name
 
     ethnic_group = forms.CharField(required=False, label=(_('population / social group')), widget=forms.Select(attrs={'style': 'width:100%'}, choices=list_ethnic_group()))
-
     instruments = forms.CharField(required=False, label=(_('instruments')), widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'search'}))
     collectors = forms.CharField(required=False, label=(_('recordist')), widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'search'}))
 
-    #to create a dynamic list of publish year
+    #to create a dynamic list of publishing years
     def list_recorded_year():
         list_all_year = []
         list_collect = MediaCollection.objects.all()
@@ -79,7 +115,7 @@ class HayAdvanceForm(SearchForm):
     recorded_from_date = forms.IntegerField(required=False, label=(_('recording date (from)')), widget=forms.Select(attrs={'style': 'width:47%'}, choices=list_recorded_year()))
     recorded_to_date = forms.IntegerField(required=False, label=(_('recording date (until')), widget=forms.Select(attrs={'style': 'width:47%'}, choices=list_recorded_year()))
 
-    #to create a dynamic list of publish year
+    #to create a dynamic list of publishing years
     def list_publish_year():
         list_all_year = []
         list_collect = MediaCollection.objects.all()
@@ -108,7 +144,7 @@ class HayAdvanceForm(SearchForm):
 
     item_status = forms.CharField(required=False, label=(_('Document status')), widget=forms.RadioSelect(choices=(('1', 'no preference'), ('pub', 'Published'), ('unpub', 'Unpublished'))), initial=1)
 
-    #to create a dynamic list of media type
+    #to create a dynamic list of media types
     def list_media_type():
         type_name = []
         type_name.append(('1', 'no preference'))
@@ -119,7 +155,7 @@ class HayAdvanceForm(SearchForm):
 
     media_type = forms.CharField(required=False, label=(_('media')), widget=forms.RadioSelect(choices=(list_media_type())), initial=1)
 
-    #to create a dynamic list of recording context
+    #to create a dynamic list of recording contexts
     def list_recording_context():
         type_name = []
         type_name.append(('', 'no preference'))
@@ -130,7 +166,7 @@ class HayAdvanceForm(SearchForm):
 
     recording_context = forms.CharField(required=False, label=(_('recording context')), widget=forms.Select(attrs={'style': 'width:100%'}, choices=list_recording_context()))
 
-    #to create a dynamic list of physical format
+    #to create a dynamic list of physical formats
     def list_physical_format():
         type_name = []
         type_name.append(('', 'no preference'))
@@ -140,9 +176,7 @@ class HayAdvanceForm(SearchForm):
         return type_name
 
     physical_format = forms.CharField(required=False, label=(_('physical format')), widget=forms.Select(attrs={'style': 'width:100%'}, choices=list_physical_format()))
-
     code = forms.CharField(required=False, label=(_('code')), widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'search'}))
-#end
 
     def search(self):
         sqs = SearchQuerySet().load_all()
index 07f623383e52a2a3a21fcd8d4b6a7eca7a8c7af4..14a29055094d576de078380947bd7011da2e10e5 100644 (file)
@@ -44,6 +44,7 @@ import re
 
 engine = settings.DATABASES['default']['ENGINE']
 
+
 class MediaItemQuerySet(CoreQuerySet):
     "Base class for all media item query sets"
 
@@ -367,6 +368,7 @@ class MediaCollectionQuerySet(CoreQuerySet):
             items.append(performance.media_item)
         return self.filter(items__in=items).distinct()
 
+
 class MediaCollectionManager(CoreManager):
     "Manage collection queries"
 
@@ -441,6 +443,7 @@ class LocationQuerySet(CoreQuerySet):
     def current(self):
         return self.filter(id__in=self.values_list('current_location_id', flat=True)).distinct()
 
+
 class LocationManager(CoreManager):
 
     def get_query_set(self):
index 38ebd5f3547ced065f5607dc9505c5c608daf704..0d7d5b7f6827978a71e429331fc0fd185390c6ca 100644 (file)
@@ -11,7 +11,7 @@ class HaystackSearch(FacetedSearchView):
     def __call__(self, request, type=None):
         self.type = type
         self.form_class = HaySearchForm
-        self.selected_facet=self.selected_facet_list(request.GET.getlist('selected_facets', ['a']))
+        self.selected_facet = self.selected_facet_list(request.GET.getlist('selected_facets', ['a']))
         if request.GET.get('results_page'):
             self.results_per_page=int(request.GET.get('results_page'))
         else:
@@ -56,26 +56,26 @@ class HaystackSearch(FacetedSearchView):
                 else:
                     viewable_total = viewable_total + viewable[1]
 
-            extra['Published_count']=self.get_results().narrow('item_status:Published').count()
-            extra['Unpublished_count']=self.get_results().narrow('item_status:Unpublished').count()
+            extra['Published_count'] = self.get_results().narrow('item_status:Published').count()
+            extra['Unpublished_count'] = self.get_results().narrow('item_status:Unpublished').count()
             extra['viewable_count'] = self.get_results().narrow('item_acces:full OR item_acces:mixed').narrow('digitized:T').count()
             extra['digitized_count'] = self.get_results().narrow('digitized:T').count()
-            extra['CDR_count']=self.get_results().narrow('physical_format:CDR').count()
-            extra['Disque_count']=self.get_results().narrow('physical_format:Disque').count()
-            extra['Cylindre_count']=self.get_results().narrow('physical_format:Cylindre').count()
-            extra['Studio_count']=self.get_results().narrow('recording_context:Studio').count()
-            extra['Terrain_count']=self.get_results().narrow('recording_context:Terrain').count()
-            extra['Radio_count']=self.get_results().narrow('recording_context:Radio').count()
-            extra['Video_count']=self.get_results().narrow('media_type:Video').count()
-            extra['Audio_count']=self.get_results().narrow('media_type:Audio').count()
+            extra['CDR_count'] = self.get_results().narrow('physical_format:CDR').count()
+            extra['Disque_count'] = self.get_results().narrow('physical_format:Disque').count()
+            extra['Cylindre_count'] = self.get_results().narrow('physical_format:Cylindre').count()
+            extra['Studio_count'] = self.get_results().narrow('recording_context:Studio').count()
+            extra['Terrain_count'] = self.get_results().narrow('recording_context:Terrain').count()
+            extra['Radio_count'] = self.get_results().narrow('recording_context:Radio').count()
+            extra['Video_count'] = self.get_results().narrow('media_type:Video').count()
+            extra['Audio_count'] = self.get_results().narrow('media_type:Audio').count()
         if self.type == 'collection':
             extra['type'] = 'collection'
         else:
             extra['type'] = 'item'
 
-        extra['selected_facets']=self.selected_facet
-        extra['selected_facets_url']=self.request.GET.getlist('selected_facets')
-        extra['results_page']=self.results_per_page
+        extra['selected_facets'] = self.selected_facet
+        extra['selected_facets_url'] = self.request.GET.getlist('selected_facets')
+        extra['results_page'] = self.results_per_page
         return extra
 
 
@@ -110,5 +110,5 @@ class HaystackAdvanceSearch(SearchView):
             extra['type'] = 'collection'
         else:
             extra['type'] = 'item'
-        extra['results_page']=self.results_per_page
+        extra['results_page'] = self.results_per_page
         return extra