mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-02-19 20:36:20 +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">
|
<div class="block">
|
||||||
<h1 class="title">{% trans "Import Books" %}</h1>
|
<h1 class="title">{% trans "Import Books" %}</h1>
|
||||||
|
|
||||||
|
{% if site.imports_enabled %}
|
||||||
{% if recent_avg_hours or recent_avg_minutes %}
|
{% if recent_avg_hours or recent_avg_minutes %}
|
||||||
<div class="notification">
|
<div class="notification">
|
||||||
<p>
|
<p>
|
||||||
|
@ -85,6 +86,16 @@
|
||||||
</div>
|
</div>
|
||||||
<button class="button is-primary" type="submit">{% trans "Import" %}</button>
|
<button class="button is-primary" type="submit">{% trans "Import" %}</button>
|
||||||
</form>
|
</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>
|
||||||
|
|
||||||
<div class="content block">
|
<div class="content block">
|
||||||
|
|
|
@ -4,6 +4,7 @@ import datetime
|
||||||
|
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db.models import Avg, ExpressionWrapper, F, fields
|
from django.db.models import Avg, ExpressionWrapper, F, fields
|
||||||
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from django.http import HttpResponseBadRequest
|
from django.http import HttpResponseBadRequest
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
|
@ -54,6 +55,10 @@ class Import(View):
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
"""ingest a goodreads csv"""
|
"""ingest a goodreads csv"""
|
||||||
|
site = models.Site.objects.get()
|
||||||
|
if not site.imports_enabled:
|
||||||
|
raise PermissionDenied()
|
||||||
|
|
||||||
form = forms.ImportForm(request.POST, request.FILES)
|
form = forms.ImportForm(request.POST, request.FILES)
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
return HttpResponseBadRequest()
|
return HttpResponseBadRequest()
|
||||||
|
|
Loading…
Reference in a new issue