Prettied things up a bit

This commit is contained in:
Jeremy Stretch 2017-03-29 16:45:25 -04:00
parent a5dc91c175
commit 66615f1a96
6 changed files with 21 additions and 11 deletions

View File

@ -199,7 +199,6 @@ class SearchView(View):
})
class APIRootView(APIView):
_ignore_model_permissions = True
exclude_from_schema = True

View File

@ -92,6 +92,9 @@ tfoot td {
table.attr-table td:nth-child(1) {
width: 25%;
}
.table-headings th {
background-color: #f5f5f5;
}
/* Paginator */
div.paginator {

View File

@ -20,6 +20,7 @@
{% endblock %}
{% block pagination %}
{% include 'paginator.html' %}
{% if not hide_paginator %}
{% include 'paginator.html' %}
{% endif %}
{% endblock pagination %}

View File

@ -1,4 +1,5 @@
{% extends '_base.html' %}
{% load helpers %}
{% load form_helpers %}
{% block title %}Search{% endblock %}
@ -10,12 +11,12 @@
<div class="row">
<div class="col-md-10">
{% for obj_type in results %}
<h3 id="{{ obj_type.name }}">{{ obj_type.name }}</h3>
{% include 'table.html' with table=obj_type.table hide_paginator=True %}
<h3 id="{{ obj_type.name|lower }}">{{ obj_type.name|bettertitle }}</h3>
{% include 'panel_table.html' with table=obj_type.table hide_paginator=True %}
{% if obj_type.table.page.has_next %}
<a href="{{ obj_type.url }}" class="btn btn-primary pull-right">
<span class="fa fa-search" aria-hidden="true"></span>
All {{ obj_type.table.page.paginator.count }} results
<span class="fa fa-arrow-right" aria-hidden="true"></span>
See all {{ obj_type.table.page.paginator.count }} results
</a>
{% endif %}
<div class="clearfix"></div>
@ -28,8 +29,8 @@
</div>
<div class="list-group">
{% for obj_type in results %}
<a href="#{{ obj_type.name }}" class="list-group-item">
{{ obj_type.name }}
<a href="#{{ obj_type.name|lower }}" class="list-group-item">
{{ obj_type.name|bettertitle }}
<span class="badge">{{ obj_type.table.page.paginator.count }}</span>
</a>
{% endfor %}
@ -41,7 +42,6 @@
<h3 class="text-muted text-center">No results found</h3>
{% endif %}
{% else %}
{# Larger search form #}
<div class="row" style="margin-top: 150px;">
<div class="col-sm-4 col-sm-offset-4">
<form action="{% url 'search' %}" method="get" class="form form-horizontal">

View File

@ -26,7 +26,7 @@ class SearchTable(tables.Table):
"""
class Meta:
attrs = {
'class': 'table table-hover',
'class': 'table table-hover table-headings',
}
orderable = False

View File

@ -51,6 +51,13 @@ def startswith(value, arg):
"""
return str(value).startswith(arg)
@register.filter()
def bettertitle(value):
"""
Alternative to the builtin title(); uppercases words without replacing letters that are already uppercase.
"""
return ' '.join([w[0].upper() + w[1:] for w in value.split()])
#
# Tags