Browse Source

[FIX] Controller Change

pull/30/merge
SHEREEF PT 8 years ago
parent
commit
b1be5bef25
  1. 2
      website_event_attachements/__manifest__.py
  2. 43
      website_event_attachements/__manifest__.py~
  3. 6
      website_event_attachements/controllers/main.py
  4. 70
      website_event_attachements/controllers/main.py~
  5. 2
      website_product_attachments/__manifest__.py
  6. 42
      website_product_attachments/__manifest__.py~
  7. 6
      website_product_attachments/controllers/main.py
  8. 87
      website_product_attachments/controllers/main.py~

2
website_event_attachements/__manifest__.py

@ -22,7 +22,7 @@
##############################################################################
{
'name': 'Event Attachments on Website',
'version': '10.0.1.0.0',
'version': '10.0.1.0.1',
'summary': """Download Documents That are Attached to the Events from Website""",
'description': 'This Module allows customer to download documents '
'that are attached to the Events from website',

43
website_event_attachements/__manifest__.py~

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Fasluca(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Event Attachments on Website',
'version': '10.0.1.0.0',
'summary': """Download Documents That are Attached to the Events from Website""",
'description': 'This Module allows customer to download documents '
'that are attached to the Events from website',
'category': 'Website',
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'website': "https://www.cybrosys.com",
'depends': ['document', 'website_event'],
'data': [
'views/template.xml'
],
'images': ['static/description/banner.jpg'],
'license': 'LGPL-3',
'demo': [],
'installable': True,
'auto_install': False,
'application': False,
}

6
website_event_attachements/controllers/main.py

@ -57,6 +57,10 @@ class WebsiteEventControllerEx(WebsiteEventController):
[('id', '=', int(attachment_id))],
["name", "datas", "file_type", "res_model", "res_id", "type", "url"]
)
if attachment:
attachment = attachment[0]
else:
return redirect('/event')
if attachment["type"] == "url":
if attachment["url"]:
@ -67,4 +71,4 @@ class WebsiteEventControllerEx(WebsiteEventController):
data = StringIO(base64.standard_b64decode(attachment["datas"]))
return http.send_file(data, filename=attachment['name'], as_attachment=True)
else:
return request.not_found()
return request.not_found()

70
website_event_attachements/controllers/main.py~

