Commit Graph
38 Commits
Author SHA1 Message Date
Simon Genin (ges) ecfe85db84 [REF] web: static/src/(img|fonts) => static/(img|fonts) 2021-04-29 07:34:40 +00:00
Nicolas Lempereur 2b4981ec1f [FIX] website_profile: _prepare_user_value edit tl ok
In courses home page, we use _prepare_user_value to get values from
search strings as render values.

But for example this cause an issue in case of edit_translations, it
has no value but if present is set to `{'edit_translations': True}` in
context.

But _prepare_user_value will set it to context as:

  {'edit_translations': ''}

Which make translation not work on page that used
`_prepare_user_value(kw)` to get values for rendering.

opw-2305816
closes #55444

closes odoo/odoo#55457

X-original-commit: 11c5daae47b50c26ceebe8feb736352b7a27a85b
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-08-05 11:13:09 +00:00
Okan SUMER (osu) f759a316f6 [IMP] website_profile: add badge breadcrumb and profile rank
This commit add a breadcrumb in the badge frontend view to redirect
to the last page the user was.
It highlights the user profile line in ranking view (profile/users).
It add this line at the top of every pages except for the one where
it already was.

Part of https://github.com/odoo/odoo/pull/46634

task-2201708
2020-05-15 08:40:14 +00:00
Nicolas Martinelli 42690cb4da [FIX] website_profile: fallback if missing kwargs
Avoid casting `None` to integer.

opw-2231620

closes odoo/odoo#49136

X-original-commit: d0eb912242ba0932ce8c56cf625775cb50f1526a
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-04-07 12:17:00 +00:00
Patrick Hoste e711dc08d4 [FIX] website_profile: fix edit profile issue
PURPOSE

Before this commit when an administrator edit another user's profile it
was his own data that displayed for the changes.
This commit fixes this issue.

SPECIFICATION

Add a test in both controller route when displaying the edit view and
when submitting the changes that check if the edited user is the same
as the actual user.

LINKS

Task ID : 2222043
PR : #48262

closes odoo/odoo#48575

X-original-commit: 4ab4de5b57a17002d8b14584c7d39a29e8bca357
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-03-30 09:24:14 +00:00
David Beguin 5ac64d6e02 [IMP] website_slides_survey: add certification badges section to ranks badge page
This commit adds a section to distinguish the certification badges from the
other badges users may obtain in eLearning. Certification badges are available
on the ranks page, linked to a running survey. Clicking on them directly
redirects into the linked course.

Task ID : 1961053
PR #32594
2019-11-22 15:30:53 +00:00
David Beguin be3f074a91 [REF] gamification, * : rename challenge.category into challenge.challenge_category
To ease grep in the code, especially that challenge is quite heavily used.

Task ID : 1961053
PR #32594
2019-11-22 14:45:39 +00:00
David Beguin 6f0d36fa67 [REF] gamification : rename stat_* fields into granted_* to ease understanding
In this commit we rename stat_count into granted_count, and stat_count_distinct
into granted_users_count to reflect more what are those variables, aka count
of granted badges.

Task ID: 1961053
PR #32594
2019-11-22 14:44:39 +00:00
Thibault Delavallée 1d468caf94 [IMP] website_profile: handle both groupby and search in users page
Purpose is to support both search term and karma gain group by in the
URL, using keep_query.

Clean some code and move karma computation to res.users model to avoid
having sql in controllers.

Also fix some display issues.

LINKS

Task ID 2003505
PR #34594
2019-11-05 15:08:34 +00:00
Patrick Hoste bfbc7c6a18 [IMP] gamification: track karma change on users
PURPOSE

Allow karma gain tracking enabling notably display of top users based on
weekly / monthly gain in website profile.

SPECIFCIATIONS

Each time a user gains karma a record is created in the gamification karma
tracking model. Scheduled activity runs to consolidate the records into
monthly gain records to avoid having crowdy table and unnecessary noise
in karma gain.

This model is made private and only accessible through some dedicated
compute methods / controllers used in website profile.

In website profile module buttons are added to see users ranking based
on their total karma (like before) but also by last week and last month
gains (using the newly introduced tracking model).

LINKS

Task ID 2003505
PR #34594
2019-11-05 15:08:34 +00:00
Jeremy Kersten e19227d3ba [IMP] website*: clean sitemap
From now, you need to explicitely add sitemap=True if you want your controller
into the sitemap.

It's the default value, but if you forgot it, it will raise a Warning on runbot.
It will avoid wrong controller in sitemap and duplicate (empty) content.

From now, if your model contains a field website_id, the modelConverter for
sitemap will automatically add the domain:
   "[('website_id', 'in', (False, current_website_id))]"

It avoid redundant declaration and ugly url in redirect/rewrite view.

Migration: need to remove it from url_from in website.rewrite

task-2065018

closes odoo/odoo#39427

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-10-28 10:36:56 +00:00
Sébastien Theys b6288e5446 [IMP] *: remove image_64 and clean views
There are too many image sizes. Since they are stored resized this takes time to
generate when saving a new image, it's more rows on the attachment table, more
files on the disk, ...

64px is close enough to 128px that it can be removed without a big impact on
download size.

It will even reduce download and number of requests when both images are
displayed because now only one has to be downloaded and then benefit from cache.

The difference between the two is typically around 1.5kB which is negligible
these days, especially when the request overhead is around 0.5kB already, not
even taking into account other factors such as latency.

If a 64px image must absolutely be returned, it is still possible to pass the
size parameters to the image route. But the current guideline is to handle
resizing in the views when necessary.

Views
=====

- remove width and height attributes when existing CSS rules are overriding them
  (eg. `.oe_kanban_avatar` in the right context)
- add CSS rules instead of width and height attributes when possible
- use `object-fit: cover;` where width and height are forced to avoid distortion
  of non-square images
- for products, use `object-fit: contain;` instead, keep ratio but without crop
- add new CSS rules where the expected size was max 64px*64px before due to the
  image size itself
- remove `img-fluid` where using size classes to avoid conflicting rules

task-2060865

closes odoo/odoo#36147

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2019-09-19 10:23:39 +00:00
Thibault Delavallée 1dbeaddeae [FIX] website_profile: fix another broken image thingy
As image fields have been renamed recently [1] we have to update controllers
of profile in order to write on image_1920, not image anymore.

Task 2067872 (eLearning internal testing)
Task 2058598 (survey internal testing)
PR #36756

[1] See 58a2ffa26f
2019-09-13 10:05:15 +00:00
Sébastien Theys 58a2ffa26f [IMP] *: rename image fields
image_original => image_1920 (now resized to 1920)
image_big => image_1024
image_large => image_256
image_medium => image_128
image_small  => image_64
image replaced by image_1920 (when writing) or by image_1024 (when displaying
	what was previously the big size)

+ add new intermediate format:
image_512

PR: #34925
2019-08-02 16:47:58 +00:00
qmo-odoo 75153e72bc [IMP] website_slides: Improve methods to get user certificates
This commit improves a few methods related to the user profiles:
- Change _prepare_all_users_values so that it
works with a batch of users
- Change the _get_user_certificates and rename it to _get_users_certificates
so that it works with a batch of users to avoid doing a search in a
list comprehension.
This method will also be used to get the number of certificates per users

TaskID: 1952064
PR: #32229

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-07-30 13:03:35 +00:00
Patrick Hoste 94c332b499 [FIX] website_profile: changes the display of the users search error message
The error message now display a message containing the term of
the search and it is also not always displayed as it was before

Task ID : 2036652

closes odoo/odoo#35052

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-07-22 07:38:23 +00:00
Christophe Simonis bfd34e14b1 [MERGE] forward port branch saas-12.3 up to 40e8b67179 2019-07-26 15:12:29 +02:00
Julien Castiaux 5c705c51cd [FIX] website_profile: bypass IR Rules on karma ranking
Install website_slides, create a bunch of users all published on the
website. Using raw sql queries, give some karma to those users. Go to
the `/profile/users` web page. When connected the ranking is correctly
shown, when not connected all users are ranked 0.

The problem is that the public user (id: 4) can only access is own user
which prevent him to access the karma of the other user required to rank
them.

As the injected IR Rules are not adding any value and that a domain is
applied already, it is safe to skip the ir rules.

opw-2029105

closes odoo/odoo#34656

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-07-08 11:30:19 +00:00
Christophe Simonis 71a50a2214 [MERGE] forward port branch saas-12.3 up to 409679866b 2019-06-06 11:54:35 +02:00
Jeremy Kersten 9f56353b79 [FIX] w_profile: don't call _get_users_karma_position without users
Before this commit, if you was searching something that return no results,
you will call the sql query generating an error syntax:

Traceback:
ERROR: syntax error at or near ")"
LINE 8:             WHERE sub.id IN ()

