Skip to content

Commit d9b6a72

Browse files
Merge pull request #1487 from IFRCGo/develop
2022 end-July release
2 parents 99c2822 + 5d796f3 commit d9b6a72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+3858
-378
lines changed

CHANGELOG.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## Unreleased
88

9+
## 1.1.446
10+
11+
### Added
12+
- Indexing ElasticSearch results by visibilities
13+
- Surge map performance tuning:
14+
- eliminated FR queries
15+
- molnix and country stuff to prefetch
16+
- so there are only 10 queries now by personnel end-point call
17+
- end_date index matters (is_active not), so end_date index added
18+
- Accounts with identical email addresses - use the active one.
19+
- PER Overview creation fix
20+
21+
## 1.1.445
22+
## 1.1.444
23+
## 1.1.443
24+
- DREF final report
25+
- Flash update notification
26+
- Notification GUID details - showing "created_at"
27+
- Real_data_update date comparison to appeal endpoint
28+
- Rich Text Editor enhancements
29+
- Adding Notes to AppealFilter
30+
- Fixing flash update PDF
31+
- Logging frontend login attempts
32+
- Search output enhanced with visibility
33+
- Contacts to FR notification
34+
935
## 1.1.442
1036

1137
### Added
@@ -1988,7 +2014,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
19882014

19892015
## 0.1.20
19902016

1991-
[Unreleased]: https://github.com/IFRCGo/go-api/compare/1.1.442...HEAD
2017+
[Unreleased]: https://github.com/IFRCGo/go-api/compare/1.1.446...HEAD
2018+
[1.1.446]: https://github.com/IFRCGo/go-api/compare/1.1.445...1.1.446
2019+
[1.1.445]: https://github.com/IFRCGo/go-api/compare/1.1.444...1.1.445
2020+
[1.1.444]: https://github.com/IFRCGo/go-api/compare/1.1.443...1.1.444
2021+
[1.1.443]: https://github.com/IFRCGo/go-api/compare/1.1.442...1.1.443
19922022
[1.1.442]: https://github.com/IFRCGo/go-api/compare/1.1.441...1.1.442
19932023
[1.1.441]: https://github.com/IFRCGo/go-api/compare/1.1.440...1.1.441
19942024
[1.1.440]: https://github.com/IFRCGo/go-api/compare/1.1.439...1.1.440

api/drf_views.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,13 @@ class EventViewset(ReadOnlyVisibilityViewset):
384384
search_fields = ('name', 'countries__name', 'dtype__name',) # for /docs
385385

