-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from pep-un/v3.0
Publish v3.0
- Loading branch information
Showing
52 changed files
with
1,910 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
__pycache__ | ||
db.sqlite3 | ||
media | ||
attachments/ | ||
|
||
# Backup files # | ||
*.bak | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from django.contrib.auth.signals import user_logged_in | ||
from django.dispatch import receiver | ||
from datetime import datetime | ||
from dateutil.relativedelta import relativedelta | ||
from .models import ControlPoint | ||
|
||
|
||
class SanityCheckMiddleware: | ||
last_checked = datetime.today() # Class variable to store the last check date | ||
|
||
def __init__(self, get_response): | ||
self.get_response = get_response | ||
|
||
def __call__(self, request): | ||
response = self.get_response(request) | ||
self.run_daily_checks() | ||
return response | ||
|
||
def run_daily_checks(self): | ||
"""Performs the daily integrity checks.""" | ||
today = datetime.today().date() | ||
|
||
if SanityCheckMiddleware.last_checked != today: | ||
self.check_control_points(today) | ||
SanityCheckMiddleware.last_checked = today | ||
|
||
@staticmethod | ||
def check_control_points(today): | ||
"""Checks and updates the status of ControlPoint.""" | ||
yesterday=today - relativedelta(days=1) | ||
|
||
"""Update SCHD to TOBE when period start""" | ||
s=today.replace(day=1) | ||
e=today.replace(day=1) + relativedelta(months=1) | ||
scheduled_controls = ControlPoint.objects.filter(period_start_date__lte=today, | ||
period_end_date__gte=today, | ||
status="SCHD") | ||
scheduled_controls.update(status='TOBE') | ||
|
||
"""Update expired TOBE to MISS """ | ||
missed_controls = ControlPoint.objects.filter(period_start_date__lt=today, | ||
period_end_date__lt=today, | ||
status="TOBE") | ||
missed_controls.update(status='MISS') | ||
|
||
|
||
# Connect the user login signal | ||
@receiver(user_logged_in) | ||
def update_on_login(sender, user, request, **kwargs): | ||
middleware = SanityCheckMiddleware(None) | ||
middleware.run_daily_checks() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
conformity/migrations/0041_rename_policy_framework_alter_framework_options_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Generated by Django 4.2.9 on 2024-08-25 02:39 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('conformity', '0040_alter_control_level'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameModel( | ||
old_name='Policy', | ||
new_name='Framework', | ||
), | ||
migrations.AlterModelOptions( | ||
name='framework', | ||
options={'ordering': ['name'], 'verbose_name': 'Framework', 'verbose_name_plural': 'Frameworks'}, | ||
), | ||
migrations.RenameField( | ||
model_name='measure', | ||
old_name='policy', | ||
new_name='framework', | ||
), | ||
migrations.RenameField( | ||
model_name='audit', | ||
old_name='audited_policies', | ||
new_name='audited_frameworks', | ||
), | ||
] |
30 changes: 30 additions & 0 deletions
30
conformity/migrations/0042_rename_measure_requirement_alter_conformity_options_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 4.2.9 on 2024-08-25 04:38 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('conformity', '0041_rename_policy_framework_alter_framework_options_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameModel( | ||
old_name='Measure', | ||
new_name='Requirement', | ||
), | ||
migrations.AlterModelOptions( | ||
name='conformity', | ||
options={'ordering': ['organization', 'requirement'], 'verbose_name': 'Conformity', 'verbose_name_plural': 'Conformities'}, | ||
), | ||
migrations.RenameField( | ||
model_name='conformity', | ||
old_name='measure', | ||
new_name='requirement', | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='conformity', | ||
unique_together={('organization', 'requirement')}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 4.2.9 on 2024-10-12 02:57 | ||
|
||
from django.db import migrations, models | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('conformity', '0042_rename_measure_requirement_alter_conformity_options_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Attachment', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('file', models.FileField(upload_to='attachments/')), | ||
('comment', models.TextField(blank=True, max_length=4096)), | ||
('mime_type', models.CharField(blank=True, max_length=255)), | ||
('create_date', models.DateField(default=django.utils.timezone.now)), | ||
], | ||
), | ||
] |
43 changes: 43 additions & 0 deletions
43
conformity/migrations/0044_action_attachment_audit_attachment_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 4.2.9 on 2024-10-12 03:03 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('conformity', '0043_attachment'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='action', | ||
name='attachment', | ||
field=models.ManyToManyField(blank=True, related_name='actions', to='conformity.attachment'), | ||
), | ||
migrations.AddField( | ||
model_name='audit', | ||
name='attachment', | ||
field=models.ManyToManyField(blank=True, related_name='audits', to='conformity.attachment'), | ||
), | ||
migrations.AddField( | ||
model_name='controlpoint', | ||
name='attachment', | ||
field=models.ManyToManyField(blank=True, related_name='ControlPoint', to='conformity.attachment'), | ||
), | ||
migrations.AddField( | ||
model_name='finding', | ||
name='attachment', | ||
field=models.ManyToManyField(blank=True, related_name='findings', to='conformity.attachment'), | ||
), | ||
migrations.AddField( | ||
model_name='framework', | ||
name='attachment', | ||
field=models.ManyToManyField(blank=True, related_name='frameworks', to='conformity.attachment'), | ||
), | ||
migrations.AddField( | ||
model_name='organization', | ||
name='attachment', | ||
field=models.ManyToManyField(blank=True, related_name='organizations', to='conformity.attachment'), | ||
), | ||
] |
Oops, something went wrong.