summaryrefslogtreecommitdiff
path: root/addons/website_mail/controllers/main.py
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@openerp.com>2013-07-29 10:49:15 +0200
committerChristophe Matthieu <chm@openerp.com>2013-07-29 10:49:15 +0200
commit0d168ea3f49202568f466c951f7a5a5a3ea52ee7 (patch)
treec4e962aacf26657362e13d4539799266b76f8d1d /addons/website_mail/controllers/main.py
parentb21b10d1f39152d0feebb0723f750c3283e36fde (diff)
[IMP] website_mail: post with login
bzr revid: chm@openerp.com-20130729084915-yy713hv4e9r60ap4
Diffstat (limited to 'addons/website_mail/controllers/main.py')
-rw-r--r--addons/website_mail/controllers/main.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/addons/website_mail/controllers/main.py b/addons/website_mail/controllers/main.py
index 806fda76b03..f1d906f1204 100644
--- a/addons/website_mail/controllers/main.py
+++ b/addons/website_mail/controllers/main.py
@@ -25,8 +25,6 @@ class website_mail(website):
else:
values['blog_id'] = message_obj.browse(cr, uid, blog_id)
- print values
-
html = self.render(cr, uid, "website_mail.index", values)
return html
@@ -42,23 +40,23 @@ class website_mail(website):
return blog.website_published and "1" or "0"
@website.route(['/blog/<int:mail_group_id>/<int:blog_id>/post'], type='http', auth="admin")
- def message_post(self, cr, uid, mail_group_id=None, blog_id=None, **post):
- if post.get('body') and post.get('name') and post.get('email') and post.get('email').index('@') > 0:
- if self.isloggued():
- author_id = request.registry['res.users'].browse(cr, uid, uid).partner_id.id
- else:
- partner_obj = request.registry['res.partner']
- partner_ids = partner_obj.search(cr, uid, [('name', '=', post.get('name')), ('email', '=', post.get('email'))])
- if partner_ids:
- author_id = partner_ids[0]
- else:
- author_id = partner_obj.create(cr, openerp.SUPERUSER_ID, {'name': post.get('name'), 'email': post.get('email')})
-
+ def blog_post(self, cr, uid, mail_group_id=None, blog_id=None, **post):
+ url = request.httprequest.host_url
+ if post.get('body'):
+ request.session.body = post.get('body')
+ if not self.isloggued():
+ return '%s/admin#action=redirect&url=%s/blog/%s/%s/post' % (url, url, mail_group_id, blog_id)
+
+ if 'body' in request.session and request.session.body:
request.registry['mail.group'].message_post(cr, uid, mail_group_id,
- body=post.get('body'),
+ body=request.session.body,
parent_id=blog_id,
- author_id=author_id,
- website_published= blog_id and True or False
+ website_published=blog_id and True or False,
+ context={'mail_create_nosubscribe': True},
)
+ request.session.body = False
- return werkzeug.utils.redirect("/blog/%s/%s" % (mail_group_id, blog_id))
+ if post.get('body'):
+ return '%s/blog/%s/%s' % (url, mail_group_id, blog_id)
+ else:
+ return werkzeug.utils.redirect("/blog/%s/%s" % (mail_group_id, blog_id))