Merge pull request #109 from danieldupriest/policy-error-handling
Policy error handling implemented
This commit is contained in:
commit
05f29b3584
5 changed files with 36 additions and 30 deletions
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.1.7 on 2019-03-03 08:55
|
||||
# Generated by Django 2.1.7 on 2019-03-03 09:06
|
||||
|
||||
import datetime
|
||||
from django.db import migrations, models
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.1.7 on 2019-03-03 08:55
|
||||
# Generated by Django 2.1.7 on 2019-03-03 09:06
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
|
@ -53,6 +53,7 @@ def get_sections(r_id):
|
|||
data.update(get_fields(i.id))
|
||||
# process rules from the policy file if the section is completed
|
||||
if i.completed and not i.approved:
|
||||
try:
|
||||
rules = pol.sections[index].rules
|
||||
for rule in rules:
|
||||
try:
|
||||
|
@ -66,6 +67,8 @@ def get_sections(r_id):
|
|||
data['rule_violations'].append(info)
|
||||
except Exception as e:
|
||||
print('Rule "{}" encountered an error. {}'.format(rule['title'], e))
|
||||
except Exception as e:
|
||||
print('Error accessing policy section {}. Policy file may have changed.'.format(index))
|
||||
# append section to the array
|
||||
section_set["sections"].append(data.copy())
|
||||
|
||||
|
@ -345,6 +348,7 @@ def section(request, report_pk, section_pk):
|
|||
data.update(get_fields(s.id))
|
||||
# process rules from the policy file if the section is completed
|
||||
if s.completed and not s.approved:
|
||||
try:
|
||||
rules = pol.sections[s.number].rules
|
||||
for rule in rules:
|
||||
try:
|
||||
|
@ -358,6 +362,8 @@ def section(request, report_pk, section_pk):
|
|||
data['rule_violations'].append(info)
|
||||
except Exception as e:
|
||||
print('Rule "{}" encountered an error. {}'.format(rule['title'], e))
|
||||
except Exception as e:
|
||||
print('Error accessing policy section {}. Policy file may have been changed.'.format(s.number))
|
||||
return JsonResponse(data)
|
||||
|
||||
def section_complete(section_pk):
|
||||
|
|
BIN
back/db.sqlite3
BIN
back/db.sqlite3
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.1.7 on 2019-03-03 08:55
|
||||
# Generated by Django 2.1.7 on 2019-03-03 09:06
|
||||
|
||||
import django.contrib.auth.models
|
||||
import django.contrib.auth.validators
|
||||
|
@ -34,9 +34,9 @@ class Migration(migrations.Migration):
|
|||
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'users',
|
||||
'verbose_name': 'user',
|
||||
'abstract': False,
|
||||
'verbose_name_plural': 'users',
|
||||
},
|
||||
managers=[
|
||||
('objects', django.contrib.auth.models.UserManager()),
|
||||
|
|
Loading…
Reference in a new issue