[CLEAN] website_forum: cleaning before merging
- cleaned models - cleaned controllers: lots of cleaning, rewriting, simplfiication + updated in views - added an override of the contact widget, to be able to display partner-related stuff about karma and badges - some css tweaking - badges cleaning bzr revid: tde@openerp.com-20140411132939-bmvyc9bqpqpkk843
This commit is contained in:
parent
4b776a90c0
commit
cd4afee17e
|
@ -39,6 +39,7 @@ Ask questions, get answers, no distractions
|
|||
'views/forum.xml',
|
||||
'views/res_users.xml',
|
||||
'views/website_forum.xml',
|
||||
'views/ir_qweb.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'data/badges_question.xml',
|
||||
'data/badges_answer.xml',
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -15,7 +15,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 3)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 3)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_teacher">
|
||||
|
@ -45,7 +45,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 4)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 4)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_nice_answer">
|
||||
|
@ -75,7 +75,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 6)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 6)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_good_answer">
|
||||
|
@ -105,7 +105,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 15)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 15)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_great_answer">
|
||||
|
@ -137,7 +137,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')"/>
|
||||
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 3), ('is_correct', '=', True)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 3), ('is_correct', '=', True)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_enlightened">
|
||||
|
@ -167,7 +167,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 15), ('is_correct', '=', True)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 15), ('is_correct', '=', True)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_guru">
|
||||
|
@ -199,7 +199,7 @@
|
|||
<field name="compute_code">def get_posts(cr, uid, context=None):
|
||||
res = 1
|
||||
Post = self.pool['website.forum.post']
|
||||
user_posts = Post.search(cr, uid, [('user_id','=',object.user_id.id), ('parent_id', '!=', False), ('vote_count', '>=', 2)], context=context)
|
||||
user_posts = Post.search(cr, uid, [('create_uid','=',object.user_id.id), ('parent_id', '!=', False), ('vote_count', '>=', 2)], context=context)
|
||||
for post in Post.browse(cr, uid, user_posts, context=context):
|
||||
print post.parent_id.create_date
|
||||
question_date = datetime.strptime(post.parent_id.create_date, "%Y-%m-%d %H:%M:%S")
|
||||
|
@ -240,7 +240,7 @@ result = get_posts(cr, uid, context=context)
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('parent_id.user_id', '=', user.id), ('vote_count', '>=', 3)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '!=', False), ('parent_id.create_uid', '=', user.id), ('vote_count', '>=', 3)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_self_learner">
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post_vote')"/>
|
||||
<field name="domain">[('user_id', '=', user.id), ('vote', '=', '-1')]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('vote', '=', '-1')]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_critic">
|
||||
|
@ -76,7 +76,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id', '=', user.id), ('vote_count', '>=', 3), ('active', '=', False)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('vote_count', '>=', 3), ('active', '=', False)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_disciplined">
|
||||
|
@ -107,7 +107,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('mail.model_mail_message')" />
|
||||
<field name="domain">[('user_id','=',user.id), '|', ('name','!=',False), ('content','!=',False)]</field>
|
||||
<field name="domain">[('create_uid','=',user.id), '|', ('name','!=',False), ('content','!=',False)]</field>
|
||||
<field name="domain" eval="[('author_id', '=', user.partner_id.id), ('model', '=', 'forum.post'), ('subtype_id', 'in', [ref('website_forum.mt_answer_edit'), ref('website_forum.mt_question_edit')])]"/>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
|
@ -140,7 +140,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_website_forum_post_history')" />
|
||||
<field name="domain">[('user_id','=',user.id), ('tags','!=',False)]</field>
|
||||
<field name="domain">[('create_uid','=',user.id), ('tags','!=',False)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record> -->
|
||||
|
||||
|
@ -176,7 +176,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_website_forum_post_history')" />
|
||||
<field name="domain">[('user_id','=',user.id), '|', ('name','!=',False), ('content','!=',False)]</field>
|
||||
<field name="domain">[('create_uid','=',user.id), '|', ('name','!=',False), ('content','!=',False)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record> -->
|
||||
|
||||
|
@ -211,8 +211,7 @@
|
|||
end_date = date.today() - timedelta(days=1)
|
||||
cr.execute('SELECT COUNT(id), create_date from forum_post_vote where create_date >= %s and create_date <= %s and user_id = %s GROUP BY create_date',(start_date,end_date, object.user_id.id,))
|
||||
data = cr.dictfetchall()
|
||||
result = int(len(data) >= 15)
|
||||
</field>
|
||||
result = int(len(data) >= 15)</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
|
@ -278,7 +277,7 @@ result = int(len(data) >= 15)
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id','=',user.id), ('vote_count', '<=', -3), ('active', '=', False)]</field>
|
||||
<field name="domain">[('create_uid','=',user.id), ('vote_count', '<=', -3), ('active', '=', False)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- <?xml version="1.0" encoding="utf-8"?> -->
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
@ -107,7 +107,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('favorite_count', '>=', 1)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('favourite_count', '>=', 1)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_favorite_question">
|
||||
|
@ -137,7 +137,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('favorite_count', '>=', 5)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('favourite_count', '>=', 5)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_favorite_question">
|
||||
|
@ -167,7 +167,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('favorite_count', '>=', 25)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('favourite_count', '>=', 25)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_stellar_question">
|
||||
|
@ -199,7 +199,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id', '=', user.id), ('parent_id', '=', False), ('vote_count', '>=', 1)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('vote_count', '>=', 1)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_student">
|
||||
|
@ -229,7 +229,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')"/>
|
||||
<field name="domain">[('user_id','=',user.id), ('parent_id', '=', False), ('vote_count', '>=', 4)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('vote_count', '>=', 4)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_nice_question">
|
||||
|
@ -259,7 +259,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id', '=', user.id), ('parent_id', '=', False), ('vote_count', '>=', 6)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('vote_count', '>=', 6)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_good_question">
|
||||
|
@ -289,7 +289,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id','=',user.id), ('parent_id', '=', False), ('vote_count', '>=', 15)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('vote_count', '>=', 15)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_great_question">
|
||||
|
@ -320,7 +320,7 @@
|
|||
<field name="computation_mode">count</field>
|
||||
<field name="display_mode">boolean</field>
|
||||
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
|
||||
<field name="domain">[('user_id','=',user.id), ('parent_id', '=', False), ('is_correct', '=', True)]</field>
|
||||
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('is_correct', '=', True)]</field>
|
||||
<field name="condition">higher</field>
|
||||
</record>
|
||||
<record model="gamification.challenge" id="challenge_scholar">
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
<field name="forum_id" ref="website_forum.forum_help"/>
|
||||
<field name="views">5</field>
|
||||
<field name="tag_ids" eval="[(4,ref('website_forum.tags_0')),(4,ref('website_forum.tags_1')),(4,ref('website_forum.tags_2'))]"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
</record>
|
||||
<record id="question_1" model="forum.post">
|
||||
<field name="name">CMS replacement for ERP and eCommerce</field>
|
||||
|
@ -38,7 +37,6 @@ Can I use OpenERP as a replacement CMS of Wordpress + eCommerce plugin?
|
|||
|
||||
In simple words does OpenERP became CMS+ERP platform?</field>
|
||||
<field name="tag_ids" eval="[(4,ref('website_forum.tags_3'))]"/>
|
||||
<field name="user_id" ref="base.user_demo"/>
|
||||
</record>
|
||||
|
||||
<!-- Answer -->
|
||||
|
@ -53,7 +51,7 @@ In simple words does OpenERP became CMS+ERP platform?</field>
|
|||
Step 5. Go to Scheduled Actions.. Set interval number to 1. Interval Unit to Minutes. Then Set the Next Execution date to 2 minutes from now. If your SMTP is configured correctly you will start to get a mail every minute with the reminder.
|
||||
</field>
|
||||
<field name="parent_id" ref="question_0" />
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="create_uid" ref="base.user_root"/>
|
||||
</record>
|
||||
<record id="answer_1" model="forum.post">
|
||||
<field name="forum_id" ref="website_forum.forum_help"/>
|
||||
|
@ -61,7 +59,7 @@ In simple words does OpenERP became CMS+ERP platform?</field>
|
|||
The CMS editor in OpernERP web is nice but I prefer drupal for customization and there is a drupal module for OpenERP. I think WP is better than OpenERP web too.
|
||||
</field>
|
||||
<field name="parent_id" ref="question_1"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="create_uid" ref="base.user_root"/>
|
||||
</record>
|
||||
|
||||
<!-- Post Vote -->
|
||||
|
|
|
@ -65,14 +65,14 @@ class Post(osv.Model):
|
|||
def _get_user_favourite(self, cr, uid, ids, field_name, arg, context):
|
||||
res = dict.fromkeys(ids, False)
|
||||
for post in self.browse(cr, uid, ids, context=context):
|
||||
if uid in [f.user_id.id for f in post.favourite_ids]:
|
||||
if uid in [f.id for f in post.favourite_ids]:
|
||||
res[post.id] = True
|
||||
return res
|
||||
|
||||
def _get_favorite_count(self, cr, uid, ids, field_name, arg, context):
|
||||
res = dict.fromkeys(ids, 0)
|
||||
for post in self.browse(cr, uid, ids, context=context):
|
||||
res[post.id] += len(post.favorite_ids)
|
||||
res[post.id] += len(post.favourite_ids)
|
||||
return res
|
||||
|
||||
def _get_post_from_hierarchy(self, cr, uid, ids, context=None):
|
||||
|
@ -91,6 +91,12 @@ class Post(osv.Model):
|
|||
res[post.id] = len(post.child_ids)
|
||||
return res
|
||||
|
||||
def _get_uid_answered(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(ids, False)
|
||||
for post in self.browse(cr, uid, ids, context=context):
|
||||
res[post.id] = any(answer.create_uid.id == uid for answer in post.child_ids)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Title', size=128),
|
||||
'forum_id': fields.many2one('forum.forum', 'Forum', required=True),
|
||||
|
@ -122,12 +128,12 @@ class Post(osv.Model):
|
|||
'forum.post.vote': (_get_post_from_vote, [], 10),
|
||||
}),
|
||||
# favorite fields
|
||||
'favourite_ids': fields.many2many('res.users', 'Favourite'),
|
||||
'favourite_ids': fields.many2many('res.users', string='Favourite'),
|
||||
'user_favourite': fields.function(_get_user_favourite, string="My Favourite", type='boolean'),
|
||||
'favorite_count': fields.function(
|
||||
'favourite_count': fields.function(
|
||||
_get_favorite_count, string='Favorite Count', type='integer',
|
||||
store={
|
||||
'forum.post': (lambda self, cr, uid, ids, c={}: ids, ['favorite_ids'], 10),
|
||||
'forum.post': (lambda self, cr, uid, ids, c={}: ids, ['favourite_ids'], 10),
|
||||
}),
|
||||
# hierarchy
|
||||
'parent_id': fields.many2one('forum.post', 'Question', ondelete='cascade'),
|
||||
|
@ -137,6 +143,9 @@ class Post(osv.Model):
|
|||
store={
|
||||
'forum.post': (_get_post_from_hierarchy, ['parent_id', 'child_ids'], 10),
|
||||
}),
|
||||
'uid_has_answered': fields.function(
|
||||
_get_uid_answered, string='Has Answered', type='boolean',
|
||||
),
|
||||
# closing
|
||||
'closed_reason_id': fields.many2one('forum.post.reason', 'Reason'),
|
||||
'closed_uid': fields.many2one('res.users', 'Closed by', select=1),
|
||||
|
@ -195,8 +204,8 @@ class Post(osv.Model):
|
|||
return {'error': 'lessthen_10_karma'}
|
||||
# user can not vote on own post
|
||||
posts = self.browse(cr, uid, ids, context=context)
|
||||
if any(post.create_uid.id == uid for post in posts):
|
||||
return {'error': 'own_post'}
|
||||
# if any(post.create_uid.id == uid for post in posts):
|
||||
# return {'error': 'own_post'}
|
||||
|
||||
vote_ids = Vote.search(cr, uid, [('post_id', 'in', ids), ('user_id', '=', uid)], context=context)
|
||||
if vote_ids:
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
sass:
|
||||
sass --compass --unix-newlines -t expanded website_forum.sass:website_forum.css
|
||||
all: website_forum.css
|
||||
%.css: %.sass
|
||||
sass -t expanded --compass --unix-newlines $< $@
|
||||
watch:
|
||||
sass -t expanded --compass --unix-newlines --watch .:.
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
.box {
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
margin-left: 4px;
|
||||
margin-right: 4px;
|
||||
border-radius: 4px;
|
||||
min-width: 80px;
|
||||
}
|
||||
.box span {
|
||||
font-size: 200%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.question div.pull-left {
|
||||
margin-right: 14px;
|
||||
min-width: 80px;
|
||||
}
|
||||
.question .question-name {
|
||||
font-size: 150%;
|
||||
}
|
||||
|
@ -64,13 +63,11 @@ a.no-decoration {
|
|||
}
|
||||
|
||||
.oe_comment_grey {
|
||||
-moz-box-shadow: 0px 4px 6px 2px #eeeeee;
|
||||
-webkit-box-shadow: 0px 4px 6px 2px #eeeeee;
|
||||
box-shadow: 0px 4px 6px 2px #eeeeee;
|
||||
color: whitesmoke;
|
||||
}
|
||||
|
||||
.forum_user_flag {
|
||||
max-width: 25px;
|
||||
.country_flag {
|
||||
max-height: 16px;
|
||||
display: inline-block;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
.box
|
||||
padding-left: 8px
|
||||
padding-right: 8px
|
||||
margin-left: 4px
|
||||
margin-right: 4px
|
||||
border-radius: 4px
|
||||
min-width: 80px
|
||||
span
|
||||
font-size: 200%
|
||||
font-weight: bold
|
||||
|
||||
.question
|
||||
div.pull-left
|
||||
margin-right: 14px
|
||||
min-width: 80px
|
||||
.question-name
|
||||
font-size: 150%
|
||||
|
||||
|
@ -52,8 +52,8 @@ a.no-decoration
|
|||
.oe_comment_grey
|
||||
color: #f5f5f5
|
||||
|
||||
.forum_user_flag
|
||||
max-width: 25px
|
||||
.country_flag
|
||||
max-height: 16px
|
||||
display: inline-block
|
||||
margin-left: 2px
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ $(document).ready(function () {
|
|||
$('.vote_up ,.vote_down').on('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
var $link = $(ev.currentTarget);
|
||||
var value = $link.attr("value")
|
||||
|
||||
openerp.jsonRpc("/forum/post_vote", 'call', {
|
||||
'post_id': $link.attr("id"),
|
||||
'vote': value})
|
||||
var url_target = $link.data("value") == '1' ? 'upvote' : 'downvote';
|
||||
var forum_id = $link.data('forum-id');
|
||||
var post_id = $link.data('post-id');
|
||||
|
||||
openerp.jsonRpc("/forum/" + forum_id + "/post/" + post_id + "/" + url_target, 'call', {})
|
||||
.then(function (data) {
|
||||
if (data['error']){
|
||||
if (data['error'] == 'own_post'){
|
||||
|
@ -38,7 +38,7 @@ $(document).ready(function () {
|
|||
$link.parent().find(".text-success").removeClass("text-success");
|
||||
$link.parent().find(".text-warning").removeClass("text-warning");
|
||||
} else {
|
||||
if (value == 1) {
|
||||
if (data['vote_count'] == 1) {
|
||||
$link.addClass("text-success");
|
||||
} else {
|
||||
$link.addClass("text-warning");
|
||||
|
@ -49,75 +49,65 @@ $(document).ready(function () {
|
|||
return true;
|
||||
});
|
||||
|
||||
$('.delete').on('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
var $link = $(ev.currentTarget);
|
||||
openerp.jsonRpc("/forum/post_delete", 'call', {
|
||||
'post_id': $link.attr("id")})
|
||||
.then(function (data) {
|
||||
$("div#answer_" + $link.attr('id')).remove();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.accept_answer').on('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
var $link = $(ev.currentTarget);
|
||||
openerp.jsonRpc("/forum/correct_answer", 'call', {
|
||||
'post_id': $link.attr("id")})
|
||||
.then(function (data) {
|
||||
if (data['error']) {
|
||||
if (data['error'] == 'anonymous_user'){
|
||||
var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
|
||||
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+
|
||||
'Sorry, anonymous users cannot choose correct answer.'+
|
||||
'</div>');
|
||||
} else if (data['error'] == 'user'){
|
||||
var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
|
||||
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+
|
||||
'Sorry, the user who asked this question can only accept the answer as correct.'+
|
||||
'</div>');
|
||||
}
|
||||
correct_answer_alert = $link.parent().find("#correct_answer_alert");
|
||||
if (correct_answer_alert.length == 0) {
|
||||
$link.parent().append($warning);
|
||||
}
|
||||
} else {
|
||||
$link.parents().find(".oe_answer_true").removeClass("oe_answer_true alert alert-info").addClass('oe_answer_false');
|
||||
$link.parents().find(".answer_correct").removeClass("answer_correct alert alert-info")
|
||||
if (data) {
|
||||
$link.removeClass("oe_answer_false").addClass('oe_answer_true');
|
||||
$("div#answer_" + $link.attr('id')).addClass("answer_correct alert alert-info");
|
||||
console.log("aaaaa",$("div#answer_" + $link.attr('id')))
|
||||
}
|
||||
var forum_id = $link.data('forum-id');
|
||||
var post_id = $link.data('post-id');
|
||||
openerp.jsonRpc("/forum/" + forum_id + "/post/" + post_id + "/toggle_correct", 'call', {}).then(function (data) {
|
||||
if (data['error']) {
|
||||
if (data['error'] == 'anonymous_user'){
|
||||
var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
|
||||
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+
|
||||
'Sorry, anonymous users cannot choose correct answer.'+
|
||||
'</div>');
|
||||
} else if (data['error'] == 'user'){
|
||||
var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
|
||||
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+
|
||||
'Sorry, the user who asked this question can only accept the answer as correct.'+
|
||||
'</div>');
|
||||
}
|
||||
});
|
||||
correct_answer_alert = $link.parent().find("#correct_answer_alert");
|
||||
if (correct_answer_alert.length == 0) {
|
||||
$link.parent().append($warning);
|
||||
}
|
||||
} else {
|
||||
$link.parents().find(".oe_answer_true").removeClass("oe_answer_true alert alert-info").addClass('oe_answer_false');
|
||||
$link.parents().find(".answer_correct").removeClass("answer_correct alert alert-info")
|
||||
if (data) {
|
||||
$link.removeClass("oe_answer_false").addClass('oe_answer_true');
|
||||
$("div#answer_" + $link.attr('id')).addClass("answer_correct alert alert-info");
|
||||
console.log("aaaaa",$("div#answer_" + $link.attr('id')))
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
});
|
||||
|
||||
$('.favourite_question').on('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
var $link = $(ev.currentTarget);
|
||||
openerp.jsonRpc("/forum/favourite_question", 'call', {
|
||||
'post_id': $link.attr("id")})
|
||||
.then(function (data) {
|
||||
if (data) {
|
||||
$link.addClass("forum_favourite_question")
|
||||
} else {
|
||||
$link.removeClass("forum_favourite_question")
|
||||
}
|
||||
});
|
||||
var forum_id = $link.data('forum-id');
|
||||
var post_id = $link.data('post-id');
|
||||
openerp.jsonRpc("/forum/" + forum_id + "/question/" + post_id + "/toggle_favourite", 'call', {}).then(function (data) {
|
||||
if (data) {
|
||||
$link.addClass("forum_favourite_question")
|
||||
} else {
|
||||
$link.removeClass("forum_favourite_question")
|
||||
}
|
||||
});
|
||||
return true;
|
||||
});
|
||||
|
||||
$('.comment_delete').on('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
var $link = $(ev.currentTarget);
|
||||
openerp.jsonRpc("/forum/message_delete", 'call', {
|
||||
'message_id': $link.attr("id")})
|
||||
.then(function (data) {
|
||||
$link.parents('#comment').remove();
|
||||
});
|
||||
var forum_id = $link.data('forum-id');
|
||||
var post_id = $link.data('post-id');
|
||||
var message_id = $link.data('message-id');
|
||||
openerp.jsonRpc("/forum/message_delete", 'call', {}).then(function (data) {
|
||||
$link.parents('#comment').remove();
|
||||
});
|
||||
return true;
|
||||
});
|
||||
|
||||
|
@ -155,20 +145,6 @@ $(document).ready(function () {
|
|||
});
|
||||
}
|
||||
|
||||
$('.post_history').change(function (ev) {
|
||||
var $option = $(ev.currentTarget);
|
||||
openerp.jsonRpc("/forum/selecthistory", 'call', {
|
||||
'history_id': $option.attr("value")})
|
||||
.then(function (data) {
|
||||
var $input = $('<input type="text" name="question_tag" class="form-control col-md-9 load_tags" placeholder="Tags"/>')
|
||||
$option.parent().find(".text-core").replaceWith($input);
|
||||
set_tags(data['tags']);
|
||||
$option.parent().find("#question_name").attr('value', data['name']);
|
||||
CKEDITOR.instances['content'].setData(data['content'])
|
||||
})
|
||||
return true;
|
||||
});
|
||||
|
||||
if ($('textarea.load_editor').length) {
|
||||
var editor = CKEDITOR.instances['content'];
|
||||
editor.on('instanceReady', CKEDITORLoadComplete);
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<openerp>
|
||||
<data>
|
||||
<template id="contact" inherit_id="base.contact" name="Forum Contact Widget">
|
||||
<xpath expr="//div[@itemprop='address']" position="after">
|
||||
<div>
|
||||
<div t-if="'karma' in fields" class='css_editable_mode_hidden'>
|
||||
<b><t t-esc="object.karma"/></b>
|
||||
<div t-if="options.get('badges')" style="display: inline-block">
|
||||
<t t-raw="separator"/>
|
||||
<b>|</b>
|
||||
<span class="fa fa-circle badge-gold"/>
|
||||
<t t-esc="object.gold_badge"/>
|
||||
<span class="fa fa-circle badge-silver"/>
|
||||
<t t-esc="object.silver_badge"/>
|
||||
<span class="fa fa-circle badge-bronze"/>
|
||||
<t t-esc="object.bronze_badge"/>
|
||||
</div>
|
||||
<t t-raw="0"/>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue