Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rw navbar update #157

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
895aef4
added react table to deployments
ward438 Nov 30, 2021
9abbd0d
deployment table
ward438 Dec 1, 2021
acef632
Deployment table, search and sort functionality implemented
ward438 Dec 1, 2021
0327084
styling table
ward438 Dec 1, 2021
fd7b369
deployment table buttons
SergioJFalcon Dec 1, 2021
1a4b660
styling table header
ward438 Dec 1, 2021
c75a786
deployment table - tool tips added to action buttons
SergioJFalcon Dec 1, 2021
95e5ccb
fixing endpoint for poems
SergioJFalcon Dec 2, 2021
8c59131
Use Django db filter in get_producer_elements
govreadydeploy Dec 4, 2021
bf534c2
Improve queries
govreadydeploy Dec 6, 2021
e169af7
Merge pull request #86 from GovReady/react-tables-component-fix
alexanderward Dec 6, 2021
94defe8
commit
ward438 Dec 7, 2021
3a862f0
commit
ward438 Dec 7, 2021
89c37f1
React controls and and portfolios table
SergioJFalcon Dec 7, 2021
eaa5f6b
Merge branch 'react-tables' of github.com:GovReady/govready-q-private…
ward438 Dec 7, 2021
24fb893
Added record count to control table
SergioJFalcon Dec 7, 2021
f3bd648
Merge branch 'react-tables' of https://github.com/GovReady/govready-q…
SergioJFalcon Dec 7, 2021
bcf9e6f
Added record count to control table
SergioJFalcon Dec 7, 2021
ea5c140
added systemsControlsTable to differentiate from controls catalog
ward438 Dec 7, 2021
e533d5a
projects table subbed out until data layer is fixed
ward438 Dec 8, 2021
447455b
React Tables for Component Library, Controls, Portfolios
SergioJFalcon Dec 11, 2021
dce748d
Merge branch 'react-tables' of https://github.com/GovReady/govready-q…
SergioJFalcon Dec 11, 2021
5ca0e2b
React Tables for Component Library, Controls, Portfolios
SergioJFalcon Dec 11, 2021
d0a4639
Update requirements
govreadydeploy Dec 13, 2021
2e687a9
created React components, replaced MUI with react-bootstrap
ward438 Dec 17, 2021
7757560
created React components, replaced MUI with react-bootstrap
ward438 Dec 17, 2021
35530cb
removed text shadow from button
ward438 Dec 20, 2021
ff9cb5e
removed text shadow from button
ward438 Dec 20, 2021
8398d89
react-pro-sidebar now fixed position, corrected styling, commented co…
ward438 Dec 21, 2021
8dc622f
Merge branch 'develop' into rw-navbar-update
ward438 Dec 23, 2021
3aa8bd8
Project Updated will update with changes to selected components, sele…
ward438 Dec 29, 2021
9042c06
project updated represented in sidenav. Shows 'time since' updated wi…
ward438 Dec 29, 2021
773b98b
Sync with develop branch
gregelin Jan 10, 2022
e3c698f
Sync with 0.9.11.11 release
gregelin Jan 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions api/base/permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from rest_framework import permissions

class CustomObjectPermissions(permissions.DjangoObjectPermissions):
"""
Similar to `DjangoObjectPermissions`, but adding 'view' permissions.
"""
perms_map = {
'GET': ['%(app_label)s.view_%(model_name)s'],
'OPTIONS': ['%(app_label)s.view_%(model_name)s'],
'HEAD': ['%(app_label)s.view_%(model_name)s'],
'POST': ['%(app_label)s.add_%(model_name)s'],
'PUT': ['%(app_label)s.change_%(model_name)s'],
'PATCH': ['%(app_label)s.change_%(model_name)s'],
'DELETE': ['%(app_label)s.delete_%(model_name)s'],
}
1 change: 0 additions & 1 deletion api/base/serializers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def build_joins(self):
else:
fks.append("{}__{}".format(formatted, fk.column))
except:
import ipdb; ipdb.set_trace()
pass
for prefetch in child_prefetches:
try:
Expand Down
4 changes: 3 additions & 1 deletion api/base/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class BaseViewSet(GenericViewSet):
ordering = ('-created',)
ordering_fields = '__all__'
ROLLUP = {} # Include Django ORM syntax to get rollup on values
extra_filter_backends = []