Now, we don't make more useless query if we know that there are no users.
+ preventive fix the call of this method without user_ids

This commit is related to #14667

closes odoo/odoo#33715

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-05-28 09:51:38 +00:00
Jeremy Kersten 45e1d196f9 [FIX] website_profile: use company from the partner
This commit closes #14667 again

closes odoo/odoo#33697

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-05-27 10:14:23 +00:00
Quentin Mourier 369143c986 [FIX] website_profile: allow to edit its profile
Move code from website_forum allowing to edit its own profile. Otherwise
fields to update are not white listed. Also add an unpublished flag when
seeing unpublished users in order to know it if you have access to
depending on ACLs.

Linked to task 1978530
Related to PR #33559
2019-05-22 09:16:30 +00:00
David Beguin 472c95e4af [FIX] website_profile, gamification : compute rank for website_published users only
If a non website_published user was 2nd in karma position, the all users page was
displaying in the top 3 a user with position 4 (in rank) as "normal users" cannot see
non published users.

The field karma_position is now deprecated and will be removed in master.

Task ID : 2000687
PR #33475

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-05-21 11:22:08 +00:00
Sébastien Theys d445f46806 [FIX] *: convert image route size param to int and use named param
* = tools, base, web, website_profile, website_slides

Before this commit it was impossible to pass those parameters in the URL because
they were received as string but expected as int.

The opportunity is also taken to properly use named parameters when calling
`image_process`.

closes odoo/odoo#33506

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-05-21 10:34:40 +00:00
Sébastien Theys 7d3fe51100 [FIX] http,web,website_*: return the correct Content-Type for images
* = website_profile, website_slides

Before this commit, the returned Content-Type was not always correct, for
example if the image tool was changing the format, which happens when given
a BMP (converted to PNG), or other types being converted to JPEG.

The previous method `force_contenttype` was too specific and it wasn't available
in every controller. It didn't even need to be a controller method because it
didn't use self.

Now we create a generic helper to ease updating headers.
The Content-Type is only updated when it is safe to do. It is especially unsafe
for example for SVG files.

task-1958000
PR: #31811
2019-04-29 13:45:34 +00:00
Sébastien Theys 425f197f16 [IMP] tools,base,*: remove intermediary image functions
* = hr, im_livechat, mail, payment, purchase, web, web_editor, web_unsplash,
	website_profile, website_slides

Since the merge of all image tools into one function, the intermediary functions
are not needed anymore.

task-1958000
PR: #31811
2019-04-29 13:45:34 +00:00
Sébastien Theys d870877967 [IMP] tools,base,web,website_*: keep image ratio on resize
* = website_partner, website_profile, website_sale, website_slides

Before
======

Since commit: 2e3848b394

The images that are resized have additional borders if the target ratio is
different than the image ratio. Those borders are transparent if the image
format supports it, and are white otherwise.

With that current solution, if the background where the image is displayed is
another color than white, it is looking really bad.

Moreover, most images are stored resized like this, so it is not even possible
to decide if it should have borders or not depending on the context, the
original image and ratio is forever lost.

It is also inconsistent because if the image is already smaller than the target
size then it doesn't include borders. In that case it keeps the original ratio
instead of the target ratio. So it isn't even guaranteed that the target
ratio is going to be respected.

After
=====

This commit will solve all of those problems by always keeping the ratio of the
original image.

This implies the views should be taking care of adding borders when necessary.

task-1958000
PR: #31811
2019-04-29 13:45:03 +00:00
Sébastien Theys b230114fcf [IMP] web,website_profile,website_slides: rename content and base64
There is a mix in the variable names: before this commit, what is called
`image_base64` is actually not base64 encoded, and what is called `content` is
actually base64 encoded.

The variables have been renamed to avoid further confusion.

task-1958000
PR: #31811
2019-04-29 13:45:03 +00:00
sri-odoo@stefanorigano@dbeguin
8ecff655e0 [IMP] website_profile: merge ranks/badges pages
Merge ranks & badges pages. This commit adapt the final page
layout, controllers and templates.

Added the badge category filter. If used in url parameter, hide ranks and show
only the badge part of the page, filtered on matching badge_category.

Task ID : 1941250
PR #31567

Co-authored-by: @stefanorigano
Co-authored-by: @dbeguin
2019-03-19 13:03:40 +00:00
David Beguin d7cc1520f4 [IMP] website_profile, gamification, : add search bar in all users page
This commit adds the search bar in 'All users' page in order to filter on name or company name.
To be able to keep the position, a non stored computed field has been added on res_users
to get the position depending on the user's karma.

