-
Notifications
You must be signed in to change notification settings - Fork 0
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 #2170 from laws-africa/search-alerts-ui
Search alerts UI
- Loading branch information
Showing
16 changed files
with
236 additions
and
244 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
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
3 changes: 3 additions & 0 deletions
3
peachjam_search/templates/peachjam_search/_saved_search_filters.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,3 @@ | ||
{# djlint:off #} | ||
{% for values in saved_search.get_filters_dict.values %}{% if not forloop.first %}, {% endif %}{{ values|join:", " }}{% endfor %} | ||
{# djlint:on #} |
54 changes: 0 additions & 54 deletions
54
peachjam_search/templates/peachjam_search/_saved_search_list.html
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
peachjam_search/templates/peachjam_search/_saved_search_modal.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,70 @@ | ||
{% load i18n %} | ||
<div hx-swap-oob="true" | ||
id="saved-search-modal-dialog" | ||
class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h1 id="saved-search-modal-label" class="modal-title fs-5">{% trans 'Search alert' %}</h1> | ||
<button type="button" | ||
class="btn-close" | ||
data-bs-dismiss="modal" | ||
aria-label="{% trans "Close" %}"></button> | ||
</div> | ||
<div class="modal-body"> | ||
{% if request.user.is_authenticated %} | ||
{% if saved_search.pk %} | ||
<p class="alert alert-primary">{% trans "We'll email you when new documents are found for this search." %}</p> | ||
<form id="saved-search-form" | ||
hx-target="#saved-search-button" | ||
hx-post="{% url 'search:saved_search_update' saved_search.pk %}"> | ||
<div class="mb-3">{{ saved_search.q }}</div> | ||
<div class="mb-3">{% include 'peachjam_search/_saved_search_filters.html' %}</div> | ||
<div> | ||
<label class="form-label" for="{{ form.note.id_for_label }}">{{ form.note.label }}</label> | ||
<textarea class="form-control" | ||
id="{{ form.note.id_for_label }}" | ||
name="{{ form.note.name }}" | ||
placeholder="{% trans "A note to yourself about this search" %}">{{ form.note.value|default_if_none:'' }}</textarea> | ||
</div> | ||
</form> | ||
{% else %} | ||
{% trans "Saving..." %} | ||
{% endif %} | ||
<div class="mt-3"> | ||
<a href="{% url 'search:saved_search_list' %}">{% trans "All search alerts" %}</a> | ||
</div> | ||
{% else %} | ||
{% blocktrans trimmed %} | ||
You are not logged in. Please log in to receive alerts when we find new matches for your search. | ||
{% endblocktrans %} | ||
{% endif %} | ||
</div> | ||
<div class="modal-footer {% if saved_search.pk %}d-flex justify-content-between{% endif %}"> | ||
{% if saved_search.pk %} | ||
<button class="btn btn-danger" | ||
type="button" | ||
data-bs-dismiss="modal" | ||
hx-target="#saved-search-button" | ||
hx-post="{% url 'search:saved_search_delete' saved_search.pk %}?next={% url 'search:saved_search_button' %}" | ||
hx-confirm="{% trans "Are you sure?" %}"> | ||
{% trans 'Delete alert' %} | ||
</button> | ||
{% endif %} | ||
<div> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans 'Close' %}</button> | ||
{% if request.user.is_authenticated %} | ||
{% if saved_search.pk %} | ||
<button type="submit" | ||
form="saved-search-form" | ||
class="btn btn-primary" | ||
data-bs-dismiss="modal"> | ||
{% trans 'Save' %} | ||
</button> | ||
{% endif %} | ||
{% else %} | ||
<a href="{% url 'account_login' %}" class="btn btn-primary">{% trans 'Login' %}</a> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
27 changes: 16 additions & 11 deletions
27
peachjam_search/templates/peachjam_search/emails/search_alert.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 |
---|---|---|
@@ -1,21 +1,26 @@ | ||
{% load i18n %} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"/> | ||
<title>Search Alert</title> | ||
<title>{% trans "Search Alert" %}</title> | ||
</head> | ||
<body> | ||
<p>Hi {{ saved_search.user }}</p> | ||
<p>We have found new documents that match your search for:</p> | ||
<p>{{ saved_search.user }},</p> | ||
<p>{% trans "We have found new documents that match your search alert:" %}</p> | ||
<p> | ||
<strong>{{ saved_search.q }}</strong> | ||
<strong><a href="{{ site.domain }}{{ saved_search.get_absolute_url }}">{{ saved_search.q }}</a></strong> | ||
</p> | ||
<p>{% include 'peachjam_search/_saved_search_filters.html' %}</p> | ||
<ul> | ||
{% for doc in hits %} | ||
<li> | ||
<a href="{{ site.domain }}{{ doc.expression_frbr_uri }}">{{ doc.title }}</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
<p> | ||
<a href="{{ site.domain }}{% url "search:saved_search_list" %}">{% trans "Manage your search alerts" %}</a> | ||
</p> | ||
<p>Here are the new documents:</p> | ||
{% for doc in hits %} | ||
<h3> | ||
<a href="{{ site.domain }}{{ doc.expression_frbr_uri }}">{{ doc.title }}</a> | ||
</h3> | ||
{% endfor %} | ||
<p>Best regards.</p> | ||
</body> | ||
</html> |
19 changes: 11 additions & 8 deletions
19
peachjam_search/templates/peachjam_search/emails/search_alert.txt
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,13 +1,16 @@ | ||
Search Alert | ||
Hi {{ saved_search.user }} | ||
We have found new documents that match your search for: | ||
{{ saved_search.user }}, | ||
|
||
We have found new documents that match your search alert: | ||
|
||
{{ saved_search.q }} | ||
Here are the new documents: | ||
|
||
{{ site.domain }}{{ saved_search.get_absolute_url }} | ||
|
||
{% for doc in hits %} | ||
TITLE: {{ doc.title }} | ||
URL: {{ site.domain }}{{ doc.expression_frbr_uri }} | ||
======================== | ||
Title: {{ doc.title }} | ||
{{ site.domain }}{{ doc.expression_frbr_uri }} | ||
|
||
{% endfor %} | ||
|
||
Best regards. | ||
|
||
Manage your search alerts: {{ site.domain }}{% url "search:saved_search_list" %} |
15 changes: 15 additions & 0 deletions
15
peachjam_search/templates/peachjam_search/saved_search_button.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,15 @@ | ||
{% load i18n %} | ||
{% if request.user.is_authenticated %} | ||
<form id="saved-search-button" | ||
hx-post="{% url 'search:saved_search_create' %}"> | ||
<input type="hidden" name="q" value="{{ saved_search.q }}"/> | ||
<input type="hidden" name="filters" value="{{ saved_search.filters }}"/> | ||
{% endif %} | ||
<button class="btn btn-outline-primary" | ||
data-bs-toggle="modal" | ||
data-bs-target="#saved-search-modal"> | ||
<i class="bi bi-bell"></i> | ||
{% trans 'Get alerts for this search' %} | ||
</button> | ||
{% if request.user.is_authenticated %}</form>{% endif %} | ||
{% include 'peachjam_search/_saved_search_modal.html' %} |
Oops, something went wrong.