Ensure /favicon.ico does not raise Resolver404 on custom domains

This commit is contained in:
Raphael Michel
2022-08-08 10:01:50 +02:00
parent 9a5e07e078
commit 3bb590c1ae
2 changed files with 17 additions and 0 deletions

View File

@@ -93,6 +93,10 @@ event_patterns = [
name='event.payment.unlock'), name='event.payment.unlock'),
re_path(r'resend/$', pretix.presale.views.user.ResendLinkView.as_view(), name='event.resend_link'), re_path(r'resend/$', pretix.presale.views.user.ResendLinkView.as_view(), name='event.resend_link'),
re_path(r'^favicon.ico/?$',
pretix.presale.views.organizer.OrganizerFavicon.as_view(),
name='event.favicon'),
re_path(r'^order/(?P<order>[^/]+)/(?P<secret>[A-Za-z0-9]+)/open/(?P<hash>[a-z0-9]+)/$', pretix.presale.views.order.OrderOpen.as_view(), re_path(r'^order/(?P<order>[^/]+)/(?P<secret>[A-Za-z0-9]+)/open/(?P<hash>[a-z0-9]+)/$', pretix.presale.views.order.OrderOpen.as_view(),
name='event.order.open'), name='event.order.open'),
re_path(r'^order/(?P<order>[^/]+)/(?P<secret>[A-Za-z0-9]+)/$', pretix.presale.views.order.OrderDetails.as_view(), re_path(r'^order/(?P<order>[^/]+)/(?P<secret>[A-Za-z0-9]+)/$', pretix.presale.views.order.OrderDetails.as_view(),
@@ -164,6 +168,9 @@ event_patterns = [
organizer_patterns = [ organizer_patterns = [
re_path(r'^$', pretix.presale.views.organizer.OrganizerIndex.as_view(), name='organizer.index'), re_path(r'^$', pretix.presale.views.organizer.OrganizerIndex.as_view(), name='organizer.index'),
re_path(r'^favicon.ico/?$',
pretix.presale.views.organizer.OrganizerFavicon.as_view(),
name='organizer.favicon'),
re_path(r'^events/ical/$', re_path(r'^events/ical/$',
pretix.presale.views.organizer.OrganizerIcalDownload.as_view(), pretix.presale.views.organizer.OrganizerIcalDownload.as_view(),
name='organizer.ical'), name='organizer.ical'),

View File

@@ -48,6 +48,7 @@ from django.db.models import Exists, Max, Min, OuterRef, Prefetch, Q
from django.db.models.functions import Coalesce, Greatest from django.db.models.functions import Coalesce, Greatest
from django.http import Http404, HttpResponse from django.http import Http404, HttpResponse
from django.shortcuts import redirect from django.shortcuts import redirect
from django.templatetags.static import static
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.utils.formats import date_format, get_format from django.utils.formats import date_format, get_format
from django.utils.timezone import get_current_timezone, now from django.utils.timezone import get_current_timezone, now
@@ -66,6 +67,7 @@ from pretix.helpers.daterange import daterange
from pretix.helpers.formats.en.formats import ( from pretix.helpers.formats.en.formats import (
SHORT_MONTH_DAY_FORMAT, WEEK_FORMAT, SHORT_MONTH_DAY_FORMAT, WEEK_FORMAT,
) )
from pretix.helpers.thumb import get_thumbnail
from pretix.multidomain.urlreverse import eventreverse from pretix.multidomain.urlreverse import eventreverse
from pretix.presale.ical import get_public_ical from pretix.presale.ical import get_public_ical
from pretix.presale.views import OrganizerViewMixin from pretix.presale.views import OrganizerViewMixin
@@ -1170,3 +1172,11 @@ class OrganizerIcalDownload(OrganizerViewMixin, View):
if request.organizer.settings.meta_noindex: if request.organizer.settings.meta_noindex:
resp['X-Robots-Tag'] = 'noindex' resp['X-Robots-Tag'] = 'noindex'
return resp return resp
class OrganizerFavicon(View):
def get(self, *args, **kwargs):
if self.request.organizer.settings.favicon:
return redirect(get_thumbnail(self.request.organizer.settings.favicon, '32x32^').thumb.url)
else:
return redirect(static("pretixbase/img/favicon.ico"))