@property
def permission_classes(self):
Expand All @@ -70,8 +71,9 @@ def permission_classes(self, permissions):

serializer_classes = None

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs):
self.serializer_classes_tmp = TmpSerializerClasses()
self.filter_backends += self.extra_filter_backends
super().__init__(*args, **kwargs)

def serializer_class_override(self, serializer_type, serializer_class):
Expand Down
4 changes: 2 additions & 2 deletions api/base/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(queryset)

post_filter = kwargs.get('post_filter')
if post_filter:
if post_filter:
queryset = queryset.filter(post_filter)

rollup = self.get_rollup(request, queryset)
Expand All @@ -71,7 +71,7 @@ def search(self, request, keyword):
pass

def _search(self, request):
keyword = request.GET.get('keyword')
keyword = request.GET.get('search')
if keyword:
return self.search(request, keyword)

Expand Down
Empty file.
11 changes: 11 additions & 0 deletions api/controls/filters/deployment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from api.base.filters import BaseFilterSet, FilterFields
from controls.models import Deployment
from rest_framework_filters import filters

class DeploymentFilter(BaseFilterSet):
# author = filters.RelatedFilter(UserFilter, queryset=User.objects.all())
name = filters.AutoFilter(lookups=FilterFields.String)

class Meta:
model = Deployment
fields = []
18 changes: 18 additions & 0 deletions api/controls/serializers/components.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from api.base.serializers.types import ReadOnlySerializer
# from api.controls.serializers.system import DetailedSystemSerializer
from controls.models import Element, Statement
from api.controls.serializers.statements import SimpleStatementSerializer, DetailedStatementSerializer
from api.siteapp.serializers.tags import SimpleTagSerializer


class SimpleComponentSerializer(ReadOnlySerializer):
class Meta:
model = Element
fields = ['uuid', 'name', 'description', 'element_type', 'created', 'updated', 'component_type', 'component_state']

class DetailedComponentSerializer(SimpleComponentSerializer):
tags = SimpleTagSerializer(many=True)
statements_produced = SimpleStatementSerializer(many=True)
class Meta:
model = Element
fields = SimpleComponentSerializer.Meta.fields + ['tags', 'statements_produced']
29 changes: 28 additions & 1 deletion api/controls/serializers/controls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from api.base.serializers.types import ReadOnlySerializer
from api.controls.serializers.element import DetailedElementSerializer
from controls.models import CommonControlProvider, CommonControl, ElementCommonControl

from controls.oscal import CatalogData
from rest_framework import serializers

class SimpleCommonControlProviderSerializer(ReadOnlySerializer):
class Meta:
Expand Down Expand Up @@ -36,3 +37,29 @@ class DetailedElementCommonControlSerializer(SimpleElementCommonControlSerialize
class Meta:
model = ElementCommonControl
fields = SimpleElementCommonControlSerializer.Meta.fields + ['element', 'common_control']


class CatalogDataReadSerializer(ReadOnlySerializer):

title = serializers.SerializerMethodField()

def get_title(self, obj):
return obj.catalog_json['catalog']['metadata']['title'].strip()

class Meta:
model = CatalogData
fields = ['catalog_key', 'title']

class CatalogDataGroup(serializers.Serializer):
id = serializers.CharField()
title = serializers.CharField()

class CatalogDataWithGroupReadSerializer(CatalogDataReadSerializer):
groups = serializers.SerializerMethodField()

def get_groups(self, obj):
return [CatalogDataGroup(x).data for x in obj.catalog_json['catalog'].get('groups', [])]

class Meta:
model = CatalogData
fields = CatalogDataReadSerializer.Meta.fields + ['groups']
11 changes: 5 additions & 6 deletions api/controls/serializers/poam.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from api.base.serializers.types import ReadOnlySerializer
from api.controls.serializers.statements import DetailedStatementSerializer
from controls.models import Poam


Expand All @@ -11,9 +10,9 @@ class Meta:
'risk_rating_original', 'risk_rating_adjusted', 'poam_group']


