Skip to content

Commit

Permalink
Merge pull request #2991 from unicef/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
ntrncic authored Apr 29, 2021
2 parents cac1e68 + 517a31b commit 04ec0b8
Show file tree
Hide file tree
Showing 148 changed files with 1,324 additions and 11,311 deletions.
16 changes: 8 additions & 8 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ isort = "*"
ipython = "*"
pdbpp = "*"
tox = "*"
drf-api-checker = "*"
factory-boy = ">=2.11"
sphinx = "*"
vcrpy = "*"

[packages]
azure-common = "==1.1.26"
azure-common = "==1.1.27"
azure-storage-blob = "==2.1.0"
azure-storage-common = "==2.1.0"
carto = "==1.11.2"
celery = "==5.0.5"
cryptography = "<3.4"
dj-database-url = "==0.5"
dj-static = "==0.0.6"
Django = "<3.0"
django-appconf = "==1.0.4"
django_celery_beat = "==2.1"
django-celery-email = "==3.0.0"
django_celery_results = "==2.0.0"
django-contrib-comments = "==2.0.0"
django-contrib-comments = "==2.1.0"
django-cors-headers = "==3.6.0"
django-debug-toolbar = "==3.2"
django-extensions = "==3.1.0"
django-extensions = "==3.1.2"
django-easy-pdf = "==0.1.1" # not maintained dj<3.0
django-filter = "==2.4.0"
django-fsm = "==2.7.1"
Expand All @@ -49,15 +49,15 @@ django-redis-cache = "==3.0"
django-rest-swagger = "==2.2"
django-storages = {extras = ["azure"],version = "==1.11.1"}
django-tenants = "==3.2.1"
django-timezone-field = "==4.1.1"
django-timezone-field = "==4.1.2"
django-waffle = "==2.0.0"
djangorestframework-csv = "==2.1.0"
djangorestframework-gis = "==0.16"
djangorestframework-jwt = "==1.11.0"
djangorestframework-recursive = "==0.1.2"
djangorestframework-xml = "==2.0.0"
djangorestframework = "==3.12.2"
drf-nested-routers = "==0.92.5"
djangorestframework = "==3.12.4"
drf-nested-routers = "==0.93.3"
drf-querystringfilter = "==1.0.0"
etools-validator = "==0.3.4"
flower = "==0.9.5" # issue when locking
Expand All @@ -75,7 +75,7 @@ unicef_attachments = "==0.9.0"
unicef-djangolib = "==0.5.4"
unicef-locations = "==1.9"
unicef_notification = "==0.2.1"
unicef_restlib = "==0.6.1"
unicef_restlib = "==0.7"
unicef_snapshot = "==0.2.3"
unicef-rest-export = "==0.5.3"
xhtml2pdf = "==0.2.5"
Expand Down
841 changes: 435 additions & 406 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/etools/applications/action_points/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ def filter_queryset(self, request, queryset, view):
ActionPoint.MODULE_CHOICES.tpm: {'tpm_activity__isnull': False},
ActionPoint.MODULE_CHOICES.psea: {'psea_assessment__isnull': False},
ActionPoint.MODULE_CHOICES.audit: {'engagement__isnull': False},
ActionPoint.MODULE_CHOICES.fm: {'monitoring_activity__isnull': False},
ActionPoint.MODULE_CHOICES.apd: {
'travel_activity__isnull': True,
'tpm_activity__isnull': True,
'psea_assessment__isnull': True,
'engagement__isnull': True
'engagement__isnull': True,
'monitoring_activity__isnull': True,
},
}
if related_module not in related_instance_filters:
Expand Down
2 changes: 1 addition & 1 deletion src/etools/applications/audit/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EngagementAdmin(admin.ModelAdmin):
]
search_fields = 'partner__name', 'agreement__auditor_firm__name',
filter_horizontal = ('authorized_officers', 'active_pd', 'staff_members', 'users_notified', 'sections', 'offices')
raw_id_fields = ('po_item', 'partner')
raw_id_fields = ('po_item', 'partner', 'active_pd', 'staff_members', 'authorized_officers', 'users_notified', )


@admin.register(RiskCategory)
Expand Down
2 changes: 2 additions & 0 deletions src/etools/applications/audit/purchase_order/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class AuditorStaffAdmin(admin.ModelAdmin):
list_display = ['user', 'email', 'auditor_firm', 'hidden']
list_filter = ['auditor_firm', 'hidden']
search_fields = ['user__username', 'user__email', 'user__first_name', 'user__last_name', 'auditor_firm__name', ]
readonly_fields = 'history',
raw_id_fields = ['user', ]

def email(self, obj):
return obj.user.email
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 2.2.20 on 2021-04-15 15:46

import django.contrib.postgres.fields
from django.db import migrations, models
import django.utils.timezone
import model_utils.fields


class Migration(migrations.Migration):

dependencies = [
('purchase_order', '0007_auto_20190625_1437'),
]

operations = [
migrations.AddField(
model_name='auditorstaffmember',
name='created',
field=model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created'),
),
migrations.AddField(
model_name='auditorstaffmember',
name='history',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=50, verbose_name='History'), blank=True, default=list, size=None),
),
migrations.AddField(
model_name='auditorstaffmember',
name='modified',
field=model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.20 on 2021-04-21 17:45

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('purchase_order', '0008_auto_20210415_1546'),
]

operations = [
migrations.AlterField(
model_name='auditorstaffmember',
name='history',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=128, verbose_name='History'), blank=True, default=list, size=None),
),
]
32 changes: 31 additions & 1 deletion src/etools/applications/audit/views.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType
from django.db import transaction
from django.db.models import Prefetch
from django.http import Http404
from django.utils import timezone
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _

