Add 'force_display' param for the frontend chatter to allow public user to see the textarea. When submitting his comment, he will be redirect to login page (like it was before generic chatter) in both mode (json and post mode). This required changing the error handeling of json mode : when a login is required, the user switch to post mode to allow http redirect, keeping its submitted params (rating, comment, ...).
86 lines
5.8 KiB
XML
86 lines
5.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo>
|
|
<template id="follow">
|
|
<div class="input-group js_follow" t-att-data-id="object.id"
|
|
t-att-data-object="object._name"
|
|
t-att-data-follow="object.id and object.message_is_follower and 'on' or 'off'"
|
|
t-att-data-unsubscribe="'unsubscribe' if 'unsubscribe' in request.params else None">
|
|
<input
|
|
type="email" name="email"
|
|
class="js_follow_email form-control"
|
|
placeholder="your email..."
|
|
groups="base.group_public"/>
|
|
<span class="input-group-btn">
|
|
<button href="#" t-attf-class="btn btn-default js_unfollow_btn">Unsubscribe</button>
|
|
<button href="#" t-attf-class="btn btn-primary js_follow_btn">Subscribe</button>
|
|
</span>
|
|
</div>
|
|
</template>
|
|
|
|
<template id="head" inherit_id="website.assets_frontend" name="Mail customization">
|
|
<xpath expr="." position="inside">
|
|
<script type="text/javascript" src="/website_mail/static/src/js/follow.js"></script>
|
|
<script type="text/javascript" src="/website_mail/static/src/js/message_post.js"></script>
|
|
<link rel='stylesheet' href='/website_mail/static/src/css/website_mail.css'/>
|
|
</xpath>
|
|
</template>
|
|
|
|
<template id="message_thread">
|
|
<!--
|
|
Generic chatter template for the frontend
|
|
To use this template, you need to call it after setting the following variable in your template or in your controller:
|
|
:object browserecord : the mail_thread object
|
|
:token string (optional): if you want your chatter to be available for non-logged user,
|
|
you can use a token to verify the identity of the user;
|
|
the message will be posted with the identity of the partner_id of the object
|
|
:token_field string (optional): name of the field that contains the token on the object (default to 'token')
|
|
:sha_in string (optional): if you use the shasign to allow commenting by non-logged user, you need to set it in this variable using the
|
|
object_shasign function defined in the main controller of website_portal
|
|
:sha_time string (optional): timestamp of the shasign generation
|
|
:chatter_mode string: 'json' or 'post' depending on what kind of request you want
|
|
:force_display : True if the chatter should be display, but posting a message required a logged user. Otherwise, the user will be redirect to the login page.
|
|
-->
|
|
<section id="discussion" class="hidden-print oe_website_portal o_website_mail_thread">
|
|
<section class="mb32 css_editable_mode_hidden hidden-print">
|
|
<form class="o_website_chatter_form" t-attf-action="/website_mail/post/#{chatter_mode}" method="POST" t-if="website.env.user != request.env['ir.model.data'].xmlid_to_object('base.public_user') or token or sha_in or force_display">
|
|
<img class="img pull-left img-circle" t-attf-src="/web/image/res.partner/#{user_id.partner_id.id}/image_small/50x50" style="width: 50px; margin-right: 10px;"/>
|
|
<div class="pull-left mb32" style="width: 75%%">
|
|
<textarea rows="4" name="message" class="form-control" placeholder="Write a message..."></textarea>
|
|
<input type='hidden' name="res_model" t-att-value="object._model"/>
|
|
<input type='hidden' name="res_id" t-att-value="object.id"/>
|
|
<input type='hidden' name="token" t-att-value="token" t-if="token"/>
|
|
<input type='hidden' name="sha_in" t-att-value="sha_in" t-if="sha_in"/>
|
|
<input type='hidden' name="sha_time" t-att-value="sha_time" t-if="sha_time"/>
|
|
<input type='hidden' name="token_field" t-att-value="token_field" t-if="token_field"/>
|
|
<input type='hidden' name="force_display" t-att-value="force_display" t-if="force_display"/>
|
|
<div class="alert alert-danger mt8 mb0 o_website_chatter_error" style="display:none;">
|
|
Oops! Something went wrong. Try to reload the page and to log in.
|
|
</div>
|
|
<button t-attf-class="o_website_chatter_#{chatter_mode} btn btn-primary mt8 o_website_message_post_helper" type="submit">Send</button>
|
|
</div>
|
|
</form>
|
|
</section>
|
|
<div class="clearfix"/>
|
|
<ul class="media-list o_website_comments">
|
|
<t t-foreach="object.message_ids" t-as="message">
|
|
<t t-if="message.website_published or website.env.user.sudo(website.env.user.id).has_group('base.group_website_publisher')">
|
|
<li class="media" t-if="message.message_type == 'comment'" t-att-id="'message-%s' % message.id">
|
|
<div class="media-body">
|
|
<img class="media-object pull-left img-circle" t-att-src="website.image_url(message.author_id, 'image_small')" style="width: 50px; margin-right: 10px;"/>
|
|
<div class="media-body">
|
|
<h5 class="media-heading">
|
|
<span t-field="message.author_id"/> <small>on <span t-field="message.date"/></small>
|
|
</h5>
|
|
<t t-set="object" t-value="message"/>
|
|
<t t-call="website.publish_short"/>
|
|
<div t-field="message.body"/>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
</t>
|
|
</t>
|
|
</ul>
|
|
</section>
|
|
</template>
|
|
</odoo>
|