Compare commits

...

10 Commits

Author SHA1 Message Date
Jorge Pastor 38d31d42e8 max length 32 databaseuser 2023-11-24 02:23:54 +01:00
Jorge Pastor 7bf7518339 nextcloud size on cron 2023-11-24 02:23:54 +01:00
Jorge Pastor be039bbeeb fix resource agragation otion last value query 2023-11-24 02:23:54 +01:00
Jorge Pastor 465862e444 change update user password on mysql 2023-11-24 02:23:54 +01:00
jorgepastorr 38a671a18a add icon nextcloud on SAS 2023-11-24 02:23:54 +01:00
jorgepastorr bf84b27e8a fix last nyapa with target_server on SAS 2023-11-24 02:23:54 +01:00
jorgepastorr a41243bc70 nyapa hiden target server in SAS 2023-11-24 02:23:54 +01:00
jorgepastorr b2d335879a fix webappUser create user with groups dont exist 2023-11-24 02:23:54 +01:00
jorgepastorr 87ee955531 fix problem with sftpuser onnSAslist and webalizer 2023-11-24 02:23:54 +01:00
jorgepastorr 8ff8676773 delete local bokworm settiongs 2023-11-24 02:23:54 +01:00
11 changed files with 55 additions and 28 deletions

View File

@ -89,20 +89,12 @@ class MySQLUserController(ServiceController):
if user.type != user.MYSQL:
return
context = self.get_context(user)
if user.target_server.name != "mysql.pangea.lan":
self.append(textwrap.dedent("""\
# Create user %(username)s
mysql -e 'CREATE USER IF NOT EXISTS "%(username)s"@"%(host)s";'
mysql -e 'ALTER USER IF EXISTS "%(username)s"@"%(host)s" IDENTIFIED BY PASSWORD "%(password)s";'\
""") % context
)
else:
self.append(textwrap.dedent("""\
# Create user %(username)s
mysql -e 'CREATE USER "%(username)s"@"%(host)s";' || true # User already exists
mysql -e 'UPDATE mysql.user SET Password="%(password)s" WHERE User="%(username)s";'\
""") % context
)
self.append(textwrap.dedent("""\
# Create user %(username)s
mysql -e 'CREATE USER IF NOT EXISTS "%(username)s"@"%(host)s";'
mysql -e 'ALTER USER IF EXISTS "%(username)s"@"%(host)s" IDENTIFIED BY PASSWORD "%(password)s";'\
""") % context
)
def delete(self, user):
if user.type != user.MYSQL:

View File

@ -58,12 +58,12 @@ class DatabaseForm(forms.ModelForm):
class DatabaseCreationForm(DatabaseUserCreationForm):
username = forms.CharField(label=_("Username"), max_length=16,
username = forms.CharField(label=_("Username"), max_length=32,
required=False, validators=[validators.validate_name],
help_text=_("Required. 16 characters or fewer. Letters, digits and "
help_text=_("Required. 32 characters or fewer. Letters, digits and "
"@/./+/-/_ only."),
error_messages={
'invalid': _("This value may contain 16 characters or fewer, only letters, numbers and "
'invalid': _("This value may contain 32 characters or fewer, only letters, numbers and "
"@/./+/-/_ characters.")})
user = forms.ModelChoiceField(required=False, queryset=DatabaseUser.objects)

View File

@ -32,7 +32,12 @@ class Last(Aggregation):
verbose_name = _("Last value")
def filter(self, dataset, date=None):
dataset = dataset.order_by('object_id', '-id').distinct('monitor')
# dataset = dataset.order_by('object_id', '-id').distinct('monitor')
now = timezone.now()
epoch = now - datetime.timedelta(minutes=2)
dataset = dataset.filter( created_at__range=(epoch, now ))
if date is not None:
dataset = dataset.filter(created_at__lte=date)
return dataset

View File

@ -19,7 +19,7 @@ class NextCloudAPIMixin(object):
def validate_response(self, response):
request = response.request
context = (request.method, response.url, request.body, response.status_code)
sys.stderr.write("%s %s '%s' HTTP %s\n" % context)
# sys.stderr.write("%s %s '%s' HTTP %s\n" % context)
if response.status_code != requests.codes.ok:
raise RuntimeError("%s %s '%s' HTTP %s" % context)
root = ET.fromstring(response.text)

View File

@ -700,7 +700,6 @@ class UNIXUserControllerNewServers(ServiceController):
def get_groups(self, user):
groups = []
if user.is_main:
groups = list(user.account.systemusers.exclude(username=user.username).values_list('username', flat=True))
groups.append("main-systemusers")
return groups
@ -812,7 +811,8 @@ class WebappUserController(ServiceController):
def get_groups(self, user):
groups = []
groups = list(user.account.systemusers.exclude(username=user.username).values_list('username', flat=True))
# groups = list(user.account.systemusers.exclude(username=user.username).values_list('username', flat=True))
groups.append(user.account.main_systemuser.username)
groups.append("webapp-systemusers")
return groups

View File

@ -6,5 +6,4 @@ from orchestra.admin.utils import admin_date
display_last_run_at = admin_date('last_run_at', short_description=_("Last run"))
PeriodicTaskAdmin.list_display = ('__unicode__', display_last_run_at, 'total_run_count', 'enabled')
PeriodicTaskAdmin.list_display = ('__unicode__', display_last_run_at, 'total_run_count', 'enabled')

View File

@ -23,6 +23,11 @@ class StaticApp(AppType):
return ('static', self.instance.get_path())
class WebalizerAppform(PluginDataForm):
def __init__(self, *args, **kwargs):
super(WebalizerAppform, self).__init__(*args, **kwargs)
self.fields['sftpuser'].widget = forms.HiddenInput()
class WebalizerApp(AppType):
name = 'webalizer'
verbose_name = "Webalizer"
@ -32,7 +37,8 @@ class WebalizerApp(AppType):
"Statistics will be collected once this app is mounted into one or more Websites.")
icon = 'orchestra/icons/apps/Stats.png'
option_groups = ()
form = PluginDataForm
# form = PluginDataForm
form = WebalizerAppform
def get_directive(self):
webalizer_path = os.path.join(self.instance.get_path(), '%(site_name)s')

View File

@ -25,11 +25,9 @@ class PluginForm(forms.ModelForm):
class PluginDataForm(PluginForm):
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):
super().__init__(*args, **kwargs)
self.fields['sftpuser'].widget = forms.HiddenInput()
if self.instance:
for field in self.declared_fields:
initial = self.fields[field].initial
@ -101,8 +99,11 @@ class ExtendedPluginDataForm(PluginDataForm):
widget=forms.PasswordInput,
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):
super(ExtendedPluginDataForm, self).__init__(*args, **kwargs)
self.fields['sftpuser'].widget = forms.HiddenInput()
if self.instance.id is not None:
self.fields['username'].widget = forms.HiddenInput()
self.fields['password1'].widget = forms.HiddenInput()

View File

@ -104,6 +104,5 @@ WEB_SERVERS = Setting('WEBAPPS_SERVERS', (
'web-ng',
'web-11.pangea.lan',
'web-12.pangea.lan',
'bookworm',
)
)
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -0,0 +1,25 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="225.000000pt" height="225.000000pt" viewBox="0 0 225.000000 225.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,225.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M1020 2240 c-441 -44 -804 -329 -953 -747 -80 -222 -80 -515 0 -736
117 -328 364 -574 690 -690 221 -80 515 -80 736 0 382 136 658 457 733 850 22
114 22 302 0 416 -75 393 -352 714 -733 850 -134 48 -328 72 -473 57z m237
-832 c59 -28 122 -90 147 -145 l18 -41 32 35 c99 114 273 87 337 -52 76 -163
-102 -341 -266 -266 -22 10 -54 34 -71 54 l-32 35 -18 -41 c-25 -56 -87 -117
-149 -147 -73 -35 -180 -34 -256 1 -64 30 -129 93 -154 149 l-17 38 -32 -35
c-99 -114 -273 -87 -337 52 -76 163 102 341 266 266 22 -10 54 -34 71 -54 l32
-35 17 38 c67 149 262 219 412 148z"/>
<path d="M1045 1294 c-126 -66 -142 -234 -30 -320 65 -49 170 -45 232 9 44 38
63 82 63 141 0 111 -75 186 -187 186 -26 0 -61 -7 -78 -16z"/>
<path d="M590 1180 c-12 -12 -20 -33 -20 -55 0 -45 29 -75 73 -75 51 0 77 24
77 71 0 50 -27 79 -75 79 -22 0 -43 -8 -55 -20z"/>
<path d="M1550 1182 c-16 -13 -22 -29 -22 -57 0 -48 28 -75 78 -75 45 0 74 30
74 75 0 45 -29 75 -74 75 -19 0 -44 -8 -56 -18z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB