Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odoo CE
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
Comunitats Energètiques
Odoo CE
Merge requests
!212
Feat/adjust landing api
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Feat/adjust landing api
feat/adjust-landing-api
into
dev
Overview
0
Commits
9
Pipelines
7
Changes
4
Merged
konykon
requested to merge
feat/adjust-landing-api
into
dev
1 year ago
Overview
0
Commits
9
Pipelines
7
Changes
3
Expand
0
0
Merge request reports
Compare
version 4
version 6
da886cab
1 year ago
version 5
500056b9
1 year ago
version 4
81be56fb
1 year ago
version 3
906486a8
1 year ago
version 2
3dc940ae
1 year ago
version 1
d20aa015
1 year ago
dev (base)
and
latest version
latest version
96757219
9 commits,
1 year ago
version 6
da886cab
8 commits,
1 year ago
version 5
500056b9
7 commits,
1 year ago
version 4
81be56fb
6 commits,
1 year ago
version 3
906486a8
5 commits,
1 year ago
version 2
3dc940ae
4 commits,
1 year ago
version 1
d20aa015
3 commits,
1 year ago
Show latest version
3 files
+
47
−
45
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
energy_communities/models/landing_page.py
+
43
−
29
Options
@@ -23,8 +23,7 @@ class LandingPage(models.Model):
string
=
"
Allows new members
"
,
related
=
"
company_id.allow_new_members
"
)
number_of_members
=
fields
.
Integer
(
string
=
"
Number of members
"
)
external_website_link
=
fields
.
Char
(
string
=
"
External website link
"
,
translate
=
True
)
external_website_link
=
fields
.
Char
(
string
=
"
External website link
"
,
translate
=
True
)
twitter_link
=
fields
.
Char
(
string
=
"
Twitter link
"
,
related
=
"
company_id.social_twitter
"
)
@@ -37,13 +36,10 @@ class LandingPage(models.Model):
# TODO: group_image_link Left for backward compatibility. To be removed
group_image_link
=
fields
.
Char
(
string
=
"
Group image link
"
)
primary_image_file
=
fields
.
Image
(
"
Primary Image
"
)
primary_image_file_filename
=
fields
.
Char
(
"
Primary Image filename
"
)
secondary_image_file
=
fields
.
Image
(
"
Secondary Image
"
)
secondary_image_file_filename
=
fields
.
Char
(
"
Secondary Image filename
"
)
short_description
=
fields
.
Text
(
string
=
"
Short description
"
,
translate
=
True
)
long_description
=
fields
.
Text
(
string
=
"
Long description
"
,
translate
=
True
)
why_become_cooperator
=
fields
.
Html
(
string
=
"
Why become cooperator
"
,
translate
=
True
)
why_become_cooperator
=
fields
.
Html
(
string
=
"
Why become cooperator
"
,
translate
=
True
)
become_cooperator_process
=
fields
.
Html
(
string
=
"
Become cooperator process
"
,
translate
=
True
)
@@ -75,43 +71,61 @@ class LandingPage(models.Model):
string
=
"
Community status
"
,
)
def
_get_image_attachment
(
self
,
field_name
):
file_attachment
=
self
.
env
[
"
ir.attachment
"
].
search
(
[
(
"
res_id
"
,
"
=
"
,
self
.
id
),
(
"
res_model
"
,
"
=
"
,
"
landing.page
"
),
(
"
res_field
"
,
"
=
"
,
field_name
),
]
)
return
file_attachment
def
_get_image_write_date
(
self
,
field_name
):
file_write_date
=
""
file_attachment
=
self
.
env
[
'
ir.attachment
'
].
search
([
(
'
res_id
'
,
'
=
'
,
self
.
id
),
(
'
res_model
'
,
'
=
'
,
'
landing.page
'
),
(
'
res_field
'
,
'
=
'
,
field_name
)])
file_attachment
=
self
.
_get_image_attachment
(
field_name
)
if
file_attachment
:
file_write_date
=
str
(
file_attachment
.
write_date
)
return
file_write_date
def
to_dict
(
self
):
def
_get_image_extension
(
self
,
field_name
):
file_write_date
=
""
file_attachment
=
self
.
_get_image_attachment
(
field_name
)
extension
=
""
if
file_attachment
:
extension
=
file_attachment
.
mimetype
.
split
(
"
/
"
)[
1
]
return
extension
def
_get_image_payload
(
self
,
field_name
):
base_url
=
self
.
env
[
"
ir.config_parameter
"
].
get_param
(
"
web.base.url
"
)
return
(
base_url
+
"
/web/image/landing.page/
"
+
str
(
self
.
id
)
+
"
/
"
+
field_name
+
"
/
"
+
str
(
self
.
id
)
+
"
-
"
+
field_name
+
"
.
"
+
self
.
_get_image_extension
(
field_name
)
)
def
to_dict
(
self
):
if
self
.
primary_image_file
:
primary_image_file
=
(
base_url
+
"
/web/image/landing.page/
"
+
str
(
self
.
id
)
+
"
/primary_image_file/
"
+
self
.
primary_image_file_filename
)
primary_image_file
=
self
.
_get_image_payload
(
"
primary_image_file
"
)
primary_image_file_write_date
=
self
.
_get_image_write_date
(
'
primary_image_file
'
)
"
primary_image_file
"
)
else
:
primary_image_file
=
""
primary_image_file_write_date
=
""
if
self
.
secondary_image_file
:
secondary_image_file
=
(
base_url
+
"
/web/image/landing.page/
"
+
str
(
self
.
id
)
+
"
/secondary_image_file/
"
+
self
.
secondary_image_file_filename
)
secondary_image_file
=
self
.
_get_image_payload
(
"
secondary_image_file
"
)
secondary_image_file_write_date
=
self
.
_get_image_write_date
(
'
secondary_image_file
'
)
"
secondary_image_file
"
)
else
:
secondary_image_file
=
""
secondary_image_file_write_date
=
""
Loading