Skip to content

Commit

Permalink
Merge pull request #3490 from unicef/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
robertavram authored May 8, 2023
2 parents 0c44509 + 70f50bc commit f6e9b83
Show file tree
Hide file tree
Showing 42 changed files with 1,169 additions and 552 deletions.
2 changes: 1 addition & 1 deletion src/etools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION = __version__ = '9.12.1'
VERSION = __version__ = '10.1'
NAME = 'eTools'
1 change: 1 addition & 0 deletions src/etools/applications/audit/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@ class Meta:
'date_of_draft_report_to_ip': ['lte', 'gte', 'gt', 'lt'],
'offices': ['exact', 'in'],
'sections': ['exact', 'in'],
'year_of_audit': ['exact', 'in'],
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Command(BaseCommand):
'audit.engagement.end_date',
'audit.engagement.total_value',
'audit.engagement.joint_audit',
'audit.engagement.year_of_audit',
'audit.engagement.shared_ip_with',
'audit.engagement.related_agreement',
'audit.engagement.sections',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Generated by Django 3.2.6 on 2023-04-14 07:53

from django.db import migrations, models
from django.db.models import F, Subquery, OuterRef
from django.db.models.functions import Extract
from django.utils import timezone

import etools.applications.audit.models


def fill_year_of_audit(apps, schema_editor):
Engagement = apps.get_model('audit', 'Engagement')
Engagement.objects.filter(
engagement_type='audit',
date_of_draft_report_to_ip__isnull=False,
).update(
year_of_audit=Subquery(
Engagement.objects.filter(
pk=OuterRef('pk')
).annotate(
end_year=Extract("date_of_draft_report_to_ip", "year")
).values('end_year')[:1]
)
)
Engagement.objects.filter(
engagement_type='audit',
date_of_draft_report_to_ip__isnull=True,
).update(
year_of_audit=timezone.now().year,
)


class Migration(migrations.Migration):

dependencies = [
('audit', '0023_auto_20220415_1130'),
]

