diff --git a/borgweb/borg/forms/__init__.py b/borgweb/borg/forms/__init__.py
index b5ecdb2..1d1bc58 100644
--- a/borgweb/borg/forms/__init__.py
+++ b/borgweb/borg/forms/__init__.py
@@ -1,4 +1,4 @@
-from .repoform import RepoForm
+from .repoform import RepoForm, ToggleVisibility
from .archiveform import ArchiveForm
from .errorform import ErrorForm
from .locationform import LocationForm
diff --git a/borgweb/borg/forms/repoform.py b/borgweb/borg/forms/repoform.py
index 445dcbf..c13097b 100644
--- a/borgweb/borg/forms/repoform.py
+++ b/borgweb/borg/forms/repoform.py
@@ -6,3 +6,7 @@ class RepoForm(forms.Form):
fingerprint = forms.CharField(label='Fingerprint')
location = forms.CharField(label='Location')
last_modified = forms.DateTimeField(label='Last Modified', input_formats=["%Y-%m-%dT%H:%M:%S.%z"])
+
+
+class ToggleVisibility(forms.Form):
+ label = forms.CharField(label='Label')
diff --git a/borgweb/borg/templates/borg/post/toggle.html b/borgweb/borg/templates/borg/post/toggle.html
new file mode 100644
index 0000000..fdb1319
--- /dev/null
+++ b/borgweb/borg/templates/borg/post/toggle.html
@@ -0,0 +1,14 @@
+
+
+
+
+ Toggle repo visibility
+
+
+
+
+
\ No newline at end of file
diff --git a/borgweb/borg/urls.py b/borgweb/borg/urls.py
index 1e299d5..43d885b 100644
--- a/borgweb/borg/urls.py
+++ b/borgweb/borg/urls.py
@@ -24,6 +24,7 @@ urlpatterns = [
# POST
path('post/repo', views.post_repo, name='post repo'),
+ path('post/toggle', views.toggle_visibility, name='toggle repo visibility'),
path('post/archive', views.post_archive, name='post archive'),
path('post/error', views.post_error, name='post error'),
path('post/location', views.post_location, name='post location'),
diff --git a/borgweb/borg/views/post.py b/borgweb/borg/views/post.py
index 9d473f4..54ac75f 100644
--- a/borgweb/borg/views/post.py
+++ b/borgweb/borg/views/post.py
@@ -5,7 +5,28 @@ from django.urls import reverse
from django.contrib.auth.decorators import permission_required
from django.core.cache import cache
from ..models import Repo, Label, Archive, Cache, Error, Location
-from ..forms import RepoForm, ArchiveForm, ErrorForm, LocationForm
+from ..forms import RepoForm, ArchiveForm, ErrorForm, LocationForm, ToggleVisibility
+
+
+@permission_required("borg.change_repo")
+def toggle_visibility(request):
+ if request.method == 'POST':
+ form = ToggleVisibility(request.POST)
+ if form.is_valid():
+ cdata = form.cleaned_data
+
+ label = get_object_or_404(Label, label=cdata['label'])
+
+ label.visible = not label.visible
+
+ label.save()
+ cache.clear()
+
+ return HttpResponseRedirect(reverse('index'))
+ else:
+ form = ToggleVisibility()
+
+ return render(request, 'borg/post/toggle.html', {'form': form})
@permission_required("borg.add_repo")
diff --git a/borgweb/borg/views/views.py b/borgweb/borg/views/views.py
index 6a63843..291f7b1 100644
--- a/borgweb/borg/views/views.py
+++ b/borgweb/borg/views/views.py
@@ -4,7 +4,7 @@ from ..models import Repo
def index(request):
- repo_list = Repo.objects.all()
+ repo_list = Repo.objects.filter(label__visible=True)
context = {
'repo_list': repo_list,