Skip to content

Commit

Permalink
Merge pull request #2006 from IFRCGo/feature/add-appeal-doc-to-opslea…
Browse files Browse the repository at this point in the history
…rning

Appeal document id to OpsLearning
  • Loading branch information
szabozoltan69 authored Jan 17, 2024
2 parents 4c95aa0 + 42d9b78 commit faccdf6
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api/management/commands/ingest_appeal_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def handle(self, *args, **options):
else:
body = {
"name": "ingest_appeal_docs",
"message": f"Error ingesting appeals_docs on url: {baseurl}, error_code: {smoke_response.code}",
"message": f"Error ingesting appeals_docs on url: {baseurl}, error_code: {smoke_response.status}{smoke.response.reason}",
"status": CronJobStatus.ERRONEOUS,
}
CronJob.sync_cron(body)
Expand Down
3 changes: 3 additions & 0 deletions api/templates/admin/opslearning_change_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{% extends "admin/change_form.html" %}
{% block object-tools-items %}
<li>
<a href="/admin/api/appealdocument/?q={{ original.appeal_code }}" target="_blank" class="historylink">Related Appeal document</a>
</li>
<li>
<a href="/admin/dref/dreffinalreport/?q={{ original.appeal_code }}" target="_blank" class="historylink">Related DREF Final Report</a>
</li>
Expand Down
14 changes: 7 additions & 7 deletions deployments/snapshots/snap_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
'target_total': 0
},
{
'budget_amount_total': 3720000,
'budget_amount_total': 1940000,
'id': 33,
'iso3': 'qdv',
'name': 'country-gEjLhkzKGguporwomItnbNOiAMDGGPmnhdTlXdGvSjcPxzqvNH',
Expand All @@ -371,16 +371,16 @@
'target_total': 0
},
{
'budget_amount_total': 7040000,
'budget_amount_total': 3090000,
'id': 35,
'iso3': 'rSa',
'name': 'country-vqBqljxxKiiFeNlOaEtrfQgsRHykMQTFGmiOGsumHhWkWKVhOB',
'iso3': 'BZd',
'name': 'country-ETrgvqBqljxxKiiFeNlOaEtrfQgsRHykMQTFGmiOGsumHhWkWK',
'ongoing_projects': 1,
'operation_types': [
1
0
],
'operation_types_display': [
'Emergency Operation'
'Programme'
],
'projects_per_sector': [
{
Expand All @@ -389,7 +389,7 @@
'primary_sector_display': 'sect-zoXLUsiDGGfzxGaQpZNRkWGiCklKKQjVUEwcoWFoeqxocQnHYx'
}
],
'society_name': 'society-name-SXZWbVLJLoVBIUCceEjexSfIqPYDWsqYcdduqRpPfQkikTAtLl',
'society_name': 'society-name-rSaSXZWbVLJLoVBIUCceEjexSfIqPYDWsqYcdduqRpPfQkikTA',
'target_total': 0
}
]
Expand Down
3 changes: 3 additions & 0 deletions per/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def get_fields(self, request, obj=None):
return (
'learning_validated',
'appeal_code',
'appeal_document_id',
'type_validated',
'organization_validated',
'sector_validated',
Expand All @@ -196,6 +197,7 @@ def get_fields(self, request, obj=None):
return (
'learning',
'appeal_code',
'appeal_document_id',
'type',
'organization',
'sector',
Expand All @@ -204,6 +206,7 @@ def get_fields(self, request, obj=None):
return (
'learning',
'appeal_code',
'appeal_document_id',
'type',
'organization',
'sector',
Expand Down
18 changes: 18 additions & 0 deletions per/migrations/0095_opslearning_appeal_document_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.23 on 2024-01-17 11:57

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('per', '0094_auto_20240116_1845'),
]

operations = [
migrations.AddField(
model_name='opslearning',
name='appeal_document_id',
field=models.IntegerField(blank=True, null=True, verbose_name='Appeal document ID'),
),
]
3 changes: 2 additions & 1 deletion per/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,12 @@ class OrganizationType(models.IntegerChoices):
NS = 2, _('National Society')


@reversion.register()
@reversion.register(follow=('organization', 'sector', 'per_component', 'organization_validated', 'sector_validated', 'per_component_validated'))
class OpsLearning(models.Model):
learning = models.TextField(verbose_name=_("learning"), null=True, blank=True)
learning_validated = models.TextField(verbose_name=_("learning (validated)"), null=True, blank=True)
appeal_code = models.CharField(verbose_name=_("appeal (MDR) code"), max_length=20, null=True, blank=True)
appeal_document_id = models.IntegerField(verbose_name=_("Appeal document ID"), null=True, blank=True)
type = models.IntegerField(verbose_name=_("type"), choices=LearningType.choices, default=LearningType.LESSON_LEARNED)
type_validated = models.IntegerField(verbose_name=_("type (validated)"), choices=LearningType.choices, default=LearningType.LESSON_LEARNED)
organization = models.ManyToManyField(OrganizationTypes, related_name="organizations", verbose_name=_("Organizations"), blank=True)
Expand Down

0 comments on commit faccdf6

Please sign in to comment.