diff --git a/back/.env b/back/.env deleted file mode 100644 index b47f7a4..0000000 --- a/back/.env +++ /dev/null @@ -1,4 +0,0 @@ -EMAIL_HOST_USER=accountemail@yourmail.com -EMAIL_HOST_PASSWORD=accountpasswordhere -SUBMIT_REPORT_DESTINATION_EMAIL=to-address@yourmail.com -SUBMIT_REPORT_FROM_EMAIL=from-address@yourmail.com diff --git a/back/backend/views.py b/back/backend/views.py index 1d55aec..3d62b6b 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -52,19 +52,22 @@ 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: - rules = pol.sections[index].rules - for rule in rules: - try: - named_fields = generate_named_fields_for_section(data['fields']) - result = rule['rule'](data, named_fields) - if not result is None: - info = { - "label": rule['title'], - "rule_break_text": result, - } - data['rule_violations'].append(info) - except Exception as e: - print('Rule "{}" encountered an error. {}'.format(rule['title'], e)) + try: + rules = pol.sections[index].rules + for rule in rules: + try: + named_fields = generate_named_fields_for_section(data['fields']) + result = rule['rule'](data, named_fields) + if not result is None: + info = { + "label": rule['title'], + "rule_break_text": result, + } + 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()) @@ -339,19 +342,22 @@ 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: - rules = pol.sections[s.number].rules - for rule in rules: - try: - named_fields = generate_named_fields_for_section(data['fields']) - result = rule['rule'](data, named_fields) - if not result is None: - info = { - "label": rule['title'], - "rule_break_text": result, - } - data['rule_violations'].append(info) - except Exception as e: - print('Rule "{}" encountered an error. {}'.format(rule['title'], e)) + try: + rules = pol.sections[s.number].rules + for rule in rules: + try: + named_fields = generate_named_fields_for_section(data['fields']) + result = rule['rule'](data, named_fields) + if not result is None: + info = { + "label": rule['title'], + "rule_break_text": result, + } + 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): diff --git a/back/db.sqlite3 b/back/db.sqlite3 index e1d4159..96f3158 100644 Binary files a/back/db.sqlite3 and b/back/db.sqlite3 differ