diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/digest/controllers | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/digest/controllers')
| -rw-r--r-- | addons/digest/controllers/__init__.py | 4 | ||||
| -rw-r--r-- | addons/digest/controllers/portal.py | 36 |
2 files changed, 40 insertions, 0 deletions
diff --git a/addons/digest/controllers/__init__.py b/addons/digest/controllers/__init__.py new file mode 100644 index 00000000..903b755e --- /dev/null +++ b/addons/digest/controllers/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import portal diff --git a/addons/digest/controllers/portal.py b/addons/digest/controllers/portal.py new file mode 100644 index 00000000..451956a7 --- /dev/null +++ b/addons/digest/controllers/portal.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from werkzeug.exceptions import Forbidden +from werkzeug.urls import url_encode + +from odoo import _ +from odoo.http import Controller, request, route + + +class DigestController(Controller): + + @route('/digest/<int:digest_id>/unsubscribe', type='http', website=True, auth='user') + def digest_unsubscribe(self, digest_id): + digest = request.env['digest.digest'].browse(digest_id).exists() + digest.action_unsubcribe() + return request.render('digest.portal_digest_unsubscribed', { + 'digest': digest, + }) + + @route('/digest/<int:digest_id>/set_periodicity', type='http', website=True, auth='user') + def digest_set_periodicity(self, digest_id, periodicity='weekly'): + if not request.env.user.has_group('base.group_erp_manager'): + raise Forbidden() + if periodicity not in ('daily', 'weekly', 'monthly', 'quarterly'): + raise ValueError(_('Invalid periodicity set on digest')) + + digest = request.env['digest.digest'].browse(digest_id).exists() + digest.action_set_periodicity(periodicity) + + url_params = { + 'model': digest._name, + 'id': digest.id, + 'active_id': digest.id, + } + return request.redirect('/web?#%s' % url_encode(url_params)) |
