diff --git a/website_event_attachements/__init__.py b/website_event_attachements/__init__.py new file mode 100644 index 000000000..c654aef30 --- /dev/null +++ b/website_event_attachements/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Fasluca() +# 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 . +# +############################################################################## +import controllers diff --git a/website_event_attachements/__manifest__.py b/website_event_attachements/__manifest__.py new file mode 100644 index 000000000..96a81ae57 --- /dev/null +++ b/website_event_attachements/__manifest__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Fasluca() +# 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 . +# +############################################################################## +{ + '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, +} diff --git a/website_event_attachements/controllers/__init__.py b/website_event_attachements/controllers/__init__.py new file mode 100644 index 000000000..e68b6b884 --- /dev/null +++ b/website_event_attachements/controllers/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Fasluca() +# 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 . +# +############################################################################## +import main diff --git a/website_event_attachements/controllers/main.py b/website_event_attachements/controllers/main.py new file mode 100644 index 000000000..261de6ac8 --- /dev/null +++ b/website_event_attachements/controllers/main.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Fasluca() +# 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 . +# +############################################################################## + +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//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() \ No newline at end of file diff --git a/website_event_attachements/static/description/banner.jpg b/website_event_attachements/static/description/banner.jpg new file mode 100644 index 000000000..ee5741855 Binary files /dev/null and b/website_event_attachements/static/description/banner.jpg differ diff --git a/website_event_attachements/static/description/cybro_logo.png b/website_event_attachements/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/website_event_attachements/static/description/cybro_logo.png differ diff --git a/website_event_attachements/static/description/event.png b/website_event_attachements/static/description/event.png new file mode 100644 index 000000000..831f76ce5 Binary files /dev/null and b/website_event_attachements/static/description/event.png differ diff --git a/website_event_attachements/static/description/icon.png b/website_event_attachements/static/description/icon.png new file mode 100644 index 000000000..12a4896e4 Binary files /dev/null and b/website_event_attachements/static/description/icon.png differ diff --git a/website_event_attachements/static/description/index.html b/website_event_attachements/static/description/index.html new file mode 100644 index 000000000..9dc24e623 --- /dev/null +++ b/website_event_attachements/static/description/index.html @@ -0,0 +1,62 @@ +
+
+

Event Attachments on Website

+ This Module allows customer to download documents that are attached to the events from website. +

Author : Cybrosys Techno Solutions , www.cybrosys.com

+
+
+ +
+
+

Attach your documents

+
+
+ +
+ ☛ Attach your documents like, brochures on event. +
+
+
+
+ +
+
+

Download from Website

+
+
+ +
+ ☛ Visitors of your Website can download these attachments +
+
+
+
+ +
+

Need Any Help?

+ +
+ + + diff --git a/website_event_attachements/static/description/website.png b/website_event_attachements/static/description/website.png new file mode 100644 index 000000000..1fc122a08 Binary files /dev/null and b/website_event_attachements/static/description/website.png differ diff --git a/website_event_attachements/views/template.xml b/website_event_attachements/views/template.xml new file mode 100644 index 000000000..17be479fb --- /dev/null +++ b/website_event_attachements/views/template.xml @@ -0,0 +1,23 @@ + + + + \ No newline at end of file