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

[MIG] website_apps_store: Migration to 12.0 #61

Merged
merged 35 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6b6230f
[WIP]partial commit for migration of apps-store
Aug 31, 2018
7df4bed
[FIX]small changes
Sep 5, 2018
86cbe07
[FIX]remove console from js file
Sep 5, 2018
b14dada
[FIX]remove coding from files
Sep 5, 2018
bf22533
[FIX]correct version number
Sep 5, 2018
15ab731
[FIX] Changes as per suggested
Sep 6, 2018
4ed7cb4
[FIX] add changes as per requested
Sep 17, 2018
edd238d
[FIX] remove phantomjs for download zip file
Sep 20, 2018
b591d0a
[FIX] made changes as per suggested
Sep 20, 2018
1714a02
[FIX]Proper path for the phantomjs
bizzappdev Sep 20, 2018
1f35b54
[UPD] Update website_apps_store.pot
oca-travis Sep 28, 2018
692dff0
[IMP] Show a default 'OCA' icon on product
StephanRozendaal Oct 1, 2018
1d8c030
[IMP] website_apps_store: improved download button (#16)
oscarolar Oct 1, 2018
e212a28
[FIX] download file name Fix (#18)
bizzappdev Oct 2, 2018
693a96f
11.0 Improvement for filters and product page description (#14)
bizzappdev Oct 2, 2018
a59fe37
[IMP] apps-store (#15)
oscarolar Oct 2, 2018
cf33587
[IMP] Fix overflow on repository URL
StephanRozendaal Oct 2, 2018
c4fd98f
[ADD] website_apps_store: App maturity filter to the shop.
oscarolar Oct 2, 2018
882244f
[ADD] website_apps_store: new PDP layout. (#23)
oscarolar Oct 2, 2018
074c3de
[REF] Remove some whitespace
StephanRozendaal Oct 3, 2018
4501225
[IMP] Remove shop product qweb changes
StephanRozendaal Oct 3, 2018
db03d32
update products attributes and create attribute values (#40)
bizzappdev Nov 11, 2018
61394e1
Fix Bad rendering of links inside README (#42)
bizzappdev Nov 20, 2018
db7d217
[FIX]visibility for the selected options and filters improvements (#43)
bizzappdev Nov 23, 2018
9c9bfac
[FIX]CSS module description
bizzappdev Nov 24, 2018
a601f25
[FIX]website_apps_store: fix the shop pager
bizzappdev Nov 25, 2018
09488cc
[FIX][49] solve pager with search parameter (#51)
bizzappdev Dec 3, 2018
0b7774c
Sort by Download and rating (#46)
bizzappdev Dec 6, 2018
6698a23
11.0 issue #50 add the module technical name in front page (#52)
bizzappdev Jan 3, 2019
b2bec31
[FIX] website product page event not define problem
bizzappdev Jan 12, 2019
990d884
[FIX]fix 403 public user error
bizzappdev Jan 12, 2019
8b2bdd1
[FIX]website_apps_store: attribute value change was not changing the …
bizzappdev Mar 12, 2019
eb1bd7f
[ADD] icon.png
OCA-git-bot Apr 3, 2019
37b153d
[FIX] webstie_apps_store: Icon sizes are now consistent
oscarolar May 5, 2019
f6a92a5
[MIG] website_apps_store: Migration to 12.0
May 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# List the OCA project dependencies, one per line
# Add a repository url and branch if you need a forked version
interface-github

website
85 changes: 85 additions & 0 deletions website_apps_store/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
==================
Website Apps Store
==================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fapps--store-lightgray.png?logo=github
:target: https://github.com/OCA/apps-store/tree/12.0/website_apps_store
:alt: OCA/apps-store
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/apps-store-12-0/apps-store-12-0-website_apps_store
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/249/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

Providing facility for displaying the module specific information in a standard Odoo
e-commerce website (front-end) and download the zip file of the selected product.

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

* Creation of an error queue if the exception occurs while generating zip file of the product

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/apps-store/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 <https://github.com/OCA/apps-store/issues/new?body=module:%20website_apps_store%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* BizzAppDev

Contributors
~~~~~~~~~~~~

* Ruchir Shukla <ruchir@bizzappdev.com
* Divya Modi <divya.modi@bizzappdev.com>
* Eric Caudal <eric.caudal@elico-corp.com>
* Oscar Alcala <oscar@vauxoo.com>
* `Tecnativa <https://www.tecnativa.com>`_:

* Víctor M.M. Torres

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

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

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.

This module is part of the `OCA/apps-store <https://github.com/OCA/apps-store/tree/12.0/website_apps_store>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions website_apps_store/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
27 changes: 27 additions & 0 deletions website_apps_store/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2018 BizzAppDev
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Website Apps Store",
"version": "12.0.1.0.0",
'author': 'Odoo Community Association (OCA), BizzAppDev',
"website": "https://github.com/OCA/apps-store",
"license": "AGPL-3",
"category": "Sales",
"depends": [
'website_sale',
'website_form_recaptcha',
'apps_download',
'apps_product_creator',
],
"summary": "Website Apps Store",
"data": [
'views/assets.xml',
'views/templates.xml',
],
'demo': [
'demo/product_template_demo.xml',
],
'installable': True,
'auto_install': False,
'application': False
}
1 change: 1 addition & 0 deletions website_apps_store/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
221 changes: 221 additions & 0 deletions website_apps_store/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
# Copyright 2017-2018 BizzAppDev
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import logging
import base64

from odoo import http
from odoo.http import request
from odoo.addons.http_routing.models.ir_http import slug
from odoo.addons.website.controllers.main import QueryURL
from odoo.addons.website_sale.controllers.main import WebsiteSale, TableCompute
from odoo.exceptions import ValidationError

_logger = logging.getLogger(__name__)

PPG = 20 # Products Per Page
PPR = 4 # Products Per Row


class WebsiteSaleCustom(WebsiteSale):

def _get_search_domain(self, search, category, attrib_values):
domain = request.website.sale_product_domain()
if search:
for srch in search.split(" "):
domain += [
'|', '|', '|', '|', '|', '|', '|', '|',
('name', 'ilike', srch),
('technical_name', 'ilike', srch),
('description', 'ilike', srch),
('description_sale', 'ilike', srch),
('product_variant_ids.default_code', 'ilike', srch),
('product_variant_ids.attribute_value_ids.name',
'ilike', srch),
('product_variant_ids.app_description_rst_html',
'ilike', srch),
('product_variant_ids.app_author_ids.name', 'ilike', srch),
('product_variant_ids.app_summary', 'ilike', srch)]
if category:
domain += [('public_categ_ids', 'child_of', int(category))]

if attrib_values:
attrib = None
ids = []
for value in attrib_values:
pedrobaeza marked this conversation as resolved.
Show resolved Hide resolved
if not attrib:
attrib = value[0]
ids.append(value[1])
elif value[0] == attrib:
ids.append(value[1])
else:
pedrobaeza marked this conversation as resolved.
Show resolved Hide resolved
domain += [('attribute_line_ids.value_ids', 'in', ids)]
attrib = value[0]
ids = [value[1]]
if attrib:
domain += [('attribute_line_ids.value_ids', 'in', ids)]

return domain

@http.route()
def shop(self, page=0, category=None, search='', ppg=False, **post):
res = super(WebsiteSaleCustom, self).shop(
page=page, category=category, search=search, ppg=ppg, **post)

if ppg:
try:
ppg = int(ppg)
except ValueError:
ppg = PPG
post["ppg"] = ppg
else:
ppg = PPG

attrib_list = request.httprequest.args.getlist('attrib')
attrib_values = [
[int(x) for x in v.split("-")] for v in attrib_list if v]
attributes_ids = {v[0] for v in attrib_values}
attrib_set = {v[1] for v in attrib_values}
domain = self._get_search_domain(search, category, attrib_values)

keep = QueryURL('/shop', category=category and int(category),
search=search, attrib=attrib_list,
order=post.get('order'),
maturity=post.get('maturity'),
version=post.get('version'), author=post.get('author'))
if post.get('version'):
domain += [('product_variant_ids.attribute_value_ids.id',
'=', post.get('version'))]
if post.get('author'):
domain += [('product_variant_ids.app_author_ids.id',
'=', post.get('author'))]
if post.get('maturity', False):
domain += [('product_variant_ids.app_development_status',
'=', post.get('maturity'))]

url = "/shop"
if search:
post["search"] = search
if attrib_list:
post['attrib'] = attrib_list

if category:
category = request.env['product.public.category'].browse(
int(category))
url = "/shop/category/%s" % slug(category)

attribute_id = request.env.ref(
'apps_product_creator.attribute_odoo_version')
category_all = request.env['product.public.category'].search([])
versions = request.env['product.attribute.value'].search([
('attribute_id', '=', attribute_id.id)])
authors = request.env['odoo.author'].search([])
Product = request.env['product.template']

product_count = Product.search_count(domain)
pager = request.website.pager(url=url, total=product_count,
page=page, step=ppg,
scope=7, url_args=post)
products = Product.search(domain, limit=ppg, offset=pager['offset'],
order=self._get_search_order(post))

ProductAttribute = request.env['product.attribute']
if products:
# get all products without limit
selected_products = Product.search(domain, limit=False)
attributes = ProductAttribute.search(
[('attribute_line_ids.product_tmpl_id', 'in',
selected_products.ids)])
else:
attributes = ProductAttribute.browse(attributes_ids)

res.qcontext.update({
'search': search,
'category': category,
'attrib_values': attrib_values,
'attrib_set': attrib_set,
'pager': pager,
'products': products,
'search_count': product_count, # common for all searchbox
'bins': TableCompute().process(products, ppg),
'category_all': category_all,
'versions': versions,
'authors': authors,
'version': post.get('version'),
'author': post.get('author'),
'attributes': attributes,
'keep': keep,
'maturity': post.get('maturity'),
})
return res

@http.route(['/shop/change_attribute_version'], type='json',
auth="public", website=True)
def change_product_attribute_version(self, **kwargs):
product_id = kwargs.get('product_id', False)
product = request.env['product.product'].sudo().browse(product_id)
vals = {
'name_product': product.name,
'technical_name':
product.odoo_module_version_id.module_id.technical_name,
'license': product.app_license_id.name,
'license_url': product.app_license_id.website,
'author': ', '.join(
author.name for author in product.app_author_ids),
'website': product.app_website,
'repository': product.app_github_url,
'rst_html': product.app_description_rst_html,
'app_summary': product.app_summary,
}
return vals

def validate_recaptcha(self, captcha):
""" Function for validating Recaptcha """
captcha_obj = request.env['website.form.recaptcha']
ip_addr = request.httprequest.environ.get('HTTP_X_FORWARDED_FOR')
if ip_addr:
ip_addr = ip_addr.split(',')[0]
else:
ip_addr = request.httprequest.remote_addr
try:
captcha_obj.action_validate(
captcha, ip_addr
)
except ValidationError:
raise ValidationError([captcha_obj.RESPONSE_ATTR])

@http.route(
['/shop/download_product_zip/<model("product.template"):product_tmpl>'
'/<model("product.product"):product>/'
'<string:google_captcha>',
'/shop/download_product_zip/<model("product.template"):product_tmpl>/'
'<string:google_captcha>'],
type='http', auth="public", website=True)
def download_product_zip(self, product_tmpl, product=False,
google_captcha='', **kwargs):
self.validate_recaptcha(google_captcha)
if not product:
product = product_tmpl.get_version_info()

attachment = request.env['ir.attachment'].sudo().search([
('res_id', '=', product.id),
('res_model', '=', product._name),
], limit=1)
if not attachment:
product.sudo().generate_zip_file()
attachment = request.env['ir.attachment'].sudo().search([
('res_id', '=', product.id),
('res_model', '=', product._name),
], limit=1)

if attachment:
filecontent = base64.b64decode(attachment.datas)
disposition = 'attachment; filename="%s"' % attachment.datas_fname
# increasing count for the product download
product.sudo().download_count = product.sudo().download_count + 1
return request.make_response(
filecontent,
[('Content-Type', 'application/zip, application/octet-stream'),
('Content-Length', len(filecontent)),
('Content-Disposition', disposition)])
return False
8 changes: 8 additions & 0 deletions website_apps_store/demo/product_template_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Copyright (C) 2017-Today: BizzAppDev - Ruchir Shukla <ruchir@bizzappdev.com-->
<!--License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-->
<odoo>
<record id="apps_download.product_product_100" model="product.product">
<field name="odoo_module_id" ref="apps_download.odoo_module1"/>
</record>
</odoo>
Loading