mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-02-17 03:25:19 +00:00
Disable imports in the UI and view
This commit is contained in:
parent
7c7c0e1a93
commit
28567e2d8e
2 changed files with 89 additions and 73 deletions
|
@ -8,6 +8,7 @@
|
|||
<div class="block">
|
||||
<h1 class="title">{% trans "Import Books" %}</h1>
|
||||
|
||||
{% if site.imports_enabled %}
|
||||
{% if recent_avg_hours or recent_avg_minutes %}
|
||||
<div class="notification">
|
||||
<p>
|
||||
|
@ -85,6 +86,16 @@
|
|||
</div>
|
||||
<button class="button is-primary" type="submit">{% trans "Import" %}</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<div class="box notification has-text-centered is-warning m-6 content">
|
||||
<p class="mt-5">
|
||||
<span class="icon icon-warning is-size-2" aria-hidden="true"></span>
|
||||
</p>
|
||||
<p class="mb-5">
|
||||
{% trans "Imports are temporarily disabled; thank you for your patience." %}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="content block">
|
||||
|
|
|
@ -4,6 +4,7 @@ import datetime
|
|||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.db.models import Avg, ExpressionWrapper, F, fields
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.paginator import Paginator
|
||||
from django.http import HttpResponseBadRequest
|
||||
from django.shortcuts import redirect
|
||||
|
@ -54,6 +55,10 @@ class Import(View):
|
|||
|
||||
def post(self, request):
|
||||
"""ingest a goodreads csv"""
|
||||
site = models.Site.objects.get()
|
||||
if not site.imports_enabled:
|
||||
raise PermissionDenied()
|
||||
|
||||
form = forms.ImportForm(request.POST, request.FILES)
|
||||
if not form.is_valid():
|
||||
return HttpResponseBadRequest()
|
||||
|
|
Loading…
Reference in a new issue