Remove django-braces requirement

This commit is contained in:
Jan Dittberner 2023-04-14 19:16:58 +02:00
parent 35aae85c8d
commit a5b65974fb
4 changed files with 19 additions and 26 deletions

View file

@ -4,8 +4,8 @@ This module defines views related to domains.
""" """
from __future__ import absolute_import from __future__ import absolute_import
from braces.views import StaffuserRequiredMixin
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.shortcuts import get_object_or_404, redirect from django.shortcuts import get_object_or_404, redirect
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from django.views.generic.edit import CreateView from django.views.generic.edit import CreateView
@ -16,7 +16,7 @@ from .forms import CreateHostingDomainForm
from .models import HostingDomain from .models import HostingDomain
class CreateHostingDomain(StaffuserRequiredMixin, CreateView): class CreateHostingDomain(PermissionRequiredMixin, CreateView):
""" """
This view is used for creating a new HostingDomain instance for an existing This view is used for creating a new HostingDomain instance for an existing
hosting package. hosting package.
@ -24,6 +24,7 @@ class CreateHostingDomain(StaffuserRequiredMixin, CreateView):
model = HostingDomain model = HostingDomain
raise_exception = True raise_exception = True
permission_required = 'domains.add_hostingdomain'
template_name_suffix = "_create" template_name_suffix = "_create"
form_class = CreateHostingDomainForm form_class = CreateHostingDomainForm

View file

@ -4,10 +4,10 @@ This module defines views related to hosting packages.
""" """
from __future__ import absolute_import from __future__ import absolute_import
from braces.views import LoginRequiredMixin, StaffuserRequiredMixin
from django.conf import settings from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import PermissionRequiredMixin, UserPassesTestMixin
from django.http import Http404 from django.http import Http404
from django.shortcuts import get_object_or_404, redirect from django.shortcuts import get_object_or_404, redirect
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
@ -30,7 +30,7 @@ from .models import (
) )
class CreateHostingPackage(LoginRequiredMixin, StaffuserRequiredMixin, CreateView): class CreateHostingPackage(PermissionRequiredMixin, CreateView):
""" """
Create a hosting package. Create a hosting package.
@ -38,6 +38,7 @@ class CreateHostingPackage(LoginRequiredMixin, StaffuserRequiredMixin, CreateVie
model = CustomerHostingPackage model = CustomerHostingPackage
raise_exception = True raise_exception = True
permission_required = 'domains.add_customerhostingpackage'
template_name_suffix = "_create" template_name_suffix = "_create"
form_class = CreateHostingPackageForm form_class = CreateHostingPackageForm
@ -120,9 +121,16 @@ class CustomerHostingPackageDetails(StaffOrSelfLoginRequiredMixin, DetailView):
return context return context
class AllCustomerHostingPackageList( class StaffUserRequiredMixin(UserPassesTestMixin):
LoginRequiredMixin, StaffuserRequiredMixin, ListView """
): Mixin to make views available to staff members only.
"""
def test_func(self):
return self.request.user.is_staff
class AllCustomerHostingPackageList(StaffUserRequiredMixin, ListView):
""" """
This view is used for showing a list of all hosting packages. This view is used for showing a list of all hosting packages.
@ -161,7 +169,7 @@ class CustomerHostingPackageList(StaffOrSelfLoginRequiredMixin, ListView):
) )
class HostingOptionChoices(LoginRequiredMixin, StaffuserRequiredMixin, DetailView): class HostingOptionChoices(StaffUserRequiredMixin, DetailView):
""" """
This view displays choices of hosting options for a customer hosting This view displays choices of hosting options for a customer hosting
package. package.
@ -205,7 +213,7 @@ class HostingOptionChoices(LoginRequiredMixin, StaffuserRequiredMixin, DetailVie
return context return context
class AddHostingOption(LoginRequiredMixin, StaffuserRequiredMixin, FormView): class AddHostingOption(StaffUserRequiredMixin, FormView):
template_name = "hostingpackages/add_hosting_option.html" template_name = "hostingpackages/add_hosting_option.html"
def get_form_class(self): def get_form_class(self):

17
poetry.lock generated
View file

@ -638,21 +638,6 @@ python3-openid = ">=3.0.8"
requests = "*" requests = "*"
requests-oauthlib = ">=0.3.0" requests-oauthlib = ">=0.3.0"
[[package]]
name = "django-braces"
version = "1.15.0"
description = "Reusable, generic mixins for Django"
category = "main"
optional = false
python-versions = "*"
files = [
{file = "django-braces-1.15.0.tar.gz", hash = "sha256:f451d08ffc1078d81209a2e17f2219bce20196928853c82405451b18a46875e0"},
{file = "django_braces-1.15.0-py2.py3-none-any.whl", hash = "sha256:28f00b0f98368c9a37f30cce6087fc57127f0a24c5b8b449f9e1245bded6405d"},
]
[package.dependencies]
Django = ">=2.2"
[[package]] [[package]]
name = "django-crispy-forms" name = "django-crispy-forms"
version = "1.14.0" version = "1.14.0"
@ -1757,4 +1742,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.7" python-versions = "^3.7"
content-hash = "c11eec493daca3a228f3c99300d0ebf0fa35060624c93649e2dce4c71cdf67f2" content-hash = "6041c8bb49cd1df098f1948f8ad2cbd48fd8f42ff44e410f3fecb61be7e80a18"

View file

@ -12,7 +12,6 @@ django = "<4"
psycopg2-binary = "^2.9" psycopg2-binary = "^2.9"
celery = "^5.2.7" celery = "^5.2.7"
django-allauth = "^0.52.0" django-allauth = "^0.52.0"
django-braces = "^1.15.0"
django-crispy-forms = "<2" django-crispy-forms = "<2"
django-debug-toolbar = "^3.8" django-debug-toolbar = "^3.8"
django-model-utils = "^4.1" django-model-utils = "^4.1"