fixes for 3.0

This commit is contained in:
Adolfo Gómez García 2019-12-23 12:31:36 +01:00
parent 52208d18ae
commit c8839ed2a5
9 changed files with 51 additions and 11 deletions

View File

@ -33,13 +33,14 @@
import logging
import typing
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext, ugettext_lazy as _
from uds.models import Authenticator
from uds.core import auths
from uds.REST import NotFound
from uds.REST.model import ModelHandler
from uds.core.util import permissions
from uds.core.ui import gui
from .users_groups import Users, Groups
@ -56,7 +57,7 @@ class Authenticators(ModelHandler):
# Custom get method "search" that requires authenticator id
custom_methods = [('search', True)]
detail = {'users': Users, 'groups': Groups}
save_fields = ['name', 'comments', 'tags', 'priority', 'small_name']
save_fields = ['name', 'comments', 'tags', 'priority', 'small_name', 'visible']
table_title = _('Authenticators')
table_fields = [
@ -65,6 +66,7 @@ class Authenticators(ModelHandler):
{'type_name': {'title': _('Type')}},
{'comments': {'title': _('Comments')}},
{'priority': {'title': _('Priority'), 'type': 'numeric', 'width': '5em'}},
{'visible': {'title': _('Visible'), 'type': 'callback', 'width': '3em'}},
{'small_name': {'title': _('Label')}},
{'users_count': {'title': _('Users'), 'type': 'numeric', 'width': '5em'}},
{'tags': {'title': _('tags'), 'visible': False}},
@ -90,9 +92,19 @@ class Authenticators(ModelHandler):
def getGui(self, type_: str) -> typing.List[typing.Any]:
try:
gui = auths.factory().lookup(type_)
if gui:
return self.addDefaultFields(gui.guiDescription(), ['name', 'comments', 'tags', 'priority', 'small_name'])
tgui = auths.factory().lookup(type_)
if tgui:
g = self.addDefaultFields(tgui.guiDescription(), ['name', 'comments', 'tags', 'priority', 'small_name'])
self.addField(g, {
'name': 'visible',
'value': True,
'label': ugettext('Visible'),
'tooltip': ugettext('If active, transport will be visible for users'),
'type': gui.InputField.CHECKBOX_TYPE,
'order': 107,
'tab': ugettext('Display'),
})
return g
raise Exception() # Not found
except Exception:
raise NotFound('type not found')
@ -106,6 +118,7 @@ class Authenticators(ModelHandler):
'tags': [tag.tag for tag in item.tags.all()],
'comments': item.comments,
'priority': item.priority,
'visible': item.visible,
'small_name': item.small_name,
'users_count': item.users.count(),
'type': type_.type(),

View File

@ -337,6 +337,11 @@ class GlobalConfig:
# Global UDS ID (common for all servers on the same cluster)
UDS_ID: Config.Value = Config.section(GLOBAL_SECTION).value('UDS ID', cryptoManager().uuid(), type=Config.READ_FIELD)
# Site display name & copyright info
SITE_NAME: Config.Value = Config.section(GLOBAL_SECTION).value('Site name', 'UDS Enterprise', type=Config.TEXT_FIELD)
SITE_COPYRIGHT: Config.Value = Config.section(GLOBAL_SECTION).value('Site copyright info', '© 2012-2018 Virtual Cable S.L.U.', type=Config.TEXT_FIELD)
SITE_COPYRIGHT_LINK: Config.Value = Config.section(GLOBAL_SECTION).value('Site copyright link', 'https://www.udsenterprise.com', type=Config.TEXT_FIELD)
_initDone = False
@staticmethod

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.1 on 2019-12-23 11:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('uds', '0034_actortoken'),
]
operations = [
migrations.AddField(
model_name='authenticator',
name='visible',
field=models.BooleanField(default=True),
),
]

View File

@ -62,8 +62,9 @@ class Authenticator(ManagedObjectModel, TaggingMixin):
priority = models.IntegerField(default=0, db_index=True)
small_name = models.CharField(max_length=32, default='', db_index=True)
visible = models.BooleanField(default=True)
class Meta(ManagedObjectModel.Meta):
class Meta(ManagedObjectModel.Meta): # pylint: disable=too-few-public-methods
"""
Meta class to declare default order
"""

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -92,6 +92,6 @@
</svg>
</div>
</uds-root>
<script src="/uds/res/admin/runtime.js?stamp=1576559844" defer></script><script src="/uds/res/admin/polyfills-es5.js?stamp=1576559844" nomodule defer></script><script src="/uds/res/admin/polyfills.js?stamp=1576559844" defer></script><script src="/uds/res/admin/main.js?stamp=1576559844" defer></script></body>
<script src="/uds/res/admin/runtime.js?stamp=1577100525" defer></script><script src="/uds/res/admin/polyfills-es5.js?stamp=1577100525" nomodule defer></script><script src="/uds/res/admin/polyfills.js?stamp=1577100525" defer></script><script src="/uds/res/admin/main.js?stamp=1577100525" defer></script></body>
</html>

View File

@ -81,7 +81,7 @@ def udsJs(request: 'HttpRequest') -> str:
except Exception: # There is no authenticators yet...
authenticators = []
else:
authenticators = Authenticator.objects.all()
authenticators = Authenticator.objects.all().exclude(visible=False)
# the auths for client
def getAuthInfo(auth: Authenticator):
@ -105,6 +105,9 @@ def udsJs(request: 'HttpRequest') -> str:
'csrf': csrf_token,
'image_size': Image.MAX_IMAGE_SIZE,
'reload_time': GlobalConfig.RELOAD_TIME.getInt(True),
'site_name': GlobalConfig.SITE_NAME.get(),
'site_copyright_info': GlobalConfig.SITE_COPYRIGHT.get(),
'site_copyright_link': GlobalConfig.SITE_COPYRIGHT_LINK.get(),
'messages': {
# Calendar denied message
'calendarDenied': GlobalConfig.LIMITED_BY_CALENDAR_TEXT.get().strip() or gettext("Access limited by calendar")