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 8 commits
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
49 changes: 49 additions & 0 deletions website_base_multi_image/README.rst
@@ -0,0 +1,49 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

========================
Website Base Multi-Image
========================

This module extends the functionality of 'base_multi_image' module
to show winery data in website
Copy link
Member

Choose a reason for hiding this comment

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

winery?


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...


.. 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}
Copy link
Member

Choose a reason for hiding this comment

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

Put right id


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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/xxx/issues>`_.
Copy link
Member

Choose a reason for hiding this comment

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

xxx?

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**>`_.
Copy link
Member

Choose a reason for hiding this comment

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

Use newer template.


Credits
=======

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

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

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit http://odoo-community.org.
Copy link
Member

Choose a reason for hiding this comment

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

https

5 changes: 5 additions & 0 deletions website_base_multi_image/__init__.py
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Sergio Teruel <sergio.teruel@tecnativa.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import models
24 changes: 24 additions & 0 deletions website_base_multi_image/__openerp__.py
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# © 2016 Sergio Teruel <sergio.teruel@tecnativa.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
'name': "Website Base Multi Image",
'summary': "Show multi images data in frontend",
'category': 'Website',
'version': '9.0.1.0.0',
'depends': [
'website',
'base_multi_image',
],
'data': [
'security/ir.model.access.csv',
'views/assets.xml',
'views/layout.xml',
],
'qweb': ['static/src/xml/*.xml'],
'author': 'Tecnativa',
Copy link
Member

Choose a reason for hiding this comment

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

and oca?

'website': 'http://www.tecnativa.com',
'license': 'LGPL-3',
'installable': True,
}
71 changes: 71 additions & 0 deletions website_base_multi_image/i18n/es.po
@@ -0,0 +1,71 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_base_multi_image
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-19 13:56+0200\n"
"PO-Revision-Date: 2016-09-19 13:57+0200\n"
"Last-Translator: Sergio Teruel <sergio@incaser.es>\n"
"Language-Team: sergio.teruel@tecnativa.com\n"
"Language: es_ES\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.7.1\n"

#. module: website_base_multi_image
#: model:ir.ui.view,arch_db:website_base_multi_image.upload_image_action
msgid "Add Pictures"
msgstr "Añadir fotos"

#. module: website_base_multi_image
#: code:addons/website_base_multi_image/controllers/main.py:26
#, python-format
msgid "Failed to remove image"
msgstr "Error al intentar borrar una imagen"

#. module: website_base_multi_image
#: code:addons/website_base_multi_image/controllers/main.py:54
#, python-format
msgid "Failed to set main image"
msgstr "Error al intentar establecer la imagen principal"

#. module: website_base_multi_image
#: model:ir.ui.view,arch_db:website_base_multi_image.image_main
msgid "Image"
msgstr "Imagen"

#. module: website_base_multi_image
#: model:ir.ui.view,arch_db:website_base_multi_image.image_thumbnails
msgid "More Images"
msgstr "Más imágenes"

#. module: website_base_multi_image
#. openerp-web
#: code:addons/website_base_multi_image/static/src/js/website_multi_image.js:58
#, python-format
msgid "This image already exists"
msgstr "Esta imagen ya existe."

#. module: website_base_multi_image
#. openerp-web
#: code:addons/website_base_multi_image/static/src/xml/website_multi_image.xml:36
#, python-format
msgid "Warning!"
msgstr "¡Aviso!"

#. module: website_base_multi_image
#: model:ir.model,name:website_base_multi_image.model_base_multi_image_image
msgid "base_multi_image.image"
msgstr ""

#. module: website_base_multi_image
#: model:ir.model,name:website_base_multi_image.model_base_multi_image_owner
msgid "base_multi_image.owner"
msgstr ""

#~ msgid "Main Image"
#~ msgstr "Imágen principal"
5 changes: 5 additions & 0 deletions website_base_multi_image/models/__init__.py
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import image
35 changes: 35 additions & 0 deletions website_base_multi_image/models/image.py
@@ -0,0 +1,35 @@
# -*- 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).

import base64
from openerp import api, models


class Image(models.Model):
_inherit = "base_multi_image.image"

@api.model
def get_images_to_add(self, post, model_name):
"""
@param post: dict with images in format 'new_image_xxx'
Copy link
Member

Choose a reason for hiding this comment

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

'new_image_xxx' is not a dict format nor an image format, I don't understand this doc line. Besides, add a general description for what the method does in its 1st line please.

@param model_name: Model to store image
@return: List of images to add
"""
images_to_add = []
for key in post.keys():
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not for key, image in post.iteritems(). IMO it would make the list check and new_image assignment block much cleaner.

if 'new_image_' in key:
Copy link
Contributor

@lasley lasley Sep 20, 2016

Choose a reason for hiding this comment

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

key.startswith('new_image_') would better match with the documented/intended logic

if isinstance(post[key], list):
new_image = post[key][0]
else:
new_image = post[key]
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()),
'owner_model': model_name,
'name': new_image.filename,
'extension': 'jpg',
Copy link
Contributor

Choose a reason for hiding this comment

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

mimetype?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, but base_multi_image.image does not have mimetype field.

Copy link
Member

Choose a reason for hiding this comment

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

I think @lasley means that you should guess the mimetype from the incoming bytes and then choose the right extension instead of hardcoding jpg, right?

}))
return images_to_add
3 changes: 3 additions & 0 deletions website_base_multi_image/security/ir.model.access.csv
@@ -0,0 +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
Copy link
Member

Choose a reason for hiding this comment

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

So any portal users can modify any image? 👎

write/create/unlink perms must be ir.rule-constrained, and I guess that should be made per submodule, so delete this please.

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.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions website_base_multi_image/static/src/css/style.css
@@ -0,0 +1,62 @@
/* Theme css */

.custom-file-input input {
visibility: hidden;
width: 100%;
}

#file_input_multi{
display: none;
}

.image-thumb {
max-width: 90px;
}

.image_main{
max-width: 250px;
max-height: 250px;
}

#base_multi_image .carousel-indicators{
position: relative;
bottom: 0px;
left: 0px;
z-index: 15;
width: 100%;
margin-left: 0px;
padding-left: 0;
list-style: none;
text-align: left;
}

#base_multi_image .carousel-indicators li{
display: inline-block;
width: 120px;
height: 100px;
margin: 1px;
text-indent: 0px;
border: 1px solid #000;
border-radius: 0px;
cursor: pointer;
background-color: #000 \9;
background-color: rgba(0, 0, 0, 0);
background-size: cover;
}

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

@lasley lasley Sep 20, 2016

Choose a reason for hiding this comment

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

Please remove this (see @yajo useless code comment)


}

#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;
}*/
Copy link
Member

Choose a reason for hiding this comment

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

Do not leave useless code around please.