@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Fasluca(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
##############################################################################
import base64
from cStringIO import StringIO
from werkzeug.utils import redirect
from odoo import http, tools, _
from odoo.http import request
from odoo.addons.website.models.website import slug
from odoo.addons.website.controllers.main import QueryURL
from odoo.addons.website_event.controllers.main import WebsiteEventController
class WebsiteEventControllerEx(WebsiteEventController):
@http.route(['/event/<model("event.event"):event>/register'], type='http', auth="public", website=True)
def event_register(self, event, **post):
if event.state == 'done':
return request.redirect("/event/%s" % slug(event))
attachments = request.env['ir.attachment'].search(
[('res_model', '=', 'event.event'),
('res_id', '=', event.id)], order='id')
values = {
'event': event,
'main_object': event,
'range': range,
'attachments': attachments,
}
return request.render("website_event.event_description_full", values)
@http.route(['/attachment/download'], type='http', auth='public')
def download_attachment(self, attachment_id):
# Check if this is a valid attachment id
attachment = request.env['ir.attachment'].sudo().search_read(
[('id', '=', int(attachment_id))],
["name", "datas", "file_type", "res_model", "res_id", "type", "url"]
)
if attachment["type"] == "url":
if attachment["url"]:
return redirect(attachment["url"])
else:
return request.not_found()
elif attachment["datas"]:
data = StringIO(base64.standard_b64decode(attachment["datas"]))
return http.send_file(data, filename=attachment['name'], as_attachment=True)
else:
return request.not_found()

2
website_product_attachments/__manifest__.py

@ -22,7 +22,7 @@
##############################################################################
{
'name': 'Product Attachments on Website',
'version': '10.0.1.0.0',
'version': '10.0.1.0.1',
'summary': """This Module Allows Customer to Download Documents
That Are Attached to the Products From Website""",
'description': 'This Module allows customer to download documents '

42
website_product_attachments/__manifest__.py~

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Fasluca(<http://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Product Attachments on Website',
'version': '10.0.1.0.0',
'summary': """This Module Allows Customer to Download Documents
That Are Attached to the Products From Website""",
'description': 'This Module allows customer to download documents '
'that are attached to the products from website',
'category': 'Website',
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'website': "http://www.cybrosys.com",
'depends': ['document', 'website_sale'],
'data': ['views/template.xml'],
'images': ['static/description/banner.jpg'],
'license': 'LGPL-3',
'demo': [],
'installable': True,
'auto_install': False,
'application': False,
}

6
website_product_attachments/controllers/main.py

@ -62,7 +62,7 @@ class WebsiteSale(WebsiteSale):
}
return request.render("website_sale.product", values)
@http.route(['/attachment/download',], type='http', auth='public')
@http.route(['/attachment/download'], type='http', auth='public')
def download_attachment(self, attachment_id):
# Check if this is a valid attachment id
attachment = request.env['ir.attachment'].sudo().search_read(
@ -73,7 +73,7 @@ class WebsiteSale(WebsiteSale):
if attachment:
attachment = attachment[0]
else:
return redirect('/shop/payment')
return redirect('/shop')
if attachment["type"] == "url":
if attachment["url"]:
@ -84,4 +84,4 @@ class WebsiteSale(WebsiteSale):
data = StringIO(base64.standard_b64decode(attachment["datas"]))
return http.send_file(data, filename=attachment['name'], as_attachment=True)
else:
return request.not_found()
return request.not_found()

87
website_product_attachments/controllers/main.py~

@ -0,0 +1,87 @@
# -*- coding: utf-8 -*-
import base64
from cStringIO import StringIO
from werkzeug.utils import redirect
from odoo import http, tools, _
from odoo.http import request
from odoo.addons.website.controllers.main import QueryURL
from odoo.addons.website_sale.controllers.main import WebsiteSale
class WebsiteSale(WebsiteSale):
@http.route(['/shop/product/<model("product.template"):product>'], type='http', auth="public", website=True)
def product(self, product, category='', search='', **kwargs):
product_context = dict(request.env.context, active_id=product.id)
ProductCategory = request.env['product.public.category']
Rating = request.env['rating.rating']
if category:
category = ProductCategory.browse(int(category)).exists()
attrib_list = request.httprequest.args.getlist('attrib')
attrib_values = [map(int, v.split("-")) for v in attrib_list if v]
attrib_set = set([v[1] for v in attrib_values])
keep = QueryURL('/shop', category=category and category.id, search=search, attrib=attrib_list)
categs = ProductCategory.search([('parent_id', '=', False)])
pricelist = request.website.get_current_pricelist()
from_currency = request.env.user.company_id.currency_id
to_currency = pricelist.currency_id
compute_currency = lambda price: from_currency.compute(price, to_currency)
# get the rating attached to a mail.message, and the rating stats of the product
ratings = Rating.search([('message_id', 'in', product.website_message_ids.ids)])
rating_message_values = dict([(record.message_id.id, record.rating) for record in ratings])
rating_product = product.rating_get_stats([('website_published', '=', True)])
if not product_context.get('pricelist'):
product_context['pricelist'] = pricelist.id
product = product.with_context(product_context)
attachments = request.env['ir.attachment'].search(
[('res_model', '=', 'product.template'),
('res_id', '=', product.id)], order='id')
values = {
'search': search,
'category': category,
'pricelist': pricelist,
'attrib_values': attrib_values,
'compute_currency': compute_currency,
'attrib_set': attrib_set,
'keep': keep,
'categories': categs,
'main_object': product,
'product': product,
'get_attribute_value_ids': self.get_attribute_value_ids,
'rating_message_values': rating_message_values,
'rating_product': rating_product,
'attachments': attachments
}
return request.render("website_sale.product", values)
@http.route(['/attachment/download',], type='http', auth='public')
def download_attachment(self, attachment_id):
# Check if this is a valid attachment id
attachment = request.env['ir.attachment'].sudo().search_read(
[('id', '=', int(attachment_id))],
["name", "datas", "file_type", "res_model", "res_id", "type", "url"]
)
if attachment:
attachment = attachment[0]
else:
return redirect('/shop/payment')
if attachment["type"] == "url":
if attachment["url"]:
return redirect(attachment["url"])
else:
return request.not_found()
elif attachment["datas"]:
data = StringIO(base64.standard_b64decode(attachment["datas"]))
return http.send_file(data, filename=attachment['name'], as_attachment=True)
else:
return request.not_found()
Loading…
Cancel
Save