[IMP] website_forum: added management and support of private profile (unpublished partners).
This commit is contained in:
parent
74168c4e9d
commit
a3cfed1809
|
@ -444,10 +444,10 @@ class WebsiteForum(http.Controller):
|
|||
User = request.registry['res.users']
|
||||
|
||||
step = 30
|
||||
tag_count = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], count=True, context=context)
|
||||
tag_count = User.search(cr, SUPERUSER_ID, [('karma', '>', 1), ('website_published', '=', True)], count=True, context=context)
|
||||
pager = request.website.pager(url="/forum/%s/users" % slug(forum), total=tag_count, page=page, step=step, scope=30)
|
||||
|
||||
obj_ids = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], limit=step, offset=pager['offset'], order='karma DESC', context=context)
|
||||
obj_ids = User.search(cr, SUPERUSER_ID, [('karma', '>', 1), ('website_published', '=', True)], limit=step, offset=pager['offset'], order='karma DESC', context=context)
|
||||
# put the users in block of 3 to display them as a table
|
||||
users = [[] for i in range(len(obj_ids)/3+1)]
|
||||
for index, user in enumerate(User.browse(cr, SUPERUSER_ID, obj_ids, context=context)):
|
||||
|
@ -496,9 +496,9 @@ class WebsiteForum(http.Controller):
|
|||
Data = request.registry["ir.model.data"]
|
||||
|
||||
user = User.browse(cr, SUPERUSER_ID, user_id, context=context)
|
||||
if not user.exists() or (user_id != request.session.uid and user.karma < 1):
|
||||
return werkzeug.utils.redirect("/forum/%s" % slug(forum))
|
||||
|
||||
values = self._prepare_forum_values(forum=forum, **post)
|
||||
if not user.exists() or (user_id != request.session.uid and (not user.website_published or user.karma < 1)):
|
||||
return request.website.render("website_forum.private_profile", values)
|
||||
# questions and answers by user
|
||||
user_questions, user_answers = [], []
|
||||
user_post_ids = Post.search(
|
||||
|
@ -549,13 +549,11 @@ class WebsiteForum(http.Controller):
|
|||
|
||||
post['users'] = 'True'
|
||||
|
||||
values = self._prepare_forum_values(**post)
|
||||
values.update({
|
||||
'uid': uid,
|
||||
'user': user,
|
||||
'main_object': user,
|
||||
'searches': post,
|
||||
'forum': forum,
|
||||
'questions': user_questions,
|
||||
'answers': user_answers,
|
||||
'followed': followed,
|
||||
|
|
|
@ -9,7 +9,7 @@ class Users(osv.Model):
|
|||
init_res = super(Users, self).__init__(pool, cr)
|
||||
self.SELF_WRITEABLE_FIELDS = list(set(
|
||||
self.SELF_WRITEABLE_FIELDS + \
|
||||
['country_id', 'city', 'website', 'website_description']))
|
||||
['country_id', 'city', 'website', 'website_description', 'website_published']))
|
||||
return init_res
|
||||
|
||||
def _get_user_badge_level(self, cr, uid, ids, name, args, context=None):
|
||||
|
|
|
@ -11,6 +11,24 @@
|
|||
<field name="signature" position="after">
|
||||
<field name="karma" string="Forum Karma"/>
|
||||
</field>
|
||||
<xpath expr="//div[contains(@class, 'oe_right oe_button_box')]" position="inside">
|
||||
<br/>
|
||||
<field name="website_published" class="pull-right" widget="website_button"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Update user prefrence form!-->
|
||||
<record id="view_users_form_simple_modif_forum" model="ir.ui.view">
|
||||
<field name="name">res.users.preferences.form</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form_simple_modif"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="preferences" position="before">
|
||||
<div style="margin-top: 19px;">
|
||||
<field name="website_published" class="pull-right" widget="website_button"/>
|
||||
</div>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -754,9 +754,23 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<!--Private profile-->
|
||||
<template id="private_profile">
|
||||
<t t-call="website_forum.header">
|
||||
<h1 class="mt32">This profile is private!</h1>
|
||||
<p>
|
||||
<a t-attf-href="/forum/#{slug(forum)}">Return to the question list.</a>
|
||||
</p>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="edit_profile">
|
||||
<t t-call="website_forum.header">
|
||||
<h3>Edit Profile </h3>
|
||||
<h3>Edit Profile
|
||||
<t t-call="website.publish_management">
|
||||
<t t-set="object" t-value="user"/>
|
||||
</t>
|
||||
</h3>
|
||||
<div class="col-md-2">
|
||||
<img class="img img-responsive img-circle" t-attf-src="/forum/user/#{user.id}/avatar"/>
|
||||
</div>
|
||||
|
@ -805,6 +819,9 @@
|
|||
<h1 class="mt0 page-header">
|
||||
<span t-field="user.name"/>
|
||||
<small>profile</small>
|
||||
<t t-call="website.publish_management" groups="base.group_website_publisher">
|
||||
<t t-set="object" t-value="user"/>
|
||||
</t>
|
||||
</h1>
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
|
|
Loading…
Reference in New Issue