misc: apply django-upgrade (#69798)

This commit is contained in:
Valentin Deniaud 2022-10-03 14:24:55 +02:00
parent 150e97d59d
commit 5a6b5c5cd2
16 changed files with 86 additions and 84 deletions

View File

@ -14,10 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
url(r'^api/provision/$', views.provision_view),
path('api/provision/', views.provision_view),
]

View File

@ -14,26 +14,26 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path, re_path
from . import views
urlpatterns = [
url(r'^$', views.home, name='applications-home'),
url(r'^create/$', views.init, name='application-init'),
url(r'^install/$', views.install, name='application-install'),
url(r'^manifest/(?P<slug>[\w-]+)/delete/$', views.delete, name='application-delete'),
url(r'^manifest/(?P<app_slug>[\w-]+)/$', views.manifest, name='application-manifest'),
url(r'^manifest/(?P<app_slug>[\w-]+)/metadata/$', views.metadata, name='application-metadata'),
url(r'^manifest/(?P<app_slug>[\w-]+)/scandeps/$', views.scandeps, name='application-scandeps'),
url(r'^manifest/(?P<app_slug>[\w-]+)/generate/$', views.generate, name='application-generate'),
url(r'^manifest/(?P<app_slug>[\w-]+)/download/$', views.download, name='application-download'),
url(
path('', views.home, name='applications-home'),
path('create/', views.init, name='application-init'),
path('install/', views.install, name='application-install'),
re_path(r'^manifest/(?P<slug>[\w-]+)/delete/$', views.delete, name='application-delete'),
re_path(r'^manifest/(?P<app_slug>[\w-]+)/$', views.manifest, name='application-manifest'),
re_path(r'^manifest/(?P<app_slug>[\w-]+)/metadata/$', views.metadata, name='application-metadata'),
re_path(r'^manifest/(?P<app_slug>[\w-]+)/scandeps/$', views.scandeps, name='application-scandeps'),
re_path(r'^manifest/(?P<app_slug>[\w-]+)/generate/$', views.generate, name='application-generate'),
re_path(r'^manifest/(?P<app_slug>[\w-]+)/download/$', views.download, name='application-download'),
re_path(
r'^manifest/(?P<app_slug>[\w-]+)/add/(?P<type>[\w-]+)/$',
views.add_element,
name='application-add-element',
),
url(
re_path(
r'^manifest/(?P<app_slug>[\w-]+)/delete/(?P<pk>\d+)/$',
views.delete_element,
name='application-delete-element',

View File

@ -14,10 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
url(r'^$', views.home, name='debug-home'),
path('', views.home, name='debug-home'),
]

View File

@ -14,10 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
url(r'^$', views.home, name='emails-home'),
path('', views.home, name='emails-home'),
]

View File

@ -14,38 +14,40 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path, re_path
from . import views
urlpatterns = [
url(r'^$', views.HomeView.as_view(), name='environment-home'),
url(r'^variables$', views.VariablesView.as_view(), name='environment-variables'),
url(
r'^new-variable$',
path('', views.HomeView.as_view(), name='environment-home'),
path('variables', views.VariablesView.as_view(), name='environment-variables'),
path(
'new-variable',
views.VariableCreateView.as_view(),
name='new-variable',
),
url(r'^update-variable/(?P<pk>\w+)$', views.VariableUpdateView.as_view(), name='update-variable'),
url(r'^delete-variable/(?P<pk>\w+)$', views.VariableDeleteView.as_view(), name='delete-variable'),
url(
re_path(r'^update-variable/(?P<pk>\w+)$', views.VariableUpdateView.as_view(), name='update-variable'),
re_path(r'^delete-variable/(?P<pk>\w+)$', views.VariableDeleteView.as_view(), name='delete-variable'),
re_path(
r'^check_operational/(?P<service>\w+)/(?P<slug>[\w-]+)$',
views.operational_check_view,
name='operational-check',
),
url(r'^new-(?P<service>\w+)$', views.ServiceCreateView.as_view(), name='create-service'),
url(r'^save-(?P<service>\w+)/(?P<slug>[\w-]+)$', views.ServiceUpdateView.as_view(), name='save-service'),
url(
re_path(r'^new-(?P<service>\w+)$', views.ServiceCreateView.as_view(), name='create-service'),
re_path(
r'^save-(?P<service>\w+)/(?P<slug>[\w-]+)$', views.ServiceUpdateView.as_view(), name='save-service'
),
re_path(
r'^delete-(?P<service>\w+)/(?P<slug>[\w-]+)$',
views.ServiceDeleteView.as_view(),
name='delete-service',
),
url(
re_path(
r'^new-variable-(?P<service>\w+)/(?P<slug>[\w-]+)$',
views.VariableCreateView.as_view(),
name='new-variable-service',
),
url(r'^import/$', views.ImportView.as_view(), name='environment-import'),
url(r'^export/$', views.ExportView.as_view(), name='environment-export'),
url(r'^debug.json$', views.debug_json, name='debug-json'),
path('import/', views.ImportView.as_view(), name='environment-import'),
path('export/', views.ExportView.as_view(), name='environment-export'),
re_path(r'^debug.json$', views.debug_json, name='debug-json'),
]

View File

@ -14,10 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
url(r'^$', views.home, name='franceconnect-home'),
path('', views.home, name='franceconnect-home'),
]

View File

@ -14,10 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
url(r'^$', views.home, name='maintenance-home'),
path('', views.home, name='maintenance-home'),
]

View File

@ -14,13 +14,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
url(r'^$', views.home, name='matomo-home'),
url(r'^enable-manual$', views.enable_manual, name='matomo-enable-manual'),
url(r'^enable-auto$', views.enable_auto, name='matomo-enable-auto'),
url(r'^disable$', views.disable, name='matomo-disable'),
path('', views.home, name='matomo-home'),
path('enable-manual', views.enable_manual, name='matomo-enable-manual'),
path('enable-auto', views.enable_auto, name='matomo-enable-auto'),
path('disable', views.disable, name='matomo-disable'),
]

View File

@ -20,7 +20,7 @@ class CORSMiddleware(MiddlewareMixin):
return None
def process_response(self, request, response):
origin = request.META.get('HTTP_ORIGIN')
origin = request.headers.get('Origin')
if origin:
whitelist = getattr(settings, 'CORS_ORIGIN_WHITELIST', [])
if origin not in whitelist:

View File

@ -11,7 +11,7 @@ class XForwardedForMiddleware(MiddlewareMixin):
def process_request(self, request):
if getattr(settings, 'USE_X_FORWARDED_FOR', False):
if 'HTTP_X_FORWARDED_FOR' in request.META:
ip = request.META.get('HTTP_X_FORWARDED_FOR', '').split(",")[0].strip()
ip = request.headers.get('X-Forwarded-For', '').split(",")[0].strip()
if ip:
request.META['REMOTE_ADDR'] = ip
return None

View File

@ -14,13 +14,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path, re_path
from . import views
urlpatterns = [
url(r'^$', views.home, name='profile-home'),
url(r'(?P<name>[\w-]+)/options', views.options, name='profile-attribute-options'),
url(r'^reorder$', views.reorder, name='profile-reorder'),
url(r'^add-attribute$', views.add_attribute, name='profile-add-attribute'),
path('', views.home, name='profile-home'),
re_path(r'(?P<name>[\w-]+)/options', views.options, name='profile-attribute-options'),
path('reorder', views.reorder, name='profile-reorder'),
path('add-attribute', views.add_attribute, name='profile-add-attribute'),
]

View File

@ -14,13 +14,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
url(r'^$', views.home, name='seo-home'),
url(r'^allow$', views.allow, name='robots-allow'),
url(r'^disallow$', views.disallow, name='robots-disallow'),
url(r'^customize$', views.customize, name='robots-customize'),
path('', views.home, name='seo-home'),
path('allow', views.allow, name='robots-allow'),
path('disallow', views.disallow, name='robots-disallow'),
path('customize', views.customize, name='robots-customize'),
]

View File

@ -14,10 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
url(r'^$', views.home, name='sms-home'),
path('', views.home, name='sms-home'),
]

View File

@ -1,8 +1,8 @@
import logging
from django.conf.urls import url
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
from django.urls import path, re_path
from rest_framework import permissions
from rest_framework.response import Response
from rest_framework.views import APIView
@ -28,6 +28,6 @@ class AuthenticatedTestView(APIView):
urlpatterns = [
url(r'^$', helloworld),
url(r'^authenticated-testview/', AuthenticatedTestView.as_view()),
path('', helloworld),
re_path(r'^authenticated-testview/', AuthenticatedTestView.as_view()),
]

View File

@ -14,12 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
url(r'^$', views.home, name='theme-home'),
url(r'^select$', views.select, name='theme-select'),
url(r'^options$', views.options, name='theme-options'),
path('', views.home, name='theme-home'),
path('select', views.select, name='theme-select'),
path('options', views.options, name='theme-options'),
]

