2017-04-24 15:51:12 +00:00
|
|
|
#
|
|
|
|
# Copyright 2016,2017
|
|
|
|
# - Skia <skia@libskia.so>
|
2018-12-06 13:22:55 +00:00
|
|
|
# - Sli <antoine@bartuccio.fr>
|
2017-04-24 15:51:12 +00:00
|
|
|
#
|
|
|
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
|
|
|
# http://ae.utbm.fr.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU General Public License a published by the Free Software
|
|
|
|
# Foundation; either version 3 of the License, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along with
|
|
|
|
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
|
|
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2018-10-10 00:07:13 +00:00
|
|
|
from django.http import (
|
|
|
|
HttpResponseForbidden,
|
|
|
|
HttpResponseNotFound,
|
|
|
|
HttpResponseServerError,
|
|
|
|
)
|
2025-01-10 20:37:12 +00:00
|
|
|
from django.shortcuts import render
|
2025-01-16 14:10:46 +00:00
|
|
|
from django.views.generic.detail import BaseDetailView
|
2024-06-24 11:07:36 +00:00
|
|
|
from django.views.generic.edit import FormView
|
|
|
|
from sentry_sdk import last_event_id
|
2015-11-27 14:39:42 +00:00
|
|
|
|
2016-08-31 00:43:49 +00:00
|
|
|
from core.views.forms import LoginForm
|
2015-12-07 15:08:24 +00:00
|
|
|
|
2018-10-04 19:29:19 +00:00
|
|
|
|
2019-10-05 22:09:58 +00:00
|
|
|
def forbidden(request, exception):
|
2024-06-27 12:46:43 +00:00
|
|
|
context = {"next": request.path, "form": LoginForm()}
|
|
|
|
if popup := request.resolver_match.kwargs.get("popup"):
|
|
|
|
context["popup"] = popup
|
|
|
|
return HttpResponseForbidden(render(request, "core/403.jinja", context=context))
|
2018-10-04 19:29:19 +00:00
|
|
|
|
2015-12-07 16:23:52 +00:00
|
|
|
|
2019-10-05 22:09:58 +00:00
|
|
|
def not_found(request, exception):
|
2023-03-02 14:11:23 +00:00
|
|
|
return HttpResponseNotFound(
|
|
|
|
render(request, "core/404.jinja", context={"exception": exception})
|
|
|
|
)
|
2015-12-07 16:23:52 +00:00
|
|
|
|
2018-10-04 19:29:19 +00:00
|
|
|
|
2018-10-10 00:07:13 +00:00
|
|
|
def internal_servor_error(request):
|
|
|
|
request.sentry_last_event_id = last_event_id
|
|
|
|
return HttpResponseServerError(render(request, "core/500.jinja"))
|
|
|
|
|
|
|
|
|
2025-01-16 14:10:46 +00:00
|
|
|
class DetailFormView(FormView, BaseDetailView):
|
2024-07-12 07:34:16 +00:00
|
|
|
"""Class that allow both a detail view and a form view."""
|
2019-04-10 11:21:34 +00:00
|
|
|
|
2025-01-16 14:10:46 +00:00
|
|
|
def post(self, request, *args, **kwargs):
|
|
|
|
self.object = self.get_object()
|
|
|
|
return super().post(request, *args, **kwargs)
|
2019-04-10 11:21:34 +00:00
|
|
|
|
|
|
|
|
2024-10-15 09:36:26 +00:00
|
|
|
# F403: those star-imports would be hellish to refactor
|
|
|
|
# E402: putting those import at the top of the file would also be difficult
|
|
|
|
from .files import * # noqa: F403 E402
|
|
|
|
from .group import * # noqa: F403 E402
|
|
|
|
from .page import * # noqa: F403 E402
|
|
|
|
from .site import * # noqa: F403 E402
|
|
|
|
from .user import * # noqa: F403 E402
|