<?xml version="1.0" encoding="utf-8"?>
<odoo><data>
    <!--Access Denied - Profile Page-->
    <template id="profile_access_denied" inherit_id="website_profile.profile_access_denied">
        <xpath expr="//div[@id='profile_access_denied_return_link_container']" position="inside">
            <t t-if="request.params.get('forum_id')">
                <a t-attf-href="/forum/#{request.params.get('forum_id')}" class="btn btn-primary">Return to the forum</a>
            </t>
        </xpath>
    </template>

    <template id="user_profile_content" inherit_id="website_profile.user_profile_content">
        <xpath expr="//table[@id='o_wprofile_sidebar_table']//tr[last()]" position="after">
            <t t-if="forum and (up_votes or down_votes)">
                <tr id="profile_abstract_info_company">
                    <th><small class="fw-bold">Votes</small></th>
                    <td>
                        <span>
                            <i class="fa fa-thumbs-up text-success" role="img" aria-label="Positive votes" title="Positive votes"/>
                            <span class="fw-bold" t-out="up_votes"/>
                            <i class="fa fa-thumbs-down text-danger ms-3" role="img" aria-label="Negative votes" title="Negative votes"/>
                            <span class="fw-bold" t-out="down_votes"/>
                        </span>
                    </td>
                </tr>
            </t>
        </xpath>
        <xpath expr="//ul[@id='profile_extra_info_tablist']" position="inside">
            <t t-if="forum">
                <li class="nav-item">
                    <a role="tab" aria-controls="activities" href="#activities" t-attf-class="#{ 'active' if active_tab == 'activities' else '' } nav-link o_wprofile_navlink" data-bs-toggle="tab">Activities</a>
                </li>
                <li t-if="uid == user.id" class="nav-item">
                    <a role="tab" aria-controls="votes" href="#votes" class="nav-link o_wprofile_navlink" data-bs-toggle="tab">Votes</a>
                </li>
            </t>
        </xpath>
        <xpath expr="//div[@id='profile_extra_info_tabcontent']" position="inside">
            <t t-if="forum">
                <t t-set="is_profile" t-value="true"/>
                <div role="tabpanel" t-attf-class="o_wforum_profile_tab tab-pane o_wprofile_forum_activity #{ 'show active' if active_tab == 'activities' else '' }" id="activities"
                     t-att-data-active-tab="activities_active_tab">
                    <h5 class="border-bottom pb-1 d-flex align-items-start align-items-md-center justify-content-between">
                        <div>Activities</div>
                        <div class="d-flex flex-wrap gap-1">
                            <div class="m-auto"/>
                            <div class="dropdown" id="o_wprofile_forum_activity_filter" role="tablist">
                                <button class="btn btn-light dropdown-toggle" type="button" id="o_wprofile_forum_activity_filter_button"
                                        data-bs-toggle="dropdown" aria-expanded="false">
                                    <i class="fa fa-filter"/><span class="o_wprofile_forum_activity_filter_label ms-2"/>
                                </button>
                                <ul class="dropdown-menu" aria-labelledby="o_wprofile_forum_activity_filter_button">
                                    <li t-if="uid == user.id">
                                        <a role="tab" aria-controls="activity" href="#o_wprofile_forum_activity_tab_activity"
                                            t-attf-class="#{ 'active' if activities_active_tab =='activity' else '' } dropdown-item o_wprofile_navlink px-3 py-2"
                                            data-bs-toggle="tab">Activity</a>
                                    </li>
                                    <li>
                                        <a role="tab" aria-controls="questions" href="#o_wprofile_forum_activity_tab_question"
                                            t-attf-class="#{ 'active' if activities_active_tab =='question' else '' } dropdown-item o_wprofile_navlink px-3 py-2"
                                            data-bs-toggle="tab" aria-selected="true"><t t-out="count_questions"/> Questions</a>
                                    </li>
                                    <li>
                                        <a role="tab" aria-controls="answers" href="#o_wprofile_forum_activity_tab_answer"
                                            t-attf-class="#{ 'active' if activities_active_tab =='answer' else '' } dropdown-item o_wprofile_navlink px-3 py-2"
                                            data-bs-toggle="tab"><t t-out="count_answers"/> Answers</a>
                                    </li>
                                </ul>
                            </div>
                            <div class="w-100 d-block d-sm-none"></div>
                            <form method="post" class="o_wprofile_forum_activity_search_question ms-auto">
                                <div class="input-group" role="search">
                                    <input type="text" class="form-control oe_search_box border-0 bg-light"
                                        name="activity_search_question" t-att-value="activity_search_question"
                                        placeholder="Search Questions..."/>
                                    <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
                                    <button type="submit" class="btn btn-light" aria-label="Search" title="Search">
                                        <i class="oi oi-search"/>
                                    </button>
                                </div>
                            </form>
                            <form method="post" class="o_wprofile_forum_activity_search_answer d-none ms-auto">
                                <div class="input-group" role="search">
                                    <input type="text" class="form-control oe_search_box border-0 bg-light"
                                        name="activity_search_answer" t-att-value="activity_search_answer"
                                        placeholder="Search Answers..."/>
                                    <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
                                    <button type="submit" class="btn btn-light" aria-label="Search" title="Search">
                                        <i class="oi oi-search"/>
                                    </button>
                                </div>
                            </form>
                        </div>

                    </h5>
                    <t t-call="website_forum.forum_filter_tag"/>

                    <div class="tab-content mt-2" id="profile_extra_info_tabcontent_activities">
                        <div role="tabpanel" t-attf-class="#{ 'show active' if activities_active_tab =='question' else '' } o_wforum_profile_tab tab-pane" id="o_wprofile_forum_activity_tab_question">
                            <div class="mb-4">
                                <t t-if="questions">
                                    <div class="mb-1" t-foreach="questions" t-as="question">
                                        <t t-call="website_forum.display_post"/>
                                    </div>
                                </t>
                                <div t-elif="my_profile" class="text-muted">
                                    <t t-if="activity_search_question">No results.</t>
                                    <t t-else="">You have not posted any questions yet.</t>
                                    <br />
                                    <a href="/forum/" class="btn btn-link px-0">
                                        <i class="oi oi-arrow-right d-inline-block"/> Go to Forums
                                    </a>
                                </div>
                                <t t-else="">
                                    <div class="text-muted">
                                        <t t-if="activity_search_question">No results.</t>
                                        <t t-else="">This user hasn't posted any questions yet.</t>
                                        <br/>
                                        <a href="/forum/" class="btn btn-link px-0">
                                            <i class="oi oi-arrow-right d-inline-block"/> Go to Forums
                                        </a>
                                    </div>
                                </t>
                            </div>
                            <t t-if="favourite">
                                <div class="mb-4">
                                    <h5 class="border-bottom pb-1">Favourite Questions</h5>
                                    <div class="mb-1" t-foreach="favourite" t-as="question">
                                        <t t-call="website_forum.display_post">
                                            <t t-set="hide_fav_icon" t-value="True"/>
                                        </t>
                                    </div>
                                </div>
                            </t>
                            <t t-if="followed">
                                <div class="mb-4">
                                    <h5 class="border-bottom pb-1">Followed Questions</h5>
                                    <div class="mb-1" t-foreach="followed" t-as="question">
                                        <t t-call="website_forum.display_post"/>
                                    </div>
                                </div>
                            </t>
                        </div>
                        <div role="tabpanel" t-attf-class="#{ 'show active' if activities_active_tab =='answer' else '' } o_wforum_profile_tab tab-pane" id="o_wprofile_forum_activity_tab_answer">
                            <div class="mb-4">
                                <t t-if="answers">
                                    <div class="mb-1" t-foreach="answers" t-as="answer">
                                        <t t-call="website_forum.display_post_answer"/>
                                    </div>
                                </t>
                                <div t-elif="my_profile" class="text-muted">
                                    <t t-if="activity_search_answer">No results.</t>
                                    <t t-else="">You have not answered any questions yet.</t>
                                    <br />
                                    <a href="/forum/" class="btn btn-link px-0">
                                        <i class="oi oi-arrow-right d-inline-block"/> Go to Forums
                                    </a>
                                </div>
                                <div t-else="" class="text-muted">
                                    <t t-if="activity_search_answer">No results.</t>
                                    <t t-else="">This user hasn't answered any questions yet.</t>
                                    <br/>
                                    <a href="/forum/" class="btn btn-link px-0">
                                        <i class="oi oi-arrow-right d-inline-block"/> Go to Forums
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div t-if="uid == user.id" role="tabpanel" t-attf-class="#{ 'show active' if activities_active_tab =='activity' else '' } o_wforum_profile_tab tab-pane" id="o_wprofile_forum_activity_tab_activity">
                            <div class="mb-4">
                                <t t-call="website_forum.display_activities"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div role="tabpanel" class="o_wforum_profile_tab tab-pane" id="votes" t-if="uid == user.id">
                    <div class="mb-4">
                        <h5 class="border-bottom pb-1 flex align-items-center justify-content-between" style="height:43px;">
                            Votes
                            <t t-if="my_profile" t-call="website.website_search_box_input">
                                <t t-set="_form_classes" t-valuef="d-flex flex-row align-items-center flex-wrap float-end"/>
                                <t t-set="search_type" t-valuef="forums"/>
                                <t t-set="action" t-value="'/forum/%s%s' % (forum_id or 'all', '/tag/%s/questions' % slug(tag) if tag else '')"/>
                                <t t-set="display_description" t-valuef="false"/>
                                <t t-set="display_detail" t-valuef="false"/>
                                <t t-set="placeholder" t-valuef="Search Posts..."/>
                                <input type="hidden" name="my" value="upvoted"/>
                                <input t-if="filters" type="hidden" name="filters" t-att-value="filters"/>
                                <input t-if="sorting" type="hidden" name="sorting" t-att-value="sorting"/>
                                <input type="hidden" name="include_answers" t-att-value="True"/>
                            </t>
                        </h5>
                        <t t-call="website_forum.forum_filter_tag"/>
                        <t t-call="website_forum.user_votes"/>
                    </div>
                </div>
            </t>
        </xpath>
    </template>

    <template id="forum_filter_tag" name="Filtering Forum Tag">
        <t t-if="forum_filtered">
            <span class="d-inline-flex align-items-center gap-2 rounded py-1 ps-2 pe-0 bg-200 small">
                <i class="fa fa-filter text-muted"/>
                <t t-out="forum_filtered"/>
                <a t-attf-href="/profile/user/#{user.id}" class="oi oi-close btn m-n1 text-muted"/>
            </span>
        </t>
    </template>

    <template id="display_activities" name="Forum Profile Activities">
        <t t-if="activities">
            <div t-foreach="activities" t-as="activity" class="card mb-2">
                <div class="card-body">
                    <span t-out="activity.subtype_id.name" class="badge text-bg-info me-2 mt-1"/>
                    <span t-field="activity.date" t-options='{"format": "short"}' class="me-2"/>
                    <t t-set="post" t-value="posts[activity.res_id]"/>
                    <span t-if="post[1]">
                        <a t-attf-href="/forum/#{ slug(post[0].forum_id) }/#{ slug(post[0]) }#answer-#{ str(post[1].id) }">
                            <span t-out="post[0].name"/>
                        </a>
                    </span>
                    <span t-if="not post[1]">
                        <a t-attf-href="/forum/#{ slug(post[0].forum_id) }/#{ slug(post[0]) }">
                            <span t-out="post[0].name"/>
                        </a>
                    </span>
                </div>
            </div>
        </t>
        <t t-else="">
            <span class="text-muted">There is no activity yet.</span>
        </t>
    </template>

    <template id="user_votes" name="Forum User Votes">
        <div t-foreach="vote_post" t-as="vote" class="card mb-2">
            <div class="card-body">
                <span t-if="vote.vote == '1'" class="fa fa-thumbs-up text-success me-2" role="img" aria-label="Positive vote" title="Positive vote"/>
                <span t-if="vote.vote == '-1'" class="fa fa-thumbs-down text-warning me-2" role="img" aria-label="Negative vote" title="Negative vote"/>
                <span t-field="vote.post_id.create_date"/>
                <a t-if="vote.post_id.parent_id" class="ms-2" t-attf-href="/forum/#{ slug(vote.post_id.forum_id) }/#{ vote.post_id.parent_id.id }/#answer-#{ vote.post_id.id }" t-out="vote.post_id.parent_id.name"/>
                <a t-else="" class="text-black ms-2" t-attf-href="/forum/#{ slug(vote.post_id.forum_id) }/#{ vote.post_id.id }" t-out="vote.post_id.name"/>
            </div>
        </div>
        <div class="mb16" t-if="not vote_post">
            <div t-if="my_profile" class="text-muted">
                Help moderating the forums by upvoting and downvoting posts. <br />
                <a href="/forum/" class="btn-link">
                    <i class="fa fa-arrow-right"></i> Go To Forums
                </a>
            </div>
            <p t-else="" class="text-muted">You haven't given any votes yet.</p>
        </div>
    </template>
</data></odoo>
