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

Upload systems by CSV and OSCAL #1756

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
be8e288
Start of uploading a system based on a excel doc or json file, or an …
SergioJFalcon Jun 28, 2022
d734349
Refactor for DRY __create_new_system, better HTML
gregelin Jun 29, 2022
8d39cde
Refactor for DRY __create_new_system, better HTML
gregelin Jun 29, 2022
9a12106
Merge branch 'system-upload' of github.com:govready/govready-q into s…
gregelin Jun 29, 2022
b74106f
Show drag and drop input field temporarily
gregelin Jun 29, 2022
5c34332
wip
SergioJFalcon Jun 29, 2022
0b61024
Create landing page to display system import results
gregelin Jun 29, 2022
9a14b32
Merge branch 'main' into system-upload
SergioJFalcon Jun 29, 2022
257d992
system import from a xlsl and json file
SergioJFalcon Jun 30, 2022
2584ead
wip
SergioJFalcon Jun 30, 2022
0946655
creating systems from a CSV file
SergioJFalcon Jun 30, 2022
4281dad
Code clean up and add example systems import spreadsheet
gregelin Jul 3, 2022
60b297f
Sync recent changes
gregelin Jul 3, 2022
3df4bf0
Remove extra test files
gregelin Jul 3, 2022
c1ecaf6
system templates for CSV and XLSX formats
SergioJFalcon Jul 5, 2022
34bb207
Update Django to 3.2.14 to address vulnerability
gregelin Jul 6, 2022
8c29e6e
Remove Opera from testing
gregelin Jul 6, 2022
908dfbc
updated urllib3 hashes, wip on system imports
SergioJFalcon Jul 8, 2022
91ab146
wip
SergioJFalcon Jul 9, 2022
998355b
Use older selenium 4.2.0 for tests to work
govreadydeploy Jul 9, 2022
6b6314e
Merge pull request #1759 from GovReady/develop-django-upgrade
gregelin Jul 9, 2022
2e229a9
Merge branch 'develop' of github.com:GovReady/govready-q into develop
govreadydeploy Jul 9, 2022
3b28957
Merge branch 'develop' into system-upload
govreadydeploy Jul 9, 2022
fbba6d4
wip - Import of POAMs
SergioJFalcon Jul 11, 2022
c3c14a7
Remove statement edit from proposed system component; Upgrade moment…
gregelin Jul 12, 2022
3211018
Import of System and POA&Ms
SergioJFalcon Jul 13, 2022
3d167b6
Updating System info appropriately
SergioJFalcon Jul 13, 2022
175ba62
Import of POAMs
SergioJFalcon Jul 14, 2022
79ce157
Update CHANGELOG
gregelin Jul 19, 2022
aa34adb
Merge branch 'main' into develop
gregelin Jul 25, 2022
ba88a17
Merge branch 'develop' into system-upload
gregelin Jul 25, 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
14 changes: 14 additions & 0 deletions controls/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ class ImportProjectForm(forms.Form):
)
json_content = forms.CharField(label='Project (JSON)', widget=forms.Textarea(), help_text="The JSON necessary for importing a project.")

class ImportSystemForm(forms.Form):

file = forms.FileField(label="Select system file (.json)",
widget=forms.FileInput(
attrs={
'onchange': "fillFileContent(this);",
# 'accept':'application/json'
}
),
required=False
)
file_content = forms.CharField(label='System (File)', widget=forms.Textarea(), help_text="The FILE necessary for importing a system.")
file_name = forms.CharField(label='Imported File Name', widget=forms.HiddenInput(), required=False)

class DeploymentForm(ModelForm):

def __init__(self, *args, **kwargs):
Expand Down
20 changes: 20 additions & 0 deletions controls/migrations/0076_system_import_record.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.14 on 2022-07-12 14:24

import auto_prefetch
from django.db import migrations
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('controls', '0075_systemevent'),
]

operations = [
migrations.AddField(
model_name='system',
name='import_record',
field=auto_prefetch.ForeignKey(blank=True, help_text='The Import Record which created this System.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='import_record_systems', to='controls.importrecord'),
),
]
14 changes: 12 additions & 2 deletions controls/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ def __str__(self):
def __repr__(self):
# For debugging.
return "'%s %s %s %s %s'" % (self.statement_type, self.sid, self.pid, self.sid_class, self.id)

def save(self, *args, **kwargs):
return super(Statement, self).save(*args, **kwargs)

@cached_property
def producer_element_name(self):
Expand Down Expand Up @@ -658,7 +661,8 @@ class System(auto_prefetch.Model, TagModelMixin, ProposalModelMixin):
info = models.JSONField(blank=True, default=dict, help_text="JSON object representing additional system information")
created = models.DateTimeField(auto_now_add=True, db_index=True)
updated = models.DateTimeField(auto_now_add=True, db_index=True)

import_record = auto_prefetch.ForeignKey(ImportRecord, related_name="import_record_systems", on_delete=models.CASCADE,
unique=False, blank=True, null=True, help_text="The Import Record which created this System.")
# Notes
# Retrieve system implementation statements
# system = System.objects.get(pk=2)
Expand All @@ -677,6 +681,9 @@ def __repr__(self):
# For debugging.
return "'System %s id=%d'" % (self.root_element.name, self.id)

def save(self, *args, **kwargs):
return super(System, self).save(*args, **kwargs)

# @property
# def statements_consumed(self):
# smts = self.root_element.statements_consumed.all()
Expand Down Expand Up @@ -1168,7 +1175,10 @@ def __repr__(self):
def get_next_poam_id(self, system):
"""Count total number of POAMS and return next linear id"""
return Statement.objects.filter(statement_type="POAM", consumer_element=system.root_element).count()


def save(self, *args, **kwargs):
return super(Poam, self).save(*args, **kwargs)

# TODO:
# - On Save be sure to replace any '\r\n' with '\n' added by round-tripping with excel

Expand Down
2 changes: 1 addition & 1 deletion controls/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

class CreateSystemTests(OrganizationSiteFunctionalTests):

# def test_create_system_from_string(self):
# def test_create_new_system(self):
# cases = (
# ('ac-1', 'a', 'ac-1_smt.a'),
# ('ac-1', '', 'ac-1_smt'),
Expand Down
8 changes: 6 additions & 2 deletions controls/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
url(r'^(?P<system_id>.*)/controls/selected$', views.controls_selected, name="controls_selected"),
url(r'^(?P<system_id>.*)/controls/add$', views.system_controls_add, name="system_controls_add"),
url(r'^(?P<system_id>.*)/controls/remove/(?P<element_control_id>.*)$', views.system_control_remove, name="system_control_remove"),

url(r'^(?P<system_id>.*)/controls/catalogs/(?P<catalog_key>.*)/control/(?P<cl_id>.*)/compare$', views.editor_compare, name="control_compare"),
url(r'^(?P<system_id>.*)/controls/catalogs/(?P<catalog_key>.*)/control/(?P<cl_id>.*)$', views.editor, name="control_editor"),
url(r'^editor_autocomplete/', views.EditorAutocomplete.as_view(), name="search_system_component"),
Expand All @@ -46,7 +46,10 @@
url(r'^(?P<system_id>.*)/aspen/summary$', views.system_summary_aspen, name="system_summary"),
url(r'^(?P<system_id>.*)/aspen/integrations$', views.system_integrations_aspen, name="system_integrations"),

url(r'^new', views.create_system_from_string, name="create_system_from_string"),
url(r'^new', views.create_new_system, name="create_new_system"),
url(r'^csv_system_template', views.system_csv_template, name="csv_system_template"),
url(r'^xlsx_system_template', views.system_xlsx_template, name="xlsx_system_template"),
url(r'^oscal_system_template', views.system_oscal_template, name="oscal_system_template"),

# Systems Assessment Results
url(r'^(?P<system_id>.*)/assessments$', views.system_assessment_results_list, name="system_assessment_results_list"),
Expand Down Expand Up @@ -81,6 +84,7 @@
url(r'^(?P<system_id>.*)/components/(?P<element_id>.*)/proposal_message$', views.proposal_message, name="proposal_message"),
url(r'^(?P<system_id>.*)/component/(?P<element_id>.*)$', views.system_element, name="system_element"),
url(r'^(?P<system_id>.*)/controls/updated$', views.controls_updated, name="controls_updated"),
url(r'^system_import$', views.system_import, name="system_import"),

# Component Library
url(r'^components$', views.component_library, name="component_library"),
Expand Down
Loading