diff --git a/src/wagtailtrans/conf.py b/src/wagtailtrans/conf.py index e4279f2..8d20588 100644 --- a/src/wagtailtrans/conf.py +++ b/src/wagtailtrans/conf.py @@ -4,8 +4,6 @@ 'SYNC_TREE': True, 'LANGUAGES_PER_SITE': False, 'HIDE_TRANSLATION_TREES': False, - 'NO_PREFIX_FOR_DEFAULT_LANGUAGE': False, - 'REDIRECT_UNPREFIXED_PATHS': False, } diff --git a/src/wagtailtrans/models.py b/src/wagtailtrans/models.py index 38425a3..e580217 100644 --- a/src/wagtailtrans/models.py +++ b/src/wagtailtrans/models.py @@ -169,12 +169,6 @@ def get_admin_display_title(self): return "{} ({})".format(super().get_admin_display_title(), self.language) def serve(self, request, *args, **kwargs): - if get_wagtailtrans_setting('REDIRECT_UNPREFIXED_PATHS'): - language = get_user_language(request) - if not request.path.startswith('/{}/'.format(language.code)): - if not get_wagtailtrans_setting('NO_PREFIX_FOR_DEFAULT_LANGUAGE') or not language.is_default: - return redirect(self.url) - activate(self.language.code) return super().serve(request, *args, **kwargs) @@ -362,29 +356,7 @@ def serve(self, request, *args, **kwargs): except TranslatablePage.DoesNotExist: raise Http404 - def route(self, request, path_components): - path_components = self.prepend_language_code_to_path_components(request, path_components) - return super().route(request, path_components) - def prepend_language_code_to_path_components(self, request, path_components): - """Prepend path_components with a language code if needed - :param request: Request object - :param path_components: List containing path elements - :return: List containing path elements - """ - if ( - get_wagtailtrans_setting('NO_PREFIX_FOR_DEFAULT_LANGUAGE') or - get_wagtailtrans_setting('REDIRECT_UNPREFIXED_PATHS') - ): - language = get_user_language(request) - if language.is_default or get_wagtailtrans_setting('REDIRECT_UNPREFIXED_PATHS'): - if path_components: - if language.code != path_components[0]: - path_components.insert(0, language.code) - else: - path_components = [language.code] - return path_components - def page_permissions_for_user(self, user): """Patch for the page permissions adding our custom proxy