Skip to content

Commit f1a71f8

Browse files
susilnemsudip-khanalshreeyash07
authored
Project/local unit updates and permisson (#2611)
* feat(local_units): add fields in health data model * fix(local-units): remove other profiles field from and add mixin * feat(local-unit): add permission for country admin to edit local unit * feat(local-unit): add permission for regional admin to edit local unit * Refactor bulk upload logic for XLSX file processing (#2575) * fix(bulk-upload) update bulk upload logic for XLSX files * fix(local-unit): update import template * feat(bulk-upload): add .xlsm file support to bulk upload * local-unit(bulk-upload-template): update bulk upload health data template * local-unit(permission): add ifrc admin permission to update local unit * feat(permission): add organization type and country check to update local unit * feat(local_unit): Enable email notification * chore(assets): Update assets reference * chore(assets): Update assets commit reference --------- Co-authored-by: sudip-khanal <sudipkhanal0777@gmail.com> Co-authored-by: Shreeyash Shrestha <shreeyash.shrestha@togglecorp.com> Co-authored-by: Sudip Khanal <101724348+sudip-khanal@users.noreply.github.com>
1 parent 0c83759 commit f1a71f8

22 files changed

Lines changed: 568 additions & 164 deletions

assets

deploy/helm/ifrcgo-helm/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ cronjobs:
274274
schedule: '0 0 * * 0'
275275
- command: 'ingest_icrc'
276276
schedule: '0 3 * * 0'
277-
# - command: 'notify_validators'
278-
# schedule: '0 0 * * *'
277+
- command: 'notify_validators'
278+
schedule: '0 0 * * *'
279279
# https://github.com/jazzband/django-oauth-toolkit/blob/master/docs/management_commands.rst#cleartokens
280280
- command: 'oauth_cleartokens'
281281
schedule: '0 1 * * *'
Binary file not shown.
Binary file not shown.

go-static/files/local_units/local-unit-bulk-upload-template.csv

Lines changed: 0 additions & 1 deletion
This file was deleted.

go-static/files/local_units/local-unit-health-bulk-upload-template.csv

Lines changed: 0 additions & 1 deletion
This file was deleted.

local_units/admin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
LocalUnitChangeRequest,
2222
LocalUnitLevel,
2323
LocalUnitType,
24+
OtherProfile,
2425
PrimaryHCC,
2526
ProfessionalTrainingFacility,
2627
SpecializedMedicalService,
@@ -206,6 +207,11 @@ class ProfessionalTrainingFacilityAdmin(admin.ModelAdmin):
206207
search_fields = ("name",)
207208

208209

210+
@admin.register(OtherProfile)
211+
class OtherProfileAdmin(admin.ModelAdmin):
212+
search_fields = ("position",)
213+
214+
209215
@admin.register(HealthData)
210216
class HealthDataAdmin(CompareVersionAdmin, admin.ModelAdmin):
211217
autocomplete_fields = [

local_units/bulk_upload.py

Lines changed: 213 additions & 90 deletions
Large diffs are not rendered by default.

local_units/management/commands/notify_validators.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,44 @@
44
from django.core.management.base import BaseCommand
55
from django.template.loader import render_to_string
66
from django.utils import timezone
7+
from sentry_sdk.crons import monitor
78

89
from local_units.models import LocalUnit, Validator
910
from local_units.utils import (
1011
get_email_context,
1112
get_local_unit_global_validators,
1213
get_local_unit_region_validators,
1314
)
14-
15-
# from main.sentry import SentryMonitor
15+
from main.sentry import SentryMonitor
1616
from notifications.notification import send_notification
1717

18-
# from sentry_sdk.crons import monitor
19-
2018

2119
class Command(BaseCommand):
2220
help = "Notify validators for the pending local units in different period of time"
2321

24-
# @monitor(monitor_slug=SentryMonitor.NOTIFY_VALIDATORS) # NOTE: Disabled for now
22+
@monitor(monitor_slug=SentryMonitor.NOTIFY_VALIDATORS)
2523
def handle(self, *args, **options):
2624
self.stdout.write(self.style.NOTICE("Notifying the validators..."))
27-
# NOTE: In production use standard email notification time(7days/14days),shorter delays(1day/2days) elsewhere for testing
25+
"""NOTE:
26+
Notification delays are environment-dependent:
27+
7/14 days in production, 1/2 days in other environments for testing purposes.
28+
"""
2829
production = settings.GO_ENVIRONMENT == "production"
2930
if production:
3031
regional_email_notification_days = 7
3132
global_email_notification_days = 14
3233
else:
3334
regional_email_notification_days = 1
3435
global_email_notification_days = 2
35-
# Regional Validators: 14 days
36+
# Regional Validators: 7 days
3637
queryset_for_regional_validators = LocalUnit.objects.filter(
3738
status__in=[LocalUnit.Status.UNVALIDATED, LocalUnit.Status.PENDING_EDIT_VALIDATION],
3839
is_deprecated=False,
3940
last_sent_validator_type=Validator.LOCAL,
4041
created_at__lte=timezone.now() - timedelta(days=regional_email_notification_days),
4142
)
4243

43-
# Global Validators: 28 days
44+
# Global Validators: 14 days
4445
queryset_for_global_validators = LocalUnit.objects.filter(
4546
status__in=[LocalUnit.Status.UNVALIDATED, LocalUnit.Status.PENDING_EDIT_VALIDATION],
4647
is_deprecated=False,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Generated by Django 4.2.19 on 2025-10-16 09:46
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('local_units', '0023_remove_localunit_is_locked_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name='OtherProfile',
15+
fields=[
16+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17+
('position', models.CharField(verbose_name='Position')),
18+
('number', models.PositiveIntegerField(verbose_name='Number')),
19+
],
20+
options={
21+
'verbose_name': 'Other Profile',
22+
'verbose_name_plural': 'Other Profiles',
23+
},
24+
),
25+
migrations.AddField(
26+
model_name='healthdata',
27+
name='other_training_facilities',
28+
field=models.TextField(blank=True, null=True, verbose_name='Other Training Facilities'),
29+
),
30+
migrations.AddField(
31+
model_name='healthdata',
32+
name='pharmacists',
33+
field=models.IntegerField(blank=True, null=True, verbose_name='Pharmacists'),
34+
),
35+
migrations.RemoveField(
36+
model_name='healthdata',
37+
name='other_profiles',
38+
),
39+
migrations.AddField(
40+
model_name='healthdata',
41+
name='other_profiles',
42+
field=models.ManyToManyField(blank=True, related_name='health_data_other_profile', to='local_units.otherprofile', verbose_name='Other Profiles'),
43+
),
44+
]

0 commit comments

Comments
 (0)