Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • konstantin/akplanning
  • matedealer/akplanning
  • kif/akplanning
  • mirco/akplanning
  • lordofthevoid/akplanning
  • voidptr/akplanning
  • xayomer/akplanning-fork
  • mollux/akplanning
  • neumantm/akplanning
  • mmarx/akplanning
  • nerf/akplanning
  • felix_bonn/akplanning
  • sebastian.uschmann/akplanning
13 results
Select Git revision
Show changes
...@@ -23,6 +23,13 @@ ...@@ -23,6 +23,13 @@
); );
}); });
</script> </script>
<style>
#id_present_helptext::after {
content: " ({% trans "only relevant for KIF-AKs - determines whether the AK appears in the slides for the closing plenary session" %})";
color: #6c757d;
}
</style>
{% endblock %} {% endblock %}
{% block breadcrumbs %} {% block breadcrumbs %}
......
from datetime import timedelta from datetime import datetime, timedelta
from django.test import TestCase from django.test import TestCase
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils.datetime_safe import datetime
from AKModel.models import AK, AKSlot, Event from AKModel.models import AK, AKSlot, Event
from AKModel.tests import BasicViewTests from AKModel.tests import BasicViewTests
from AKSubmission.forms import AKSubmissionForm
class ModelViewTests(BasicViewTests, TestCase): class ModelViewTests(BasicViewTests, TestCase):
...@@ -46,8 +46,8 @@ class ModelViewTests(BasicViewTests, TestCase): ...@@ -46,8 +46,8 @@ class ModelViewTests(BasicViewTests, TestCase):
'expected_message': "AK successfully updated"}, 'expected_message': "AK successfully updated"},
{'view': 'akslot_edit', 'target_view': 'ak_detail', 'kwargs': {'event_slug': 'kif42', 'pk': 5}, {'view': 'akslot_edit', 'target_view': 'ak_detail', 'kwargs': {'event_slug': 'kif42', 'pk': 5},
'target_kwargs': {'event_slug': 'kif42', 'pk': 1}, 'expected_message': "AK Slot successfully updated"}, 'target_kwargs': {'event_slug': 'kif42', 'pk': 1}, 'expected_message': "AK Slot successfully updated"},
{'view': 'akowner_edit', 'target_view': 'submission_overview', 'kwargs': {'event_slug': 'kif42', 'slug': 'a'}, {'view': 'akowner_edit', 'target_view': 'submission_overview', 'kwargs': {'event_slug': 'kif42', 'slug': 'a'},
'target_kwargs': {'event_slug': 'kif42'}, 'expected_message': "Person Info successfully updated"}, 'target_kwargs': {'event_slug': 'kif42'}, 'expected_message': "Person Info successfully updated"},
] ]
def test_akslot_edit_delete_prevention(self): def test_akslot_edit_delete_prevention(self):
...@@ -146,7 +146,8 @@ class ModelViewTests(BasicViewTests, TestCase): ...@@ -146,7 +146,8 @@ class ModelViewTests(BasicViewTests, TestCase):
add_redirect_url = reverse_lazy(f"{self.APP_NAME}:submit_ak", kwargs={'event_slug': 'kif42', 'owner_slug': 'a'}) add_redirect_url = reverse_lazy(f"{self.APP_NAME}:submit_ak", kwargs={'event_slug': 'kif42', 'owner_slug': 'a'})
response = self.client.post(select_url, {'owner_id': 1}) response = self.client.post(select_url, {'owner_id': 1})
self.assertRedirects(response, add_redirect_url, status_code=302, target_status_code=200, self.assertRedirects(response, add_redirect_url, status_code=302, target_status_code=200,
msg_prefix=f"Dispatch redirect to ak submission page failed (should go to {add_redirect_url})") msg_prefix=f"Dispatch redirect to ak submission page failed "
f"(should go to {add_redirect_url})")
def test_orga_message_submission(self): def test_orga_message_submission(self):
""" """
...@@ -200,7 +201,8 @@ class ModelViewTests(BasicViewTests, TestCase): ...@@ -200,7 +201,8 @@ class ModelViewTests(BasicViewTests, TestCase):
# Test indication outside of indication window -> HTTP 403, counter not increased # Test indication outside of indication window -> HTTP 403, counter not increased
response = self.client.post(interest_api_url) response = self.client.post(interest_api_url)
self.assertEqual(response.status_code, 403, self.assertEqual(response.status_code, 403,
"API end point still reachable even though interest indication window ended ({interest_api_url})") "API end point still reachable even though interest indication window ended "
"({interest_api_url})")
self.assertEqual(AK.objects.get(pk=1).interest_counter, ak_interest_counter + 1, self.assertEqual(AK.objects.get(pk=1).interest_counter, ak_interest_counter + 1,
"Counter was increased even though interest indication window ended") "Counter was increased even though interest indication window ended")
...@@ -236,3 +238,39 @@ class ModelViewTests(BasicViewTests, TestCase): ...@@ -236,3 +238,39 @@ class ModelViewTests(BasicViewTests, TestCase):
msg_prefix=f"No correct redirect: {add_new_user_to_ak_url} (POST) -> {detail_url}") msg_prefix=f"No correct redirect: {add_new_user_to_ak_url} (POST) -> {detail_url}")
self._assert_message(response, "Added 'New test owner' as new owner of 'Test AK Inhalt'") self._assert_message(response, "Added 'New test owner' as new owner of 'Test AK Inhalt'")
self.assertEqual(AK.objects.get(pk=1).owners.count(), 2) self.assertEqual(AK.objects.get(pk=1).owners.count(), 2)
def test_visibility_requirements_in_submission_form(self):
"""
Test visibility of requirements field in submission form
"""
event = Event.get_by_slug('kif42')
form = AKSubmissionForm(data={'name': 'Test AK', 'event': event}, instance=None, initial={"event": event})
self.assertIn('requirements', form.fields,
msg="Requirements field not present in form even though event has requirements")
event2 = Event.objects.create(name='Event without requirements',
slug='no_req',
start=datetime.now().astimezone(event.timezone),
end=datetime.now().astimezone(event.timezone),
active=True)
form2 = AKSubmissionForm(data={'name': 'Test AK', 'event': event2}, instance=None, initial={"event": event2})
self.assertNotIn('requirements', form2.fields,
msg="Requirements field should not be present for events without requirements")
def test_visibility_types_in_submission_form(self):
"""
Test visibility of types field in submission form
"""
event = Event.get_by_slug('kif42')
form = AKSubmissionForm(data={'name': 'Test AK', 'event': event}, instance=None, initial={"event": event})
self.assertIn('types', form.fields,
msg="Requirements field not present in form even though event has requirements")
event2 = Event.objects.create(name='Event without types',
slug='no_types',
start=datetime.now().astimezone(event.timezone),
end=datetime.now().astimezone(event.timezone),
active=True)
form2 = AKSubmissionForm(data={'name': 'Test AK', 'event': event2}, instance=None, initial={"event": event2})
self.assertNotIn('types', form2.fields,
msg="Requirements field should not be present for events without types")
from datetime import timedelta
from math import floor
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from datetime import datetime, timedelta
from math import floor
from django.apps import apps from django.apps import apps
from django.conf import settings from django.conf import settings
...@@ -8,19 +8,17 @@ from django.contrib import messages ...@@ -8,19 +8,17 @@ from django.contrib import messages
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils.datetime_safe import datetime
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.views import View from django.views import View
from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView, TemplateView from django.views.generic import CreateView, DeleteView, DetailView, ListView, TemplateView, UpdateView
from AKModel.availability.models import Availability from AKModel.availability.models import Availability
from AKModel.metaviews import status_manager from AKModel.metaviews import status_manager
from AKModel.metaviews.status import TemplateStatusWidget
from AKModel.models import AK, AKCategory, AKOwner, AKSlot, AKTrack, AKOrgaMessage
from AKModel.metaviews.admin import EventSlugMixin, FilterByEventSlugMixin from AKModel.metaviews.admin import EventSlugMixin, FilterByEventSlugMixin
from AKModel.metaviews.status import TemplateStatusWidget
from AKModel.models import AK, AKCategory, AKOrgaMessage, AKOwner, AKSlot, AKTrack
from AKSubmission.api import ak_interest_indication_active from AKSubmission.api import ak_interest_indication_active
from AKSubmission.forms import AKWishForm, AKOwnerForm, AKSubmissionForm, AKDurationForm, AKOrgaMessageForm, \ from AKSubmission.forms import AKDurationForm, AKForm, AKOrgaMessageForm, AKOwnerForm, AKSubmissionForm, AKWishForm
AKForm
class SubmissionErrorNotConfiguredView(EventSlugMixin, TemplateView): class SubmissionErrorNotConfiguredView(EventSlugMixin, TemplateView):
...@@ -47,7 +45,7 @@ class AKOverviewView(FilterByEventSlugMixin, ListView): ...@@ -47,7 +45,7 @@ class AKOverviewView(FilterByEventSlugMixin, ListView):
template_name = "AKSubmission/ak_overview.html" template_name = "AKSubmission/ak_overview.html"
wishes_as_category = False wishes_as_category = False
def filter_aks(self, context, category): # pylint: disable=unused-argument def filter_aks(self, context, category): # pylint: disable=unused-argument
""" """
Filter which AKs to display based on the given context and category Filter which AKs to display based on the given context and category
...@@ -59,7 +57,7 @@ class AKOverviewView(FilterByEventSlugMixin, ListView): ...@@ -59,7 +57,7 @@ class AKOverviewView(FilterByEventSlugMixin, ListView):
:rtype: QuerySet[AK] :rtype: QuerySet[AK]
""" """
# Use prefetching and relation selection/joining to reduce the amount of necessary queries # Use prefetching and relation selection/joining to reduce the amount of necessary queries
return category.ak_set.select_related('event').prefetch_related('owners').all() return category.ak_set.select_related('event').prefetch_related('owners').prefetch_related('types').all()
def get_active_category_name(self, context): def get_active_category_name(self, context):
""" """
...@@ -73,7 +71,7 @@ class AKOverviewView(FilterByEventSlugMixin, ListView): ...@@ -73,7 +71,7 @@ class AKOverviewView(FilterByEventSlugMixin, ListView):
""" """
return context["categories_with_aks"][0][0].name return context["categories_with_aks"][0][0].name
def get_table_title(self, context): # pylint: disable=unused-argument def get_table_title(self, context): # pylint: disable=unused-argument
""" """
Specify the title above the AK list/table in this view Specify the title above the AK list/table in this view
...@@ -91,7 +89,7 @@ class AKOverviewView(FilterByEventSlugMixin, ListView): ...@@ -91,7 +89,7 @@ class AKOverviewView(FilterByEventSlugMixin, ListView):
redirect to error page if necessary (see :class:`SubmissionErrorNotConfiguredView`) redirect to error page if necessary (see :class:`SubmissionErrorNotConfiguredView`)
""" """
self._load_event() self._load_event()
self.object_list = self.get_queryset() # pylint: disable=attribute-defined-outside-init self.object_list = self.get_queryset() # pylint: disable=attribute-defined-outside-init
# No categories yet? Redirect to configuration error page # No categories yet? Redirect to configuration error page
if self.object_list.count() == 0: if self.object_list.count() == 0:
...@@ -124,12 +122,14 @@ class AKOverviewView(FilterByEventSlugMixin, ListView): ...@@ -124,12 +122,14 @@ class AKOverviewView(FilterByEventSlugMixin, ListView):
if self.wishes_as_category: if self.wishes_as_category:
categories_with_aks.append( categories_with_aks.append(
(AKCategory(name=_("Wishes"), pk=0, 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["categories_with_aks"] = categories_with_aks
context["active_category"] = self.get_active_category_name(context) context["active_category"] = self.get_active_category_name(context)
context['table_title'] = self.get_table_title(context) context['table_title'] = self.get_table_title(context)
context['show_types'] = self.event.aktype_set.count() > 0
# ========================================================== # ==========================================================
# Display interest indication button? # Display interest indication button?
# ========================================================== # ==========================================================
...@@ -181,10 +181,13 @@ class AKListByCategoryView(AKOverviewView): ...@@ -181,10 +181,13 @@ class AKListByCategoryView(AKOverviewView):
This view inherits from :class:`AKOverviewView`, but produces only one list instead of a tabbed one. This view inherits from :class:`AKOverviewView`, but produces only one list instead of a tabbed one.
""" """
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
# Override dispatching # Override dispatching
# Needed to handle the checking whether the category exists # Needed to handle the checking whether the category exists
self.category = get_object_or_404(AKCategory, pk=kwargs['category_pk']) # pylint: disable=attribute-defined-outside-init,line-too-long # noinspection PyAttributeOutsideInit
# pylint: disable=attribute-defined-outside-init
self.category = get_object_or_404(AKCategory, pk=kwargs['category_pk'])
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_active_category_name(self, context): def get_active_category_name(self, context):
...@@ -207,11 +210,12 @@ class AKListByTrackView(AKOverviewView): ...@@ -207,11 +210,12 @@ class AKListByTrackView(AKOverviewView):
This view inherits from :class:`AKOverviewView` and there will be one list per category This view inherits from :class:`AKOverviewView` and there will be one list per category
-- but only AKs of a certain given track will be included in them. -- but only AKs of a certain given track will be included in them.
""" """
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
# Override dispatching # Override dispatching
# Needed to handle the checking whether the track exists # Needed to handle the checking whether the track exists
self.track = get_object_or_404(AKTrack, pk=kwargs['track_pk']) # pylint: disable=attribute-defined-outside-init self.track = get_object_or_404(AKTrack, pk=kwargs['track_pk']) # pylint: disable=attribute-defined-outside-init
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def filter_aks(self, context, category): def filter_aks(self, context, category):
...@@ -290,6 +294,7 @@ class EventInactiveRedirectMixin: ...@@ -290,6 +294,7 @@ class EventInactiveRedirectMixin:
Will add a message explaining why the action was not performed to the user Will add a message explaining why the action was not performed to the user
and then redirect to start page of the submission component and then redirect to start page of the submission component
""" """
def get_error_message(self): def get_error_message(self):
""" """
Error message to display after redirect (can be adjusted by this method) Error message to display after redirect (can be adjusted by this method)
...@@ -349,6 +354,7 @@ class AKSubmissionView(AKAndAKWishSubmissionView): ...@@ -349,6 +354,7 @@ class AKSubmissionView(AKAndAKWishSubmissionView):
Extends :class:`AKAndAKWishSubmissionView` Extends :class:`AKAndAKWishSubmissionView`
""" """
def get_initial(self): def get_initial(self):
# Load initial values for the form # Load initial values for the form
# Used to directly add the first owner and the event this AK will belong to # Used to directly add the first owner and the event this AK will belong to
...@@ -498,7 +504,6 @@ class AKOwnerDispatchView(ABC, EventSlugMixin, View): ...@@ -498,7 +504,6 @@ class AKOwnerDispatchView(ABC, EventSlugMixin, View):
:rtype: HttpResponseRedirect :rtype: HttpResponseRedirect
""" """
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
# This view is solely meant to handle POST requests # This view is solely meant to handle POST requests
# Perform dispatching based on the submitted owner_id # Perform dispatching based on the submitted owner_id
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.