Permalink
Browse files

[IMP] website_slides : show completed and ongoing course on profile

  • Loading branch information...
dbeguin committed Feb 8, 2019
1 parent 896d594 commit 58f48980a6638e07456d56495d8828a34883d128
@@ -393,9 +393,10 @@ def slides_embed(self, slide_id, page="1", **kw):
# Profile
# ---------------------------------------------------
def _prepare_open_slide_user(self, user):
slides = request.env['slide.slide'].sudo().search([('user_ids', '=', user.id)])
slides = request.env['slide.slide'].sudo().search([('partner_ids', '=', user.partner_id.id)])
courses = request.env['slide.channel.partner'].sudo().search([('partner_id', '=', user.partner_id.id)]).channel_id

courses_completed = courses.filtered(lambda c: c.completed)
courses_ongoing = courses - courses_completed
survey_done = request.env['survey.user_input'].sudo().search(['&', ('partner_id', '=', user.partner_id.id), ('state', '=', 'done')])
certificates = survey_done.filtered(lambda s: s.survey_id.certificate)

@@ -405,7 +406,8 @@ def _prepare_open_slide_user(self, user):
'main_object': user,
'slides': slides,
'count_slides': len(slides),
'courses': courses,
'courses_completed': courses_completed,
'courses_ongoing': courses_ongoing,
'count_courses': len(courses),
'certificates': certificates,
'is_profile_page': True,
@@ -119,7 +119,6 @@ def _default_access_token(self):
can_publish = fields.Boolean('Can Publish', compute='_compute_access')
# karma generation
karma_gen_slide_vote = fields.Integer(string='Lesson voted', default=1)
karma_gen_channel_share = fields.Integer(string='Course shared', default=2)
karma_gen_channel_rank = fields.Integer(string='Course ranked', default=5)
karma_gen_channel_finish = fields.Integer(string='Course finished', default=10)
# TODO DBE : Add karma based action rules (like in forum)
@@ -24,6 +24,21 @@
top: 13px;
right: 16px;
}
.o_wprofile_slide_course_progress {
position: absolute;
bottom: 4px;
width: 100%;
padding-left: 88px;
.o_wprofile_slide_course_progress_bar {
background-color: lightgray;
top: 2px;
padding: 0px;
}
.o_wprofile_slide_course_progress_value {
min-width: 70px;
text-align: right;
}
}
}

// Certification Card
@@ -93,16 +93,27 @@
<template id="user_detail_content" inherit_id="website_profile.user_detail_content">
<xpath expr="//div[@id='profile_about_badge']" position="before">
<t t-if="channel">
<!-- TODO
<div class="mb32">
<h4>Completed Courses</h4>
<t t-call="website_slides.display_completed_course"></t>
</div>
<h4><i class="fa fa-graduation-cap"/> Completed Courses</h4>
<t t-if="courses_completed">
<t t-call="website_slides.display_course">
<t t-set="courses" t-value="courses_completed"></t>
</t>
</t>
<t t-else="">
<b>No completed course yet!</b>
</t>
</div>
-->
<div class="mb32">
<h4><i class="fa fa-graduation-cap"/> Courses</h4>
<t t-call="website_slides.display_course"/>
<h4><i class="fa fa-book"/> Followed Courses</h4>
<t t-if="courses_ongoing">
<t t-call="website_slides.display_course">
<t t-set="courses" t-value="courses_ongoing"></t>
</t>
</t>
<t t-else="">
<b>No followed course!</b>
</t>
</div>
<div class="mb32">
<h4><i class="fa fa-trophy"/> Certifications</h4>
@@ -129,31 +140,33 @@
</template>

<template id="display_course">
<t t-if="courses">
<div class="row">
<div class="col-lg-6 o_wprofile_slides_card" t-foreach="courses" t-as="course">
<div class="card-body o_wprofile_slides_course_card_body o_wprofile_bb_grey" t-attf-onclick="location.href='/slides/#{slug(course)}';">
<div class="row">
<div class="o_wprofile_slides_course_img">
<img class="o_img_small mb-3" t-attf-src="/web/image/slide.channel/#{course.id}/image_small"/>
</div>
<div class="col-10 o_wprofile_slides_title">
<b t-field="course.name"/>
</div>
<div class="o_wprofile_slide_course_rating">
<t t-call="website_rating.rating_widget_stars_static">
<t t-set="rating_avg" t-value="course.rating_avg"/>
<t t-set="rating_count" t-value="course.rating_count"/>
</t>
<div class="row">
<div class="col-lg-6 o_wprofile_slides_card" t-foreach="courses" t-as="course">
<div class="card-body o_wprofile_slides_course_card_body o_wprofile_bb_grey" t-attf-onclick="location.href='/slides/#{slug(course)}';">
<div class="row">
<div class="o_wprofile_slides_course_img">
<img class="o_img_small mb-3" t-attf-src="/web/image/slide.channel/#{course.id}/image_small"/>
</div>
<div class="col-10 o_wprofile_slides_title">
<b t-field="course.name"/>
</div>
<div class="o_wprofile_slide_course_rating">
<t t-call="website_rating.rating_widget_stars_static">
<t t-set="rating_avg" t-value="course.rating_avg"/>
<t t-set="rating_count" t-value="course.rating_count"/>
</t>
</div>
<div class="row o_wprofile_slide_course_progress">
<div class="col progress o_wprofile_slide_course_progress_bar">
<div class="progress-bar" style="background-color: #00A09D !important"
t-att-style="'width: '+ str(course.completion)+'%'"></div>
</div>
<span class="col-3 text-primary o_wprofile_slide_course_progress_value"><span t-field="course.completion"/> %</span>
</div>
</div>
</div>
</div>
</t>
<t t-else="">
<b>No followed course yet!</b>
</t>
</div>
</template>

<template id="display_certificate">

0 comments on commit 58f4898

Please sign in to comment.