mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-06-01 19:33:29 +00:00
Merge 0630e34973
into b6aba44e42
This commit is contained in:
commit
242349ff14
|
@ -24,7 +24,6 @@ class FileLinkForm(CustomForm):
|
|||
"""make sure the domain isn't blocked or pending"""
|
||||
cleaned_data = super().clean()
|
||||
url = cleaned_data.get("url")
|
||||
filetype = cleaned_data.get("filetype")
|
||||
book = cleaned_data.get("book")
|
||||
domain = urlparse(url).netloc
|
||||
if models.LinkDomain.objects.filter(domain=domain).exists():
|
||||
|
@ -38,7 +37,7 @@ class FileLinkForm(CustomForm):
|
|||
),
|
||||
)
|
||||
if (
|
||||
models.FileLink.objects.filter(url=url, book=book, filetype=filetype)
|
||||
models.FileLink.objects.filter(url=url, book=book)
|
||||
.exclude(pk=self.instance)
|
||||
.exists()
|
||||
):
|
||||
|
@ -46,6 +45,6 @@ class FileLinkForm(CustomForm):
|
|||
self.add_error(
|
||||
"url",
|
||||
_(
|
||||
"This link with file type has already been added for this book. If it is not visible, the domain is still pending."
|
||||
"This link has already been added for this book. If it is not visible, the domain is still pending."
|
||||
),
|
||||
)
|
||||
|
|
|
@ -32,63 +32,71 @@
|
|||
<th>{% trans "URL" %}</th>
|
||||
<th>{% trans "Added by" %}</th>
|
||||
<th>{% trans "Filetype" %}</th>
|
||||
<th>{% trans "Availability" %}</th>
|
||||
<th>{% trans "Domain" %}</th>
|
||||
<th>{% trans "Status" %}</th>
|
||||
<th colspan="2">{% trans "Actions" %}</th>
|
||||
</tr>
|
||||
{% for link in links %}
|
||||
<tr>
|
||||
<td class="overflow-wrap-anywhere">
|
||||
<a href="{{ link.url }}" target="_blank" rel="nofollow noopener noreferrer">{{ link.url }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if link.added_by %}
|
||||
<a href="{% url 'user-feed' link.added_by.id %}">{{ link.added_by.display_name }}</a>
|
||||
{% else %}
|
||||
<em>{% trans "Unknown user" %}</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{ link.filelink.filetype }}
|
||||
</td>
|
||||
<td>
|
||||
{{ link.domain.name }}
|
||||
<p>
|
||||
<a href="{% url 'report-link' link.id %}">{% trans "Report spam" %}</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
{% with status=link.domain.status %}
|
||||
<span class="tag {% if status == 'blocked' %}has-background-danger{% elif status == 'approved' %}has-background-primary{% endif %}">
|
||||
<span class="icon" aria-hidden="true">
|
||||
<span class="icon-{% if status == 'blocked' %}x{% elif status == 'approved' %}check{% else %}lock{% endif %}"></span>
|
||||
</span>
|
||||
<span>
|
||||
{{ link.domain.get_status_display }}
|
||||
</span>
|
||||
</span>
|
||||
{% endwith %}
|
||||
</td>
|
||||
<td>
|
||||
<form name="edit-link" class="control" method="post" action="{% url 'file-link' book.id link.id %}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="url" value="{{ link.form.url.value }}">
|
||||
<input type="hidden" name="filetype" value="{{ link.form.filetype.value }}">
|
||||
<input type="hidden" name="added_by" value="{{ link.form.added_by.value }}">
|
||||
<input type="hidden" name="book" value="{{ link.form.book.value }}">
|
||||
<div class="field has-addons">
|
||||
<form name="edit-link-{{ link.id }}" class="control" method="post" action="{% url 'file-link' book.id link.id %}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="url" value="{{ link.form.url.value }}">
|
||||
<input type="hidden" name="added_by" value="{{ link.form.added_by.value }}">
|
||||
<input type="hidden" name="book" value="{{ link.form.book.value }}">
|
||||
<td class="overflow-wrap-anywhere">
|
||||
<a href="{{ link.url }}" target="_blank" rel="nofollow noopener noreferrer">{{ link.url }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if link.added_by %}
|
||||
<a href="{% url 'user-feed' link.added_by.id %}">{{ link.added_by.display_name }}</a>
|
||||
{% else %}
|
||||
<em>{% trans "Unknown user" %}</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
{{ link.form.filetype }}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
{{ link.form.availability }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{{ link.domain.name }}
|
||||
<p>
|
||||
<a href="{% url 'report-link' link.id %}">{% trans "Report spam" %}</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
{% with status=link.domain.status %}
|
||||
<span class="tag {% if status == 'blocked' %}has-background-danger{% elif status == 'approved' %}has-background-primary{% endif %}">
|
||||
<span class="icon" aria-hidden="true">
|
||||
<span class="icon-{% if status == 'blocked' %}x{% elif status == 'approved' %}check{% else %}lock{% endif %}"></span>
|
||||
</span>
|
||||
<span>
|
||||
{{ link.domain.get_status_display }}
|
||||
</span>
|
||||
</span>
|
||||
{% endwith %}
|
||||
</td>
|
||||
<td>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit">{% trans "Save" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
{% include 'snippets/form_errors.html' with errors_list=link.form.availability.errors id="desc_availability" %}
|
||||
</form>
|
||||
</td>
|
||||
</td>
|
||||
</form>
|
||||
<td>
|
||||
<form name="delete-link-{{ link.id }}" class="control" method="post" action="{% url 'file-link-delete' book.id link.id %}">
|
||||
{% csrf_token %}
|
||||
|
@ -99,7 +107,7 @@
|
|||
{% endfor %}
|
||||
{% if not book.file_links.exists %}
|
||||
<tr>
|
||||
<td colspan="5"><em>{% trans "No links available for this book." %}</em></td>
|
||||
<td colspan="8"><em>{% trans "No links available for this book." %}</em></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
|
|
Loading…
Reference in a new issue