better group creation form logic and placement

This commit is contained in:
Hugh Rundle 2021-09-27 16:39:12 +10:00
parent 0ccd54b05a
commit 493ed14f34
2 changed files with 2 additions and 3 deletions

View file

@ -24,7 +24,7 @@
{% block panel %}
<section class="block">
<form name="create-group" method="post" action="{% url 'user-groups' request.user.username %}" class="box is-hidden" id="create_group">
<form name="create-group" method="post" action="{% url 'user-groups' 'empty_arg' %}" class="box is-hidden" id="create_group">
<header class="columns">
<h3 class="title column">{% trans "Create group" %}</h3>
<div class="column is-narrow">

View file

@ -69,10 +69,9 @@ class UserGroups(View):
# pylint: disable=unused-argument
def post(self, request, username):
"""create a user group"""
user = get_user_from_username(request.user, username)
form = forms.GroupForm(request.POST)
if not form.is_valid():
return redirect("user-groups")
return redirect(request.user.local_path + "groups")
group = form.save()
# add the creator as a group member
models.GroupMember.objects.create(group=group, user=request.user)