Skip to content

Commit

Permalink
feat(config_management): Add button to groups ui for adding child group
Browse files Browse the repository at this point in the history
!17 #42
  • Loading branch information
jon-nfc committed Jun 3, 2024
1 parent 7fe1260 commit 55f0db2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
<div id="Children" class="tabcontent">
<h3>Child Groups</h3>

<input type="button" value="Add Child Group" onclick="window.location='{% url 'Config Management:_group_add_child' group.id %}';">

<table class="data">
<tr>
<th>Name</th>
Expand Down
1 change: 1 addition & 0 deletions app/config_management/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
path('group', GroupIndexView.as_view(), name='Groups'),
path('group/add', GroupAdd.as_view(), name='_group_add'),
path('group/<int:pk>', GroupView.as_view(), name='_group_view'),
path('group/<int:group_id>/child', GroupAdd.as_view(), name='_group_add_child'),
path('group/<int:pk>/delete', GroupDelete.as_view(), name='_group_delete'),

path('group/<int:group_id>/host', GroupHostAdd.as_view(), name='_group_add_host'),
Expand Down
17 changes: 15 additions & 2 deletions app/config_management/views/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def get_queryset(self):




class GroupAdd(OrganizationPermission, generic.CreateView):

fields = [
Expand All @@ -74,13 +73,27 @@ class GroupAdd(OrganizationPermission, generic.CreateView):

def get_initial(self):

return {
initial: dict = {
'organization': UserSettings.objects.get(user = self.request.user).default_organization
}

if 'group_id' in self.kwargs:

if self.kwargs['group_id']:

initial.update({'parent': self.kwargs['group_id']})

self.model.parent.field.hidden = True

return initial


def get_success_url(self, **kwargs):

if self.kwargs['group_id']:

return reverse('Config Management:_group_view', args=(self.kwargs['group_id'],))

return reverse('Config Management:Groups')


Expand Down

0 comments on commit 55f0db2

Please sign in to comment.