general: remove django.contrib.admin usage (#62339) #104
|
@ -1,24 +0,0 @@
|
|||
# lingo - basket and payment system
|
||||
# Copyright (C) 2015 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as 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 Affero General Public License for more details.
|
||||
#
|
||||
# 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.contrib import admin
|
||||
|
||||
from .models import Regie
|
||||
|
||||
|
||||
@admin.register(Regie)
|
||||
class RegieAdmin(admin.ModelAdmin):
|
||||
prepopulated_fields = {'slug': ('label',)}
|
|
@ -1,48 +0,0 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2014-2018 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as 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 Affero General Public License for more details.
|
||||
#
|
||||
# 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.contrib import admin
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import reverse
|
||||
from django.urls.exceptions import NoReverseMatch
|
||||
from django.views.decorators.cache import never_cache
|
||||
|
||||
|
||||
@never_cache
|
||||
def login(request, *args, **kwargs):
|
||||
try:
|
||||
auth_login_url = reverse('auth_login')
|
||||
except NoReverseMatch:
|
||||
return admin.site.orig_login(request, *args, **kwargs)
|
||||
auth_login_url += '?%s' % request.GET.urlencode()
|
||||
return redirect(auth_login_url)
|
||||
|
||||
|
||||
@never_cache
|
||||
def logout(request, *args, **kwargs):
|
||||
try:
|
||||
return redirect(reverse('auth_logout'))
|
||||
except NoReverseMatch:
|
||||
return admin.site.orig_logout(request, *args, **kwargs)
|
||||
|
||||
|
||||
if admin.site.login != login:
|
||||
admin.site.orig_login = admin.site.login
|
||||
admin.site.login = login
|
||||
|
||||
if admin.site.logout != logout:
|
||||
admin.site.orig_logout = admin.site.logout
|
||||
admin.site.logout = logout
|
|
@ -48,7 +48,6 @@ ALLOWED_HOSTS = []
|
|||
# Application definition
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
from django.conf import settings
|
||||
from django.conf.urls import re_path
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.urls import include
|
||||
from django.views.i18n import JavaScriptCatalog
|
||||
|
@ -29,7 +28,6 @@ from .urls_utils import decorated_includes, manager_required
|
|||
|
||||
urlpatterns = [
|
||||
re_path(r'^manage/', decorated_includes(manager_required, include(combo_manager_urls))),
|
||||
re_path(r'^admin/', admin.site.urls),
|
||||
re_path(r'^logout/$', logout, name='auth_logout'),
|
||||
re_path(r'^login/$', login, name='auth_login'),
|
||||
re_path(r'^404$', error404),
|
||||
|
|
|
@ -4,7 +4,6 @@ import json
|
|||
import os
|
||||
import re
|
||||
import shutil
|
||||
import urllib.parse
|
||||
import uuid
|
||||
from io import BytesIO
|
||||
from unittest import mock
|
||||
|
@ -2780,17 +2779,7 @@ def test_view_snapshot_redirect_url(app, admin_user):
|
|||
|
||||
|
||||
def test_django_admin(app, admin_user):
|
||||
resp = app.get('/admin/')
|
||||
resp = resp.follow() # -> /admin/login/
|
||||
resp = resp.follow() # -> /login/
|
||||
resp.form['username'] = 'admin'
|
||||
resp.form['password'] = 'admin'
|
||||
resp = resp.form.submit()
|
||||
resp = resp.follow() # -> /admin/
|
||||
assert '/admin/logout/' in resp.text
|
||||
resp = resp.click(href='/admin/logout/')
|
||||
resp = resp.follow() # -> /logout/
|
||||
assert urllib.parse.urlparse(resp.location).path == '/'
|
||||
app.get('/admin/', status=404)
|
||||
|
||||
|
||||
def test_json_cell_syntax_validation(app, admin_user):
|
||||
|
|
Loading…
Reference in New Issue