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> </label>
</div> </div>
<div class="field"> <div class="field">
<label> <label class="label" for="privacy_import">
<span class="label">{% trans "Privacy setting for imported reviews:" %}</span> {% trans "Privacy setting for imported reviews:" %}
{% include 'snippets/privacy_select.html' with no_label=True %}
</label> </label>
{% include 'snippets/privacy_select.html' with no_label=True privacy_uuid="import" %}
</div> </div>
</div> </div>
</div> </div>

View file

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

View file

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