from django_filters.rest_framework import DjangoFilterBackend
from easy_pdf.rendering import render_to_pdf_response
from rest_framework import generics, mixins, viewsets
from rest_framework.decorators import action
from rest_framework.exceptions import NotFound
from rest_framework.exceptions import NotFound, ValidationError
from rest_framework.filters import OrderingFilter, SearchFilter
from rest_framework.permissions import IsAuthenticated
from rest_framework.renderers import JSONRenderer
Expand Down Expand Up @@ -512,9 +514,33 @@ def perform_create(self, serializer, **kwargs):
instance.user.groups.add(Auditor.as_group())
instance.user.profile.save()

@transaction.atomic
def perform_update(self, serializer):
self.check_serializer_permissions(serializer, edit=True)

if 'email' in serializer.validated_data['user']:
hidden_staff = AuditorStaffMember.objects.filter(
user__email=serializer.validated_data['user']['email'], hidden=True).first()
if hidden_staff:
if hidden_staff.auditor_firm != self.get_parent_object():
raise ValidationError(f'User already associated with {hidden_staff.auditor_firm}')
else:
hidden_staff.hidden = False
timestamp = str(now())
hidden_staff.history.append(
f'requestor:{self.request.user.username},hidden:{hidden_staff.hidden},timestamp:{timestamp}'
)
hidden_staff.save()
deactivated_user = hidden_staff.user
deactivated_user.is_active = True
deactivated_user.save()
deleted_profile = hidden_staff.user.profile
deleted_profile.countries_available.add(self.request.tenant)
if not deleted_profile.country:
deleted_profile.country = self.request.tenant
deleted_profile.save()
return

super().perform_update(serializer)
instance = serializer.save(auditor_firm=self.get_parent_object())
if not instance.user.profile.country:
Expand All @@ -524,7 +550,11 @@ def perform_update(self, serializer):

def perform_destroy(self, instance):
# deactivate staff member & user
timestamp = str(now())
instance.hidden = True
instance.history.append(
f'requestor:{self.request.user.username},hidden:{instance.hidden},timestamp:{timestamp}'
)
instance.save()
if not instance.user.is_unicef_user():
instance.user.is_active = False
Expand Down
175 changes: 174 additions & 1 deletion src/etools/applications/core/data/field_monitoring_questions.json
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,62 @@
"sections": []
}
},
{
"model": "field_monitoring_settings.question",
"pk": 1033,
"fields": {
"answer_type": "likert_scale",
"choices_size": null,
"level": "partner",
"category": 6,
"text": "Do UNICEF-supported sites of the partner have visible communications materials (posters, leaflets, brochures) on how to report allegations of sexual exploitation and abuse?",
"is_hact": false,
"is_custom": false,
"is_active": true,
"methods": [
3
],
"sections": []
}
},
{
"model": "field_monitoring_settings.question",
"pk": 1034,
"fields": {
"answer_type": "likert_scale",
"choices_size": null,
"level": "partner",
"category": 6,
"text": "Proportion of partner personnel (staff, consultants, volunteers, interns, sub-contractors) in the location who have received a training on PSEA In the last 12 months that meets the minimum criteria?",
"is_hact": false,
"is_custom": false,
"is_active": true,
"methods": [
1,
2
],
"sections": []
}
},
{
"model": "field_monitoring_settings.question",
"pk": 1035,
"fields": {
"answer_type": "likert_scale",
"choices_size": null,
"level": "partner",
"category": 6,
"text": "Proportion of beneficiaries in the programme location that can explain at least one channel to report SEA (such as SMS, phone hotline, email, feedback box, PSEA focal point from partner organization)",
"is_hact": false,
"is_custom": false,
"is_active": true,
"methods": [
1,
2
],
"sections": []
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1,
Expand Down Expand Up @@ -1359,5 +1415,122 @@
"label": "Plausible good sustainability after programme exit",
"value": "3"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1084,
"fields": {
"question": 1033,
"label": "No",
"value": "1"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1085,
"fields": {
"question": 1033,
"label": "Yes, includes some of the necessary elements",
"value": "2"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1086,
"fields": {
"question": 1033,
"label": "Yes, includes all of the necessary elements",
"value": "3"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1087,
"fields": {
"question": 1034,
"label": "None",
"value": "1"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1088,
"fields": {
"question": 1034,
"label": "1-25% have received training",
"value": "2"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1089,
"fields": {
"question": 1034,
"label": "26%-50% have received training",
"value": "3"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1090,
"fields": {
"question": 1034,
"label": "51-75% have received training",
"value": "4"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1091,
"fields": {
"question": 1034,
"label": "76-100% have received training",
"value": "5"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1092,
"fields": {
"question": 1035,
"label": "None of the beneficiaries are aware",
"value": "1"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1093,
"fields": {
"question": 1035,
"label": "1-25% of beneficiaries are aware",
"value": "2"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1094,
"fields": {
"question": 1035,
"label": "26-50% of beneficiaries are aware",
"value": "3"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1095,
"fields": {
"question": 1035,
"label": "51%-75% of beneficiaries are aware",
"value": "4"
}
},
{
"model": "field_monitoring_settings.option",
"pk": 1096,
"fields": {
"question": 1035,
"label": "76%-100% of beneficiaries are aware",
"value": "5"
}
}
]
]
Loading

0 comments on commit 04ec0b8

Please sign in to comment.