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

Add orga setting 'require_duplicate_from' #2524

Merged
merged 9 commits into from
Jul 30, 2024

Conversation

reiterl
Copy link
Member

@reiterl reiterl commented Jul 12, 2024

Resolve #2507

@reiterl reiterl added feature Michelson projectname labels Jul 12, 2024
@reiterl reiterl added this to the 4.2 milestone Jul 12, 2024
@reiterl
Copy link
Member Author

reiterl commented Jul 12, 2024

@luisa-beerboom Please review.
Perhaps I need to forbid the meeting.create for committee admins, if the setting is set?

If enable_duplicate_from_mandatory is set, committee manager are not
allowed to create meetings, they need to user clone instead.
@reiterl reiterl changed the title Add orga setting 'enable_duplicate_from_mandatory' Add orga setting 'require_duplicate_from' Jul 15, 2024
@luisa-beerboom
Copy link
Member

luisa-beerboom commented Jul 15, 2024

Perhaps I need to forbid the meeting.create for committee admins, if the setting is set?

Correct, the committee admin should always use meeting.clone, if I've understood the issue correctly

@Elblinator
Copy link
Member

Some requirements were not documented and now need some implementing in this PR:
If the new setting is activated then....

  • A committee admin should not be allowed to turn meetings into templates/ remove them as templates
  • A committee admin should not be allowed to duplicate

@reiterl
Copy link
Member Author

reiterl commented Jul 22, 2024

If a cm is not allowed to duplicate a meeting ("meeting.clone") they cannot create a new meeting, because the
create a meeting from a template is a meeting.clone.
I suppose, a cm can only clone template meetings if duplicate from is required. Or do I miss s.th. ?

@Elblinator
Copy link
Member

If a cm is not allowed to duplicate a meeting ("meeting.clone") they cannot create a new meeting, because the create a meeting from a template is a meeting.clone. I suppose, a cm can only clone template meetings if duplicate from is required. Or do I miss s.th. ?

If that is possible then yes, only allow a cm to clone template meetings if the settings is active.

@reiterl
Copy link
Member Author

reiterl commented Jul 22, 2024

@luisa-beerboom I have added the two changes @Elblinator requested. (With docs and tests).
Please review.

@@ -202,3 +202,4 @@ This action doesn't allow for a meeting to be set as a template and have `locked
- Admins of the meeting can modify group D
- Users with CML `can_manage` or users with a OML of `can_manage_organization` can modify group E
- Only users with OML `superadmin` can modify group F
- Users need OML `can_manage_organization` to `set_as_template` if organization setting `require_duplicate_from` is set.
Copy link
Member

Choose a reason for hiding this comment

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

To keep the format, set_as_template should be it's own group

Copy link
Member Author

Choose a reason for hiding this comment

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

Now use a Group G for 'set_as_template'.

Comment on lines 85 to 95
organization = self.datastore.get(
ONE_ORGANIZATION_FQID, ["require_duplicate_from", "template_meeting_ids"]
)
if organization.get("require_duplicate_from"):
if not has_organization_management_level(
self.datastore,
self.user_id,
OrganizationManagementLevel.CAN_MANAGE_ORGANIZATION,
) and not instance["meeting_id"] in (
organization.get("template_meeting_ids") or []
):
Copy link
Member

Choose a reason for hiding this comment

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

Either combine the if-conditions using and (i.e. organization.get("require_duplicate_from") and not has_organization_management_level(self.datastore, self.user_id, OrganizationManagementLevel.CAN_MANAGE_ORGANIZATION) and not instance["meeting_id"] in (organization.get("template_meeting_ids") or [])) or do something like the following

Suggested change
organization = self.datastore.get(
ONE_ORGANIZATION_FQID, ["require_duplicate_from", "template_meeting_ids"]
)
if organization.get("require_duplicate_from"):
if not has_organization_management_level(
self.datastore,
self.user_id,
OrganizationManagementLevel.CAN_MANAGE_ORGANIZATION,
) and not instance["meeting_id"] in (
organization.get("template_meeting_ids") or []
):
if not instance["meeting_id"] in (
organization.get("template_meeting_ids") or []
):
organization = self.datastore.get(
ONE_ORGANIZATION_FQID, ["require_duplicate_from", "template_meeting_ids"], lock_result=False
)
if organization.get("require_duplicate_from") and not has_organization_management_level(
self.datastore,
self.user_id,
OrganizationManagementLevel.CAN_MANAGE_ORGANIZATION,
):

Copy link
Member Author

Choose a reason for hiding this comment

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

Use 'and' to combine the if-conditionals.

organization.get("template_meeting_ids") or []
):
raise ActionException(
"Committee manager cannot clone a non-template meeting, if duplicate-from is required."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Committee manager cannot clone a non-template meeting, if duplicate-from is required."
"Committee manager cannot clone a non-template meeting if duplicate-from is required."

Copy link
Member Author

Choose a reason for hiding this comment

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

Rm the comma

Comment on lines 231 to 242
organization = self.datastore.get(
ONE_ORGANIZATION_FQID, ["require_duplicate_from"]
)
if organization.get("require_duplicate_from"):
if set_as_template is not None and not has_organization_management_level(
self.datastore,
self.user_id,
OrganizationManagementLevel.CAN_MANAGE_ORGANIZATION,
):
raise ActionException(
"A meeting cannot be set as a template by a committee manager, if duplicate from is required."
)
Copy link
Member

Choose a reason for hiding this comment

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

see my comment in meeting/clone.py

Copy link
Member Author

Choose a reason for hiding this comment

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

Use 'and' to combine the if-conditionals and rm the comma.

Also a update of the meeting.update docs, use group G
@reiterl
Copy link
Member Author

reiterl commented Jul 23, 2024

I have worked on the changes for the CR. I hope, this is now okay. @luisa-beerboom pls review.

Copy link
Member

@luisa-beerboom luisa-beerboom left a comment

Choose a reason for hiding this comment

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

the datastore calls should not lock fields

@reiterl
Copy link
Member Author

reiterl commented Jul 29, 2024

Don't lock the fields of the two datastore calls, which get the organization.

@reiterl reiterl assigned luisa-beerboom and unassigned reiterl Jul 29, 2024
@Elblinator Elblinator added this pull request to the merge queue Jul 30, 2024
Merged via the queue into OpenSlides:main with commit 9c81ade Jul 30, 2024
6 checks passed
@reiterl reiterl deleted the make-duplicate-from-mandatory branch July 30, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Meeting.create: make duplicate from (optionally) mandatory
3 participants