diff --git a/user/forms.py b/user/forms.py index 2dd7e6b..ec3f17f 100644 --- a/user/forms.py +++ b/user/forms.py @@ -7,9 +7,9 @@ class SettingsForm(forms.Form): ) erasure = forms.ChoiceField( choices = [(0, 'Not erasure'), - ('erasure1', 'Erasure easy'), - ('erasure2', 'Erasure mediom'), - ('erasure3', 'Erasure hard'), + ('basic', 'Erasure Basic'), + ('baseline', 'Erasure Baseline'), + ('enhanced', 'Erasure Enhanced'), ], ) diff --git a/user/templates/settings.ini b/user/templates/settings.ini index 390b650..217e993 100644 --- a/user/templates/settings.ini +++ b/user/templates/settings.ini @@ -1,3 +1,6 @@ +[settings] +url = {{ url }} token = {{ token }} -erasure = {{ erasure }} -legacy = False \ No newline at end of file +erase = {{ erasure }} +legacy = false +# path = /path/to/save \ No newline at end of file diff --git a/user/templates/settings_legacy.ini b/user/templates/settings_legacy.ini new file mode 100644 index 0000000..6407090 --- /dev/null +++ b/user/templates/settings_legacy.ini @@ -0,0 +1,6 @@ +[settings] +url = {{ url }} +token = {{ token }} +legacy = true +# erase = {{ erasure }} +# path = /path/to/save \ No newline at end of file diff --git a/user/views.py b/user/views.py index 36093b8..750b9a3 100644 --- a/user/views.py +++ b/user/views.py @@ -1,3 +1,5 @@ +from decouple import config +from django.urls import reverse from django.http import HttpResponse from django.shortcuts import render from django.utils.translation import gettext_lazy as _ @@ -25,8 +27,17 @@ class SettingsView(DashboardView, FormView): form_class = SettingsForm def form_valid(self, form): - form.devices = self.get_session_devices() - data = render(self.request, "settings.ini", form.cleaned_data) + cleaned_data = form.cleaned_data.copy() + 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['Content-Disposition'] = 'attachment; filename={}'.format("settings.ini") return response