[IMP] improved code.

bzr revid: tpa@tinyerp.com-20140401115727-scumxfkue2cyqa3f
This commit is contained in:
Turkesh Patel (Open ERP) 2014-04-01 17:27:27 +05:30
parent c4b54541b4
commit c3610687fc
4 changed files with 24 additions and 24 deletions

View File

@ -604,16 +604,12 @@ class website_forum(http.Controller):
@http.route('/forum/<model("website.forum"):forum>/save/profile/', type='http', auth="user", multilang=True, website=True)
def save_edited_profile(self, forum, **post):
cr, uid, context = request.cr, request.uid, request.context
User = request.registry['res.users']
User.write(cr, SUPERUSER_ID, [int(post.get('user_id'))], {
user = request.registry['res.users'].browse(cr, uid, int(post.get('user_id')),context=context)
request.registry['res.partner'].write( cr, uid, [user.partner_id.id], {
'name': post.get('name'),
}, context=context)
record_id = User.browse(cr, uid, int(post.get('user_id')),context=context).partner_id.id
request.registry['res.partner'].write( cr, uid, [record_id], {
'website': post.get('website'),
'city': post.get('city'),
'country_id':post.get('country'),
'birthdate':post.get('dob'),
'country_id': post.get('country'),
'website_description': post.get('description'),
}, context=context)
return werkzeug.utils.redirect("/forum/%s/user/%s" % (slug(forum),post.get('user_id')))

View File

@ -1,11 +1,10 @@
-
Admin User Edit a Question asked by demo user to improve typo
-
!python {model: website.forum.post}: |
self.write(cr, ref('base.user_root'), [ref('website_forum.question_5')],{
'name': 'CMS Replacement For ERP and ECommerce ?',
})
#-
# Admin User Edit a Question asked by demo user to improve typo
#-
# !python {model: website.forum.post}: |
# self.write(cr, ref('base.user_root'), [ref('website_forum.question_5')],{
# 'name': 'CMS Replacement For ERP and ECommerce ?',
# })
-
Make mail notifications as read for assigned badges.
-

View File

@ -236,20 +236,25 @@ class Post(osv.Model):
super(Post, self).write(cr, uid, ids, vals, context=context)
#NOTE: to avoid message post on write of last comment time
if not vals.get('message_last_post'):
user = self.pool['res.users'].browse(cr, uid ,uid, context=context)
self.create_history(cr, uid, ids, context=context)
for post in self.browse(cr, uid, ids, context=context):
#just for precaution
if user.karma < 300 and post.user_id != uid:
raise osv.except_osv(_('Error!'), _('You are not allowed to edit this post!'))
body, subtype = "Edited question", "website_forum.mt_question_edit"
if post.parent_id:
body, subtype = "Edited answer", "website_forum.mt_answer_edit"
self.message_post(cr, uid, [post.id], body=_(body), subtype=subtype, context=context)
#update karma of related user when any answer accepted.
for post in self.browse(cr, uid, ids, context=context):
value = 0
if vals.get('correct'):
value = 15
elif vals.get('correct') == False:
value = -15
self.pool['res.users'].write(cr, SUPERUSER_ID, [post.user_id.id], {'karma': value}, context=context)
#update karma of related user when any answer accepted.
value = 0
if vals.get('correct'):
value = 15
elif vals.get('correct') == False:
value = -15
self.pool['res.users'].write(cr, SUPERUSER_ID, [post.user_id.id], {'karma': value}, context=context)
return True
class PostStatistics(osv.Model):

View File

@ -2,7 +2,7 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_website_forum,website.forum,model_website_forum,,1,0,0,0
access_website_forum_post,website.forum.post,model_website_forum_post,,1,1,1,0
access_website_forum_post_history,website.forum.post.history,model_website_forum_post_history,,1,1,1,0
access_website_forum_post_history,website.forum.post.history,model_website_forum_post_history,,1,0,1,0
access_website_forum_post_vote,website.forum.post.vote,model_website_forum_post_vote,,1,1,1,0
access_website_forum_post_reason,website.forum.post.reason,model_website_forum_post_reason,,1,0,0,0
access_website_forum_post_statistics,website.forum.post.statistics,model_website_forum_post_statistics,,1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_website_forum website.forum model_website_forum 1 0 0 0
3 access_website_forum_post website.forum.post model_website_forum_post 1 1 1 0
4 access_website_forum_post_history website.forum.post.history model_website_forum_post_history 1 1 0 1 0
5 access_website_forum_post_vote website.forum.post.vote model_website_forum_post_vote 1 1 1 0
6 access_website_forum_post_reason website.forum.post.reason model_website_forum_post_reason 1 0 0 0
7 access_website_forum_post_statistics website.forum.post.statistics model_website_forum_post_statistics 1 0 0 0
8 access_website_forum_tag website.forum.tag model_website_forum_tag 1 0 1 0