Commit 44798159 by Kálmán Viktor

network: filter records by type

parent b0c97aa9
......@@ -15,6 +15,14 @@
</h1>
</div>
<ul class="nav nav-pills" style="margin: 5px 0 20px 0;">
<li class="disabled"><a href="#">{% trans "Filter by type" %}</a></li>
<li {% if not request.GET.type %} class="active"{% endif %}><a href="{{ request.path }}">{% trans "ALL" %}</a></li>
{% for type in types %}
<li{% if request.GET.type == type.0 %} class="active"{% endif %}><a href="?type={{ type.0 }}">{{ type.0 }}</a></li>
{% endfor %}
</ul>
<div class="table-responsive">
{% render_table table %}
</div>
......
......@@ -420,6 +420,19 @@ class RecordList(SingleTableView):
template_name = "network/record-list.html"
table_pagination = False
def get_context_data(self, **kwargs):
context = super(RecordList, self).get_context_data(**kwargs)
context['types'] = Record.CHOICES_type
return context
def get_table_data(self):
type_id = self.request.GET.get('type')
if type_id:
data = Record.objects.filter(type=type_id).select_related()
else:
data = Record.objects.select_related()
return data
class RecordDetail(UpdateView, SuccessMessageMixin):
model = Record
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment