@login_required
@require_http_methods(['GET', 'POST'])
def remove_member(request, group_slug, user_id):
 prof = get_object_or_404(GroupProfile, slug=group_slug)
 user = get_object_or_404(User, id=user_id)
 if (not _user_can_edit(request.user, prof)):
  raise PermissionDenied
 if (request.method == 'POST'):
  if (user in prof.leaders.all()):
   prof.leaders.remove(user)
  user.groups.remove(prof.group)
  msg = _('{user} removed from the group successfully!').format(user=user.username)
  messages.add_message(request, messages.SUCCESS, msg)
  return HttpResponseRedirect(prof.get_absolute_url())
 return render(request, 'groups/confirm_remove_member.html', {'profile': prof, 'member': user})

@ login_required @ require_http_methods ( [ 'GET' , 'POST' ] ) def remove_member ( request , group_slug , user_id ) : prof = get_object_or_404 ( GroupProfile , slug = group_slug ) user = get_object_or_404 ( User , id = user_id ) if ( not _user_can_edit ( request . user , prof ) ) : raise PermissionDenied if ( request . method == 'POST' ) : if ( user in prof . leaders . all ( ) ) : prof . leaders . remove ( user ) user . groups . remove ( prof . group ) msg = _ ( '{user} removed from the group successfully!' ) . format ( user = user . username ) messages . add_message ( request , messages . SUCCESS , msg ) return HttpResponseRedirect ( prof . get_absolute_url ( ) ) return render ( request , 'groups/confirm_remove_member.html' , { 'profile' : prof , 'member' : user } )
remove a member from the group .