Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
7cf554af
Commit
7cf554af
authored
8 years ago
by
Vipul Bhatt
Committed by
Denis Vermylen (dve)
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[IMP] website_event_track: display event time in website language format
parent
4d9f5bbf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
addons/website_event_track/controllers/main.py
+16
-4
16 additions, 4 deletions
addons/website_event_track/controllers/main.py
addons/website_event_track/views/website_event_track_templates.xml
+3
-3
3 additions, 3 deletions
...bsite_event_track/views/website_event_track_templates.xml
with
19 additions
and
7 deletions
addons/website_event_track/controllers/main.py
+
16
−
4
View file @
7cf554af
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import
babel
import
collections
import
datetime
import
pytz
...
...
@@ -18,8 +19,18 @@ class WebsiteEventTrackController(http.Controller):
values
=
{
'
track
'
:
track
,
'
event
'
:
track
.
event_id
,
'
main_object
'
:
track
}
return
request
.
render
(
"
website_event_track.track_view
"
,
values
)
def
_get_locale_time
(
self
,
dt_time
,
lang_code
):
"""
Get locale time from datetime object
:param dt_time: datetime object
:param lang_code: language code (eg. en_US)
"""
locale
=
babel
.
Locale
.
parse
(
lang_code
)
return
babel
.
dates
.
format_time
(
dt_time
,
format
=
'
short
'
,
locale
=
locale
)
def
_prepare_calendar
(
self
,
event
,
event_track_ids
):
local_tz
=
pytz
.
timezone
(
event
.
date_tz
or
'
UTC
'
)
lang_code
=
request
.
env
.
context
.
get
(
'
lang
'
)
locations
=
{}
# { location: [track, start_date, end_date, rowspan]}
dates
=
[]
# [ (date, {}) ]
for
track
in
event_track_ids
:
...
...
@@ -34,7 +45,8 @@ class WebsiteEventTrackController(http.Controller):
# New TR, align all events
if
forcetr
or
(
start_date
>
dates
[
-
1
][
0
])
or
not
location
:
dates
.
append
((
start_date
,
{},
bool
(
location
)))
formatted_time
=
self
.
_get_locale_time
(
start_date
,
lang_code
)
dates
.
append
((
start_date
,
{},
bool
(
location
),
formatted_time
))
for
loc
in
locations
.
keys
():
if
locations
[
loc
]
and
(
locations
[
loc
][
-
1
][
2
]
>
start_date
):
locations
[
loc
][
-
1
][
3
]
+=
1
...
...
@@ -62,9 +74,9 @@ class WebsiteEventTrackController(http.Controller):
days_tracks
[
track
.
date
[:
10
]].
append
(
track
)
days
=
{}
days_
tracks_
count
=
{}
tracks_
by_days
=
{}
for
day
,
tracks
in
days_tracks
.
iteritems
():
days_
tracks_
count
[
day
]
=
len
(
tracks
)
tracks_
by_days
[
day
]
=
tracks
days
[
day
]
=
self
.
_prepare_calendar
(
event
,
tracks
)
speakers
=
{}
...
...
@@ -75,7 +87,7 @@ class WebsiteEventTrackController(http.Controller):
return
request
.
render
(
"
website_event_track.agenda
"
,
{
'
event
'
:
event
,
'
days
'
:
days
,
'
days_nbr
'
:
days
_
tracks_
count
,
'
tracks_by_
days
'
:
tracks_
by_days
,
'
speakers
'
:
speakers
,
'
tag
'
:
tag
})
...
...
This diff is collapsed.
Click to expand it.
addons/website_event_track/views/website_event_track_templates.xml
+
3
−
3
View file @
7cf554af
...
...
@@ -55,8 +55,8 @@
<t
t-set=
"locations"
t-value=
"days[day]['locations']"
/>
<t
t-set=
"dates"
t-value=
"days[day]['dates']"
/>
<h3
class=
"page-header mt0"
>
<
t
t-esc=
"day
"
/>
<small><t
t-esc=
"days
_nbr
[day]"
/>
talks
</small>
<
span
t-field=
"tracks_by_days[day][0].date"
t-field-options=
"{'widget': 'date'}
"
/>
<small><t
t-esc=
"
len(tracks_by_
days[day]
)
"
/>
talks
</small>
</h3>
<table
id=
"table_search"
class=
"table table-bordered table-condensed"
>
<tr>
...
...
@@ -69,7 +69,7 @@
</tr>
<tr
t-foreach=
"dates"
t-as=
"dt"
>
<td
class=
"active"
>
<b
t-esc=
"dt[
0].strftime('%H:%M')
"
/>
<b
t-esc=
"dt[
-1]
"
/>
</td>
<t
t-if=
"dt[2]"
>
<!-- Not a multi location -->
<t
t-foreach=
"locations"
t-as=
"location"
>
...
...
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