Commit Graph
278 Commits
Author SHA1 Message Date
Jeremy Kersten 665496fc5c [FIX] website_forum: fix 'submit a link' feature
The pooling of the title was wrong since P3 refactoring.
2018-02-15 16:01:45 +01:00
Christophe Simonis 10128fa7e8 [MERGE] forward port branch saas-16 up to dc2a6c6cd2 2017-10-20 19:27:04 +02:00
Goffin Simon cd21942ab8 [FIX] website_forum: 404 error message for empty question
When a empty question was posted in the forum, a 404 error was raised.

opw:76940
2017-10-16 09:53:11 +02:00
Jeremy Kersten 1b52b00d2a [IMP] website*: clean sitemap + add method to declare sitemap function.
Don't add useless routes or route that will return 404.
Improve generate function from ModelConverter to have a better management of
query_string.

Now we have an helper sitemap_qs2dom that will analyse the current route and
check if query string is plausible and if yes, generate a domain, when the
query_string don't seems to match the route, we return a Falsy domain.

Before this commit, if qs was /product/ipad, enumerate_page check for each
modelconverter of the route a name ilike '/product/ipad'.

Now we check all routes that contains product and one converter that match ipad
or routes that contains ipad and one converter that match product.

This commit a new way to declare the sitemap for a route.
    def sitemap_xx(env, rule, query_string):
        yield {'loc': '/my_url'}
    @http.route(..., sitemap=sitemap_xx)

    In this case, only the loc returned by this function will be in the sitemap
    for all rules.

    You can pass sitempa=False, if you don't want that route are into the sitemap
2017-09-27 21:33:49 +02:00
Christophe Simonis 017ee5eab3 [MERGE] forward port branch saas-17 up to 877e709871 2017-08-24 13:17:53 +02:00
Xavier Morel 3824b5dcc1 [FIX] P3: fix base64 and StringIO uses
* StringIO removed from stdlib, replace with io
* try to correctly handle BytesIO/StringIO (one is for bytes the other
  is for text)
* fix base64: Python 3 removed bytes-encoding and bytes-bytes
  codecs (via #encode) so replace all calls to str.encode('base64'),
  also b64encode is a bytes->bytes conversion so attempt to properly
  handle that

issue #8530
2017-08-20 23:25:54 +02:00
Xavier Morel 25df2352f5 [FIX] P3: / has become 'real division' in all cases 2017-08-19 02:34:22 +02:00
qsm-odoo 2972976962 [REF] web_editor, website, *: complete refactoring
* mass_mailing, payment, point_of_sale, portal, survey, web, web_tour,
  website_blog, website_crm_partner_assign, website_event,
  website_event_questions, website_form, website_forum, website_gengo,
  website_hr_recruitment, website_links, website_mail,
  website_mail_channel, website_mass_mailing, website_quote,
  website_sale, website_sale_options, website_slides, website_twitter

This commit reviews the whole "JS side" of the web_editor and website
apps. This is a first step to be able to improve them with new and
better functionnalities; this commit is not supposed to change any
visual behavior.

The main goal was to achieve a structure similar to the backend one.
Now, the frontend side also has a root widget (like the WebClient)
and all other widgets are attached to it one way or another. This allows
the benefits of using the 'trigger_up' functionnality for example.

As RPC are now mainly done with the `this._rpc` functionnality (being
possible thanks to the parent hierarchy), the frontend will also be
possible to test thanks to QUnit in a future update (besides the "text"
editor side which still requires a refactoring to be able to do that).

---

Here are some of the changes:

(-) conventions and documentation

The code has been updated to follow JS conventions and a lot of code has
been commented (around +2000 lines of comment). This also means that
lots of functions have been renamed to use camelCase or simply to make
their name understandable.
See https://github.com/odoo/odoo/wiki/Javascript-coding-guidelines.

(-) deprecated: web_editor.base

The "web_editor.base" module has been split and does not force the
modules which require it to wait for DOM ready anymore. This was indeed
slowing loading times, but also prevented to use some modules in some
contexts (see the LESS editor use in web_studio which is the subject of
another task).
Now the "editor context" can be got thanks to the "web_editor.context"
JS module with its "get" function.
The "web_editor.base" module should probably not be used anymore (see
its code and recent updates).

(-) new: web.dom_ready

If a JS module should wait for the DOM to be ready to be executed, a
new JS module has been created: "web.dom_ready". This should always
be used in a module which only want to instantiate stuff. Do not
extend (or worst, include) classes after DOM ready.

(-) website.website

The "website.website" module has been split. "website.website" does not
return anything useful anymore, it just initialize some miscellaneous
stuff, without waiting for the DOM to be ready. You might want to check
"website.utils", "website.content.compatibility" or `WebsiteRoot`. Also
`website.form` has been deleted (use `this._rpc`), so has been
`website.error`. `website.prompt` will be removed in a future update to
be replaced by `Dialog.prompt`.

(-) widgets are great

Many classes which were not widgets are now widgets. This allows them to
use the 'events', the 'xmlDependencies' and the 'this._rpc' features for
example. Here are some of the main ones:

- Snippet options: these were classes with a `$el` for the menu element
    and `$target` for the customized element. This is still the case
    but following standard `Widget` structure (one exception: using
    `this.$(...)` searches in the `$target` as before this update).

- Snippet animations: instead of class instances with a `$target`
    element which can be `start` and `stop`, these are now standard
    widgets which can be `start` and `destroy`. `this.$target` is
    an alias to `this.$el` for ease of compatibility.

- Snippet editors: instead of class instances in charge of an editor
    overlay, these are now widgets. Each "child" snippet editor is
    properly attached as a "child", which allows editors to communicate
    and to be properly destroyed.

(-) root widgets and website navbar

The frontend is different of the backend. In the backend, the page has
an empty <body/> element and all the components are instantiated from
parent to children (i.e. the `WebClient` is instantiated and is in
charge of instantiating the `ControlPanel`, etc). The frontend cannot
work like that on page loadings as they are way more frequent than in
the backend and we do not want them to flicker. A frontend page is
loaded as a <body/> element which already contains the website navbar
and its menus and the whole content page. JS code has to be "attached"
to these existing elements. This is possible thanks to the `RootWidget`
instances and the specialized `WebsiteRoot`, `IframeRoot` and
`WebsiteNavbar` (see code for details).

(-) lazy loading

No more (or at least a lot less) XML/JS has to be loaded on page
loading, thanks to the use of the `Widget.xmlDependencies` feature.
XML which have to be lazy loaded is loaded only on related Widget
instantiation if necessary, which allows to execute a lot of JS code
before the DOM is ready and to start many widgets on DOM ready (not
later). A visual benefit of this is clicking on the 'edit' button as
soon as it is possible: before this commit, this was sometimes not
doing anything as event handlers were not binded yet.

Still a possible exception: loading the session and locales. This may
be asynchronous stuff which is still required before widget
instantiations but this will be the subject of another task.

(-) deprecated code and code location

More than reviewing code and organizing it, many apparent dead code was
removed. More importantly, mislocated code was put in the right app.
This is the case for snippet animations which is a concept for website
apps but was defined in the web_editor app, or some translation concepts
which were part of website but should have been part of web_editor.

---

There are probably more things to say about this commit but I will let
the comments speak for those.
2017-08-16 11:04:14 +02:00
Thibault Delavallée 014b5c9f7c [MOV] website, http_routing: move (un)slug support to http_routing
Slug and unslug API is now available in http_routing. Indeed there is no
link to any website or any reason to not support slufigied URLs when
website is not installed. A new unslug_url method is added as a tool
coming from an embedded method from website. Doing it allows to have all
slug related methods defined at the same point.

Support of slug and unslug in qweb rendering is also moved directly in
http_routing version of ir_ui_view instead of website inheritance. This
is done in order to keep things coherent.

Some code from website about ModelConverter is also moved. Indeed both
versions of ir_http uses some kind of placeholder to store the uid
when converting urls to python. This commit unifies it by using the
website one directly in base to simplify the override.

This commit also updates all module importing slug. Enterprise modules
will have to be updated, see related commit.
2017-08-08 14:23:58 +02:00
Xavier Morel 9bd793e1b5 [FIX] P3: / has become 'real division' in all cases 2017-07-18 11:49:28 +02:00
Christophe Simonis 99c34c4119 [MERGE] forward port branch saas-16 up to 6f3eada2c3 2017-06-06 19:38:29 +02:00
Olivier Dony de38d0262b [MERGE] Forward-port 10.0 up to 76cd8d2558 2017-06-03 01:24:21 +02:00
Nicolas Lempereur b5aeaa910d [FIX] website_forum: archived forum -> no ask
An archived forum could still be posted in, something better should be
done in the next version (eg. website published present on a lot of
record type) but as of 10.0 just this improvement is done.

opw-745510
closes #17365
2017-06-02 11:07:19 +02:00
Xavier Morel 01e3514147 [FIX] P3: urllib, urllib2 and urlparse
In Python 3, all of these were "consolidated" under urllib(.request,
.parse, .errors) which is inconvenient.

Since we already have hard dependencies on requests and
werkzeug(.urls, which is a backport of Python 3's unicode-aware
urllib.parse) migrate *everything* to that.

A sticking point is urllib2.URLError, those were (mostly) replaced by
the slightly more general IOError which URLError extends.
2017-05-15 12:26:30 +02:00
xmo-odoo fffaf735f5 [FIX] P3: list -> iterable builtins (#16811)
In Python 3:

* various builtins and dict methods were changed to return
  view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
  removed altogether

This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).

Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.

issue #8530
2017-05-10 09:39:55 +02:00
Dhaval Panchal c8d0fd4a50 [IMP] website_forum: Change profile picture for forum users. 2016-11-02 11:11:27 +01:00
Christophe Simonis 235ed4b2c1 [MERGE] forward port branch saas-12 up to 9ad5f26 2016-08-20 18:08:19 +02:00
Thibault Delavallée 78797a4b17 [MIG] website_forum: migrate remaining message_post and update code accordingly 2016-08-10 15:48:09 +02:00
Thibault Delavallée c8a313d51e [IMP] various: use odoo for imports instead of openerp and update class names 2016-08-10 15:48:07 +02:00
Jérome Maes 8a399930f3 [REF] website_*: remove render method on website
Since saas-3, website controllers use `request.website.render`
to render the template of a web page. This was kept for retro
compatibility. It's time to stop using deprecated stuff.
Same for `_render` method on website.

'json' route don't use `request.render` since
`JsonRequest` has no `render` method.
2016-08-04 12:02:14 +02:00
Christophe Simonis eb83ab236f [MERGE] forward port branch saas-10 up to c956075 2016-08-03 15:29:57 +02:00
Christophe Simonis c956075f5f [MERGE] forward port branch 9.0 up to cadb481 2016-08-03 15:07:24 +02:00
fwi-odoo d4e813b873 [REF] web, *: change deprecated import openerp.addons.web.http to odoo.http
We also remove the mock in web as there is no need for it anymore.
2016-08-03 13:42:05 +02:00
Jeremy Kersten d1a160aa93 [FIX] website_forum: don't allow a user to submit 2 pending post simutaneously.
Before this commit, a user was able to post withtout limit new post.
They was added to the modarator queue.

Now we only support 1 post by user.

This commit is related to #12803
2016-08-01 12:54:58 +02:00
Jeremy Kersten f19d620ebe [FIX] website_forum: don't allow to post an empty question
Instead to post the empty question, now we redirect the end user to the question page with a warning.

This commit closes #12962
2016-07-29 17:29:25 +02:00
Christophe Simonis ac5023060c [MERGE] forward port of branch saas-10 up to 2f948c7 2016-06-08 12:19:23 +02:00
Christophe Simonis 30864b6d00 [MERGE] forward port of branch 9.0 up to 5419485 2016-06-03 11:29:49 +02:00
Christophe Simonis 5419485e72 [MERGE] forward port of branch saas-6 up to d5df729 2016-06-03 11:15:10 +02:00
Christophe Simonis d5df729294 [MERGE] forward port of branch 8.0 up to 2779d46 2016-06-03 11:07:56 +02:00
Martin Trigaux 30f06fd39e [FIX] website_forum: convert content of posted comment to plaintext
HTML content should be escaped before being sanitized. Any content (link, image,
code,...) that is acceptable in usual mail.message but should not be interprated
when posted on a comment of the forum.

Fixes #3737
2016-06-02 17:00:17 +02:00
Martin Trigaux e641ec7815 Revert "[FIX] website_forum: notification of comments like answers"
This reverts commit e32ba845de.

This commit is wrong as it had an undifined variable and was losing the content
of the comment anyway.

Fixes #12213
2016-05-30 12:05:49 +02:00
Martin Trigaux e32ba845de [FIX] website_forum: notification of comments like answers
Fixes #12096
2016-05-27 11:30:40 +02:00
Christophe Simonis 79976bd779 [MERGE] forward port of branch saas-10 up to 6e95659 2016-04-01 19:10:34 +02:00
Denis Ledoux 17f4d22594 [MERGE] forward port of branch saas-7 up to 2d2028a 2016-04-01 11:26:27 +02:00
Olivier Dony 5b5324cb9f [FIX] website_forum: avatar route now uses 128x128 image
Many users upload large images for their avatar
(multi-Mb files). This makes most forum pages
longer to load than necessary, and wastes bandwidth.

128x128 images (`image_medium` field) are sufficient
for displaying avatar pictures on posts and profiles.
2016-03-30 03:47:23 +02:00
Christophe Matthieu 00f01b8b1d [IMP] website_forum: remove le list of the user per badge
(6 minutes to load all avatar for some page, no sense to display all users)
2016-03-23 11:21:57 +01:00
Christophe Simonis d70fde0330 [MERGE] forward port of branch saas-7 up to cab5c48 2016-02-10 18:37:01 +01:00
Jeremy Kersten 5d14c2c0ff [FIX] website_forum: don't display user profile link in post when it is private
Return 404 for seo when profile is private.
2016-02-10 17:09:20 +01:00
Jeremy Kersten 5fe84da278 [FIX] website_forum: use placeholder for controller /avatar 2016-02-08 13:57:37 +01:00
Christophe Simonis 2611a8198e [MERGE] forward port of branch saas-7 up to e765569 2016-02-02 14:48:31 +01:00
Jeremy Kersten f39e5358bc [FIX] website_forum: decrease indexed pages which will return 404
Add filter in domain converter to remove some posts in sitemap.

Avoid to add in sitemap some pages that could not be read
by public user due to a karma restriction.
2016-02-01 12:16:43 +01:00
Christophe Simonis 5f997bc4ef [MERGE] forward port of branch saas-7 up to 7fa6f73 2016-01-12 16:11:28 +01:00
Jeremy Kersten e2925909b2 [FIX] website_forum: escape search by tag, quote char to search, don't create empty tag, only display alphanum first char in pager of tags, ... 2016-01-08 19:14:31 +01:00
Christophe Simonis 5f860a4433 [MERGE] forward port of branch saas-7 up to 31ce19b 2016-01-05 17:05:17 +01:00
Denis Ledoux 9c2836090f [FIX] website_forum: set a name for answers
When replying to a question,
there is no possibility to set a title (`name`)
in the answer form, there is no input for the title,
even if the controller `/reply` would accept it.

This revision sets a title for answers so:
 - The answers doesn't appear as `False` in the breadcrumb
 - The subject of the mail notifications sent
   for these answers are set with a meaningful title

opw-659279
2015-12-23 14:35:07 +01:00
Martin Trigaux a9ec2894de [MERGE] forward port of branch saas-6 up to 19fe77b 2015-12-01 08:41:52 +01:00
Thibault Delavallée fa015c4c2e [FIX] website_forum: edit post with tags
Tags are lost when editing a post as we handle the wrong parameter.
Editing a post should not erase its tags anymore.
2015-11-26 17:00:41 +01:00
jas 284d82623f [IMP] website_forum : tag update
It is now possible to follow tags in the forum app. When following tags you
will be notified for every new post linking this tag.

A small karma update is also performed. We now correctly use karma to retag
posts, and karma to create new tags.
2015-11-26 15:16:00 +01:00
Thibault Delavallée 007e217c54 [FIX] website_forum: new mail api
set_message_read has been removed from the mail api. It is replaced by
set_message_done. Thanks Lorenzo Battistini.
2015-11-23 11:01:57 +01:00
Leonardo Rochael Almeida 60af7cac02 [IMP] replace simplejson with stdlib json
The stdlib version of the json library is more recent than the 3.5.3
version we are pinning in `requirements.txt`

There is no reason to use it.

Closes #6940
2015-09-28 10:53:32 +02:00