user-panel #9
|
@ -7,9 +7,9 @@ class SettingsForm(forms.Form):
|
||||||
)
|
)
|
||||||
erasure = forms.ChoiceField(
|
erasure = forms.ChoiceField(
|
||||||
choices = [(0, 'Not erasure'),
|
choices = [(0, 'Not erasure'),
|
||||||
('erasure1', 'Erasure easy'),
|
('basic', 'Erasure Basic'),
|
||||||
('erasure2', 'Erasure mediom'),
|
('baseline', 'Erasure Baseline'),
|
||||||
('erasure3', 'Erasure hard'),
|
('enhanced', 'Erasure Enhanced'),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
[settings]
|
||||||
|
url = {{ url }}
|
||||||
token = {{ token }}
|
token = {{ token }}
|
||||||
erasure = {{ erasure }}
|
erase = {{ erasure }}
|
||||||
legacy = False
|
legacy = false
|
||||||
|
# path = /path/to/save
|
6
user/templates/settings_legacy.ini
Normal file
6
user/templates/settings_legacy.ini
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[settings]
|
||||||
|
url = {{ url }}
|
||||||
|
token = {{ token }}
|
||||||
|
legacy = true
|
||||||
|
# erase = {{ erasure }}
|
||||||
|
# path = /path/to/save
|
|
@ -1,3 +1,5 @@
|
||||||
|
from decouple import config
|
||||||
|
from django.urls import reverse
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
@ -25,8 +27,17 @@ class SettingsView(DashboardView, FormView):
|
||||||
form_class = SettingsForm
|
form_class = SettingsForm
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form.devices = self.get_session_devices()
|
cleaned_data = form.cleaned_data.copy()
|
||||||
data = render(self.request, "settings.ini", form.cleaned_data)
|
settings_tmpl = "settings.ini"
|
||||||
|
path = reverse("api:new_snapshot")
|
||||||
|
cleaned_data['url'] = self.request.build_absolute_uri(path)
|
||||||
|
|
||||||
|
if config("LEGACY", False):
|
||||||
|
cleaned_data['token'] = config.get('TOKEN_LEGACY', '')
|
||||||
|
cleaned_data['url'] = config.get('URL_LEGACY', '')
|
||||||
|
settings_tmpl = "settings_legacy.ini"
|
||||||
|
|
||||||
|
data = render(self.request, settings_tmpl, cleaned_data)
|
||||||
response = HttpResponse(data.content, content_type="application/text")
|
response = HttpResponse(data.content, content_type="application/text")
|
||||||
response['Content-Disposition'] = 'attachment; filename={}'.format("settings.ini")
|
response['Content-Disposition'] = 'attachment; filename={}'.format("settings.ini")
|
||||||
return response
|
return response
|
||||||
|
|
Loading…
Reference in a new issue