Implement organization editing
This commit is contained in:
parent
8cab325f9f
commit
3d9cfd40b2
3 changed files with 19 additions and 1 deletions
|
@ -28,5 +28,6 @@ urlpatterns = [
|
||||||
path('users/<int:user_id>/edit/', views.edituser, name='edituser'),
|
path('users/<int:user_id>/edit/', views.edituser, name='edituser'),
|
||||||
path('users/<int:user_id>/delete/', views.deleteuser, name='deleteuser'),
|
path('users/<int:user_id>/delete/', views.deleteuser, name='deleteuser'),
|
||||||
path('organizations/<int:orga_id>/delete/', views.deleteorga, name='deleteorga'),
|
path('organizations/<int:orga_id>/delete/', views.deleteorga, name='deleteorga'),
|
||||||
|
path('organizations/<int:orga_id>/edit/', views.editorganization, name='editorganization'),
|
||||||
path('update', views.update, name='update')
|
path('update', views.update, name='update')
|
||||||
]
|
]
|
||||||
|
|
|
@ -518,6 +518,23 @@ def makeorganization(request):
|
||||||
|
|
||||||
return render(request, "manager/form.html", { "title": "Add Organization", "form": form })
|
return render(request, "manager/form.html", { "title": "Add Organization", "form": form })
|
||||||
|
|
||||||
|
@user_passes_test(is_superuser)
|
||||||
|
def editorganization(request, orga_id):
|
||||||
|
orga = get_object_or_404(Organization, id=orga_id)
|
||||||
|
if request.method == "POST":
|
||||||
|
form = OrgaForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
data = form.cleaned_data
|
||||||
|
orga.name = data["name"]
|
||||||
|
orga.userlimit = data["users"]
|
||||||
|
orga.save()
|
||||||
|
return redirect("/organizations/")
|
||||||
|
|
||||||
|
else:
|
||||||
|
form = OrgaForm(initial={ "name": orga.name, "users": orga.userlimit })
|
||||||
|
|
||||||
|
return render(request, "manager/form.html", { "title": "Change Organization", "form": form })
|
||||||
|
|
||||||
@user_passes_test(is_superuser)
|
@user_passes_test(is_superuser)
|
||||||
def makedevice(request):
|
def makedevice(request):
|
||||||
CADIR = "/etc/openvpn/ca/"
|
CADIR = "/etc/openvpn/ca/"
|
||||||
|
|
|
@ -148,7 +148,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td><div style="display:inline;">{{ orga.name }}</div></td>
|
<td><div style="display:inline;">{{ orga.name }}</div></td>
|
||||||
<td>{{ orga.users.all|length }}{% if orga.userlimit %}/{{ orga.userlimit }}{% endif %}</td>
|
<td>{{ orga.users.all|length }}{% if orga.userlimit %}/{{ orga.userlimit }}{% endif %}</td>
|
||||||
<td><a href="#"><i style="color: darkred;" onclick="askdeleteorga({{ orga.id }});" class="fas fa-trash-alt" title="Delete Organization"></i></a></td>
|
<td><a href="/organizations/{{ orga.id }}/edit"><i class="fas fa-edit" title="Edit Organization"></i></a> <a href="#"><i style="color: darkred;" onclick="askdeleteorga({{ orga.id }});" class="fas fa-trash-alt" title="Delete Organization"></i></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue