[MRG] added template and controller to edit user profile lp:~openerp-dev/openobject-addons/trunk-website-forum-tpa-imp2-ssh
bzr revid: tpa@tinyerp.com-20140314132743-v2fh5a7p8uqcqqjl
This commit is contained in:
commit
1f7c510d7f
|
@ -383,3 +383,33 @@ class website_forum(http.Controller):
|
|||
'correct': correct,
|
||||
}, context=context)
|
||||
return correct
|
||||
|
||||
@http.route('/forum/<model("website.forum"):forum>/edit/profile/<model("res.users"):user>', type='http', auth="user", multilang=True, website=True)
|
||||
def edit_profile(self, forum, user, **kwarg):
|
||||
cr,context = request.cr, request.context
|
||||
country = request.registry['res.country']
|
||||
country_ids = country.search(cr, SUPERUSER_ID, [], context=context)
|
||||
countries = country.browse(cr, SUPERUSER_ID, country_ids, context)
|
||||
values = {
|
||||
'user': user,
|
||||
'forum': forum,
|
||||
'searches': kwarg,
|
||||
'countries': countries,
|
||||
}
|
||||
return request.website.render("website_forum.edit_profile", values)
|
||||
|
||||
@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
|
||||
request.registry['res.users'].write( cr, uid, [int(post.get('user_id'))], {
|
||||
'name': post.get('name'),
|
||||
}, context=context)
|
||||
record_id = request.registry['res.users'].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'),
|
||||
'comment': post.get('comment'),
|
||||
}, context=context)
|
||||
return werkzeug.utils.redirect("/forum/%s/user/%s" % (slug(forum),post.get('user_id')))
|
||||
|
|
|
@ -532,6 +532,50 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<template id="edit_profile">
|
||||
<t t-call="website_forum.header">
|
||||
<h3>Edit Profile </h3>
|
||||
<div class="col-md-2">
|
||||
<span t-field="user.image" t-field-options='{"widget": "image", "class": "img img-responsive img-circle"}'/>
|
||||
</div>
|
||||
<form t-attf-action="/forum/#{ slug(forum) }/save/profile/" method="post" role="form" class="form-horizontal">
|
||||
<input name="user_id" t-att-value="user.id" type="hidden"/>
|
||||
<label class="col-md-2 control-label mb16" for="user.name">Real name</label>
|
||||
<div class="col-md-7 mb16">
|
||||
<input type="text" class="col-md-7 mb16 form-control" name="name" required="True" t-attf-value="#{user.name or ''}"/>
|
||||
</div>
|
||||
<label class="col-md-2 control-label mb16" for="user.partner_id.website">Website</label>
|
||||
<div class="col-md-7 mb16">
|
||||
<input type="text" class="form-control" name="website" t-attf-value="#{user.partner_id.website or ''}"/>
|
||||
</div>
|
||||
<label class="col-md-4 control-label mb16" for="user.partner_id.city">City</label>
|
||||
<div class="col-md-7 mb16">
|
||||
<input type="text" class="form-control" name="city" t-attf-value="#{user.partner_id.city or ''}"/>
|
||||
</div>
|
||||
<label class="col-md-4 control-label mb16" for="contact_name">Country</label>
|
||||
<div class="col-md-7 mb16">
|
||||
<select class="form-control" name="country">
|
||||
<option value="">Country...</option>
|
||||
<t t-foreach="countries or []" t-as="country"><option t-att-value="country.id"><t t-esc="country.name"/></option></t>
|
||||
</select>
|
||||
</div>
|
||||
<label class="col-md-4 control-label mb16" for="user.partner_id.birthdate">Date of birth</label>
|
||||
<div class="col-md-7 mb16">
|
||||
<input type="text" class="form-control" name="dob" t-attf-value="#{user.partner_id.birthdate or ''}"/>
|
||||
</div>
|
||||
<label class="col-md-4 control-label mb16" for="user.partner_id.comment">Profile</label>
|
||||
<div class="col-md-7 mb16">
|
||||
<textarea name="comment" style="min-height: 120px" required="True" value="comment" id="textarea_ckeditor" class="form-control">
|
||||
<t t-esc="user.partner_id.comment"/>
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="col-sm-offset-4 col-md-4 mb16">
|
||||
<button class="btn btn-primary btn-lg">Update</button>
|
||||
</div>
|
||||
</form>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="user_detail_full">
|
||||
<t t-call="website_forum.header">
|
||||
<h1 class="mt0 page-header">
|
||||
|
@ -563,13 +607,13 @@
|
|||
</tr><tr>
|
||||
<td>up votes</td>
|
||||
<td>
|
||||
<span class="glyphicon glyphicon-thumbs-up"/>
|
||||
<span class="fa fa-thumbs-up"/>
|
||||
<span t-esc="up_votes"/>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<td>down votes</td>
|
||||
<td>
|
||||
<span class="glyphicon glyphicon-thumbs-down"/>
|
||||
<span class="fa fa-thumbs-down "/>
|
||||
<span t-esc="down_votes"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -578,7 +622,7 @@
|
|||
<div class="col-sm-10">
|
||||
<div class="well well-sm">
|
||||
<!-- add website description here -->
|
||||
<a href="#" class="fa fa-arrow-right"> Edit Your Bio</a>
|
||||
<a class="fa fa-arrow-right" t-attf-href="/forum/#{ slug(forum) }/edit/profile/#{ user.id }"> Edit Your Bio</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -637,7 +681,7 @@
|
|||
<t t-if="post.parent_id">
|
||||
<a t-esc="post.parent_id.name"
|
||||
t-attf-href="/forum/#{ slug(forum) }/question/#{ post.parent_id.id }"/>
|
||||
<span class="glyphicon glyphicon-play"/>
|
||||
<span class="fa fa-play"/>
|
||||
<t t-esc="post.content[0:100]"/>
|
||||
<strong> ... </strong>
|
||||
</t>
|
||||
|
|
Loading…
Reference in New Issue