[FIX] website_forum: when sending emails about forum post, use the public url instead of the private
This commit is contained in:
parent
96128a678e
commit
4c822b1a3b
|
@ -149,19 +149,9 @@ class mail_mail(osv.Model):
|
|||
link to action_mail_redirect action that will redirect to doc or Inbox """
|
||||
if partner and partner.user_ids:
|
||||
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
|
||||
# the parameters to encode for the query and fragment part of url
|
||||
query = {'db': cr.dbname}
|
||||
fragment = {
|
||||
'login': partner.user_ids[0].login,
|
||||
'action': 'mail.action_mail_redirect',
|
||||
}
|
||||
if mail.notification:
|
||||
fragment['message_id'] = mail.mail_message_id.id
|
||||
elif mail.model and mail.res_id:
|
||||
fragment.update(model=mail.model, res_id=mail.res_id)
|
||||
|
||||
url = urljoin(base_url, "/web?%s#%s" % (urlencode(query), urlencode(fragment)))
|
||||
return _("""<span class='oe_mail_footer_access'><small>Access your messages and documents <a style='color:inherit' href="%s">in OpenERP</a></small></span>""") % url
|
||||
mail_model = mail.model or 'mail.thread'
|
||||
url = urljoin(base_url, self.pool[mail_model]._get_access_link(cr, uid, mail, partner, context=context))
|
||||
return _("""<span class='oe_mail_footer_access'><small>Access your messages and documents <a style='color:inherit' href="%s">in Odoo</a></small></span>""") % url
|
||||
else:
|
||||
return None
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import socket
|
|||
import time
|
||||
import xmlrpclib
|
||||
from email.message import Message
|
||||
from urllib import urlencode
|
||||
|
||||
from openerp import tools
|
||||
from openerp import SUPERUSER_ID
|
||||
|
@ -641,6 +642,20 @@ class mail_thread(osv.AbstractModel):
|
|||
})
|
||||
return action
|
||||
|
||||
def _get_access_link(self, cr, uid, mail, partner, context=None):
|
||||
# the parameters to encode for the query and fragment part of url
|
||||
query = {'db': cr.dbname}
|
||||
fragment = {
|
||||
'login': partner.user_ids[0].login,
|
||||
'action': 'mail.action_mail_redirect',
|
||||
}
|
||||
if mail.notification:
|
||||
fragment['message_id'] = mail.mail_message_id.id
|
||||
elif mail.model and mail.res_id:
|
||||
fragment.update(model=mail.model, res_id=mail.res_id)
|
||||
|
||||
return "/web?%s#%s" % (urlencode(query), urlencode(fragment))
|
||||
|
||||
#------------------------------------------------------
|
||||
# Email specific
|
||||
#------------------------------------------------------
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import openerp
|
||||
from urlparse import urljoin
|
||||
|
||||
import openerp
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.addons.website.models.website import slug
|
||||
from openerp.osv import osv, fields
|
||||
|
@ -272,6 +273,11 @@ class Post(osv.Model):
|
|||
cr.execute("""UPDATE forum_post SET views = views+1 WHERE id IN %s""", (tuple(ids),))
|
||||
return True
|
||||
|
||||
def _get_access_link(self, cr, uid, mail, partner, context=None):
|
||||
post = self.pool['forum.post'].browse(cr, uid, mail.res_id, context=context)
|
||||
res_id = post.parent_id and "%s#answer-%s" % (post.parent_id.id, post.id) or post.id
|
||||
return "/forum/%s/question/%s" % (post.forum_id.id, res_id)
|
||||
|
||||
|
||||
class PostReason(osv.Model):
|
||||
_name = "forum.post.reason"
|
||||
|
|
Loading…
Reference in New Issue