Skip to content

Commit

Permalink
Merge pull request #3608 from unicef/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
ntrncic authored Nov 27, 2023
2 parents 8a0377e + df3ec19 commit e9132e9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/etools/applications/audit/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
SpecificProcedure,
SpotCheck,
)
from etools.libraries.djangolib.admin import RestrictedEditAdmin


@admin.register(Engagement)
class EngagementAdmin(RestrictedEditAdmin):
class EngagementAdmin(admin.ModelAdmin):
list_display = [
'__str__', 'status', 'partner', 'date_of_field_visit',
'engagement_type', 'start_date', 'end_date', 'year_of_audit',
Expand Down
49 changes: 35 additions & 14 deletions src/etools/applications/audit/serializers/risks.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,21 +361,42 @@ def calculate_risk(category):
if category.applicable_questions:
category.risk_score = category.risk_points / category.applicable_questions

lowest_score_possible = category.applicable_questions
highest_score_possible = 4 * lowest_score_possible
banding_width = highest_score_possible - lowest_score_possible
low_points_below = lowest_score_possible + banding_width * 0.15
moderate_points_below = lowest_score_possible + banding_width * 0.3
significant_points_below = lowest_score_possible + banding_width * 0.5

if category.risk_points < low_points_below:
category.risk_rating = 'low'
elif category.risk_points < moderate_points_below:
category.risk_rating = 'medium'
elif category.risk_points < significant_points_below:
category.risk_rating = 'significant'
if category.code in ['ma_questionnaire', 'ma_subject_areas']:
# v1 calculations
lowest_score_possible = 1
highest_score_possible = (4 * category.applicable_questions + 4 * category.applicable_key_questions)
highest_score_possible = highest_score_possible / category.applicable_questions
banding_width = (highest_score_possible - lowest_score_possible) / 4
low_scores_below = lowest_score_possible + banding_width
moderate_scores_below = low_scores_below + banding_width
significant_score_below = moderate_scores_below + banding_width

category.risk_rating = 0
if category.risk_score < low_scores_below:
category.risk_rating = 'low'
elif category.risk_score < moderate_scores_below:
category.risk_rating = 'medium'
elif category.risk_score < significant_score_below:
category.risk_rating = 'significant'
else:
category.risk_rating = 'high'
else:
category.risk_rating = 'high'
# v2 calculations
lowest_score_possible = category.applicable_questions
highest_score_possible = 4 * lowest_score_possible
banding_width = highest_score_possible - lowest_score_possible
low_points_below = lowest_score_possible + banding_width * 0.15
moderate_points_below = lowest_score_possible + banding_width * 0.3
significant_points_below = lowest_score_possible + banding_width * 0.5

if category.risk_points < low_points_below:
category.risk_rating = 'low'
elif category.risk_points < moderate_points_below:
category.risk_rating = 'medium'
elif category.risk_points < significant_points_below:
category.risk_rating = 'significant'
else:
category.risk_rating = 'high'
else:
category.risk_score = None
category.risk_rating = 0

0 comments on commit e9132e9

Please sign in to comment.