Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
erp5
Commits
470188fd
Commit
470188fd
authored
Aug 18, 2022
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! erp5_web: introduce translatable path.
parent
1f649a49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
bt5/erp5_web/DocumentTemplateItem/portal_components/document.erp5.WebSection.py
...emplateItem/portal_components/document.erp5.WebSection.py
+2
-2
bt5/erp5_web/TestTemplateItem/portal_components/test.erp5.testERP5Web.py
...stTemplateItem/portal_components/test.erp5.testERP5Web.py
+4
-4
No files found.
bt5/erp5_web/DocumentTemplateItem/portal_components/document.erp5.WebSection.py
View file @
470188fd
...
@@ -160,7 +160,7 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
...
@@ -160,7 +160,7 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
query_string
=
self
.
REQUEST
.
get
(
'QUERY_STRING'
,
''
)
query_string
=
self
.
REQUEST
.
get
(
'QUERY_STRING'
,
''
)
if
query_string
:
if
query_string
:
translated_url
+=
'?'
+
query_string
translated_url
+=
'?'
+
query_string
self
.
REQUEST
.
RESPONSE
.
redirect
(
translated_url
,
status
=
301
)
self
.
REQUEST
.
RESPONSE
.
redirect
(
translated_url
)
return
document
return
document
def
_getTranslatedPathDict
(
self
):
def
_getTranslatedPathDict
(
self
):
...
@@ -179,7 +179,7 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
...
@@ -179,7 +179,7 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
checkValidId
(
self
,
translated_section_id
,
allow_dup
=
True
)
checkValidId
(
self
,
translated_section_id
,
allow_dup
=
True
)
key
=
(
translated_section_id
,
language
)
key
=
(
translated_section_id
,
language
)
if
key
in
translated_path_dict
:
if
key
in
translated_path_dict
:
raise
ValueError
,
'%r is used in several sections : %r'
%
(
key
,
(
translated_path_dict
[
key
],
section_id
))
raise
ValueError
(
'%r is used in several sections : %r'
%
(
key
,
(
translated_path_dict
[
key
],
section_id
)
))
translated_path_dict
[
key
]
=
section_id
translated_path_dict
[
key
]
=
section_id
if
translated_path_dict
!=
self
.
_getTranslatedPathDict
():
if
translated_path_dict
!=
self
.
_getTranslatedPathDict
():
setattr
(
self
,
INTERNAL_TRANSLATED_PATH_DICT_NAME
,
translated_path_dict
)
setattr
(
self
,
INTERNAL_TRANSLATED_PATH_DICT_NAME
,
translated_path_dict
)
...
...
bt5/erp5_web/TestTemplateItem/portal_components/test.erp5.testERP5Web.py
View file @
470188fd
...
@@ -1629,16 +1629,16 @@ Hé Hé Hé!""", page.asText().strip())
...
@@ -1629,16 +1629,16 @@ Hé Hé Hé!""", page.asText().strip())
website_path
=
website
.
absolute_url_path
()
website_path
=
website
.
absolute_url_path
()
# /fr/ccc/ is /aaa/
# /fr/ccc/ is /aaa/
response
=
self
.
publish
(
website_path
+
'/fr/ccc/'
)
response
=
self
.
publish
(
website_path
+
'/fr/ccc/'
)
self
.
assertEqual
(
response
.
status
,
200
)
self
.
assertEqual
(
HTTP_OK
,
response
.
status
)
self
.
assertIn
(
'page1 in French'
,
response
.
getBody
())
self
.
assertIn
(
'page1 in French'
,
response
.
getBody
())
# /fr/aaa/ is /bbb/
# /fr/aaa/ is /bbb/
response
=
self
.
publish
(
website_path
+
'/fr/aaa/'
)
response
=
self
.
publish
(
website_path
+
'/fr/aaa/'
)
self
.
assertEqual
(
response
.
status
,
200
)
self
.
assertEqual
(
HTTP_OK
,
response
.
status
)
self
.
assertIn
(
'page2 in French'
,
response
.
getBody
())
self
.
assertIn
(
'page2 in French'
,
response
.
getBody
())
# /fr/bbb/ should be redirected to /fr/aaa/
# /fr/bbb/ should be redirected to /fr/aaa/
response
=
self
.
publish
(
website_path
+
'/fr/bbb/'
)
response
=
self
.
publish
(
website_path
+
'/fr/bbb/'
)
self
.
assertEqual
(
response
.
status
,
301
)
self
.
assertEqual
(
MOVED_TEMPORARILY
,
response
.
status
)
self
.
assertEqual
(
response
.
getHeader
(
'Location'
),
website
.
absolute_url
()
+
'/fr/aaa/'
)
self
.
assertEqual
(
website
.
absolute_url
()
+
'/fr/aaa/'
,
response
.
getHeader
(
'Location'
)
)
class
TestERP5WebWithSimpleSecurity
(
ERP5TypeTestCase
):
class
TestERP5WebWithSimpleSecurity
(
ERP5TypeTestCase
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment