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
Commits
da886cab
Commit
da886cab
authored
1 year ago
by
daniquilez
Browse files
Options
Downloads
Patches
Plain Diff
improve landing api codebase
parent
500056b9
No related branches found
No related tags found
Loading
Pipeline
#53892
passed
1 year ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
energy_communities/models/landing_page.py
+27
-21
27 additions, 21 deletions
energy_communities/models/landing_page.py
energy_communities/views/landing_page_view.xml
+0
-4
0 additions, 4 deletions
energy_communities/views/landing_page_view.xml
with
27 additions
and
25 deletions
energy_communities/models/landing_page.py
+
27
−
21
View file @
da886cab
...
...
@@ -36,9 +36,7 @@ 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
)
...
...
@@ -73,8 +71,8 @@ class LandingPage(models.Model):
string
=
"
Community status
"
,
)
def
_get_image_write_date
(
self
,
field_name
):
file_writ
e_
d
at
e
=
""
def
_get_imag
e_at
tachment
(
self
,
field_name
):
file_attachment
=
self
.
env
[
"
ir.attachment
"
].
search
(
[
(
"
res_id
"
,
"
=
"
,
self
.
id
),
...
...
@@ -82,39 +80,47 @@ class LandingPage(models.Model):
(
"
res_field
"
,
"
=
"
,
field_name
),
]
)
return
file_attachment
def
_get_image_write_date
(
self
,
field_name
):
file_write_date
=
""
file_attachment
=
self
.
_get_image_attachment
(
field_name
)
if
file_attachment
:
file_write_date
=
str
(
file_attachment
.
write_date
)
return
file_write_date
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
to_dict
(
self
):
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
"
)
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
"
)
else
:
secondary_image_file
=
""
secondary_image_file_write_date
=
""
...
...
This diff is collapsed.
Click to expand it.
energy_communities/views/landing_page_view.xml
+
0
−
4
View file @
da886cab
...
...
@@ -50,15 +50,11 @@
<field
name=
"primary_image_file"
widget=
"image"
filename=
"primary_image_file_filename"
/>
<field
name=
"primary_image_file_filename"
invisible=
"True"
/>
<field
name=
"secondary_image_file"
widget=
"image"
filename=
"secondary_image_file_filename"
/>
<field
name=
"secondary_image_file_filename"
invisible=
"True"
/>
</group>
<group>
...
...
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