class DetailedPoamSerializer(SimplePoamSerializer):
statement = DetailedStatementSerializer()
# class DetailedPoamSerializer(SimplePoamSerializer):
# statement = DetailedStatementSerializer()

class Meta:
model = Poam
fields = SimplePoamSerializer.Meta.fields + ['statement']
# class Meta:
# model = Poam
# fields = SimplePoamSerializer.Meta.fields + ['statement']
6 changes: 6 additions & 0 deletions api/controls/serializers/statements.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from rest_framework_recursive.fields import RecursiveField
from api.base.serializers.types import ReadOnlySerializer
from api.controls.serializers.element import DetailedElementSerializer
from api.controls.serializers.poam import SimplePoamSerializer
from api.controls.serializers.import_record import SimpleImportRecordSerializer
from controls.models import Statement

Expand All @@ -10,6 +11,11 @@ class Meta:
model = Statement
fields = ['sid', 'sid_class', 'pid', 'body', 'statement_type', 'remarks', 'status', 'version', 'uuid']

class PoamStatmentSerializer(SimpleStatementSerializer):
poam = SimplePoamSerializer()
class Meta:
model = Statement
fields = SimpleStatementSerializer.Meta.fields + ['poam']

class DetailedStatementSerializer(SimpleStatementSerializer):
parent = RecursiveField(required=False, allow_null=True)
Expand Down
18 changes: 15 additions & 3 deletions api/controls/urls.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
from django.conf.urls import url
from django.urls import include
from api.controls.views.deployments import DeploymentViewSet
from api.controls.views.components import ComponentsViewSet
from rest_framework import routers
from rest_framework_nested.routers import NestedSimpleRouter
from api.controls.views.element import ElementViewSet
from api.controls.views.system import SystemViewSet, SystemControlsViewSet, SystemAssessmentViewSet, SystemPoamViewSet
from api.controls.views.system import SystemViewSet, SystemControlsViewSet, SystemAssessmentViewSet, SystemPoamStatementsViewSet
from api.controls.views.controls import ControlsViewSet, CatalogDataViewSet, CatalogData

router = routers.DefaultRouter()
router.register(r'elements', ElementViewSet)
router.register(r'systems', SystemViewSet)

router.register(r'catalog-data', CatalogDataViewSet)


# router.register(r'controls/catalogs', CatalogData)
router.register(r'components', ComponentsViewSet)
router.register(r'controls', ControlsViewSet)

systems_router = NestedSimpleRouter(router, r'systems', lookup='systems')
systems_router.register(r'controls', SystemControlsViewSet, basename='systems-controls')
systems_router.register(r'system-controls', SystemControlsViewSet, basename='systems-controls')
systems_router.register(r'assessments', SystemAssessmentViewSet, basename='systems-assessments')
systems_router.register(r'poams', SystemPoamViewSet, basename='systems-poams')
systems_router.register(r'poam-statements', SystemPoamStatementsViewSet, basename='systems-poams')
systems_router.register(r'deployments', DeploymentViewSet, basename='systems-deployments')
#systems_router.register(r'components', ComponentsViewSet, basename='systems-components')

