Skip to content

Commit

Permalink
add request.method post to view
Browse files Browse the repository at this point in the history
  • Loading branch information
mscanlan-git committed Nov 3, 2023
1 parent f5bf2ae commit a108095
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions physionet-django/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3121,13 +3121,14 @@ def event_invite_host(request, username):
"""
Gives the user permissions to be an event host
"""
try:
user = get_object_or_404(User, username=username)
group = Group.objects.get(name='Event Host')
user.groups.add(group)
user.save()
messages.success(request, f"{user} has been added to the Event Host group.")
except User.DoesNotExist:
messages.error(request, "User not found.")
if request.method == 'POST':
try:
user = get_object_or_404(User, username=username)
group = Group.objects.get(name='Event Host')
user.groups.add(group)
user.save()
messages.success(request, f"{user} has been added to the Event Host group.")
except User.DoesNotExist:
messages.error(request, "User not found.")

return redirect(reverse('user_management', args=[username]))

0 comments on commit a108095

Please sign in to comment.