[FIX] website_slides: fix some styling issues on training course page

This commit do some small UI adjustment:

 * remove a potential doubled <hr/>;
 * remove a "mb8" to make views consistent whether you're a channel publisher
   or not;
 * add a specific parameter to see 'uncategorized' slides on a documentation
   channel as /category is a slug and does not allow Falsy values;

Commit linked to task ID 1941250 and PR #31317.
This commit is contained in:
Aurélien Warnon
2019-02-21 16:38:04 +00:00
committed by Thibault Delavallée
parent 0a73e14805
commit 9f74ccf403
2 changed files with 32 additions and 10 deletions
+22 -5
View File
@@ -221,11 +221,12 @@ class WebsiteSlides(WebsiteProfile):
'/slides/<model("slide.channel"):channel>/category/<model("slide.category"):category>',
'/slides/<model("slide.channel"):channel>/category/<model("slide.category"):category>/page/<int:page>'
], type='http', auth="public", website=True, sitemap=sitemap_slide)
def channel(self, channel, category=None, tag=None, page=1, slide_type=None, sorting=None, search=None, **kw):
def channel(self, channel, category=None, tag=None, page=1, slide_type=None, uncategorized=False, sorting=None, search=None, **kw):
if not channel.can_access_from_current_website():
raise werkzeug.exceptions.NotFound()
domain = [('channel_id', '=', channel.id)]
if not request.env.user.has_group('website.group_website_publisher'):
if not channel.can_publish:
domain = expression.AND([
domain,
['&', ('website_published', '=', True), ('channel_id.website_published', '=', True)]
@@ -250,7 +251,10 @@ class WebsiteSlides(WebsiteProfile):
elif tag:
domain += [('tag_ids.id', '=', tag.id)]
pager_url += "/tag/%s" % tag.id
if slide_type:
if uncategorized:
domain += [('category_id', '=', False)]
pager_url += "?uncategorized=1"
elif slide_type:
domain += [('slide_type', '=', slide_type)]
pager_url += "?slide_type=%s" % slide_type
@@ -270,6 +274,7 @@ class WebsiteSlides(WebsiteProfile):
'search_category': category,
'search_tag': tag,
'search_slide_type': slide_type,
'search_uncategorized': uncategorized,
'slide_types': slide_types,
'sorting': actual_sorting,
'search': search,
@@ -301,21 +306,33 @@ class WebsiteSlides(WebsiteProfile):
# Display uncategorized slides
# fetch slides; done as sudo because we want to display all of them but
# unreachable ones won't be clickable (+ slide controller will crash anyway)
if not category:
if not category and not uncategorized:
category_data = []
for category in request.env['slide.slide'].sudo().read_group(domain, ['category_id'], ['category_id']):
category_id, name = category.get('category_id') or (False, _('Uncategorized'))
slides_sudo = request.env['slide.slide'].sudo().search(category['__domain'], limit=4, offset=0, order=order)
category_data.append({
'id': category_id,
'name': name,
'slug_name': slug((category_id, name)) if category_id else name,
'total_slides': category['category_id_count'],
'slides': request.env['slide.slide'].sudo().search(category['__domain'], limit=4, offset=0, order=order)
'slides': slides_sudo,
})
elif uncategorized:
slides_sudo = request.env['slide.slide'].sudo().search(domain, limit=self._slides_per_page, offset=pager['offset'], order=order)
category_data = [{
'id': False,
'name': _('Uncategorized'),
'slug_name': _('Uncategorized'),
'total_slides': len(slides_sudo),
'slides': slides_sudo,
}]
else:
slides_sudo = request.env['slide.slide'].sudo().search(domain, limit=self._slides_per_page, offset=pager['offset'], order=order)
category_data = [{
'id': category.id,
'name': category.name,
'slug_name': slug(category),
'total_slides': len(slides_sudo),
'slides': slides_sudo,
}]
@@ -21,6 +21,9 @@
<li class="breadcrumb-item active" t-att-aria-current="'page' and search_tag" t-if="search_tag">
<a t-att-href="'/slides/%s/tag/%s' % (slug(channel), slug(search_tag))"><span t-esc="search_tag.name"/></a>
</li>
<li class="breadcrumb-item active" t-att-aria-current="'page' and search_uncategorized" t-if="search_uncategorized">
<a t-att-href="'/slides/%s?search_uncategorized=1' % (slug(channel))">Uncategorized</a>
</li>
<li class="breadcrumb-item active" t-att-aria-current="'page' and search_slide_type" t-if="search_slide_type">
<a t-att-href="'/slides/%s?slide_type=%s' % (slug(channel), search_slide_type)"><span t-esc="slide_types[search_slide_type]"/></a>
</li>
@@ -159,8 +162,8 @@
<span class="col-5">Members</span>
<span class="col" t-esc="channel.members_count"/>
</div>
<div class="row mt8"><div class="col"><hr/></div></div>
<t t-if="channel.channel_type == 'documentation'">
<div class="row mt8"><div class="col"><hr/></div></div>
<t t-set="slide_type_keys" t-value="slide_types.keys()"/>
<t t-foreach="slide_type_keys" t-as="slide_type_key">
<div class="row mt8 align-items-center">
@@ -220,7 +223,7 @@
</div>
</div>
</div>
<div t-if="channel.can_upload" class="row justify-content-center mt8 mb8">
<div t-if="channel.can_upload" class="row justify-content-center mt8">
<a role="button" class="btn btn-primary oe_slide_js_upload col-10" title="Upload Presentation"
aria-label="Upload Presentation" href="#"
t-att-data-channel-id="channel.id"
@@ -351,9 +354,11 @@
<t t-foreach="category_data" t-as="category">
<div class="row mt16 align-items-center">
<div class="col">
<a t-att-href="'/slides/%s/category/%s' % (slug(channel), category['id'])" class="float-right">
View all
</a>
<t t-if="category['id']">
<a t-att-href="'/slides/%s/category/%s' % (slug(channel), category['slug_name'])" class="float-right">
View all
</a>
</t>
<h3><t t-esc="category['name']"/></h3>
<hr/>
</div>