Skip to content

Commit

Permalink
Merge branch 'release/3.4.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunbhardwaj committed Jul 17, 2015
2 parents ff86ec2 + 5399743 commit 1641576
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
2 changes: 2 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from party import Address
from shipment import ShipmentOut
from tree import Node
from static_file import NereidStaticFile


def register():
Expand All @@ -32,5 +33,6 @@ def register():
ArticleCategory,
Node,
MenuItem,
NereidStaticFile,
module='nereid_webshop', type_='model'
)
7 changes: 3 additions & 4 deletions product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
<tryton>
<data>
<record id="default_image_folder" model="nereid.static.folder">
<field name="folder_name">Default Images</field>
<field name="name">Default Images</field>
<field name="description">Folder having default images for webshop</field>
</record>
<record id="mystery_box" model="nereid.static.file">
<field name="name">no-product-image</field>
<field name="name">no-product-image.png</field>
<field name="folder" ref="default_image_folder"/>
<field name="type">remote</field>
<field name="remote_path">http://placehold.it/350&amp;text=No%20Product%20Image.png</field>
<field name="file_binary">binary-default-image</field>
</record>
</data>
</tryton>
Binary file added static/images/no-product-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions static_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
"""
static_file
:copyright: (c) 2015 by Fulfil.IO Inc.
:license: see LICENSE for details.
"""
import os
from trytond.pool import PoolMeta

__all__ = ['NereidStaticFile']
__metaclass__ = PoolMeta


class NereidStaticFile:
"Static files for Nereid"
__name__ = "nereid.static.file"

def _set_file_binary(self, value):
"""
Setter for static file that stores file in file system
:param value: The value to set
"""
if self.name == 'no-product-image.png' and \
value == 'binary-default-image':
# XXX: This is default webshop image that need to be replaced
# by binary content of product no image. Ugly hack ;)
# Can't find provision to store binary file in xml.
value = open(os.path.join(
os.path.dirname(__file__), 'static/images/no-product-image.png'
)).read()
super(NereidStaticFile, self)._set_file_binary(value)
2 changes: 1 addition & 1 deletion tryton.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tryton]
version=3.4.3.1
version=3.4.4.0
depends:
nereid
nereid_cms
Expand Down

0 comments on commit 1641576

Please sign in to comment.