Skip to content
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

[11.0] website menu permission easy maintain #658

Merged

Conversation

NL66278
Copy link

@NL66278 NL66278 commented Aug 12, 2019

This consists of two parts.

  • a migration done by @gfcapalbo of the 10.0 module by @simahawk
  • an adaption to ensure just installing the module does not take away access rights for many existing users. Only after consciously setting groups on a menu well permissions change. To edit this easily, the editing of website menu's has been added to the website configuration menu.

The record-rule itself remains the same. Basically as also in the PR made for 8.0 by @hbrunn for this purpose.

@hbrunn hbrunn added this to the 11.0 milestone Aug 13, 2019
@hbrunn
Copy link
Member

hbrunn commented Aug 13, 2019

looks good, and when you've changed the tests I think it will be green too. Let's then finally merge a version of this, the 8 and 10 version is hanging around like forever already

@NL66278
Copy link
Author

NL66278 commented Aug 14, 2019

For some reason travis cannot setup database connection:

Creating instance:

createdb: could not connect to database template1: could not connect to server: No such file or directory

	Is the server running locally and accepting

	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Using previous openerp_template database.

@hbrunn
Copy link
Member

hbrunn commented Aug 14, 2019

you need to update this branch's .travis.yml. Best adapt to the current version in MQT - the crucial part here is to set a postgres version

@NL66278 NL66278 force-pushed the 11.0-website_menu_permission-easy-maintain branch from 89bc6fc to 7777985 Compare August 14, 2019 14:55
@NL66278 NL66278 changed the title [WIP][11.0] website menu permission easy maintain [11.0] website menu permission easy maintain Aug 14, 2019

#. Go to Website ==> Configuration ==> Website menu's.
#. Edit the menu that you want to limit to certain groups, and add
the names of the groups that should have access.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explanation is confusing because:

  • In Website -> Configuration there are 2 different menu entries for the same model website.menu
  • You need developer mode in order to see "Website menu's" entry. The other entry "Menu" you can see without developer mode.

I think is enough one menu entry and not two.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have one menu entry for website menu's. And I am in developer mode. If you see a second option for website menu's can you check from what module that is installed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's runbot installing all modules from the repository. I see xmlid website_multi_theme.action_configure_menu_website

@NL66278 NL66278 force-pushed the 11.0-website_menu_permission-easy-maintain branch from 7777985 to 5377b63 Compare August 29, 2019 10:37
Copy link

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NL66278 @gfcapalbo thanks for taking care of this :)
Mostly ok, just some small things :)


class TestMenuPerm(test_common.TransactionCase):

def setUp(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use SavepointCase and move setUp to setUpClass and replace the env like this:

cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True, no_reset_password=True))

It's going to speed up tests a lot (actually we should use this approach for all tests 👨‍🏫 )

<record id="website_menu_access" model="ir.rule">
<field name="name">website_menu_permission group access</field>
<field name="model_id" ref="model_website_menu"/>
<field name="domain_force">['|',('group_ids','in', [g.id for g in user.groups_id]), ('group_ids','=',False)]</field>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one can use user.groups_id.ids instead of the loop

@NL66278
Copy link
Author

NL66278 commented Sep 30, 2019

@simahawk Changes done!

Copy link

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, can we squash?

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

1. Prevent just installing this module of making most menu's unavailable for logged in users;
2. Make menu's directly configurable from website settings, as not all menu's are linked to a page;
3. Use group_ids field in new website.menu form to edit groups.

With this commit, just installing this module will not change anything in existing permissions.

TODO: update tests and README.rst.
@NL66278 NL66278 force-pushed the 11.0-website_menu_permission-easy-maintain branch from a2f2cb8 to e4404f3 Compare September 30, 2019 14:40
@NL66278
Copy link
Author

NL66278 commented Sep 30, 2019

@simahawk I squashed my commits, so that leaves 2.

@simahawk
Copy link

simahawk commented Oct 1, 2019

@rafaelbn fine for you?
@NL66278 what's the plan for website_menu_by_user_status?
The original plan - from my POV - was to make it dependant on this one. Is this still the case?
There are a bunch of PRs that probably need some update or references https://github.com/OCA/website/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+status+

@NL66278
Copy link
Author

NL66278 commented Oct 1, 2019

@simahawk I think the module website_menu_by_user_status does not add really anything, that cannot be done with website_menu_permission. But for some people it might be easier to just have the choice betwee users that are logged in or not. So I think the ..user_status module could be rebased om --.permission, doing away with any overlaps. But that can be done/proposed after the current PR has been merged.

@simahawk
Copy link

simahawk commented Oct 1, 2019

@NL66278 yeah, that was the original plan, also to keep backward compat: *_status module should rely on this one and just have a flag that sets the groups automatically.

@simahawk
Copy link

simahawk commented Oct 1, 2019

/ocabot merge

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 11.0-ocabot-merge-pr-658-by-simahawk-bump-no, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Oct 1, 2019
Signed-off-by simahawk
@OCA-git-bot OCA-git-bot merged commit e4404f3 into OCA:11.0 Oct 2, 2019
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 35fd790. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants