Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] 9.0 website_base_multi_image #252

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions website_base_multi_image/README.rst
Expand Up @@ -7,30 +7,34 @@ Website Base Multi-Image
========================

This module extends the functionality of 'base_multi_image' module
to show winery data in website
to show images gallery in website


Usage
=====
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage instructions? Don't know what to test...


To use this module, you need to:

#. Go to ...
Copy link
Member

@yajo yajo Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥


.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/{id}
:target: https://runbot.odoo-community.org/runbot/186/website

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/xxx/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/website/issues/new?body=module:%mypopwine_website_portal_purchase_winery%0Aversion:%209.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/website/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Credits
=======

Contributors
------------

* Carlos Dauden <carlos.dauden@tecnativa.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>

Maintainer
Expand Down
15 changes: 10 additions & 5 deletions website_base_multi_image/__openerp__.py
Expand Up @@ -5,8 +5,13 @@
{
'name': "Website Base Multi Image",
'summary': "Show multi images data in frontend",
'category': 'Website',
'version': '9.0.1.0.0',
'category': 'Website',
"website": "https://tecnativa.com/",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "LGPL-3",
"application": False,
'installable': True,
'depends': [
'website',
'base_multi_image',
Expand All @@ -16,9 +21,9 @@
'views/assets.xml',
'views/layout.xml',
],
'demo': [
'demo/website_base_multi_image_demo.xml',
'demo/pages.xml',
],
'qweb': ['static/src/xml/*.xml'],
'author': 'Tecnativa',
'website': 'http://www.tecnativa.com',
'license': 'LGPL-3',
'installable': True,
}
41 changes: 41 additions & 0 deletions website_base_multi_image/demo/pages.xml
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- © 2016 Sergio Teruel <sergio.teruel@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>

<template id="demo_page" page="True" name="Website Base Multi Image">
<t t-call="website.layout">
<div id="wrap" class="oe_structure oe_empty">
<section>
<div class="container readable mt32 mb32">
<div class="row">
<div class="col-md-12">
<h1 class="text-center">Image Gallery</h1>
<h3 class="text-muted text-center">
Test here the image gallery
</h3>
<div class="row">
<div class="col-md-12">
<t t-call="website_base_multi_image.base_multi_image_carousel">
<t t-set="owner_model" t-value="'res.partner'"/>
<t t-set="owner_id" t-value="1"/>
<t t-set="edit_action" t-value="False"/>
</t>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</t>
</template>

<record id="demo_page_link" model="website.menu">
<field name="name">Website multi image demo</field>
<field name="url">/page/website_base_multi_image.demo_page</field>
<field name="parent_id" ref="website.main_menu" />
<field name="sequence" type="int">50</field>
</record>

</odoo>
29 changes: 29 additions & 0 deletions website_base_multi_image/demo/website_base_multi_image_demo.xml
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<odoo>

<!--
Resource: base_multi_image.image
-->

<record id="partner_image_1" model="base_multi_image.image">
<field name="name">Partner Image 1</field>
<field name="owner_id">1</field>
<field name="owner_model">res.partner</field>
<field name="storage">db</field>
<field name="file_db_store"
type="base64"
file="website_base_multi_image/static/src/img/partner_image_1.jpg"/>
</record>

<record id="partner_image_2" model="base_multi_image.image">
<field name="name">Partner Image 2</field>
<field name="owner_id">1</field>
<field name="owner_model">res.partner</field>
<field name="storage">db</field>
<field name="file_db_store"
type="base64"
file="website_base_multi_image/static/src/img/partner_image_2.jpg"/>
</record>

</data>
</odoo>
16 changes: 7 additions & 9 deletions website_base_multi_image/models/image.py
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
# © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# © 2016 Sergio Teruel <sergio.teruel@tecnativa.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import base64
from openerp import api, models
Expand All @@ -19,12 +17,12 @@ def get_images_to_add(self, post, model_name):
@return: List of images to add
"""
images_to_add = []
for key in post.keys():
if 'new_image_' in key:
if isinstance(post[key], list):
new_image = post[key][0]
for key, image in post.iteritems():
if key.startswith('new_image_'):
if isinstance(image, list):
new_image = image[0]
else:
new_image = post[key]
new_image = image
images_to_add.append((0, 0, {
'storage': 'db',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could get this from context (self.env.context.get("default_storage", "db")) or from a method argument. Not a blocker.

'file_db_store': base64.encodestring(new_image.read()),
Expand Down
2 changes: 1 addition & 1 deletion website_base_multi_image/security/ir.model.access.csv
@@ -1,3 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_portal_supplier_base_multi_image,access_portal_supplier_base_multi_image,base_multi_image.model_base_multi_image_image,base.group_portal,1,1,1,0
access_portal_base_multi_image,access_portal_base_multi_image,base_multi_image.model_base_multi_image_image,base.group_portal,1,0,0,0
access_public_base_multi_image,access_public_base_multi_image,base_multi_image.model_base_multi_image_image,base.group_public,1,0,0,0
Copy link
Member

@yajo yajo Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use a single rule for this, with no group.
BTW keep in mind you are giving access to every multi image in the database. No matter if it belongs to a partner, product, human resource, or whatever...
Given this is a website_base module, I think it would be a good idea to add a "published" button to the model, and a ir.rule that constrains public access to published images.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are still giving access to public and portal users to every image in the database.

As this is right now, this is a 👎 blocking security issue. I think the best fix you could apply is something similar to what I do here for base_custom_info: giving access to images by checking access to their owners.

That IMP should go direclty into base_multi_image, BTW.

11 changes: 0 additions & 11 deletions website_base_multi_image/static/src/css/style.css
Expand Up @@ -44,19 +44,8 @@
background-size: cover;
}

#base_multi_image .carousel-indicators .active {
/*display: none;*/

}

#base_multi_image .existing-attachment-cell{
height: 0px;
width: 110px;
margin-left: 5px;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this line would become more readable/reusable if written into less/sass. Not blocking 😉


/*#base_multi_image .thumb-container{
width: 130px;
float: left;
margin-top: 5px;
}*/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.