Skip to content

Commit

Permalink
confirm group membership ending
Browse files Browse the repository at this point in the history
  • Loading branch information
rouven0 committed Dec 2, 2024
1 parent c44f543 commit 648b959
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions web/blueprints/user/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,9 @@ def get_membership_or_404(id: int) -> Membership:
abort(404)
return membership

@bp.route('/<int:user_id>/end_membership/<int:membership_id>')
@access.require('groups_change_membership')

@bp.route("/<int:user_id>/end_membership/<int:membership_id>", methods=["GET", "POST"])
@access.require("groups_change_membership")
def end_membership(user_id: int, membership_id: int) -> ResponseReturnValue:
user = get_user_or_404(user_id)
membership = get_membership_or_404(membership_id)
Expand All @@ -573,6 +574,31 @@ def end_membership(user_id: int, membership_id: int) -> ResponseReturnValue:
flash(f"Gruppenmitgliedschaft {membership.id} gehört nicht zu Nutzer {user_id}!", 'error')
return abort(404)

form = FlaskForm()

Check warning on line 577 in web/blueprints/user/__init__.py

View check run for this annotation

Codecov / codecov/patch

web/blueprints/user/__init__.py#L577

Added line #L577 was not covered by tests

def default_response() -> ResponseReturnValue:
form_args = {

Check warning on line 580 in web/blueprints/user/__init__.py

View check run for this annotation

Codecov / codecov/patch

web/blueprints/user/__init__.py#L579-L580

Added lines #L579 - L580 were not covered by tests
"form": form,
"cancel_to": url_for("user.user_show", user_id=membership.user_id, _anchor="groups"),
"submit_text": "Beenden",
"actions_offset": 0,
}

return render_template(

Check warning on line 587 in web/blueprints/user/__init__.py

View check run for this annotation

Codecov / codecov/patch

web/blueprints/user/__init__.py#L587

Added line #L587 was not covered by tests
"generic_form.html",
page_title=(
"Mitgliedschaft {} für "
"{} beenden?".format(membership.group.name, membership.user.name)
),
membership_id=membership_id,
user=membership.user,
form=form,
form_args=form_args,
)

if not form.is_submitted():
return default_response()

Check warning on line 600 in web/blueprints/user/__init__.py

View check run for this annotation

Codecov / codecov/patch

web/blueprints/user/__init__.py#L599-L600

Added lines #L599 - L600 were not covered by tests

try:
remove_member_of(user, membership.group, current_user, starting_from(session.utcnow()))
except PermissionError:
Expand Down

0 comments on commit 648b959

Please sign in to comment.