Merge pull request #1601 from bookwyrm-social/import-view

Cleans up html in import view
This commit is contained in:
Mouse Reeve 2021-11-11 13:53:07 -08:00 committed by GitHub
commit 5130053249
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 16 deletions

View file

@ -46,10 +46,10 @@
</label>
</div>
<div class="field">
<label>
<span class="label">{% trans "Privacy setting for imported reviews:" %}</span>
{% include 'snippets/privacy_select.html' with no_label=True %}
<label class="label" for="privacy_import">
{% trans "Privacy setting for imported reviews:" %}
</label>
{% include 'snippets/privacy_select.html' with no_label=True privacy_uuid="import" %}
</div>
</div>
</div>

View file

@ -10,18 +10,17 @@
<h1 class="title">{% trans "Import Status" %}</h1>
<a href="{% url 'import' %}" class="has-text-weight-normal help subtitle is-link">{% trans "Back to imports" %}</a>
{% if task.failed %}
<div class="notification is-danger">{% trans "TASK FAILED" %}</div>
{% endif %}
<dl>
<div class="is-flex">
<dt class="has-text-weight-medium">{% trans "Import started:" %}</dt>
<dd class="ml-2">{{ job.created_date | naturaltime }}</dd>
</div>
<dt class="is-pulled-left mr-5">{% trans "Import started:" %}</dt>
<dd>{{ job.created_date | naturaltime }}</dd>
{% if job.complete %}
<div class="is-flex">
<dt class="has-text-weight-medium">{% trans "Import completed:" %}</dt>
<dd class="ml-2">{{ task.date_done | naturaltime }}</dd>
</div>
{% elif task.failed %}
<div class="notification is-danger">{% trans "TASK FAILED" %}</div>
<dt class="is-pulled-left mr-5">{% trans "Import completed:" %}</dt>
<dd>{{ task.date_done | naturaltime }}</dd>
{% endif %}
</dl>
</div>

View file

@ -5,6 +5,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile
from django.template.response import TemplateResponse
from django.test import TestCase
from django.test.client import RequestFactory
from bookwyrm.tests.validate_html import validate_html
from bookwyrm import forms, models, views
@ -34,7 +35,7 @@ class ImportViews(TestCase):
request.user = self.local_user
result = view(request)
self.assertIsInstance(result, TemplateResponse)
result.render()
validate_html(result.render())
self.assertEqual(result.status_code, 200)
def test_import_status(self):
@ -47,7 +48,7 @@ class ImportViews(TestCase):
async_result.return_value = []
result = view(request, import_job.id)
self.assertIsInstance(result, TemplateResponse)
result.render()
validate_html(result.render())
self.assertEqual(result.status_code, 200)
def test_start_import(self):
@ -59,7 +60,10 @@ class ImportViews(TestCase):
form.data["include_reviews"] = False
csv_file = pathlib.Path(__file__).parent.joinpath("../data/goodreads.csv")
form.data["csv_file"] = SimpleUploadedFile(
csv_file, open(csv_file, "rb").read(), content_type="text/csv"
# pylint: disable=consider-using-with
csv_file,
open(csv_file, "rb").read(),
content_type="text/csv",
)
request = self.factory.post("", form.data)