386386
def get_queryset(self, *args, **kwargs):
387-
#import pdb; pdb.set_trace();
387+
# import pdb; pdb.set_trace();
388388
qset = super().get_queryset()
389389
if self.action == 'mini_events':
390-
#return Event.objects.filter(parent_event__isnull=True).select_related('dtype')
390+
# return Event.objects.filter(parent_event__isnull=True).select_related('dtype')
391391
return qset.filter(parent_event__isnull=True).select_related('dtype')
392392
return (
393-
#Event.objects.filter(parent_event__isnull=True)
393+
# Event.objects.filter(parent_event__isnull=True)
394394
qset.filter(parent_event__isnull=True).select_related('dtype')
395395
.prefetch_related(
396396
'regions',
@@ -531,6 +531,7 @@ class Meta:
531531
'end_date': ('exact', 'gt', 'gte', 'lt', 'lte'),
532532
'valid_from': ('exact', 'gt', 'gte', 'lt', 'lte'),
533533
'valid_to': ('exact', 'gt', 'gte', 'lt', 'lte'),
534+
'appeal__real_data_update': ('exact', 'gt', 'gte', 'lt', 'lte'),
534535
}
535536

536537

@@ -542,7 +543,7 @@ class AppealViewset(mixins.ListModelMixin, viewsets.GenericViewSet):
542543
queryset = AppealHistory.objects.select_related('appeal__event', 'dtype', 'country', 'region').filter(appeal__code__isnull=False)
543544
# serializer_class = AppealSerializer
544545
serializer_class = AppealHistorySerializer
545-
ordering_fields = ('start_date', 'end_date', 'name', 'aid', 'dtype', 'num_beneficiaries',
546+
ordering_fields = ('start_date', 'end_date', 'appeal__name', 'aid', 'dtype', 'num_beneficiaries',
546547
'amount_requested', 'amount_funded', 'status', 'atype', 'event',)
547548
# filterset_class = AppealFilter
548549
filterset_class = AppealHistoryFilter
@@ -895,6 +896,7 @@ def create_event(self, report):
895896
event = Event.objects.create(
896897
name=report.summary,
897898
dtype=report.dtype,
899+
summary=report.description or '',
898900
disaster_start_date=report.start_date,
899901
auto_generated=True,
900902
auto_generated_source=SOURCES['new_report'],

api/indexes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
'type': 'keyword',
99
'normalizer': 'lowercase'
1010
},
11+
'visibility': {'type': 'text'},
12+
'ns': {'type': 'text'},
1113
'body': {
1214
'type': 'text',
1315
'analyzer': 'autocomplete'

api/management/commands/index_and_notify.py

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from django.contrib.auth.models import User
88
from django.conf import settings
99
from django.template.loader import render_to_string
10+
from django.utils.html import strip_tags
1011

1112
from elasticsearch.helpers import bulk
1213
from utils.elasticsearch import construct_es_data
@@ -23,7 +24,7 @@
2324
time_1_week = timedelta(days=7) # for digest mode
2425
digest_time = int(10314) # weekday - hour - min for digest timing (5 minutes once a week, Monday dawn)
2526
daily_retro = int(654) # hour - min for daily retropective email timing (5 minutes a day) | Should not contain a leading 0!
26-
max_length = 860 # after this length (at the first space) we cut the sent content
27+
max_length = 860 # after this length (at the first space) we cut the sent content. In case of HTML tags we remove tags (to avoid chunked tags)
2728
events_sent_to = {} # to document sent events before re-sending them via specific following
2829
template_types = {
2930
99: 'design/generic_notification.html',
@@ -36,13 +37,19 @@
3637

3738

3839
# Used for 'Notification GUID' record creation in 'send_notification(4th param)'
40+
# Should be ~ github.com/IFRCGo/go-frontend/blob/develop/src/root/views/account.js#L80
3941
RTYPE_NAMES = {
40-
0: 'Emergency',
41-
1: 'Appeal',
42-
2: 'Field Report',
42+
0: 'Emergency', # not to use in rtype_of_subscr
43+
1: 'Appeal', # not to use in rtype_of_subscr
44+
2: 'Field Report', # not to use in rtype_of_subscr – L752 depends: RTYPE_NAMES[rtype]
4345
3: 'Surge Alert',
46+
4: 'Country',
47+
5: 'Region',
48+
6: 'Disaster Type',
49+
7: 'PER Due Date',
4450
8: 'Followed Emergency',
4551
9: 'Surge Deployment',
52+
10: 'Surge Approaching end of Mission',
4653
11: 'Weekly Digest',
4754
12: 'Field Report/Emergency',
4855
13: 'New Operation',
@@ -434,6 +441,7 @@ def construct_template_record(self, rtype, record):
434441
if rtype != RecordType.WEEKLY_DIGEST:
435442
shortened = self.get_record_content(record, rtype)
436443
if len(shortened) > max_length:
444+
shortened = strip_tags(shortened)
437445
shortened = shortened[:max_length] + \
438446
shortened[max_length:].split(' ', 1)[0] + '...' # look for the first space
439447

@@ -442,7 +450,7 @@ def construct_template_record(self, rtype, record):
442450
'resource_uri': self.get_resource_uri(record, rtype),
443451
'admin_uri': self.get_admin_uri(record, rtype),
444452
'title': self.get_record_title(record, rtype),
445-
'description': shortened,
453+
'description': shortened if shortened else None,
446454
'key_figures': {
447455
'affected': self.get_fieldreport_keyfigures(
448456
[record.num_affected, record.gov_num_affected, record.other_num_affected]),
@@ -467,11 +475,87 @@ def construct_template_record(self, rtype, record):
467475
'epi_figures_source': self.get_epi_figures_source_name(record.epi_figures_source),
468476
'sit_fields_date': record.sit_fields_date,
469477
'actions_taken': self.get_actions_taken(record.id),
470-
'actions_others': record.actions_others,
478+
'actions_others': record.actions_others.split("\n") if record.actions_others else None,
471479
'gov_assistance': 'Yes' if record.request_assistance else 'No',
472480
'ns_assistance': 'Yes' if record.ns_request_assistance else 'No',
473481
'dtype_id': record.dtype_id,
474482
'visibility': record.visibility,
483+
'other_fields': {
484+
'appeal': record.appeal,
485+
'appeal_amount': record.appeal_amount,
486+
'bulletin': record.bulletin,
487+
'countries': ', '.join(i.name for i in record.countries.all()),
488+
'contacts': [{'ctype': c.ctype,
489+
'name': c.name,
490+
'title': c.title,
491+
'email': c.email,
492+
'phone': c.phone} for c in record.contacts.all()[::-1]],
493+
#not used this way, but shortened: 'description': record.description,
494+
'districts': ', '.join(i.name for i in record.districts.all()),
495+
'dref': record.dref,
496+
'dref_amount': record.dref_amount,
497+
'epi_cases_since_last_fr': record.epi_cases_since_last_fr,
498+
'epi_deaths_since_last_fr': record.epi_deaths_since_last_fr,
499+
'epi_notes_since_last_fr': record.epi_notes_since_last_fr.split("\n") if record.epi_notes_since_last_fr else None,
500+
'eru_base_camp': record.eru_base_camp,
501+
'eru_base_camp_units': record.eru_base_camp_units,
502+
'eru_basic_health_care': record.eru_basic_health_care,
503+
'eru_basic_health_care_units': record.eru_basic_health_care_units,
504+
'eru_deployment_hospital': record.eru_deployment_hospital,
505+
'eru_deployment_hospital_units': record.eru_deployment_hospital_units,
506+
'eru_it_telecom': record.eru_it_telecom,
507+
'eru_it_telecom_units': record.eru_it_telecom_units,
508+
'eru_logistics': record.eru_logistics,
509+
'eru_logistics_units': record.eru_logistics_units,
510+
'eru_referral_hospital': record.eru_referral_hospital,
511+
'eru_referral_hospital_units': record.eru_referral_hospital_units,
512+
'eru_relief': record.eru_relief,
513+
'eru_relief_units': record.eru_relief_units,
514+
'eru_water_sanitation_15': record.eru_water_sanitation_15,
515+
'eru_water_sanitation_15_units': record.eru_water_sanitation_15_units,
516+
'eru_water_sanitation_20': record.eru_water_sanitation_20,
517+
'eru_water_sanitation_20_units': record.eru_water_sanitation_20_units,
518+
'eru_water_sanitation_40': record.eru_water_sanitation_40,
519+
'eru_water_sanitation_40_units': record.eru_water_sanitation_40_units,
520+
'event': record.event,
521+
'external_partners': ', '.join(i.name for i in record.external_partners.all()),
522+
'forecast_based_action': record.forecast_based_action,
523+
'forecast_based_action_amount': record.forecast_based_action_amount,
524+
'imminent_dref': record.imminent_dref,
525+
'imminent_dref_amount': record.imminent_dref_amount,
526+
'notes_health': record.notes_health,
527+
'notes_ns': record.notes_ns,
528+
'notes_socioeco': record.notes_socioeco,
529+
'other_sources': record.other_sources.split("\n") if record.other_sources else None,
530+
'start_date': record.start_date,
531+
'supported_activities': ', '.join(i.name for i in record.supported_activities.all()),
532+
# not used: 'fact': record.fact,
533+
# not used: 'affected_pop_centres': record.affected_pop_centres,
534+
# not used: 'gov_affected_pop_centres': record.gov_affected_pop_centres,
535+
# not used: 'gov_num_highest_risk': record.gov_num_highest_risk,
536+
# not used: 'gov_num_potentially_affected': record.gov_num_potentially_affected,
537+
# not used: 'health_min_num_assisted': record.health_min_num_assisted,
538+
# not used: 'who_num_assisted': record.who_num_assisted,
539+
# not used: 'ifrc_staff': record.ifrc_staff,
540+
# not used: 'is_covid_report': record.is_covid_report,
541+
# not used: 'num_expats_delegates': record.num_expats_delegates,
542+
# not used: 'num_fact': record.num_fact,
543+
# not used: 'num_highest_risk': record.num_highest_risk,
544+
# not used: 'num_ifrc_staff': record.num_ifrc_staff,
545+
# not used: 'num_localstaff': record.num_localstaff,
546+
# not used: 'num_potentially_affected': record.num_potentially_affected,
547+
# not used: 'rdrt': record.rdrt,
548+
# not used: 'num_rdrt': record.num_rdrt,
549+
# not used: 'num_volunteers': record.num_volunteers,
550+
# not used: 'other_affected_pop_centres': record.other_affected_pop_centres,
551+
# not used: 'other_num_highest_risk': record.other_num_highest_risk,
552+
# not used: 'other_num_potentially_affected': record.other_num_potentially_affected,
553+
# not used: 'regions': ', '.join(i.label for i in record.regions.all()),
554+
# not used: 'report_date': record.report_date,
555+
# not used: 'rid': record.rid,
556+
# not used: 'status': 'Early Warning' if record.status == 8 else 'Event-related',
557+
# not used: 'summary' here, but in the title via "get_record_title"
558+
},
475559
}
476560
elif rtype == RecordType.APPEAL:
477561
optypes = {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.2.27 on 2022-05-10 07:30
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api', '0152_countryoffieldreporttoreview'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='fieldreport',
15+
name='status',
16+
field=models.IntegerField(choices=[(0, 'Unknown'), (2, 'Two'), (3, 'Three'), (8, 'Early Warning'), (9, 'Event-related'), (10, 'Ten')], default=0, verbose_name='type'),
17+
),
18+
]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generated by Django 2.2.28 on 2022-05-13 06:33
2+
3+
import django.contrib.postgres.fields
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('api', '0152_countryoffieldreporttoreview'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='action',
16+
name='organizations',
17+
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(choices=[('NTLS', 'National Society'), ('PNS', 'RCRC'), ('FDRN', 'Federation'), ('GOV', 'Government')], max_length=4), blank=True, default=list, size=None, verbose_name='organizations'),
18+
),
19+
migrations.AlterField(
20+
model_name='actionstaken',
21+
name='organization',
22+
field=models.CharField(choices=[('NTLS', 'National Society'), ('PNS', 'RCRC'), ('FDRN', 'Federation'), ('GOV', 'Government')], max_length=16, verbose_name='organization'),
23+
),
24+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 2.2.27 on 2022-05-13 09:34
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api', '0153_auto_20220513_0633'),
10+
('api', '0153_auto_20220510_0730'),
11+
]
12+
13+
operations = [
14+
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 2.2.27 on 2022-06-21 07:57
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api', '0154_merge_20220513_0934'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='fieldreport',
15+
name='health_min_num_assisted',
16+
field=models.IntegerField(blank=True, help_text='not used any more', null=True, verbose_name='number of assisted (ministry of health)'),
17+
),
18+
migrations.AlterField(
19+
model_name='fieldreport',
20+
name='who_num_assisted',
21+
field=models.IntegerField(blank=True, help_text='not used any more', null=True, verbose_name='number of assisted (who)'),
22+
),
23+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.2.27 on 2022-06-21 09:42
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api', '0155_auto_20220621_0757'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='appealfilter',
15+
name='notes',
16+
field=models.TextField(blank=True, null=True, verbose_name='notes'),
17+
),
18+
]

0 commit comments

Comments
 (0)