Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSWeb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSWeb
Commits
7c1dd948
Commit
7c1dd948
authored
10 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Even more language handling logic fix!
parent
61b5e7f6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
VIPSWeb/views.py
+2
-2
2 additions, 2 deletions
VIPSWeb/views.py
messages/models.py
+10
-5
10 additions, 5 deletions
messages/models.py
messages/views.py
+1
-1
1 addition, 1 deletion
messages/views.py
with
13 additions
and
8 deletions
VIPSWeb/views.py
+
2
−
2
View file @
7c1dd948
...
...
@@ -15,7 +15,7 @@
# You should have received a copy of the Bioforsk Open Source License
# along with VIPSWeb. If not, see <http://www.bioforsk.no/licenses/>.
#
# @author: Tor-Einar Skog <tor-einar.skog@bioforsk.no>
from
django.shortcuts
import
render
from
django.conf
import
settings
from
django.utils
import
translation
...
...
@@ -27,7 +27,7 @@ def index(request):
message_tags
=
MessageTag
.
get_message_tags
()
messages_by_tag
=
{}
for
message_tag_id
in
settings
.
FRONTPAGE_MESSAGE_TAG_IDS
:
messages
=
Message
.
get_messages_by_tag
(
message_tag_id
)
messages
=
Message
.
get_messages_by_tag
(
message_tag_id
,
translation
.
get_language
()
)
#print "MESSAGES: %s" % messages
messages_by_tag
[
message_tag_id
]
=
messages
#for message in messages:
...
...
This diff is collapsed.
Click to expand it.
messages/models.py
+
10
−
5
View file @
7c1dd948
...
...
@@ -93,15 +93,15 @@ class Message:
Currently this is a REST service
"""
@staticmethod
def
get_message
(
message_id
):
def
get_message
(
message_id
,
current_language
=
settings
.
VIPSLOGIC_LANGUAGE_CODE
):
message_json
=
Message
.
get_message_as_json
(
message_id
)
return
Message
.
get_instance_from_dict
(
message_json
)
return
Message
.
get_instance_from_dict
(
message_json
,
current_language
)
@staticmethod
def
get_messages_by_tag
(
tag_id
):
def
get_messages_by_tag
(
tag_id
,
current_language
=
settings
.
VIPSLOGIC_LANGUAGE_CODE
):
messages
=
[]
for
item
in
Message
.
get_messages_by_tag_as_json
(
tag_id
):
message
=
Message
.
get_instance_from_dict
(
item
)
message
=
Message
.
get_instance_from_dict
(
item
,
current_language
)
messages
.
append
(
message
)
return
messages
...
...
@@ -158,7 +158,12 @@ class Message:
for
message_locale
in
message_locale_set
:
if
message_locale
[
"
messageLocalePK
"
][
"
locale
"
]
==
language
:
return
message_locale
# Fallback: Return the first locale in the set
# Fallback: Find message in web site's default language
for
message_locale
in
message_locale_set
:
if
message_locale
[
"
messageLocalePK
"
][
"
locale
"
]
==
settings
.
LANGUAGE_CODE
:
return
message_locale
# If none of this works, try to return the first locale found
# If no locale, return empty set
if
len
(
message_locale_set
)
>
0
:
return
message_locale_set
[
0
]
else
:
...
...
This diff is collapsed.
Click to expand it.
messages/views.py
+
1
−
1
View file @
7c1dd948
...
...
@@ -30,6 +30,6 @@ def index(request):
def
detail
(
request
,
message_id
):
context
=
{
#'message' : get_object_or_404(Message, pk=message_id)
'
message
'
:
Message
.
get_message
(
message_id
)
'
message
'
:
Message
.
get_message
(
message_id
,
translation
.
get_language
()
)
}
return
render
(
request
,
'
messages/detail.html
'
,
context
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment