debug query and enhance display
authorcavaliet
Wed, 28 Aug 2013 15:29:18 +0200
changeset 5 62e97cd13730
parent 4 047675624f45
child 6 ff4d2d4f1fb0
debug query and enhance display
src/p4l/forms.py
src/p4l/static/p4l/css/p4l.css
src/p4l/templates/p4l/p4l_home.html
src/p4l/views.py
--- a/src/p4l/forms.py	Wed Aug 28 13:36:31 2013 +0200
+++ b/src/p4l/forms.py	Wed Aug 28 15:29:18 2013 +0200
@@ -42,7 +42,7 @@
     title = CharField(required=True, min_length=1)
     def get_filter_qs(self, qs=None):
         if qs is None:
-            qs = Record.objects.select_related("language").prefetch_related('titles')  # @UndefinedVariable
+            qs = Record.objects.select_related("language").prefetch_related('titles').distinct()  # @UndefinedVariable
         t = self.cleaned_data.get('title',None)
         if t:
             qs = qs.filter(titles__title__icontains=t)
--- a/src/p4l/static/p4l/css/p4l.css	Wed Aug 28 13:36:31 2013 +0200
+++ b/src/p4l/static/p4l/css/p4l.css	Wed Aug 28 15:29:18 2013 +0200
@@ -9,3 +9,6 @@
 .table thead td:first-letter {
     text-transform: uppercase;
 }
+.two_buttons{
+	min-width: 100px;
+}
--- a/src/p4l/templates/p4l/p4l_home.html	Wed Aug 28 13:36:31 2013 +0200
+++ b/src/p4l/templates/p4l/p4l_home.html	Wed Aug 28 15:29:18 2013 +0200
@@ -4,7 +4,19 @@
 {% load p4lstringfilters %}
 
 {% block content %}
-<h3>{% trans 'Record List' %}</h3>
+<div class="row">
+	<h3 class="col-md-8">{% trans 'Record List' %}</h3>
+	<div class="col-md-4 text-right">
+	  <form method="GET" class="form-inline" role="form">
+	    <div class="form-group">
+	      <input id="id_title" class="form-control" type="text" placeholder="{% trans 'Title' %}" name="title" required="required"/>
+	    </div>
+	    <div class="form-group">
+	      <button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
+	    </div>
+	  </form>
+	</div>
+</div>
 {% if is_paginated %}
 <div class="pagination pull-right">
     <span class="page-links">
@@ -22,7 +34,7 @@
 {% endif %}
 <table class="table">
   <thead>
-    <tr><td>URI</td><td>lang.</td><td>{% trans 'title' %}</td><td>{% trans 'actions' %}</td></tr>
+    <tr><td>URI</td><td>lang.</td><td>{% trans 'title' %}</td><td class="two_buttons">{% trans 'actions' %}</td></tr>
   </thead>
   <tbody>
   {% for record in object_list %}
@@ -55,12 +67,4 @@
     </span>
 </div>
 {% endif %}
-<div>
-  <form method="GET">
-    <ul id='term-filter-field-list'>
-      {{ filter_form.as_ul }}
-      <li><input type="submit" value="{% trans 'Search' %}" /></li>
-    </ul>
-  </form>
-</div>
 {% endblock %}
\ No newline at end of file
--- a/src/p4l/views.py	Wed Aug 28 13:36:31 2013 +0200
+++ b/src/p4l/views.py	Wed Aug 28 15:29:18 2013 +0200
@@ -19,7 +19,7 @@
 
 class RecordListView(ListView):
     
-    queryset = Record.objects.select_related("language").prefetch_related('titles')  # @UndefinedVariable
+    queryset = Record.objects.select_related("language").prefetch_related('titles').distinct()  # @UndefinedVariable
     paginate_by = settings.NB_RECORDS_BY_PAGE
     template_name = "p4l/p4l_home.html"
     form_class = RecordFilterForm