operations = [
migrations.AddField(
model_name='engagement',
name='year_of_audit',
field=models.PositiveSmallIntegerField(default=1, null=True),
),
migrations.RunPython(fill_year_of_audit, migrations.RunPython.noop),
migrations.AlterField(
model_name='engagement',
name='year_of_audit',
field=models.PositiveSmallIntegerField(default=etools.applications.audit.models.get_current_year, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.6 on 2023-04-17 09:36

from django.db import migrations, models
import etools.applications.audit.models


class Migration(migrations.Migration):

dependencies = [
('audit', '0024_audit_year_of_audit'),
]

operations = [
migrations.AlterField(
model_name='engagement',
name='year_of_audit',
field=models.PositiveSmallIntegerField(db_index=True, default=etools.applications.audit.models.get_current_year, null=True),
),
]
5 changes: 5 additions & 0 deletions src/etools/applications/audit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
from etools.libraries.fsm.views import has_action_permission


def get_current_year():
return timezone.now().year


class Engagement(InheritedModelMixin, TimeStampedModel, models.Model):
TYPE_AUDIT = 'audit'
TYPE_MICRO_ASSESSMENT = 'ma'
Expand Down Expand Up @@ -160,6 +164,7 @@ class Engagement(InheritedModelMixin, TimeStampedModel, models.Model):
)

joint_audit = models.BooleanField(verbose_name=_('Joint Audit'), default=False, blank=True)
year_of_audit = models.PositiveSmallIntegerField(null=True, default=get_current_year, db_index=True)
shared_ip_with = ArrayField(models.CharField(
max_length=20, choices=PartnerOrganization.AGENCY_CHOICES
), blank=True, default=list, verbose_name=_('Shared Audit with'))
Expand Down
3 changes: 2 additions & 1 deletion src/etools/applications/audit/serializers/engagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class EngagementSerializer(
class Meta(EngagementListSerializer.Meta):
fields = EngagementListSerializer.Meta.fields + [
'total_value', 'staff_members', 'active_pd', 'authorized_officers', 'users_notified',
'joint_audit', 'shared_ip_with', 'exchange_rate', 'currency_of_report',
'joint_audit', 'year_of_audit', 'shared_ip_with', 'exchange_rate', 'currency_of_report',
'start_date', 'end_date', 'partner_contacted_at', 'date_of_field_visit', 'date_of_draft_report_to_ip',
'date_of_comments_by_ip', 'date_of_draft_report_to_unicef', 'date_of_comments_by_unicef',
'date_of_report_submit', 'date_of_final_report', 'date_of_cancel',
Expand Down Expand Up @@ -533,6 +533,7 @@ class Meta(EngagementSerializer.Meta):
extra_kwargs = EngagementSerializer.Meta.extra_kwargs.copy()
extra_kwargs.update({
'engagement_type': {'read_only': True},
'year_of_audit': {'required': True},
})

def get_number_of_financial_findings(self, obj):
Expand Down
5 changes: 5 additions & 0 deletions src/etools/applications/audit/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.contrib.contenttypes.models import ContentType
from django.core.management import call_command
from django.urls import reverse
from django.utils import timezone

from factory import fuzzy
from rest_framework import status
Expand Down Expand Up @@ -552,6 +553,10 @@ class TestMicroAssessmentCreateViewSet(TestEngagementCreateActivePDViewSet, Base
class TestAuditCreateViewSet(TestEngagementCreateActivePDViewSet, BaseTestEngagementsCreateViewSet, BaseTenantTestCase):
engagement_factory = AuditFactory

def setUp(self):
super().setUp()
self.create_data['year_of_audit'] = timezone.now().year


class TestSpotCheckCreateViewSet(TestEngagementCreateActivePDViewSet, BaseTestEngagementsCreateViewSet,
BaseTenantTestCase):
Expand Down
72 changes: 72 additions & 0 deletions src/etools/applications/core/data/action_points_categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,77 @@
"module": "fm",
"description": "Other"
}
},
{
"model": "categories.category",
"pk": 17,
"fields": {
"order": 17,
"module": "fm",
"description": "Bottleneck Fix / Remedy"
}
},
{
"model": "categories.category",
"pk": 18,
"fields": {
"order": 18,
"module": "fm",
"description": "Improving Performance Against Targets"
}
},
{
"model": "categories.category",
"pk": 19,
"fields": {
"order": 19,
"module": "fm",
"description": "Supplies Issue"
}
},
{
"model": "categories.category",
"pk": 20,
"fields": {
"order": 20,
"module": "fm",
"description": "Partner Performance Issue"
}
},
{
"model": "categories.category",
"pk": 21,
"fields": {
"order": 21,
"module": "fm",
"description": "Coordination Issue"
}
},
{
"model": "categories.category",
"pk": 22,
"fields": {
"order": 22,
"module": "fm",
"description": "Risk to Beneficiaries"
}
},
{
"model": "categories.category",
"pk": 23,
"fields": {
"order": 23,
"module": "fm",
"description": "Preparedness"
}
},
{
"model": "categories.category",
"pk": 24,
"fields": {
"order": 24,
"module": "fm",
"description": "Life Saving"
}
}
]
13 changes: 13 additions & 0 deletions src/etools/applications/core/templatetags/etools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from textwrap import wrap

from django import template
from django.conf import settings
from django.utils.safestring import mark_safe
Expand Down Expand Up @@ -61,3 +63,14 @@ def call_method(obj, method_name, *args):
@register.filter(is_safe=True)
def currency(value):
return currency_format(value)


@register.filter
def text_wrap(text, width=70):
"""
The used PDF libs don't allow CSS word-wrap, so to split long words (e.g. urls)
we wrap the text by lines and join them with spaces to have multiple lines. See:
https://github.com/nigma/django-easy-pdf/issues/65
https://github.com/xhtml2pdf/xhtml2pdf/issues/379
"""
return ' '.join(wrap(text, width))
6 changes: 3 additions & 3 deletions src/etools/applications/partners/exports_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,9 @@ def render_detailed_workplan_budget(self, worksheet):
worksheet.append([
_('EEPM'), _('Effective and efficient programme management'),
'', '', '',
currency_format(self.intervention.management_budgets.total),
currency_format(self.intervention.management_budgets.partner_total),
currency_format(self.intervention.management_budgets.unicef_total),
currency_format(self.intervention.management_budgets.total),
])
self.apply_styles_to_cells(
worksheet, worksheet.max_row, 1, worksheet.max_row, total_columns, [self.fill_blue_pale_light]
Expand Down Expand Up @@ -1071,10 +1071,10 @@ def render_detailed_workplan_budget(self, worksheet):

worksheet.append([
_('Total Cost for all outputs'), '', '', '', '',
currency_format(self.intervention.planned_budget.partner_contribution_local +
self.intervention.planned_budget.total_unicef_cash_local_wo_hq),
currency_format(self.intervention.planned_budget.partner_contribution_local),
currency_format(self.intervention.planned_budget.total_unicef_cash_local_wo_hq),
currency_format(self.intervention.planned_budget.partner_contribution_local +
self.intervention.planned_budget.total_unicef_cash_local_wo_hq),
])
self.apply_styles_to_cells(
worksheet,
Expand Down
Binary file modified src/etools/applications/partners/locale/ar/LC_MESSAGES/django.mo
Binary file not shown.
36 changes: 22 additions & 14 deletions src/etools/applications/partners/locale/ar/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-03-07 13:01+0000\n"
"POT-Creation-Date: 2023-05-04 15:48+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -1176,6 +1176,9 @@ msgstr "التدخل المعدل"
msgid "Intervention amendments"
msgstr "تعديلات التدخل"

msgid "Q1"
msgstr ""

msgid "Intervention"
msgstr "تدخل"

Expand Down Expand Up @@ -1603,6 +1606,11 @@ msgstr "لا يمكن إضافة تعديل جديد أثناء حظر الشر
msgid "Other description required, if type 'Other' selected."
msgstr "مطلوب وصف آخر ، إذا تم تحديد نوع \"أخرى\"."

#, fuzzy
#| msgid "Active"
msgid "Inactive"
msgstr "نشيط"

msgid "Planned Visit to be set only at Partner level"
msgstr "سيتم تعيين الزيارة المخططة على مستوى الشريك فقط"

Expand Down Expand Up @@ -2267,19 +2275,6 @@ msgstr "لا يمكن حذف تقييم مكتمل"
msgid "No vendor number provided for Partner Organization"
msgstr "لم يتم توفير رقم البائع للمؤسسة الشريكة"

msgid ""
"There was a PCA/SSFA signed with this partner or a transaction was performed "
"against this partner. The Partner record cannot be deleted"
msgstr ""
"كان هناك PCA / SSFA موقعة مع هذا الشريك أو تم إجراء معاملة ضد هذا الشريك. لا "
"يمكن حذف سجل الشريك"

msgid "This partner has trips associated to it"
msgstr "هذا الشريك لديه رحلات مرتبطة به"

msgid "This partner has cash transactions associated to it"
msgstr "هذا الشريك لديه معاملات نقدية مرتبطة به"

msgid "Terms to be acknowledged"
msgstr "يجب الاعتراف بالشروط"

Expand All @@ -2302,3 +2297,16 @@ msgstr "لا تحتوي الاستجابة التي أرجعها الخادم ع

msgid "Partnership Manager role required for pca export."
msgstr "دور مدير الشراكة المطلوب لتصدير pca."

#~ msgid ""
#~ "There was a PCA/SSFA signed with this partner or a transaction was "
#~ "performed against this partner. The Partner record cannot be deleted"
#~ msgstr ""
#~ "كان هناك PCA / SSFA موقعة مع هذا الشريك أو تم إجراء معاملة ضد هذا الشريك. "
#~ "لا يمكن حذف سجل الشريك"

#~ msgid "This partner has trips associated to it"
#~ msgstr "هذا الشريك لديه رحلات مرتبطة به"

#~ msgid "This partner has cash transactions associated to it"
#~ msgstr "هذا الشريك لديه معاملات نقدية مرتبطة به"
Binary file modified src/etools/applications/partners/locale/es/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit f6e9b83

Please sign in to comment.