add view setting perms closes #569

This commit is contained in:
wh1te909 2021-06-17 04:36:34 +00:00
parent ba3c3a42ce
commit 581e974236
5 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.4 on 2021-06-17 04:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0020_role_can_manage_roles'),
]
operations = [
migrations.AddField(
model_name='role',
name='can_view_core_settings',
field=models.BooleanField(default=False),
),
]

View File

@ -90,6 +90,7 @@ class Role(models.Model):
# core
can_manage_notes = models.BooleanField(default=False)
can_view_core_settings = models.BooleanField(default=False)
can_edit_core_settings = models.BooleanField(default=False)
can_do_server_maint = models.BooleanField(default=False)
can_code_sign = models.BooleanField(default=False)
@ -153,6 +154,7 @@ class Role(models.Model):
"can_run_scripts",
"can_run_bulk",
"can_manage_notes",
"can_view_core_settings",
"can_edit_core_settings",
"can_do_server_maint",
"can_code_sign",

View File

@ -3,6 +3,11 @@ from rest_framework import permissions
from tacticalrmm.permissions import _has_perm
class ViewCoreSettingsPerms(permissions.BasePermission):
def has_permission(self, r, view):
return _has_perm(r, "can_view_core_settings")
class EditCoreSettingsPerms(permissions.BasePermission):
def has_permission(self, r, view):
return _has_perm(r, "can_edit_core_settings")

View File

@ -15,7 +15,12 @@ from agents.permissions import MeshPerms
from tacticalrmm.utils import notify_error
from .models import CodeSignToken, CoreSettings, CustomField, GlobalKVStore, URLAction
from .permissions import CodeSignPerms, EditCoreSettingsPerms, ServerMaintPerms
from .permissions import (
CodeSignPerms,
ViewCoreSettingsPerms,
EditCoreSettingsPerms,
ServerMaintPerms,
)
from .serializers import (
CodeSignTokenSerializer,
CoreSettingsSerializer,
@ -46,6 +51,7 @@ class UploadMeshAgent(APIView):
@api_view()
@permission_classes([IsAuthenticated, ViewCoreSettingsPerms])
def get_core_settings(request):
settings = CoreSettings.objects.first()
return Response(CoreSettingsSerializer(settings).data)

View File

@ -52,6 +52,7 @@
<q-card-section class="row">
<div class="q-gutter-sm">
<q-checkbox v-model="role.can_manage_notes" label="Manage Notes" />
<q-checkbox v-model="role.can_view_core_settings" label="View Global Settings" />
<q-checkbox v-model="role.can_edit_core_settings" label="Edit Global Settings" />
<q-checkbox v-model="role.can_do_server_maint" label="Do Server Maintenance" />
<q-checkbox v-model="role.can_code_sign" label="Manage Code Signing" />
@ -176,6 +177,7 @@ export default {
can_run_scripts: false,
can_run_bulk: false,
can_manage_notes: false,
can_view_core_settings: false,
can_edit_core_settings: false,
can_do_server_maint: false,
can_code_sign: false,