forked from shaba/openuds
added custom message per-pool for calendar access denied
This commit is contained in:
parent
63824cdeee
commit
f47b208c33
@ -63,7 +63,7 @@ class MetaPools(ModelHandler):
|
||||
}
|
||||
|
||||
save_fields = ['name', 'short_name', 'comments', 'tags',
|
||||
'image_id', 'servicesPoolGroup_id', 'visible', 'policy']
|
||||
'image_id', 'servicesPoolGroup_id', 'visible', 'policy', 'calendar_message']
|
||||
|
||||
table_title = _('Meta Pools')
|
||||
table_fields = [
|
||||
@ -112,6 +112,7 @@ class MetaPools(ModelHandler):
|
||||
'policy': item.policy,
|
||||
'fallbackAccess': item.fallbackAccess,
|
||||
'permission': permissions.getEffectivePermission(self._user, item),
|
||||
'calendar_message': item.calendar_message,
|
||||
}
|
||||
|
||||
return val
|
||||
@ -151,6 +152,14 @@ class MetaPools(ModelHandler):
|
||||
'type': gui.InputField.CHECKBOX_TYPE,
|
||||
'order': 123,
|
||||
'tab': ugettext('Display'),
|
||||
}, {
|
||||
'name': 'calendar_message',
|
||||
'value': '',
|
||||
'label': ugettext('Calendar access denied text'),
|
||||
'tooltip': ugettext('Custom message to be shown to users if access is limited by calendar rules.'),
|
||||
'type': gui.InputField.TEXT_TYPE,
|
||||
'order': 124,
|
||||
'tab': ugettext('Display'),
|
||||
}]:
|
||||
self.addField(localGUI, field)
|
||||
|
||||
|
@ -86,7 +86,7 @@ class ServicesPools(ModelHandler):
|
||||
save_fields = ['name', 'short_name', 'comments', 'tags', 'service_id',
|
||||
'osmanager_id', 'image_id', 'pool_group_id', 'initial_srvs',
|
||||
'cache_l1_srvs', 'cache_l2_srvs', 'max_srvs', 'show_transports', 'visible',
|
||||
'allow_users_remove', 'allow_users_reset', 'ignores_unused', 'account_id']
|
||||
'allow_users_remove', 'allow_users_reset', 'ignores_unused', 'account_id', 'calendar_message']
|
||||
|
||||
remove_fields = ['osmanager_id', 'service_id']
|
||||
|
||||
@ -159,6 +159,7 @@ class ServicesPools(ModelHandler):
|
||||
'ignores_unused': item.ignores_unused,
|
||||
'fallbackAccess': item.fallbackAccess,
|
||||
'meta_member': [{'id': i.uuid, 'name': i.name} for i in item.meta.all()],
|
||||
'calendar_message': item.calendar_message,
|
||||
}
|
||||
|
||||
# Extended info
|
||||
@ -245,6 +246,14 @@ class ServicesPools(ModelHandler):
|
||||
'type': gui.InputField.CHECKBOX_TYPE,
|
||||
'order': 113,
|
||||
'tab': ugettext('Advanced'),
|
||||
}, {
|
||||
'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'),
|
||||
}, {
|
||||
'name': 'image_id',
|
||||
'values': [gui.choiceImage(-1, '--------', DEFAULT_THUMB_BASE64)] + gui.sortedChoices([gui.choiceImage(v.uuid, v.name, v.thumb64) for v in Image.objects.all()]),
|
||||
@ -262,12 +271,12 @@ class ServicesPools(ModelHandler):
|
||||
'order': 121,
|
||||
'tab': ugettext('Display'),
|
||||
}, {
|
||||
'name': 'visible',
|
||||
'value': True,
|
||||
'label': ugettext('Visible'),
|
||||
'tooltip': ugettext('If active, transport will be visible for users'),
|
||||
'type': gui.InputField.CHECKBOX_TYPE,
|
||||
'order': 107,
|
||||
'name': 'calendar_message',
|
||||
'value': '',
|
||||
'label': ugettext('Calendar access denied text'),
|
||||
'tooltip': ugettext('Custom message to be shown to users if access is limited by calendar rules.'),
|
||||
'type': gui.InputField.TEXT_TYPE,
|
||||
'order': 122,
|
||||
'tab': ugettext('Display'),
|
||||
}, {
|
||||
'name': 'initial_srvs',
|
||||
|
@ -134,6 +134,7 @@ class BaseModelHandler(Handler):
|
||||
if 'name' in flds:
|
||||
self.addField(gui, {
|
||||
'name': 'name',
|
||||
'type': 'text',
|
||||
'required': True,
|
||||
'label': _('Name'),
|
||||
'length': 128,
|
||||
|
23
server/src/uds/migrations/0036_auto_20200131_1224.py
Normal file
23
server/src/uds/migrations/0036_auto_20200131_1224.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.0.1 on 2020-01-31 12:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('uds', '0035_authenticator_visible'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='metapool',
|
||||
name='calendar_message',
|
||||
field=models.CharField(default='', max_length=256),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='servicepool',
|
||||
name='calendar_message',
|
||||
field=models.CharField(default='', max_length=256),
|
||||
),
|
||||
]
|
@ -82,6 +82,8 @@ class MetaPool(UUIDModel, TaggingMixin): # type: ignore
|
||||
assignedGroups = models.ManyToManyField(Group, related_name='metaPools', db_table='uds__meta_grps')
|
||||
|
||||
accessCalendars = models.ManyToManyField(Calendar, related_name='accessMeta', through='CalendarAccessMeta')
|
||||
# Message if access denied
|
||||
calendar_message = models.CharField(default='', max_length=256)
|
||||
# Default fallback action for access
|
||||
fallbackAccess = models.CharField(default=states.action.ALLOW, max_length=8)
|
||||
|
||||
|
@ -93,6 +93,8 @@ class ServicePool(UUIDModel, TaggingMixin): # type: ignore
|
||||
servicesPoolGroup: typing.Optional[ServicePoolGroup] = models.ForeignKey(ServicePoolGroup, null=True, blank=True, related_name='servicesPools', on_delete=models.SET_NULL)
|
||||
|
||||
accessCalendars = models.ManyToManyField(Calendar, related_name='accessSP', through='CalendarAccess')
|
||||
# Message if access denied
|
||||
calendar_message = models.CharField(default='', max_length=256)
|
||||
# Default fallback action for access
|
||||
fallbackAccess = models.CharField(default=states.action.ALLOW, max_length=8)
|
||||
actionsCalendars = models.ManyToManyField(Calendar, related_name='actionsSP', through='CalendarAction')
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -116,7 +116,6 @@ def getServicesData(request: 'HttpRequest') -> typing.Dict[str, typing.Any]: #
|
||||
# If no usable pools, this is not visible
|
||||
if hasUsablePools:
|
||||
group = meta.servicesPoolGroup.as_dict if meta.servicesPoolGroup else ServicePoolGroup.default().as_dict
|
||||
calendar_text = ''
|
||||
|
||||
services.append({
|
||||
'id': 'M' + meta.uuid,
|
||||
@ -139,7 +138,7 @@ def getServicesData(request: 'HttpRequest') -> typing.Dict[str, typing.Any]: #
|
||||
'in_use': in_use,
|
||||
'to_be_replaced': None,
|
||||
'to_be_replaced_text': '',
|
||||
'custom_calendar_text': calendar_text,
|
||||
'custom_calendar_text': meta.calendar_message,
|
||||
})
|
||||
|
||||
# Now generic user service
|
||||
@ -184,7 +183,6 @@ def getServicesData(request: 'HttpRequest') -> typing.Dict[str, typing.Any]: #
|
||||
in_use = ads.in_use
|
||||
|
||||
group = svr.servicesPoolGroup.as_dict if svr.servicesPoolGroup else ServicePoolGroup.default().as_dict
|
||||
calendar_text = ''
|
||||
|
||||
tbr = svr.toBeReplaced(request.user)
|
||||
if tbr:
|
||||
@ -209,7 +207,7 @@ def getServicesData(request: 'HttpRequest') -> typing.Dict[str, typing.Any]: #
|
||||
'in_use': in_use,
|
||||
'to_be_replaced': tbr,
|
||||
'to_be_replaced_text': tbrt,
|
||||
'custom_calendar_text': calendar_text,
|
||||
'custom_calendar_text': svr.calendar_message,
|
||||
})
|
||||
|
||||
logger.debug('Services: %s', services)
|
||||
|
Loading…
Reference in New Issue
Block a user