[FIX] mail, website_slides: fix while accept the request from the new attendee
Before this commit: We have a new feature that if the course is private, and attendee make the request to access the course it will create an activity for 'course responsible'. Currently, after accepting the invitation request from the new user, it is still not considered the user as an attendee and not displaying like 'You're enrolled' to the respective users After this commit: The features of access invitation on courses will be workable. Task-2328389 closes odoo/odoo#60135 X-original-commit: becf051f38fcf08d4a0aea758cb2758ad0f25bc3 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -114,6 +114,18 @@ function factory(dependencies) {
|
||||
];
|
||||
}
|
||||
}
|
||||
if ('request_partner_id' in data) {
|
||||
if (!data.request_partner_id) {
|
||||
data2.requestingPartner = [['unlink']];
|
||||
} else {
|
||||
data2.requestingPartner = [
|
||||
['insert', {
|
||||
id: data.request_partner_id[0],
|
||||
display_name: data.request_partner_id[1],
|
||||
}],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return data2;
|
||||
}
|
||||
@@ -292,6 +304,14 @@ function factory(dependencies) {
|
||||
'note',
|
||||
],
|
||||
}),
|
||||
/**
|
||||
* Determines that an activity is linked to a requesting partner or not.
|
||||
* It will be used notably in website slides to know who triggered the
|
||||
* "request access" activity.
|
||||
* Also, be useful when the assigned user is different from the
|
||||
* "source" or "requesting" partner.
|
||||
*/
|
||||
requestingPartner: many2one('mail.partner'),
|
||||
state: attr(),
|
||||
summary: attr(),
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
odoo.define('website_slides/static/src/tests/activity_tests.js', function (require) {
|
||||
'use strict';
|
||||
|
||||
const components = {
|
||||
Activity: require('mail/static/src/components/activity/activity.js'),
|
||||
};
|
||||
|
||||
const {
|
||||
afterEach,
|
||||
beforeEach,
|
||||
createRootComponent,
|
||||
start,
|
||||
} = require('mail/static/src/utils/test_utils.js');
|
||||
|
||||
QUnit.module('website_slides', {}, function () {
|
||||
QUnit.module('components', {}, function () {
|
||||
QUnit.module('activity', {}, function () {
|
||||
QUnit.module('activity_tests.js', {
|
||||
beforeEach() {
|
||||
beforeEach(this);
|
||||
|
||||
this.createActivityComponent = async activity => {
|
||||
await createRootComponent(this, components.Activity, {
|
||||
props: { activityLocalId: activity.localId },
|
||||
target: this.widget.el,
|
||||
});
|
||||
};
|
||||
|
||||
this.start = async params => {
|
||||
const { env, widget } = await start(Object.assign({}, params, {
|
||||
data: this.data,
|
||||
}));
|
||||
this.env = env;
|
||||
this.widget = widget;
|
||||
};
|
||||
},
|
||||
afterEach() {
|
||||
afterEach(this);
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test('grant course access', async function (assert) {
|
||||
assert.expect(8);
|
||||
|
||||
await this.start({
|
||||
async mockRPC(route, args) {
|
||||
if (args.method === 'action_grant_access') {
|
||||
assert.strictEqual(args.args.length, 1);
|
||||
assert.strictEqual(args.args[0].length, 1);
|
||||
assert.strictEqual(args.args[0][0], 100);
|
||||
assert.strictEqual(args.kwargs.partner_id, 5);
|
||||
assert.step('access_grant');
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
const activity = this.env.models['mail.activity'].create({
|
||||
canWrite: true,
|
||||
thread: [['insert', {
|
||||
id: 100,
|
||||
model: 'slide.channel',
|
||||
}]],
|
||||
requestingPartner: [['insert', {
|
||||
id: 5,
|
||||
displayName: "Pauvre pomme",
|
||||
}]],
|
||||
type: [['insert', {
|
||||
id: 1,
|
||||
displayName: "Access Request",
|
||||
}]],
|
||||
});
|
||||
await this.createActivityComponent(activity);
|
||||
|
||||
assert.containsOnce(document.body, '.o_Activity', "should have activity component");
|
||||
assert.containsOnce(document.body, '.o_Activity_grantAccessButton', "should have grant access button");
|
||||
|
||||
document.querySelector('.o_Activity_grantAccessButton').click();
|
||||
assert.verifySteps(['access_grant'], "Grant button should trigger the right rpc call");
|
||||
});
|
||||
|
||||
QUnit.test('refuse course access', async function (assert) {
|
||||
assert.expect(8);
|
||||
|
||||
await this.start({
|
||||
async mockRPC(route, args) {
|
||||
if (args.method === 'action_refuse_access') {
|
||||
assert.strictEqual(args.args.length, 1);
|
||||
assert.strictEqual(args.args[0].length, 1);
|
||||
assert.strictEqual(args.args[0][0], 100);
|
||||
assert.strictEqual(args.kwargs.partner_id, 5);
|
||||
assert.step('access_refuse');
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
const activity = this.env.models['mail.activity'].create({
|
||||
canWrite: true,
|
||||
thread: [['insert', {
|
||||
id: 100,
|
||||
model: 'slide.channel',
|
||||
}]],
|
||||
requestingPartner: [['insert', {
|
||||
id: 5,
|
||||
displayName: "Pauvre pomme",
|
||||
}]],
|
||||
type: [['insert', {
|
||||
id: 1,
|
||||
displayName: "Access Request",
|
||||
}]],
|
||||
});
|
||||
await this.createActivityComponent(activity);
|
||||
|
||||
assert.containsOnce(document.body, '.o_Activity', "should have activity component");
|
||||
assert.containsOnce(document.body, '.o_Activity_refuseAccessButton', "should have refuse access button");
|
||||
|
||||
document.querySelector('.o_Activity_refuseAccessButton').click();
|
||||
assert.verifySteps(['access_refuse'], "refuse button should trigger the right rpc call");
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -42,4 +42,46 @@ function applyInclude(Activity) {
|
||||
|
||||
applyInclude(KanbanActivity);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
odoo.define('website_slides/static/src/components/activity/activity.js', function (require) {
|
||||
'use strict';
|
||||
|
||||
const components = {
|
||||
Activity: require('mail/static/src/components/activity/activity.js'),
|
||||
};
|
||||
const { patch } = require('web.utils');
|
||||
|
||||
patch(components.Activity, 'website_slides/static/src/components/activity/activity.js', {
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
async _onGrantAccess(ev) {
|
||||
await this.env.services.rpc({
|
||||
model: 'slide.channel',
|
||||
method: 'action_grant_access',
|
||||
args: [[this.activity.thread.id]],
|
||||
kwargs: { partner_id: this.activity.requestingPartner.id },
|
||||
});
|
||||
this.trigger('reload');
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
async _onRefuseAccess(ev) {
|
||||
await this.env.services.rpc({
|
||||
model: 'slide.channel',
|
||||
method: 'action_refuse_access',
|
||||
args: [[this.activity.thread.id]],
|
||||
kwargs: { partner_id: this.activity.requestingPartner.id },
|
||||
});
|
||||
this.trigger('reload');
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -19,4 +19,20 @@
|
||||
</t>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
||||
|
||||
<t t-inherit="mail.Activity" t-inherit-mode="extension">
|
||||
<xpath expr="//*[@name='tools']" position="replace">
|
||||
<t t-if="activity.requestingPartner and activity.thread.model === 'slide.channel'">
|
||||
<div class="o_Activity_tools">
|
||||
<button class="o_Activity_toolButton o_Activity_grantAccessButton btn btn-link" t-on-click="_onGrantAccess">
|
||||
<i class="fa fa-check"/> Grant Access
|
||||
</button>
|
||||
<button class="o_Activity_toolButton o_Activity_refuseAccessButton btn btn-link" t-on-click="_onRefuseAccess">
|
||||
<i class="fa fa-times"/> Refuse Access
|
||||
</button>
|
||||
</div>
|
||||
</t>
|
||||
<t t-else="">$0</t>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
|
||||
@@ -65,6 +65,11 @@
|
||||
<script type="text/javascript" src="/website_slides/static/src/js/slides_embed.js"></script>
|
||||
</template>
|
||||
|
||||
<template id="website_slides_tests" name="eLearning tests" inherit_id="web.qunit_suite_tests">
|
||||
<xpath expr="//script[last()]" position="after">
|
||||
<script type="text/javascript" src="/website_slides/static/src/components/activity/activity_tests.js"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user