The podium (top 3 users) is now displayed only if there is no search applied and if the page = 1
because it has no sens anymore in other cases.

Special thanks to @jem-odoo who helped me finding smart solution for position computing.

Task ID : 1943788
PR #31321
2019-03-15 14:59:12 +00:00
David Beguin fb40c6bf60 [IMP] website(_profile,_forum,_slides): move validation email to profile and use in forum and elearning
Email validation was necessary on the forum to be able to begin to use the forum
(ask or answer questions, vote, etc..)

As the new elearning also uses karma since 705376a982,
the email validation is now also necessary in the eLearning platform.

This is why this commit is moving the email validation process to website_profile
and extend website_slides (eLearning) and website_forum to use this feature.

In function of where the user asked to send him the validation email,
the user is redirected on the forum or on the elearning when he clicks on
'Validate my account' in the received 'email validation' email.

Task ID : 1943788
PR #31321
2019-03-15 14:58:28 +00:00
David Beguin 6091062e66 [IMP] website_(profile, slides): add custom pager to show on all users / courses pages
If there are too much users to show on the page and to avoid performance
issues, a pager is now applied on the all users page.

A new pager based on website_pager is added in order to ease the navigation
through the potential high number of pages. 'Go to first page' and 'Go to last
page' buttons have been added and the design of the pager have been adapted
to be more integrated into the new eLearning platform.

Also add the pager on the slide page if search category is applied. The pager
was already computed in the controller but not displayed.

Task ID : 1946160
PR #31697
2019-03-08 11:14:45 +00:00
David Beguin 9f969fbcb0 [FIX] website_profile: always give access to user to his own profile
The main condition to be able to see a profile is that the user we want to
see the profile is website_published.
But if a new user sign up and wants to access his own profile, he must
get access to his own profile, even if he is (not yet) website_published.

Commit linked to task ID 1941250 and PR #31279.
2019-02-21 06:57:05 +00:00
David Beguin 2c01452d4b [IMP] website(_profile,_forum,_survey) : redesign website all_users page
As the eLearning (website_slides) is also using website_profile users,
the All Users page is moved from website_forum to website_profile, to be
useable in both forum and eLearning.

This page displays also the number of karma point, badges and certificates
of each user.

The users are sorted by their karma points and the first 3 users are
promoted on a podium.

Use span instead of b tag in profile page

Task ID : 1922159
PR #31109
2019-02-18 15:15:06 +00:00
Thibault Delavallée 1bb7b242c0 [FIX] website_profile, website_slides: clean user avatar controller and add one for slides
Purpose of this commit is to

 * clean user avatar controller and its calls;
 * extract default image computation;
 * add a controller to get slide image even when not having access to the slide
   as all slide name and images are displayed even if not available to the
   current user;

Commit linked to task ID 1941250 and PR #31133.
2019-02-15 17:45:41 +00:00
Thibault Delavallée 00bf73cd4a [IMP] website_profile: add a specific route to access avatar of users
Purpose of this commit is to give a specific route to access users image
used as avatar in profile and various frontend applications.

Indeed current web/image controller basically checks record access rights
with current user. However in some cases we want to display user avatars
even if current user cannot read user records, which is generally the case.
Indeed res.users is a private and technical model.

To solve that issue we add a controller for avatar. Basically published
and frontend active user avatars are available.

This commit is linked to task ID 1936153 and PR #30770.
2019-02-15 09:57:46 +00:00
jem-odoo ec212de5c7 [IMP] gamification,forum: remove deprecated alert when sending badge
Since 56645335b7, when a user get a badge,
an email is sent. The subtype is not used anymore, so the alert
mecanism in forum to display a message to the user to show him
his new badges can not work.
This commit removes this dead code.
Task-1922159
2019-02-14 09:24:10 +00:00
David Beguin ff870099c5 [ADD] website_profile : add profile page template for website modules
Move Profile part from website_forum into this module in order to be usable in other modules
(like website_slides) that will depend of this module.

Applies gamification.ranks on website_profile page. Show the current rank and the next rank
but also the progression until the next rank. Adds also an 'about rank' page to allow users to know
more about available ranks.

The goal here is to make the profile page more modular and to allow other modules to add informations
or modify easily link or part of profile page in order to be specifically contextualised
for the module in question.

Task ID : 1922159
PR #30988
2019-02-14 08:30:29 +00:00