Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve search page in back office #87

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions static/supporters/style.css
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@
.supporter-list {
aside ul {
margin-left: 0;
list-style-type: none;
}
.header-with-button {
display: flex;
justify-content: space-between;
align-items: center;
a {
margin-bottom: 0;
}
}
.supporter-details {
display: flex;
flex-direction: column;
justify-content: space-between;
details summary {
cursor: pointer;
}
details {
padding-bottom: 1rem;
}
}
@media (min-width: 968px) {
.supporter-details {
flex-direction: row;
}
}
}

.edit-supporter-band {
h2 {
margin: 0.5rem .85rem;
Expand Down
45 changes: 17 additions & 28 deletions templates/consortial_billing/supporter_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,30 @@
{% endblock %}

{% block body %}
<section id="content" class="row-expanded supporter-list">
<div class="large-8 columns border-right">
<aside class="hide-for-large">
<ul class="accordion" data-accordion data-allow-all-closed="true">
<li class="accordion-item" data-accordion-item>
<a href="#" class="accordion-title">{% trans 'Show Filter Options' %}</a>
<div class="accordion-content" data-tab-content>
{% include "elements/journal/article_list_filters.html" %}
</div>
</li>
</ul>
</aside>
<div class="header-with-button">

<div class="rummage-portal">
{% include "admin/elements/list_filters.html" %}
<div class="box">
<div class="title-area">
<h2>All Supporters</h2>
<a
href="{% url 'new_supporter' %}?return={{ request.get_full_path|urlencode }}"
class="button success small">
<i class="fa fa-plus"></i>
Create new supporter
</a>
</div>
{% include "common/elements/sorting.html" with form_id=facet_form.id %}
{% for supporter in supporter_list %}
<div class="box">
{% include 'consortial_billing/supporter_list_item.html' %}
</div>
{% empty %}
<div class="box">
<p><strong>No supporters to display.</strong></p>
</div>
{% endfor %}
{% include "common/elements/pagination.html" with form_id=facet_form.id %}
{% include "common/elements/sorting.html" with form_id=facet_form.id %}
{% for supporter in supporter_list %}
<div class="callout">
{% include 'consortial_billing/supporter_list_item.html' %}
</div>
{% empty %}
<div class="callout">
<p><strong>No supporters to display.</strong></p>
</div>
{% endfor %}
{% include "common/elements/pagination.html" with form_id=facet_form.id %}
</div>
</div>
<aside class="large-4 columns show-for-large">
{% include 'elements/journal/article_list_filters.html' %}
</aside>
</section>
{% endblock body %}
147 changes: 99 additions & 48 deletions templates/consortial_billing/supporter_list_item.html
Original file line number Diff line number Diff line change
@@ -1,65 +1,116 @@
{% load humanize %}

<section id="supporter{{ supporter.pk }}">
<h3>
{{ supporter.name }}
</h3>
<hr>
<div class="supporter-details">
<div class="info">
<p><strong>{{ supporter.band.currency.symbol }}{{ supporter.fee|default:0 }}</strong></p>
<p>
{% for contact in supporter.supportercontact_set.all %}
{{ contact }}{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>
<p>{{ supporter.address|linebreaks }}</p>
<p>{{ supporter.band.country.name }}</p>
<p>{{ supporter.postal_code|linebreaks }}</p>
<p>Billed by: {{ supporter.billing_agent }}</p>
<p>Active: {% if supporter.active %}Yes{% else %}No{% endif %}</p>
<p>Display: {% if supporter.display %}Yes{% else %}No{% endif %}</p>
{% if supporter.ror %}
<p>ROR:
<a target="_blank" href="{{ supporter.ror }}">
{{ supporter.ror }}
</a>
<i class="fa fa-external-link"></i>
</p>
{% endif %}
<details>
<summary>Band details</summary>
<p>Created: {{ supporter.band.datetime }}</p>
<p>Level: {{ supporter.band.level }}</p>
<p>Size: {{ supporter.band.size }}</p>
<p>Country: {{ supporter.band.country.name }}</p>
<p>Currency: {{ supporter.band.currency }}</p>
<p>Fee: {{ supporter.band.fee }}</p>
<p>Warnings: {{ supporter.band.warnings }}</p>
<p>Prospective band: {{ supporter.prospective_band|default:"" }}</p>
</details>
{% if supporter.oldband_set.count %}
<details>
<summary>Old bands</summary>
{% for oldband in supporter.oldband_set.all %}
<p>{{ oldband.band }}</p>
<div class="rummage-result-details">
<div class="flex portrait-column landscape-column gap-0-25">
<div class="flex wrap gap-0-25">
{% if supporter.active %}
<div class="label success">
<span class="fa fa-check"></span>
Active
</div>
{% else %}
<div class="label alert">
<span class="fa fa-warning"></span>
Inactive
</div>
{% endif %}
{% if supporter.display %}
<div class="label success">
<span class="fa fa-eye"></span>
OK to display
</div>
{% else %}
<div class="label alert">
<span class="fa fa-warning"></span>
Not OK to display
</div>
{% endif %}
</div>
{% if supporter.supportercontact_set.exists %}
<div>
{% for contact in supporter.supportercontact_set.all %}
{{ contact }}{% if not forloop.last %}, {% endif %}
{% endfor %}
</details>
</div>
{% endif %}
<details>
<summary>Internal notes</summary>
<div>
{{ supporter.internal_notes|safe }}
</div>
</details>
<div>
{% if supporter.address %}
{{ supporter.address|linebreaksbr }}
<br>
{% endif %}
{% if supporter.band %}
{{ supporter.band.country.name }}
<br>
{% endif %}
{% if supporter.postal_code %}
{{ supporter.postal_code|linebreaksbr }}
{% endif %}
</div>
</div>
<div class="actions">
<a
href="{{ supporter.url }}?next={{ request.get_full_path|urlencode }}"
class="button small">
<i class="fa fa-edit"></i>
Edit
</a>
<p>Edited {{ supporter.band.datetime|naturaltime }}</p>
<div class="flex portrait-column gap-2">
<div>
<div><strong>{{ supporter.band.currency.symbol }}{{ supporter.fee|intcomma|default:0 }}</strong></div>
<div>Billed by {{ supporter.billing_agent }}</div>
{% if supporter.ror %}
<p>ROR:
<a target="_blank" href="{{ supporter.ror }}">
{{ supporter.ror }}
</a>
<i class="fa fa-external-link"></i>
</p>
{% endif %}
<details>
<summary>Band details</summary>
<div>
{% if supporter.band %}
<div>Created: {{ supporter.band.datetime }}</div>
<div>Level: {{ supporter.band.level }}</div>
<div>Size: {{ supporter.band.size }}</div>
<div>Country: {{ supporter.band.country.name }}</div>
<div>Currency: {{ supporter.band.currency }}</div>
<div>Fee: {{ supporter.band.fee }}</div>
{% if supporter.band.warnings %}
<div>Warnings: {{ supporter.band.warnings }}</div>
{% endif %}
{% if supporter.band.prospective_band %}
<div>Prospective band: {{ supporter.prospective_band }}</div>
{% endif %}
{% else %}
No band
{% endif %}
</div>
</details>
{% if supporter.oldband_set.count %}
<details>
<summary>Old bands</summary>
{% for oldband in supporter.oldband_set.all %}
<p>{{ oldband.band }}</p>
{% endfor %}
</details>
{% endif %}
<details>
<summary>Internal notes</summary>
<p>{{ supporter.internal_notes|linebreaks }}</p>
</details>
</div>
<div class="actions">
<a
href="{{ supporter.url }}?next={{ request.get_full_path|urlencode }}"
class="button small">
<i class="fa fa-edit"></i>
Edit
</a>
</div>
</div>
</div>
</section>
12 changes: 11 additions & 1 deletion views.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,12 @@ def get_facets(self):
band_obj = supporter_models.Band.objects.filter(
current_supporter__pk=OuterRef('pk'),
)

band_category = Subquery(
band_obj.values('category')[:1]
)
band_country = Subquery(
band_obj.values('country')[:1]
)

return {
'q': {
Expand Down Expand Up @@ -292,6 +294,14 @@ def get_facets(self):
'field_label': 'Institution size',
'choice_label_field': 'name',
},
'band_country': {
'type': 'charfield_with_choices',
'annotations': {
'band_country': band_country,
},
'model_choices': supporter_models.Band._meta.get_field('country').choices,
'field_label': 'Country',
},
}

def get_order_by_choices(self):
Expand Down