Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bullet/bullet_admin/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ def get_context_data(self, **kwargs):


class RedirectBackMixin:
def get_default_success_url(self):
default_success_url = None

def get_default_success_url(self) -> str:
if self.default_success_url:
return self.default_success_url

raise ImproperlyConfigured(
"No URL to redirect to. Provide a get_default_success_url."
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load utils %}
{% query_transform back=request.get_full_path as back %}
{% query_transform next=request.get_full_path as back %}
<a href="{{ attributes.url }}{% if not attributes.disable_back %}{{ back }}{% endif %}"
class="p-2 -m-2 {% if attributes.type == "edit" %} text-green-600 hover:text-green-400 {% elif attributes.type == "delete" %} text-red-600 hover:text-red-400 {% else %} text-blue-600 hover:text-blue-400 {% endif %}"
title="{% if attributes.type == "edit" %}Edit{% elif attributes.type == "delete" %}Delete{% elif attributes.type == "view" %}View{% elif attributes.type == "history" %}History{% elif attributes.type == "internal-view" %}View{% elif attributes.type == "download" %}Download sources{% elif attributes.type == "generate" %}Generate documents{% endif %}">
Expand Down
8 changes: 4 additions & 4 deletions bullet/bullet_admin/templates/bullet_admin/generic/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{% endif %}
{% endslot %}
{% slot buttons %}
{% query_replace back=request.get_full_path as back %}
{% query_replace next=request.get_full_path as back %}
{% if help_url %}
{% #abtn icon="mdi:help" label="Help" url=help_url|add:back %}
{% endif %}
Expand Down Expand Up @@ -162,13 +162,13 @@
{% if forloop.first %}
{% if view_url %}
<a class="link absolute inset-0"
href="{{ view_url }}{% query_transform back=request.get_full_path %}"></a>
href="{{ view_url }}{% query_transform next=request.get_full_path %}"></a>
{% elif edit_url %}
<a class="link absolute inset-0"
href="{{ edit_url }}{% query_transform back=request.get_full_path %}"></a>
href="{{ edit_url }}{% query_transform next=request.get_full_path %}"></a>
{% elif delete_url %}
<a class="link absolute inset-0"
href="{{ delete_url }}{% query_transform back=request.get_full_path %}"></a>
href="{{ delete_url }}{% query_transform next=request.get_full_path %}"></a>
{% endif %}
{% endif %}
{% if item or item == 0 %}{{ item }}{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% add_query back_url venue=venue.id as back_url %}
<p>
All teams in this venue are reviewed. Please, <a class="link"
href="{% url "badmin:venue_finish_review" venue.id %}?back={{ back_url|urlencode }}">finish the review</a> when ready.
href="{% url "badmin:venue_finish_review" venue.id %}?next={{ back_url|urlencode }}">finish the review</a> when ready.
</p>
{% else %}
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
Edit
</a>
{% if not competition.results_public %}
<a href="{% url "badmin:team_to_competition" pk=team.id %}?back={{ request.get_full_path|urlencode }}"
<a href="{% url "badmin:team_to_competition" pk=team.id %}?next={{ request.get_full_path|urlencode }}"
class="text-gray-400 hover:text-red-600 text-left flex items-center gap-2">
<span class="iconify"
data-icon="mdi:play"></span>
Expand Down
9 changes: 5 additions & 4 deletions bullet/bullet_admin/views/albums.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from bullet_admin.access import PhotoUploadAccess
from bullet_admin.forms.album import AlbumForm
from bullet_admin.mixins import RedirectBackMixin
from bullet_admin.utils import get_active_competition
from bullet_admin.views import GenericDelete, GenericForm, GenericList

Expand Down Expand Up @@ -53,7 +54,7 @@ def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)


class AlbumFormMixin(GenericForm):
class AlbumFormMixin(RedirectBackMixin, GenericForm):
form_class = AlbumForm
form_multipart = True

Expand All @@ -80,7 +81,7 @@ def form_valid(self, form):
photo.save()
return HttpResponseRedirect(self.get_success_url())

def get_success_url(self):
def get_default_success_url(self):
return reverse("badmin:album_edit", kwargs={"pk": self.object.id})


Expand All @@ -105,9 +106,9 @@ def form_valid(self, form):
return ret


class AlbumDeleteView(PhotoUploadAccess, GenericDelete, DeleteView):
class AlbumDeleteView(PhotoUploadAccess, RedirectBackMixin, GenericDelete, DeleteView):
model = Album
success_url = reverse_lazy("badmin:album_list")
default_success_url = reverse_lazy("badmin:album_list")

def form_valid(self, form):
super().form_valid(form)
Expand Down
8 changes: 5 additions & 3 deletions bullet/bullet_admin/views/education.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from bullet import search
from bullet_admin.access import CountryAdminAccess, CountryAdminInAccess
from bullet_admin.forms.education import SchoolForm
from bullet_admin.mixins import RedirectBackMixin
from bullet_admin.utils import get_allowed_countries
from bullet_admin.views import GenericForm, GenericList

Expand Down Expand Up @@ -69,14 +70,15 @@ def get_edit_url(self, school: School) -> str:
class SchoolUpdateView(
CountryAdminInAccess,
SchoolQuerySetMixin,
RedirectBackMixin,
GenericForm,
UpdateView,
):
form_class = SchoolForm
template_name = "bullet_admin/education/school_form.html"
form_title = "Edit school"
require_unlocked_competition = False
success_url = reverse_lazy("badmin:school_list")
default_success_url = reverse_lazy("badmin:school_list")

def get_permission_country(self):
return self.get_object().country
Expand All @@ -93,12 +95,12 @@ def form_valid(self, form):


class SchoolCreateView(
CountryAdminAccess, SchoolQuerySetMixin, GenericForm, CreateView
CountryAdminAccess, SchoolQuerySetMixin, RedirectBackMixin, GenericForm, CreateView
):
require_unlocked_competition = False
form_class = SchoolForm
form_title = "New school"
success_url = reverse_lazy("badmin:school_list")
default_success_url = reverse_lazy("badmin:school_list")

def form_valid(self, form):
school: School = form.save(commit=False)
Expand Down
Loading