search.html 6.06 KB
Newer Older
1
2
3
{% extends 'base.html' %}
{% load bt %}
{% load i18n %}
Okhin's avatar
Okhin committed
4
{% block active_tab_search %}id="current"{% endblock %}
5
{% block styles %}
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
   <link rel="stylesheet" href="{{ MEDIA_URL }}/css/map.css" type="text/css" />
{% endblock %}

{% block head %}
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
{% endblock %}

{% block scripts %}
  <script type="text/javascript" src="{{ MEDIA_URL }}/js/jquery.min.js"></script>
  <script type="text/javascript" src="{{ MEDIA_URL }}/js/jquery.tablesorter.js"></script>
  <script type="text/javascript" src="{{ MEDIA_URL }}/js/picnet.table.filter.min.js"></script>
  <script type="text/javascript" src='{{ MEDIA_URL }}/js/d3.min.js'></script>
  <script type="text/javascript" src='{{ MEDIA_URL }}/js/topojson.min.js'></script>
  <script type="text/javascript" src='{{ MEDIA_URL }}/js/datamaps.js'></script>
  <script type="text/javascript" src="{{ MEDIA_URL }}/js/map.js"></script>
  <script type="text/javascript">
     var data={% if countryweights %}{{countryweights|safe}}{%else%}[]{% endif %};
     var country="{{country}}";
     $(document).ready(function() {
       $.tablesorter.addParser({
           // set a unique id
           id: 'stateparser',
           is: function(s) {
               // return false so this parser is not auto detected
               return false;
           },
           format: function(s) {
               // format your data for normalization
               return s{% for s, translation in status %}.replace(/{{translation}}/,{{forloop.counter}}){% endfor %};
           },
           // set type, either numeric or text
           type: 'numeric'
       });
       $("#sortedlist").tablesorter({
           headers: { 8: { sorter: false },
                      0: { sorter: 'stateparser' }},
           sortList: [[1,0],[0,0],[7,1]],
       });
       var options = { enableCookies: false };
       $('#sortedlist').tableFilter(options);
       $('.confirm_form').submit(function() {
          var self=this;
          var email=$(this).find('input:first').attr('value');
          if( email.length>0) {
             $.ajax({url: '/confirm/'+$(this).attr('id').slice(1)+'/'+email, success: function(data) { $(self).html(data); }});
          } else {
             $(this).find('[type=text]').focus();
          }
          return false;
       });
       $(".confirm > .button").click(function(){
                $(this).parent().parent().parent().find('.info-validate').toggle();
             });
       $(".cancel-button").click(function(){
                $(this).parent().hide();
             });
       });
  </script>
64
65
66
67
{% endblock %}

{% block content %}
<div id="global">
68
69
70
71
72
73
74
75
76
{% if messages %}
<ul class="messages">
    {% for message in messages %}
    <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
    {% endfor %}
</ul>
{% endif %}
{% trans "Search through cases" %}
<div id="map"> </div>
77
    <form method="get" action=".">
Okhin's avatar
Okhin committed
78
79
        {{ form.as_p }}
        <input type="submit" value="Search">
80
    </form>
81
82
83
84

        {% if query %}
            <h3>Results</h3>

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	    <table class="listing tablesorter zebra-striped" id='sortedlist'>
		    <thead>
			    <tr>
				   <th filter-type='ddl'>{% trans "Status" %}</th>
				   <th filter-type='ddl'>{% trans "country" %}</th>
				   <th filter-type='ddl'>{% trans "operator" %}</th>
				   <th filter-type='ddl'>{% trans "contract" %}</th>
				   <th filter-type='ddl'>{% trans "resource" %}</th>
				   <th filter-type='ddl'>{% trans "type" %}</th>
				   <th filter-type='ddl'>{% trans "fixed / wireless" %}</th>
				   <th filter='false'>{% trans "confirmations" %}</th>
				   <th filter='false'></th>
			    </tr>
			</thead>
		  <tbody>
100
            {% for result in page.object_list %}
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
            <tr class="{%if result.object.state%}{{result.object.state}}{%else%}new{%endif%}-status">
    <td><a class="cell-link" href="{{ result.object.get_absolute_url }}">{%if result.object.state%}{{result.object.state|status}}{%else%}{% trans "New" %}{%endif%}</a></td>
    <td><a class="cell-link" href="{{ result.object.get_absolute_url }}">{{ result.object.country|country }}</a></td>
    <td><a class="cell-link" href="{{ result.object.get_absolute_url }}">{{ result.object.operator }}</a></td>
    <td><a class="cell-link" href="{{ result.object.get_absolute_url }}">{{ result.object.contract }}</a></td>
    <td><a class="cell-link" href="{{ result.object.get_absolute_url }}">{{ result.object.resource_name }}</a></td>
    <td><a class="cell-link" href="{{ result.object.get_absolute_url }}">{{ result.object.type|type }}</a></td>
    <td><a class="cell-link" href="{{ result.object.get_absolute_url }}">{{ result.object.media|media }}</a></td>
    <td>{{ result.object.confirmations }}</td>
   <td>
      <div class="confirm"><a class="button">{% trans "Me too!" %}</a>
	 <div class="info-validate float-confirm">
            <form method="get" action="" id="i{{ violation.pk }}" class="confirm_form" >
               <div>
                  <label>{% trans "In order to <strong>confirm</strong> this report, please enter your email address" %}</label>
                  <input type="text" name="email" />
                  <input type="hidden" value="{{ violation.pk }}" />
                  <input type="submit" value="{% trans "OK" %}" />
               </div>
            </form>
            <input class="cancel-button" type="button" value="{% trans "Close" %}" />
         </div>
      </div>
    </td>
	    </tr>
126
            {% endfor %}
127
128
	  </tbody>
	    </table>
129
130
131
132
133
134
135
136
137
138
139
140
141

            {% if page.has_previous or page.has_next %}
                <div>
                    {% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Previous{% if page.has_previous %}</a>{% endif %}
                    |
                    {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Next &raquo;{% if page.has_next %}</a>{% endif %}
                </div>
            {% endif %}
        {% else %}
            {# Show some example queries to run, maybe query syntax, something else? #}
        {% endif %}
</div>
{% endblock %}