This repository has been archived by the owner on Feb 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from danielquinn/feature/new-look
A nicer look for the documents listing
- Loading branch information
Showing
9 changed files
with
248 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% load hacks %} | ||
|
||
{# See documents.templatetags.hacks.change_list_results for an explanation #} | ||
|
||
{% change_list_results %} | ||
|
167 changes: 167 additions & 0 deletions
167
src/documents/templates/admin/documents/document/change_list_results.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
{% load i18n %} | ||
|
||
<style> | ||
.grid *, .grid *:after, .grid *:before { | ||
-webkit-box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
box-sizing: border-box; | ||
} | ||
.box { | ||
width: 12.5%; | ||
padding: 1em; | ||
float: left; | ||
opacity: 0.7; | ||
transition: all 0.5s; | ||
} | ||
.box:hover { | ||
opacity: 1; | ||
transition: all 0.5s; | ||
} | ||
.box:last-of-type { | ||
padding-right: 0; | ||
} | ||
.result { | ||
border: 1px solid #cccccc; | ||
border-radius: 2%; | ||
overflow: hidden; | ||
height: 300px; | ||
} | ||
.result .header { | ||
padding: 5px; | ||
background-color: #79AEC8; | ||
height: 6em; | ||
} | ||
.result .header .checkbox { | ||
margin-right: 5px; | ||
} | ||
.result .header .checkbox{ | ||
width: 5%; | ||
float: left; | ||
} | ||
.result .header .info { | ||
width: 90%; | ||
float: left; | ||
} | ||
.result .header a, | ||
.result a.tag { | ||
color: #ffffff; | ||
} | ||
.result .date { | ||
padding: 5px; | ||
} | ||
.result .tags { | ||
float: left; | ||
} | ||
.result .tags a.tag { | ||
padding: 2px 5px; | ||
border-radius: 2px; | ||
display: inline-block; | ||
margin: 2px; | ||
} | ||
.result .date { | ||
float: right; | ||
color: #cccccc; | ||
} | ||
.result .image img { | ||
width: 100%; | ||
} | ||
|
||
.grid { | ||
margin-right: 260px; | ||
} | ||
.grid:after { | ||
content: ""; | ||
display: table; | ||
clear: both; | ||
} | ||
|
||
@media (max-width: 1600px) { | ||
.box { | ||
width: 25% | ||
} | ||
} | ||
|
||
@media (max-width: 991px) { | ||
.grid { | ||
margin-right: 220px; | ||
} | ||
.box { | ||
width: 50% | ||
} | ||
} | ||
|
||
@media (max-width: 767px) { | ||
.grid { | ||
margin-right: 0; | ||
} | ||
} | ||
|
||
@media (max-width: 500px) { | ||
.box { | ||
width: 100% | ||
} | ||
} | ||
|
||
</style> | ||
|
||
|
||
{# This is just copypasta from the parent change_list_results.html file #} | ||
<table id="result_list"> | ||
<thead> | ||
<tr> | ||
{% for header in result_headers %} | ||
<th scope="col" {{ header.class_attrib }}> | ||
{% if header.sortable %} | ||
{% if header.sort_priority > 0 %} | ||
<div class="sortoptions"> | ||
<a class="sortremove" href="{{ header.url_remove }}" title="{% trans "Remove from sorting" %}"></a> | ||
{% if num_sorted_fields > 1 %}<span class="sortpriority" title="{% blocktrans with priority_number=header.sort_priority %}Sorting priority: {{ priority_number }}{% endblocktrans %}">{{ header.sort_priority }}</span>{% endif %} | ||
<a href="{{ header.url_toggle }}" class="toggle {% if header.ascending %}ascending{% else %}descending{% endif %}" title="{% trans "Toggle sorting" %}"></a> | ||
</div> | ||
{% endif %} | ||
{% endif %} | ||
<div class="text">{% if header.sortable %}<a href="{{ header.url_primary }}">{{ header.text|capfirst }}</a>{% else %}<span>{{ header.text|capfirst }}</span>{% endif %}</div> | ||
<div class="clear"></div> | ||
</th>{% endfor %} | ||
</tr> | ||
</thead> | ||
</table> | ||
{# /copypasta #} | ||
|
||
|
||
<div class="grid"> | ||
{% for result in results %} | ||
{# 0: Checkbox #} | ||
{# 1: Title #} | ||
{# 2: Date #} | ||
{# 3: Image #} | ||
{# 4: Correspondent #} | ||
{# 5: Tags #} | ||
<div class="box"> | ||
<div class="result"> | ||
<div class="header"> | ||
<div class="checkbox">{{ result.0 }}</div> | ||
<div class="info"> | ||
{{ result.4 }}<br /> | ||
{{ result.1 }} | ||
</div> | ||
<div style="clear: both;"></div> | ||
</div> | ||
<div class="tags">{{ result.5 }}</div> | ||
<div class="date">{{ result.2 }}</div> | ||
<div style="clear: both;"></div> | ||
<div class="image">{{ result.3 }}</div> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
|
||
|
||
<script> | ||
// We nee to re-build the select-all functionality as the old logic pointed | ||
// to a table and we're using divs now. | ||
django.jQuery("#action-toggle").on("change", function(){ | ||
django.jQuery(".grid .box .result .checkbox input") | ||
.prop("checked", this.checked); | ||
}); | ||
</script> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
|
||
from django.contrib import admin | ||
from django.template import Library | ||
from django.template.loader import get_template | ||
|
||
from ..models import Document | ||
|
||
|
||
register = Library() | ||
|
||
|
||
@register.simple_tag(takes_context=True) | ||
def change_list_results(context): | ||
""" | ||
Django has a lot of places where you can override defaults, but | ||
unfortunately, `change_list_results.html` is not one of them. In fact, | ||
it's a downright pain in the ass to override this file on a per-model basis | ||
and this is the cleanest way I could come up with. | ||
Basically all we've done here is defined `change_list_results.html` in an | ||
`admin` directory which globally overrides that file for *every* model. | ||
That template however simply loads this templatetag which determines | ||
whether we're currently looking at a `Document` listing or something else | ||
and loads the appropriate file in each case. | ||
Better work arounds for this are welcome as I hate this myself, but at the | ||
moment, it's all I could come up with. | ||
""" | ||
|
||
path = os.path.join( | ||
os.path.dirname(admin.__file__), | ||
"templates", | ||
"admin", | ||
"change_list_results.html" | ||
) | ||
|
||
if context["cl"].model == Document: | ||
path = "admin/documents/document/change_list_results.html" | ||
|
||
return get_template(path).render(context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = (0, 3, 4) | ||
__version__ = (0, 3, 5) |