hidden sftpuser in webalizer form

This commit is contained in:
jorgepastorr 2023-08-24 12:39:59 +02:00 committed by pedro
parent 8f84b4fee9
commit 9f50bcc672
2 changed files with 4 additions and 4 deletions

View file

@ -3,7 +3,7 @@ import os
from django import forms from django import forms
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from rest_framework import serializers from rest_framework import serializers
from orchestra.plugins.forms import ExtendedPluginDataForm from orchestra.plugins.forms import ExtendedPluginDataForm, PluginDataForm
from ..options import AppOption from ..options import AppOption
from . import AppType from . import AppType
@ -32,6 +32,7 @@ class WebalizerApp(AppType):
"Statistics will be collected once this app is mounted into one or more Websites.") "Statistics will be collected once this app is mounted into one or more Websites.")
icon = 'orchestra/icons/apps/Stats.png' icon = 'orchestra/icons/apps/Stats.png'
option_groups = () option_groups = ()
form = PluginDataForm
def get_directive(self): def get_directive(self):
webalizer_path = os.path.join(self.instance.get_path(), '%(site_name)s') webalizer_path = os.path.join(self.instance.get_path(), '%(site_name)s')

View file

@ -25,9 +25,11 @@ class PluginForm(forms.ModelForm):
class PluginDataForm(PluginForm): class PluginDataForm(PluginForm):
data = forms.CharField(widget=forms.HiddenInput, required=False) data = forms.CharField(widget=forms.HiddenInput, required=False)
target_server = forms.ModelChoiceField(queryset=Server.objects.filter(name__in=WEB_SERVERS),)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields['sftpuser'].widget = forms.HiddenInput()
if self.instance: if self.instance:
for field in self.declared_fields: for field in self.declared_fields:
initial = self.fields[field].initial initial = self.fields[field].initial
@ -99,11 +101,8 @@ class ExtendedPluginDataForm(PluginDataForm):
widget=forms.PasswordInput, widget=forms.PasswordInput,
help_text=_("Enter the same password as above, for verification.")) help_text=_("Enter the same password as above, for verification."))
target_server = forms.ModelChoiceField(queryset=Server.objects.filter(name__in=WEB_SERVERS),)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ExtendedPluginDataForm, self).__init__(*args, **kwargs) super(ExtendedPluginDataForm, self).__init__(*args, **kwargs)
self.fields['sftpuser'].widget = forms.HiddenInput()
if self.instance.id is not None: if self.instance.id is not None:
self.fields['username'].widget = forms.HiddenInput() self.fields['username'].widget = forms.HiddenInput()
self.fields['password1'].widget = forms.HiddenInput() self.fields['password1'].widget = forms.HiddenInput()