urlpatterns = [
url(r'^', include(router.urls)),
Expand Down
22 changes: 22 additions & 0 deletions api/controls/views/components.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from api.base.views.base import SerializerClasses
from api.base.views.viewsets import ReadOnlyViewSet
from api.base.views.mixins import CustomSearchModelMixin
from api.controls.serializers.components import DetailedComponentSerializer
from controls.models import Element
from django.db.models import Q


class ComponentsViewSet(CustomSearchModelMixin, ReadOnlyViewSet):
queryset = Element.objects.exclude(element_type='system')

serializer_classes = SerializerClasses(retrieve=DetailedComponentSerializer,
list=DetailedComponentSerializer)

# NESTED_ROUTER_PKS = [{'pk': 'systems_pk', 'model_field': 'system'}]

# def get_queryset(self, queryset=None, serializer_class=None):
# queryset = super().get_queryset(queryset, serializer_class)
# return queryset.filter()

def search(self, request, keyword):
return Q(name__icontains=keyword)
38 changes: 38 additions & 0 deletions api/controls/views/controls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from api.base.views.base import SerializerClasses
from api.base.views.viewsets import ReadOnlyViewSet
from api.base.views.mixins import CustomSearchModelMixin
from api.controls.serializers.controls import CatalogDataReadSerializer, CatalogDataWithGroupReadSerializer, SimpleCommonControlSerializer
from controls.oscal import CatalogData
from django.db.models import Q
from rest_framework.decorators import action
from rest_framework.response import Response
from controls.oscal import CatalogData

class ControlsViewSet(CustomSearchModelMixin, ReadOnlyViewSet):
queryset = CatalogData.objects.all()

serializer_classes = SerializerClasses(retrieve=CatalogDataReadSerializer,
list=CatalogDataReadSerializer)

# NESTED_ROUTER_PKS = [{'pk': 'systems_pk', 'model_field': 'system'}]

def get_queryset(self, queryset=None, serializer_class=None):
queryset = super().get_queryset(queryset, serializer_class)
return queryset.filter()

def search(self, request, keyword):
return Q(catalog_key__icontains=keyword) | Q(catalog_json__catalog__metadata__title__icontains=keyword)

class CatalogDataViewSet(CustomSearchModelMixin, ReadOnlyViewSet):
queryset = CatalogData.objects.all()
serializer_classes = SerializerClasses(retrieve=CatalogDataWithGroupReadSerializer,
list=CatalogDataWithGroupReadSerializer)

def search(self, request, keyword):
return Q(catalog_key__icontains=keyword) | Q(catalog_json__catalog__metadata__title__icontains=keyword)

@action(detail=True, url_path="catalog-key", methods=["GET"])
def retrieve_by_catalog_key(self, request, **kwargs):
obj = CatalogData.objects.get(catalog_key=kwargs.get('pk'))
serializer = CatalogDataWithGroupReadSerializer(obj)
return Response(serializer.data)
19 changes: 19 additions & 0 deletions api/controls/views/deployments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from api.base.views.base import SerializerClasses
from api.base.views.viewsets import ReadOnlyViewSet
from api.base.views.mixins import CustomSearchModelMixin
from api.controls.serializers.deployment import SimpleDeploymentSerializer
from controls.models import Deployment
from django.db.models import Q


class DeploymentViewSet(CustomSearchModelMixin, ReadOnlyViewSet):
queryset = Deployment.objects.all()

serializer_classes = SerializerClasses(retrieve=SimpleDeploymentSerializer,
list=SimpleDeploymentSerializer)

NESTED_ROUTER_PKS = [{'pk': 'systems_pk', 'model_field': 'system'}]

def search(self, request, keyword):
return Q(name__icontains=keyword)

2 changes: 1 addition & 1 deletion api/controls/views/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class ElementViewSet(ReadOnlyViewSet):
queryset = Element.objects.all()
serializer_classes = SerializerClasses(retrieve=DetailedElementSerializer,
list=SimpleElementSerializer,
list=DetailedElementSerializer,
tags=WriteElementTagsSerializer)

@action(detail=True, url_path="tags", methods=["PUT"])
Expand Down
72 changes: 51 additions & 21 deletions api/controls/views/system.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,73 @@
from api.base.views.base import SerializerClasses
from api.base.views.viewsets import ReadOnlyViewSet
from api.controls.serializers.element import SimpleElementControlSerializer, DetailedElementControlSerializer
from api.controls.serializers.poam import DetailedPoamSerializer, SimplePoamSerializer
from api.controls.serializers.system import DetailedSystemSerializer, SimpleSystemSerializer
from api.controls.serializers.system_assement_results import DetailedSystemAssessmentResultSerializer, \
SimpleSystemAssessmentResultSerializer
from controls.models import System, ElementControl, SystemAssessmentResult, Poam
from api.controls.serializers.element import (
SimpleElementControlSerializer,
DetailedElementControlSerializer,
)
from api.controls.serializers.statements import PoamStatmentSerializer
from api.controls.serializers.system import (
DetailedSystemSerializer,
SimpleSystemSerializer,
)
from api.controls.serializers.system_assement_results import (
DetailedSystemAssessmentResultSerializer,
SimpleSystemAssessmentResultSerializer,
)
from controls.models import System, ElementControl, SystemAssessmentResult, Statement
from api.base.views.mixins import CustomSearchModelMixin
from django.db.models import Q


class SystemViewSet(ReadOnlyViewSet):
queryset = System.objects.all()

serializer_classes = SerializerClasses(retrieve=DetailedSystemSerializer,
list=SimpleSystemSerializer)
serializer_classes = SerializerClasses(
retrieve=DetailedSystemSerializer, list=SimpleSystemSerializer
)


class SystemControlsViewSet(ReadOnlyViewSet):
class SystemControlsViewSet(CustomSearchModelMixin, ReadOnlyViewSet):
queryset = ElementControl.objects.all()

serializer_classes = SerializerClasses(retrieve=DetailedElementControlSerializer,
list=SimpleElementControlSerializer)
serializer_classes = SerializerClasses(
retrieve=DetailedElementControlSerializer, list=SimpleElementControlSerializer
)

NESTED_ROUTER_PKS = [{'pk': 'systems_pk', 'model_field': 'element.system'}]
NESTED_ROUTER_PKS = [{"pk": "systems_pk", "model_field": "element.system"}]

def search(self, request, keyword):
return Q(oscal_ctl_id__icontains=keyword)

class SystemAssessmentViewSet(ReadOnlyViewSet):


class SystemAssessmentViewSet(CustomSearchModelMixin, ReadOnlyViewSet):
queryset = SystemAssessmentResult.objects.all()

serializer_classes = SerializerClasses(retrieve=DetailedSystemAssessmentResultSerializer,
list=SimpleSystemAssessmentResultSerializer)
serializer_classes = SerializerClasses(
retrieve=DetailedSystemAssessmentResultSerializer,
list=SimpleSystemAssessmentResultSerializer,
)

NESTED_ROUTER_PKS = [{"pk": "systems_pk", "model_field": "system"}]

NESTED_ROUTER_PKS = [{'pk': 'systems_pk', 'model_field': 'system'}]
def search(self, request, keyword):
return Q(name__icontains=keyword) | Q(description__icontains=keyword)


class SystemPoamViewSet(ReadOnlyViewSet):
queryset = Poam.objects.all()
class SystemPoamStatementsViewSet(CustomSearchModelMixin, ReadOnlyViewSet):
queryset = Statement.objects.all()
ordering = ("-updated",)
serializer_classes = SerializerClasses(
retrieve=PoamStatmentSerializer, list=PoamStatmentSerializer
)

serializer_classes = SerializerClasses(retrieve=DetailedPoamSerializer,
list=SimplePoamSerializer)
NESTED_ROUTER_PKS = [{"pk": "systems_pk", "model_field": "consumer_element.system"}]

NESTED_ROUTER_PKS = [{'pk': 'systems_pk', 'model_field': 'statement.consumer_element.system'}]
def get_queryset(self, queryset=None, serializer_class=None):
queryset = super().get_queryset(queryset, serializer_class)
return queryset.filter(statement_type="POAM")

def search(self, request, keyword):
return Q(poam__weakness_name__icontains=keyword) | Q(
poam__poam_id__icontains=keyword.lower().replace("v-", "")
)
Loading