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

confirm group membership ending #767

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 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:
Comment on lines +566 to 568
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add frontend tests for this.
This is not hard, just look at the existing ones.
Hit me up if you have any questions!

user = get_user_or_404(user_id)
membership = get_membership_or_404(membership_id)
Expand All @@ -573,6 +574,32 @@ 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()

def default_response() -> ResponseReturnValue:
form_args = {
"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(
"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()

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