Merge branch 'kerl/gestion_prefix' into 'master'

Ajoute le préfixe /gestion dans toutes les urls sauf celles de la K-Fêt et de Wagtail

Closes #256

See merge request klub-dev-ens/gestioCOF!450
This commit is contained in:
Ludovic Stephan 2020-09-02 23:45:34 +02:00
commit 6e8926595d
8 changed files with 81 additions and 61 deletions

View file

@ -29,7 +29,7 @@ class InscriptionViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/bda/inscription/{}".format(self.tirage.id)
return "/gestion/bda/inscription/{}".format(self.tirage.id)
def test_get_opened(self):
self.tirage.ouverture = timezone.now() - timedelta(days=1)
@ -149,7 +149,7 @@ class PlacesViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/bda/places/{}".format(self.tirage.id)
return "/gestion/bda/places/{}".format(self.tirage.id)
class EtatPlacesViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@ -166,7 +166,7 @@ class EtatPlacesViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/bda/etat-places/{}".format(self.tirage.id)
return "/gestion/bda/etat-places/{}".format(self.tirage.id)
class TirageViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@ -185,7 +185,7 @@ class TirageViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/bda/tirage/{}".format(self.tirage.id)
return "/gestion/bda/tirage/{}".format(self.tirage.id)
def test_perform_tirage_disabled(self):
# Cannot be performed if disabled
@ -225,7 +225,7 @@ class SpectacleListViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/bda/spectacles/{}".format(self.tirage.id)
return "/gestion/bda/spectacles/{}".format(self.tirage.id)
class SpectacleViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@ -242,7 +242,7 @@ class SpectacleViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/bda/spectacles/{}/{}".format(self.tirage.id, self.show1.id)
return "/gestion/bda/spectacles/{}/{}".format(self.tirage.id, self.show1.id)
class UnpaidViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@ -259,7 +259,7 @@ class UnpaidViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/bda/spectacles/unpaid/{}".format(self.tirage.id)
return "/gestion/bda/spectacles/unpaid/{}".format(self.tirage.id)
class SendRemindersViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@ -276,7 +276,7 @@ class SendRemindersViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/bda/mails-rappel/{}".format(self.show1.id)
return "/gestion/bda/mails-rappel/{}".format(self.show1.id)
def test_post(self):
self.require_custommails()
@ -292,7 +292,7 @@ class CatalogueViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
bda_testdata = True
def test_api_list(self):
url_list = "/bda/catalogue/list"
url_list = "/gestion/bda/catalogue/list"
resp = self.client.get(url_list)
self.assertJSONEqual(
resp.content.decode("utf-8"),
@ -300,7 +300,7 @@ class CatalogueViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
)
def test_api_details(self):
url_details = "/bda/catalogue/details?id={}".format(self.tirage.id)
url_details = "/gestion/bda/catalogue/details?id={}".format(self.tirage.id)
resp = self.client.get(url_details)
self.assertJSONEqual(
resp.content.decode("utf-8"),
@ -311,7 +311,9 @@ class CatalogueViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
)
def test_api_descriptions(self):
url_descriptions = "/bda/catalogue/descriptions?id={}".format(self.tirage.id)
url_descriptions = "/gestion/bda/catalogue/descriptions?id={}".format(
self.tirage.id
)
resp = self.client.get(url_descriptions)
raw = resp.content.decode("utf-8")
try:

View file

@ -6,10 +6,13 @@ from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from django.views.generic.base import RedirectView
# Website administration (independent from installed apps)
admin.autodiscover()
urlpatterns = [
# Redirection / → /gestion, only useful for developpers.
path("", RedirectView.as_view(url="gestion/")),
# Website administration (independent from installed apps)
path("admin/doc/", include("django.contrib.admindocs.urls")),
path("admin/", admin.site.urls),
]
@ -22,13 +25,13 @@ bds_is_alone = (
app_dict = {
"bds": "" if bds_is_alone else "bds/",
"gestioncof": "",
"bda": "bda/",
"petitscours": "petitcours/",
"kfet": "k-fet/",
# events module is still experimental !
"events": "event_v2/",
"authens": "authens/",
# Below = GestioCOF → goes under gestion/
"gestioncof": "gestion/",
"bda": "gestion/bda/",
"petitscours": "gestion/petitcours/",
"events": "gestion/event_v2/", # the events module is still experimental !
"authens": "gestion/authens/",
}
for (app_name, url_prefix) in app_dict.items():
if app_name in settings.INSTALLED_APPS:
@ -52,6 +55,7 @@ if settings.DEBUG:
# Il faut dire à Django de servir MEDIA_ROOT lui-même en développement.
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# Wagtail URLs (wagtail.core urls must be last, as catch-all)
if "wagtail.core" in settings.INSTALLED_APPS:
from wagtail.admin import urls as wagtailadmin_urls

View file

@ -26,7 +26,7 @@ User = get_user_model()
class RegistrationViewTests(ViewTestCaseMixin, TestCase):
url_name = "registration"
url_expected = "/registration/"
url_expected = "/gestion/registration/"
http_methods = ["GET", "POST"]
@ -210,16 +210,16 @@ class RegistrationViewTests(ViewTestCaseMixin, TestCase):
class RegistrationFormViewTests(ViewTestCaseMixin, TestCase):
urls_conf = [
{"name": "empty-registration", "expected": "/registration/empty"},
{"name": "empty-registration", "expected": "/gestion/registration/empty"},
{
"name": "user-registration",
"kwargs": {"username": "user"},
"expected": "/registration/user/user",
"expected": "/gestion/registration/user/user",
},
{
"name": "clipper-registration",
"kwargs": {"login_clipper": "uid", "fullname": "First Last1 Last2"},
"expected": "/registration/clipper/uid/First%20Last1%20Last2",
"expected": "/gestion/registration/clipper/uid/First%20Last1%20Last2",
},
]
@ -269,7 +269,7 @@ class RegistrationFormViewTests(ViewTestCaseMixin, TestCase):
@override_settings(LDAP_SERVER_URL="ldap_url")
class RegistrationAutocompleteViewTests(MockLDAPMixin, ViewTestCaseMixin, TestCase):
url_name = "cof.registration.autocomplete"
url_expected = "/registration/autocomplete"
url_expected = "/gestion/registration/autocomplete"
auth_user = "staff"
auth_forbidden = [None, "user", "member"]
@ -360,7 +360,7 @@ class RegistrationAutocompleteViewTests(MockLDAPMixin, ViewTestCaseMixin, TestCa
class HomeViewTests(ViewTestCaseMixin, TestCase):
url_name = "home"
url_expected = "/"
url_expected = "/gestion/"
auth_user = "user"
auth_forbidden = [None]
@ -372,7 +372,7 @@ class HomeViewTests(ViewTestCaseMixin, TestCase):
class ProfileViewTests(ViewTestCaseMixin, TestCase):
url_name = "profile"
url_expected = "/profile"
url_expected = "/gestion/profile"
http_methods = ["GET", "POST"]
@ -413,7 +413,7 @@ class ProfileViewTests(ViewTestCaseMixin, TestCase):
class UtilsViewTests(ViewTestCaseMixin, TestCase):
url_name = "utile_cof"
url_expected = "/utile_cof"
url_expected = "/gestion/utile_cof"
auth_user = "staff"
auth_forbidden = [None, "user", "member"]
@ -425,7 +425,7 @@ class UtilsViewTests(ViewTestCaseMixin, TestCase):
class MailingListDiffCof(ViewTestCaseMixin, TestCase):
url_name = "ml_diffcof"
url_expected = "/utile_cof/diff_cof"
url_expected = "/gestion/utile_cof/diff_cof"
auth_user = "staff"
auth_forbidden = [None, "user", "member"]
@ -446,7 +446,7 @@ class MailingListDiffCof(ViewTestCaseMixin, TestCase):
class ConfigUpdateViewTests(ViewTestCaseMixin, TestCase):
url_name = "config.edit"
url_expected = "/config"
url_expected = "/gestion/config"
http_methods = ["GET", "POST"]
@ -468,7 +468,7 @@ class ConfigUpdateViewTests(ViewTestCaseMixin, TestCase):
class UserAutocompleteViewTests(ViewTestCaseMixin, TestCase):
url_name = "cof-user-autocomplete"
url_expected = "/user/autocomplete"
url_expected = "/gestion/user/autocomplete"
auth_user = "staff"
auth_forbidden = [None, "user", "member"]
@ -481,7 +481,7 @@ class UserAutocompleteViewTests(ViewTestCaseMixin, TestCase):
class ExportMembersViewTests(CSVResponseMixin, ViewTestCaseMixin, TestCase):
url_name = "export.members"
url_expected = "/export/members"
url_expected = "/gestion/export/members"
auth_user = "staff"
auth_forbidden = [None, "user", "member"]
@ -521,7 +521,7 @@ class ExportMembersViewTests(CSVResponseMixin, ViewTestCaseMixin, TestCase):
class ExportMegaViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase):
url_name = "export.mega.all"
url_expected = "/export/mega/all"
url_expected = "/gestion/export/mega/all"
auth_user = "staff"
auth_forbidden = [None, "user", "member"]
@ -550,7 +550,7 @@ class ExportMegaViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase):
class ExportMegaOrgasViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase):
url_name = "export.mega.orgas"
url_expected = "/export/mega/orgas"
url_expected = "/gestion/export/mega/orgas"
auth_user = "staff"
auth_forbidden = [None, "user", "member"]
@ -579,7 +579,7 @@ class ExportMegaOrgasViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase):
class ExportMegaParticipantsViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase):
url_name = "export.mega.participants"
url_expected = "/export/mega/participants"
url_expected = "/gestion/export/mega/participants"
auth_user = "staff"
auth_forbidden = [None, "user", "member"]
@ -596,7 +596,7 @@ class ExportMegaParticipantsViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCa
class ExportMegaRemarksViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase):
url_name = "export.mega.remarks"
url_expected = "/export/mega/avecremarques"
url_expected = "/gestion/export/mega/avecremarques"
auth_user = "staff"
auth_forbidden = [None, "user", "member"]
@ -624,7 +624,7 @@ class ExportMegaRemarksViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase):
class ClubListViewTests(ViewTestCaseMixin, TestCase):
url_name = "liste-clubs"
url_expected = "/clubs/liste"
url_expected = "/gestion/clubs/liste"
auth_user = "member"
auth_forbidden = [None, "user"]
@ -671,7 +671,7 @@ class ClubMembersViewTests(ViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/clubs/membres/{}".format(self.c.name)
return "/gestion/clubs/membres/{}".format(self.c.name)
def setUp(self):
super().setUp()
@ -712,7 +712,9 @@ class ClubChangeRespoViewTests(ViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/clubs/change_respo/{}/{}".format(self.c.name, self.users["user"].pk)
return "/gestion/clubs/change_respo/{}/{}".format(
self.c.name, self.users["user"].pk
)
def setUp(self):
super().setUp()
@ -734,7 +736,7 @@ class ClubChangeRespoViewTests(ViewTestCaseMixin, TestCase):
class CalendarViewTests(ViewTestCaseMixin, TestCase):
url_name = "calendar"
url_expected = "/calendar/subscription"
url_expected = "/gestion/calendar/subscription"
auth_user = "member"
auth_forbidden = [None, "user"]
@ -801,7 +803,7 @@ class CalendarICSViewTests(ICalMixin, ViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/calendar/{}/calendar.ics".format(self.token)
return "/gestion/calendar/{}/calendar.ics".format(self.token)
def setUp(self):
super().setUp()
@ -917,7 +919,7 @@ class EventViewTests(ViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/event/{}".format(self.e.pk)
return "/gestion/event/{}".format(self.e.pk)
def setUp(self):
super().setUp()
@ -1002,7 +1004,7 @@ class EventStatusViewTests(ViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/event/{}/status".format(self.e.pk)
return "/gestion/event/{}/status".format(self.e.pk)
def setUp(self):
super().setUp()
@ -1068,7 +1070,7 @@ class SurveyViewTests(ViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/survey/{}".format(self.s.pk)
return "/gestion/survey/{}".format(self.s.pk)
def setUp(self):
super().setUp()
@ -1168,7 +1170,7 @@ class SurveyStatusViewTests(ViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/survey/{}/status".format(self.s.pk)
return "/gestion/survey/{}/status".format(self.s.pk)
def setUp(self):
super().setUp()

View file

@ -168,7 +168,7 @@ class GenericLoginViewTests(TestCase):
r = self.client.post(self.url)
self.assertRedirects(
r, "/logout?next={}".format(self.url), fetch_redirect_response=False
r, "/gestion/logout?next={}".format(self.url), fetch_redirect_response=False
)
def test_notoken_not_team(self):
@ -180,13 +180,13 @@ class GenericLoginViewTests(TestCase):
# With GET.
r = self.client.get(self.url)
self.assertRedirects(
r, "/login?next={}".format(self.url), fetch_redirect_response=False
r, "/gestion/login?next={}".format(self.url), fetch_redirect_response=False
)
# Also with POST.
r = self.client.post(self.url)
self.assertRedirects(
r, "/login?next={}".format(self.url), fetch_redirect_response=False
r, "/gestion/login?next={}".format(self.url), fetch_redirect_response=False
)
def _set_signed_cookie(self, client, key, value):

View file

@ -70,4 +70,4 @@ class TestStats(TestCase):
resp = client.get(url)
self.assertEqual(200, resp.status_code)
resp2 = client2.get(url, follow=True)
self.assertRedirects(resp2, "/")
self.assertRedirects(resp2, "/gestion/")

View file

@ -230,7 +230,9 @@ class AccountReadViewTests(ViewTestCaseMixin, TestCase):
if user is None:
response = client.get(url)
self.assertRedirects(
response, "/login?next={}".format(url), fetch_redirect_response=False
response,
"/gestion/login?next={}".format(url),
fetch_redirect_response=False,
)
else:
client.login(username=user, password=user)
@ -340,7 +342,9 @@ class AccountUpdateViewTests(ViewTestCaseMixin, TestCase):
if user is None:
response = meth(url)
self.assertRedirects(
response, "/login?next={}".format(url), fetch_redirect_response=False
response,
"/gestion/login?next={}".format(url),
fetch_redirect_response=False,
)
else:
client.login(username=user, password=user)
@ -620,7 +624,9 @@ class AccountStatOperationListViewTests(ViewTestCaseMixin, TestCase):
if user is None:
response = client.get(url)
self.assertRedirects(
response, "/login?next={}".format(url), fetch_redirect_response=False
response,
"/gestion/login?next={}".format(url),
fetch_redirect_response=False,
)
else:
client.login(username=user, password=user)
@ -716,7 +722,9 @@ class AccountStatOperationViewTests(ViewTestCaseMixin, TestCase):
if user is None:
response = client.get(url)
self.assertRedirects(
response, "/login?next={}".format(url), fetch_redirect_response=False
response,
"/gestion/login?next={}".format(url),
fetch_redirect_response=False,
)
else:
client.login(username=user, password=user)
@ -753,7 +761,9 @@ class AccountStatBalanceListViewTests(ViewTestCaseMixin, TestCase):
if user is None:
response = client.get(url)
self.assertRedirects(
response, "/login?next={}".format(url), fetch_redirect_response=False
response,
"/gestion/login?next={}".format(url),
fetch_redirect_response=False,
)
else:
client.login(username=user, password=user)
@ -817,7 +827,9 @@ class AccountStatBalanceViewTests(ViewTestCaseMixin, TestCase):
if user is None:
response = client.get(url)
self.assertRedirects(
response, "/login?next={}".format(url), fetch_redirect_response=False
response,
"/gestion/login?next={}".format(url),
fetch_redirect_response=False,
)
else:
client.login(username=user, password=user)

View file

@ -39,7 +39,7 @@ class TestCaseMixin:
querystring = QueryDict(mutable=True)
querystring["next"] = full_path
login_url = "/login?" + querystring.urlencode(safe="/")
login_url = "/gestion/login?" + querystring.urlencode(safe="/")
# We don't focus on what the login view does.
# So don't fetch the redirect.

View file

@ -19,7 +19,7 @@ User = get_user_model()
class PetitCoursDemandeListViewTestCase(ViewTestCaseMixin, TestCase):
url_name = "petits-cours-demandes-list"
url_expected = "/petitcours/demandes"
url_expected = "/gestion/petitcours/demandes"
auth_user = "staff"
auth_forbidden = [None, "user", "member"]
@ -48,7 +48,7 @@ class PetitCoursDemandeDetailListViewTestCase(ViewTestCaseMixin, TestCase):
@property
def url_expected(self):
return "/petitcours/demandes/{}".format(self.demande.pk)
return "/gestion/petitcours/demandes/{}".format(self.demande.pk)
def setUp(self):
super().setUp()
@ -61,7 +61,7 @@ class PetitCoursDemandeDetailListViewTestCase(ViewTestCaseMixin, TestCase):
class PetitCoursInscriptionViewTestCase(ViewTestCaseMixin, TestCase):
url_name = "petits-cours-inscription"
url_expected = "/petitcours/inscription"
url_expected = "/gestion/petitcours/inscription"
http_methods = ["GET", "POST"]
@ -176,7 +176,7 @@ class PetitCoursTraitementViewTestCase(
@property
def url_expected(self):
return "/petitcours/demandes/{}/traitement".format(self.demande.pk)
return "/gestion/petitcours/demandes/{}/traitement".format(self.demande.pk)
def setUp(self):
super().setUp()
@ -246,7 +246,7 @@ class PetitCoursRetraitementViewTestCase(
@property
def url_expected(self):
return "/petitcours/demandes/{}/retraitement".format(self.demande.pk)
return "/gestion/petitcours/demandes/{}/retraitement".format(self.demande.pk)
def setUp(self):
super().setUp()
@ -261,7 +261,7 @@ class PetitCoursRetraitementViewTestCase(
class PetitCoursDemandeViewTestCase(ViewTestCaseMixin, TestCase):
url_name = "petits-cours-demande"
url_expected = "/petitcours/demande"
url_expected = "/gestion/petitcours/demande"
http_methods = ["GET", "POST"]
@ -303,7 +303,7 @@ class PetitCoursDemandeViewTestCase(ViewTestCaseMixin, TestCase):
class PetitCoursDemandeRawViewTestCase(ViewTestCaseMixin, TestCase):
url_name = "petits-cours-demande-raw"
url_expected = "/petitcours/demande-raw"
url_expected = "/gestion/petitcours/demande-raw"
http_methods = ["GET", "POST"]