diff --git a/user/forms.py b/user/forms.py
new file mode 100644
index 0000000..2dd7e6b
--- /dev/null
+++ b/user/forms.py
@@ -0,0 +1,20 @@
+from django import forms
+
+
+class SettingsForm(forms.Form):
+ token = forms.ChoiceField(
+ choices = []
+ )
+ erasure = forms.ChoiceField(
+ choices = [(0, 'Not erasure'),
+ ('erasure1', 'Erasure easy'),
+ ('erasure2', 'Erasure mediom'),
+ ('erasure3', 'Erasure hard'),
+ ],
+ )
+
+ def __init__(self, *args, **kwargs):
+ tokens = kwargs.pop('tokens')
+ super().__init__(*args, **kwargs)
+ tk = [(str(x.token), x.tag) for x in tokens]
+ self.fields['token'].choices = tk
diff --git a/user/templates/panel.html b/user/templates/panel.html
index ca27036..8686062 100644
--- a/user/templates/panel.html
+++ b/user/templates/panel.html
@@ -12,9 +12,16 @@
{% endblock %}
diff --git a/user/templates/settings.html b/user/templates/settings.html
new file mode 100644
index 0000000..cf93776
--- /dev/null
+++ b/user/templates/settings.html
@@ -0,0 +1,32 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+
+{% load django_bootstrap5 %}
+
+{% endblock %}
diff --git a/user/templates/settings.ini b/user/templates/settings.ini
new file mode 100644
index 0000000..390b650
--- /dev/null
+++ b/user/templates/settings.ini
@@ -0,0 +1,3 @@
+token = {{ token }}
+erasure = {{ erasure }}
+legacy = False
\ No newline at end of file
diff --git a/user/urls.py b/user/urls.py
index da4e507..f9e6246 100644
--- a/user/urls.py
+++ b/user/urls.py
@@ -5,4 +5,5 @@ app_name = 'user'
urlpatterns = [
path("panel/", views.PanelView.as_view(), name="panel"),
+ path("settings/", views.SettingsView.as_view(), name="settings"),
]
diff --git a/user/views.py b/user/views.py
index e0a195a..36093b8 100644
--- a/user/views.py
+++ b/user/views.py
@@ -1,6 +1,14 @@
+from django.http import HttpResponse
+from django.shortcuts import render
from django.utils.translation import gettext_lazy as _
from django.views.generic.base import TemplateView
from dashboard.mixins import DashboardView
+from django.views.generic.edit import (
+ FormView,
+)
+
+from user.forms import SettingsForm
+from api.models import Token
class PanelView(DashboardView, TemplateView):
@@ -8,3 +16,24 @@ class PanelView(DashboardView, TemplateView):
title = _("User")
breadcrumb = "User / Panel"
subtitle = "User panel"
+
+
+class SettingsView(DashboardView, FormView):
+ template_name = "settings.html"
+ title = _("Download Settings")
+ breadcrumb = "user / workbench / settings"
+ form_class = SettingsForm
+
+ def form_valid(self, form):
+ form.devices = self.get_session_devices()
+ data = render(self.request, "settings.ini", form.cleaned_data)
+ response = HttpResponse(data.content, content_type="application/text")
+ response['Content-Disposition'] = 'attachment; filename={}'.format("settings.ini")
+ return response
+
+ def get_form_kwargs(self):
+ tokens = Token.objects.filter(owner=self.request.user)
+ kwargs = super().get_form_kwargs()
+ kwargs['tokens'] = tokens
+ return kwargs
+