-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD] basic modules + proper README #1
Conversation
need to fix some issues |
1 similar comment
website_cms/README.rst
Outdated
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/CMS/issues>`_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong url
website_cms/README.rst
Outdated
|
||
Read the `contributors list`_ | ||
|
||
.. _contributors list: ./AUTHORS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a new guideline? Don't you prefer a contributors list per addon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, follow OCA guideline for contributors, because this URL doesn't work when you are reading this README in Odoo Apps section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the guidelines.
website_cms/README.rst
Outdated
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https x3
website_cms/ROADMAP.rst
Outdated
* Introduce portlets for sidebar elements | ||
* Add "collections" to fetch contents from the whole website (eg: "News from 2016") | ||
* Improve test coverage | ||
* Default theme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't roadmaps better per addon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pedrobaeza asked me for that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are needed, @yajo. A general one in the README of the repository to see the goal of it, and a specific roadmap inside the module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally see this as a maintenance problem. I would definitely never know to look here, or update here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems more a maintenance burden than a help to put this file, but nevermind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we instead utilize the Wiki for the overall roadmap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or better an issue with check boxes
website_cms/__init__.py
Outdated
@@ -0,0 +1,6 @@ | |||
# -*- coding: utf-8 -*- | |||
# © <YEAR(S)> <AUTHOR(S)> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing (and in other places, but I'll apply DRY)
_description = "A mixin for protecting website content" | ||
# admin groups that bypass security checks | ||
_admin_groups = ( | ||
'base.group_website_publisher', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use perms, not groups
Bypass if: | ||
|
||
* you are super-user | ||
* you are in a group listed in `_admin_groups` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you know...
return True | ||
|
||
# obj comes w/ a temporary env, | ||
# w/ uid beeing an instance of ir_http.RequestUID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
being
# which is not suitable for std ORM operations. | ||
# Let's make sure we get the right user here! | ||
if request.session.uid: | ||
_obj = obj.with_env(self.env(user=request.session.uid)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obj.sudo(request.session.uid)
Disclaimer: yes, we could use `ir.rule`s for this | ||
but since we want the end user to select a group | ||
easily without having to get in touch w/ rules, | ||
we chosed this way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the group is attached to some record, then you can add a ir.rule like [("somefield", "in", user.group_id)]
and remove lots of code
"GROUP BY {ob_col}" | ||
).format(ob_col=ob_col, | ||
relation=relation, | ||
group_col=group_col) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 SQL injection flaw.
website_cms/security/groups.xml
Outdated
@@ -0,0 +1,24 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<openerp> | |||
<data> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<odoo>
website_cms/templates/assets.xml
Outdated
@@ -0,0 +1,16 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<openerp> | |||
<data> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<odoo>
website_cms/templates/form.xml
Outdated
@@ -0,0 +1,134 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<openerp> | |||
<data> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<odoo>
website_cms/templates/form.xml
Outdated
See http://select2.github.io/select2/#initSelection --> | ||
<input type="text" name="tag_ids" class="form-control js_select2" style="clear:both" | ||
t-att-data-can-create="is_cms_manager and 1 or None" | ||
placeholder="Tags" t-attf-data-init-value="#{tag_ids}" value="tags go here" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really want that value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, otherwise is not going to work, as commented a few lines above.
website_cms/templates/form.xml
Outdated
|
||
<div class="form-group mt32"> | ||
<div class="pull-right"> | ||
<a class="btn btn-default" t-att-href="request.httprequest.referrer">Cancel</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if no referrer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please remove website_cms_search/tests/__init__.py
website_cms/templates/layout.xml
Outdated
# we need this check here, since ir.ui.view (and potentially other models) | ||
# do not have `website_published` attribute that is used | ||
# by management actions for publishing/unpublishing contents. | ||
</t> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just put a comment, it gets stripped out in the final output.
website_cms/templates/menu.xml
Outdated
@@ -0,0 +1,48 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<openerp> | |||
<data> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
odoo
website_cms/templates/menu.xml
Outdated
|
||
<!-- edit / translate buttons have weird conditions: protect them better. | ||
For instance, the homepage controller overrides `editable` and `translatable` | ||
to allow only `bwi_website.group_homepage_manager` group to update it. --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what?
website_cms/templates/menu.xml
Outdated
<li class="edit edit-frontend ml16"> | ||
<a title="Edit metadata (name, description, etc)" class="btn btn-link btn-xs" | ||
t-att-href="website.cms_edit_link(main_object=main_object)"> | ||
<i class="fa fa-pencil-square-o" /> Metadata</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use <div>
for fontawesome icons.
The final result is the same, but <i>
tags get included in translations from v9 onwards. This way you will get a cleaner .pot
file later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you cannot do it for accessibility, see http://stackoverflow.com/questions/24360199/can-we-place-a-div-inside-an-a-tag-according-to-the-accessibility
I'll check which tag I can use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you have t-
attributes the element is ignored, see here. I think I can use t-ignore
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use t-translation="off"
instead.
website_cms/templates/menu.xml
Outdated
<li class="edit edit-backend" groups="website_cms.cms_manager"> | ||
<a title="Edit in backend (do everything trough backend)" class="btn btn-link btn-xs" | ||
t-att-href="website.cms_edit_backend_link(main_object=main_object)"> | ||
<i class="fa fa-pencil-square-o" /> Backend</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use div
AND tr.res_id=p.id | ||
AND tr.name like 'cms.page,%%' | ||
AND tr.state='translated' | ||
""".format(lang) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always use unicode strings for format.
if case_sensitive: | ||
sql_query += """ AND tr.value {like} %s""" | ||
else: | ||
sql_query += """ AND lower(tr.value) {like} %s""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you prefer to use the Query class.
order = 'published_date desc' | ||
case_sensitive = self._case_sensitive | ||
sql_query = self._get_query(lang, case_sensitive=case_sensitive) | ||
params = ['%{}%'.format(search_text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unicode here
page_ids = tuple(set([x[0] for x in res])) | ||
|
||
# limit = self._results_per_page | ||
# offset = (page - 1) * self._results_per_page |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💩
sql_query = self._get_query(lang, case_sensitive=case_sensitive) | ||
params = ['%{}%'.format(search_text) | ||
for x in xrange(sql_query.count('%s'))] | ||
request.env.cr.execute(sql_query, params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, probably above comments make no real sense in the way that... all of this makes no sense.
Did you know that the ORM already does all the translation stuff automatically? What you are doing here is basically the same as request.env["cms.page"].search(["|","|",("name", "ilike", search_text), ("description", "=", search_text), ("body", "ilike", search_text)])
?
BTW, why the case_sensitive
thing? Who would ever want a case sensitive search?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check this.
website_cms/CHANGES.rst
Outdated
@@ -0,0 +1,7 @@ | |||
CHANGELOG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be in README direct
website_cms/README.rst
Outdated
|
||
Read the `contributors list`_ | ||
|
||
.. _contributors list: ./AUTHORS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the guidelines.
website_cms/models/cms_page.py
Outdated
pages = self.search(domain, order=order) | ||
return pages | ||
|
||
def pager(self, total, page=1, step=10, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should simply drop this and use the default pager instead, which BTW is compatible with website_canonical_url
by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This are the changes commented with @simahawk in OCA Sprint in Belgium
- Make other views for common use cases, as a startup sample:
- Image/video gallery
- Related pages
- Move CMS Admin menu to Website Admin menu:
- Websites
- Websites: tree view over
website
object
- Websites: tree view over
- Content
- Menus: tree view over
website.menu
groupbywebsite_id
by default - Pages: tree view over
ir.ui.view
with domain[('page', '=', True)]
- Layouts: tree view over
ir.ui.view
with domain[('cms_view', '=', True)]
- Contents: tree view over
cms.page
- Menus: tree view over
- Websites
website_cms/README.rst
Outdated
|
||
Read the `contributors list`_ | ||
|
||
.. _contributors list: ./AUTHORS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, follow OCA guideline for contributors, because this URL doesn't work when you are reading this README in Odoo Apps section.
website_cms/.gitignore
Outdated
@@ -0,0 +1,5 @@ | |||
.DS_Store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use template gitignore https://github.com/OCA/maintainer-quality-tools/blob/master/sample_files/.gitignore
website_cms/AUTHORS
Outdated
@@ -0,0 +1 @@ | |||
* Simone Orsi at Camptocamp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this file and add to the contributors section of module readme
website_cms/CHANGES.rst
Outdated
@@ -0,0 +1,7 @@ | |||
CHANGELOG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this file, maintenance nightmare
website_cms/README.rst
Outdated
|
||
Documentation: TODO | ||
|
||
Premise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the template readme - https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst
Additionally, and IMO, describing features that Odoo lacks is not helpful and irrelevant. You should instead describe what this module does.
website_cms/README.rst
Outdated
|
||
Read the `contributors list`_ | ||
|
||
.. _contributors list: ./AUTHORS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed
website_cms/controllers/form.py
Outdated
if status_message: | ||
self.add_status_message(status_message) | ||
|
||
# def get_fields(self, writable_fields): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove useless code
website_cms/controllers/form.py
Outdated
self.before_post_action(parent=parent, **kw) | ||
# handle form submission | ||
values = self.load_defaults(parent, **kw) | ||
# TODO: handle errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this to roadmap
website_cms/controllers/form.py
Outdated
self._check_security(main_object) | ||
self.before_post_action(main_object=main_object, **kw) | ||
# handle form submission | ||
# TODO: handle errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add to roadmap
website_cms/controllers/form.py
Outdated
msg = { | ||
'type': 'warning', | ||
'title': 'Note:', | ||
'msg': _(u'No description for this page yet. ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why unicode?
website_cms/controllers/main.py
Outdated
template = view_item.view_id.key | ||
|
||
if not template: | ||
raise NotImplementedError("You must provide a template!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translate?
Admittedly only finished half the review, but I figured it would be worth submitting and coming back to in a bit |
website_cms/controllers/main.py
Outdated
|
||
@http.route('/cms/get_tags', type='http', | ||
auth="public", methods=['GET'], website=True) | ||
def tags_search(self, q='', l=25, **post): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can drop this controller method and use JSON-RPC API for searching tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that using JSON RPC will disallow the public user from using this application. This may be a hinderance to some usage, thus I would say we should probably leave the controller until I finish OCA/web#402
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right @lasley
} | ||
}, | ||
ajax: { | ||
url: '/cms/get_tags', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can drop this custom method and use JSON-RPC API for searching tags, as explained here: https://www.odoo.com/documentation/9.0/reference/javascript.html#high-level-api-calling-into-odoo-models
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same note re public user session
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
website_cms/tests/test_media.py
Outdated
# # published | ||
# # self.f2.website_published = True | ||
# # self.f2.public = True | ||
# # self.f2.invalidate_cache() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💩
website_cms/views/cms_page.xml
Outdated
<filter | ||
name="only_main" | ||
string="Only main" | ||
icon="terp-personal" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems legit
Well, the title it's self-explaining :)
TODO
if mimetype in VIDEO_TYPES
) or simply rely on categories mimetype setuplike
and dropformat
update_published
->toggle_published
to_embed_url
to methodis_image
andis_video
public_slug
attachment_ids
on cms pagepage_type and page_type.id or False
and alike: just return the browse object ->.id
return false if no obj, see also [ADD] basic modules + proper README #1 (comment)self.env.user.has_group('website_cms.cms_manager')
to check for actual read/write permission instead of checking for groups, see [ADD] basic modules + proper README #1 (comment)sudo
usage [ADD] basic modules + proper README #1 (comment).format
see [ADD] basic modules + proper README #1 (comment)website_cms_search
, see [ADD] basic modules + proper README #1 (comment)