diff --git a/AKSubmission/templates/AKSubmission/submission_not_configured.html b/AKSubmission/templates/AKSubmission/submission_not_configured.html new file mode 100644 index 0000000000000000000000000000000000000000..48de5f60b857affaa1f1a1c1c995a9baefb3d93c --- /dev/null +++ b/AKSubmission/templates/AKSubmission/submission_not_configured.html @@ -0,0 +1,22 @@ +{% extends 'AKSubmission/submission_base.html' %} + +{% load i18n %} +{% load fontawesome_5 %} +{% load static %} + +{% block title %}{% trans "AKs" %}: {{ event.name }} - {% trans "AK Submission" %}{% endblock %} + +{% block breadcrumbs %} + {% include "AKSubmission/submission_breadcrumbs.html" %} + <li class="breadcrumb-item active">{% trans "AK Submission" %}</li> +{% endblock %} + +{% block content %} + <h1>{{ event.name }}</h1> + + {% include "AKSubmission/messages.html" %} + + <div class="alert alert-warning" style="margin-top:20px;margin-bottom: 20px;"> + {% trans "System is not yet configured for AK submission and listing. Please try again later." %} + </div> +{% endblock %} diff --git a/AKSubmission/urls.py b/AKSubmission/urls.py index 982db8a7130b065a5992022be6b3ae36c248da9d..57dd16efbfd1d0f09a86545c7a3b81a1dcf03886 100644 --- a/AKSubmission/urls.py +++ b/AKSubmission/urls.py @@ -26,6 +26,7 @@ urlpatterns = [ path('<slug:slug>/edit/', views.AKOwnerEditView.as_view(), name='akowner_edit'), path('<slug:owner_slug>/new/', views.AKSubmissionView.as_view(), name='submit_ak'), path('new_wish/', views.AKWishSubmissionView.as_view(), name='submit_ak_wish'), + path('error/', views.SubmissionErrorNotConfiguredView.as_view(), name='error_not_configured'), ]) ), ] diff --git a/AKSubmission/views.py b/AKSubmission/views.py index 662d038d113c6fb1f85e7461845c4407792860a4..4678c8406fdadb374654241af8b7beb15a6c7eb0 100644 --- a/AKSubmission/views.py +++ b/AKSubmission/views.py @@ -1,11 +1,11 @@ from django.conf import settings from django.contrib import messages -from django.http import Http404, HttpResponseRedirect +from django.http import HttpResponseRedirect from django.shortcuts import get_object_or_404, redirect from django.urls import reverse_lazy from django.utils.translation import gettext_lazy as _ from django.views import View -from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView, RedirectView +from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView, RedirectView, TemplateView from AKModel.models import AK, AKCategory, AKTag, AKOwner, AKSlot, AKTrack from AKModel.views import EventSlugMixin @@ -13,6 +13,10 @@ from AKModel.views import FilterByEventSlugMixin from AKSubmission.forms import AKWishForm, AKOwnerForm, AKEditForm, AKSubmissionForm, AKDurationForm +class SubmissionErrorNotConfiguredView(EventSlugMixin, TemplateView): + template_name = "AKSubmission/submission_not_configured.html" + + class AKOverviewView(FilterByEventSlugMixin, ListView): model = AKCategory context_object_name = "categories" @@ -28,6 +32,17 @@ class AKOverviewView(FilterByEventSlugMixin, ListView): def get_table_title(self, context): return _("All AKs") + def get(self, request, *args, **kwargs): + self._load_event() + self.object_list = self.get_queryset() + + # No categories yet? Redirect to configuration error page + if self.object_list.count() == 0: + return redirect(reverse_lazy("submit:error_not_configured", kwargs={'event_slug': self.event.slug})) + + context = self.get_context_data() + return self.render_to_response(context) + def get_context_data(self, *, object_list=None, **kwargs): context = super().get_context_data(object_list=object_list, **kwargs) @@ -46,7 +61,7 @@ class AKOverviewView(FilterByEventSlugMixin, ListView): if self.wishes_as_category: categories_with_aks.append( - ({"name": _("Wishes"), "pk": "wish", "description": _("AKs one would like to have")}, ak_wishes)) + (AKCategory(name=_("Wishes"), pk=0, description=_("AKs one would like to have")), ak_wishes)) context["categories_with_aks"] = categories_with_aks context["active_category"] = self.get_active_category_name(context)