View File

@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.urls import include, path, re_path
from .applications.urls import urlpatterns as applications_urls
from .debug.urls import urlpatterns as debug_urls
@ -35,28 +35,28 @@ from .views import admin_required, health_json, hobo, home, login, login_local,
admin.autodiscover()
urlpatterns = [
url(r'^$', home, name='home'),
url(r'^sites/', decorated_includes(admin_required, include(environment_urls))),
url(r'^profile/', decorated_includes(admin_required, include(profile_urls))),
url(r'^franceconnect/', decorated_includes(admin_required, include(franceconnect_urls))),
url(r'^visits-tracking/', decorated_includes(admin_required, include(matomo_urls))),
url(r'^theme/', decorated_includes(admin_required, include(theme_urls))),
url(r'^emails/', decorated_includes(admin_required, include(emails_urls))),
url(r'^seo/', decorated_includes(admin_required, include(seo_urls))),
url(r'^sms/', decorated_includes(admin_required, include(sms_urls))),
url(r'^debug/', decorated_includes(admin_required, include(debug_urls))),
url(r'^applications/', decorated_includes(admin_required, include(applications_urls))),
url(r'^maintenance/', decorated_includes(admin_required, include(maintenance_urls))),
url(r'^api/health/$', health_json, name='health-json'),
url(r'^menu.json$', menu_json, name='menu_json'),
url(r'^hobos.json$', hobo),
url(r'^admin/', admin.site.urls),
path('', home, name='home'),
re_path(r'^sites/', decorated_includes(admin_required, include(environment_urls))),
re_path(r'^profile/', decorated_includes(admin_required, include(profile_urls))),
re_path(r'^franceconnect/', decorated_includes(admin_required, include(franceconnect_urls))),
re_path(r'^visits-tracking/', decorated_includes(admin_required, include(matomo_urls))),
re_path(r'^theme/', decorated_includes(admin_required, include(theme_urls))),
re_path(r'^emails/', decorated_includes(admin_required, include(emails_urls))),
re_path(r'^seo/', decorated_includes(admin_required, include(seo_urls))),
re_path(r'^sms/', decorated_includes(admin_required, include(sms_urls))),
re_path(r'^debug/', decorated_includes(admin_required, include(debug_urls))),
re_path(r'^applications/', decorated_includes(admin_required, include(applications_urls))),
re_path(r'^maintenance/', decorated_includes(admin_required, include(maintenance_urls))),
path('api/health/', health_json, name='health-json'),
re_path(r'^menu.json$', menu_json, name='menu_json'),
re_path(r'^hobos.json$', hobo),
re_path(r'^admin/', admin.site.urls),
]
# add authentication patterns
urlpatterns += [
url(r'^logout/$', logout, name='logout'),
url(r'^login/$', login, name='auth_login'),
url(r'^login/local/$', login_local), # to be used as backup, in case of idp down
url(r'^accounts/mellon/', include('mellon.urls')),
path('logout/', logout, name='logout'),
path('login/', login, name='auth_login'),
path('login/local/', login_local), # to be used as backup, in case of idp down
re_path(r'^accounts/mellon/', include('mellon.urls')),
]