Skip to content

Commit

Permalink
add vision app (#4274)
Browse files Browse the repository at this point in the history
* contrib refactoring

* contrib refactoring

---------

Co-authored-by: Pavlo Mokiichuk <[email protected]>
  • Loading branch information
domdinicola and pavlo-mk authored Oct 4, 2024
1 parent 048e48b commit e9dc18d
Show file tree
Hide file tree
Showing 53 changed files with 336 additions and 93 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,8 @@ cov.json
.vscode/
output_data/
.coverage

archive/
output.json
pytest_html_report.html
compose.dist.yml
9 changes: 1 addition & 8 deletions src/hct_mis_api/apps/core/management/commands/initdemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def handle(self, *args: Any, **options: Any) -> None:
call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/household/fixtures/data.json")
call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/accountability/fixtures/data.json")
call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/steficon/fixtures/data.json")
call_command("loaddata", f"{settings.PROJECT_ROOT}/aurora/fixtures/data.json")
call_command("loaddata", f"{settings.PROJECT_ROOT}/contrib/aurora/fixtures/data.json")

try:
call_command("search_index", "--rebuild", "-f")
Expand All @@ -86,14 +86,9 @@ def handle(self, *args: Any, **options: Any) -> None:
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
Expand All @@ -103,10 +98,8 @@ def handle(self, *args: Any, **options: Any) -> None:
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
]
tester_list = [
"[email protected]",
Expand Down
4 changes: 2 additions & 2 deletions src/hct_mis_api/apps/core/tasks_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# "schedule": crontab(hour="*/24"),
# },
"extract_records_task": {
"task": "hct_mis_api.aurora.celery_tasks.extract_records_task",
"task": "hct_mis_api.contrib.aurora.celery_tasks.extract_records_task",
"schedule": crontab(hour="*/24"),
},
"remove_old_cash_plan_payment_verification_xls": {
Expand All @@ -42,7 +42,7 @@
"schedule": crontab(minute="*/15"),
},
"clean_old_record_files_task": {
"task": "hct_mis_api.aurora.celery_tasks.clean_old_record_files_task",
"task": "hct_mis_api.contrib.aurora.celery_tasks.clean_old_record_files_task",
"schedule": crontab(month_of_year="2-12/2"),
},
"periodic_sync_payment_gateway_fsp": {
Expand Down
4 changes: 2 additions & 2 deletions src/hct_mis_api/apps/household/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
)

if TYPE_CHECKING:
from hct_mis_api.aurora.models import Record
from hct_mis_api.contrib.aurora.models import Record

BLANK = ""
IDP = "IDP"
Expand Down Expand Up @@ -658,7 +658,7 @@ def alternate_collector(self) -> Optional["Individual"]:

@property
def flex_registrations_record(self) -> Optional["Record"]:
from hct_mis_api.aurora.models import Record
from hct_mis_api.contrib.aurora.models import Record

return Record.objects.filter(id=self.flex_registrations_record_id).first()

Expand Down
1 change: 1 addition & 0 deletions src/hct_mis_api/apps/program/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class ProgramConfig(AppConfig):
name = "hct_mis_api.apps.program"
verbose_name = "Programme"

def ready(self) -> None:
from hct_mis_api.apps.grievance import signals as grievance_signals
Expand Down
3 changes: 2 additions & 1 deletion src/hct_mis_api/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,11 @@
"hct_mis_api.apps.steficon.apps.SteficonConfig",
"hct_mis_api.apps.reporting.apps.ReportingConfig",
"hct_mis_api.apps.activity_log.apps.ActivityLogConfig",
"hct_mis_api.aurora.apps.Config",
"hct_mis_api.apps.accountability.apps.AccountabilityConfig",
"hct_mis_api.apps.web.apps.WebConfig",
"hct_mis_api.apps.periodic_data_update.apps.PeriodicDataUpdateConfig",
"hct_mis_api.contrib.aurora.apps.Config",
"hct_mis_api.contrib.vision.apps.Config",
]

DJANGO_APPS = [
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
from hct_mis_api.apps.registration_data.models import RegistrationDataImport
from hct_mis_api.apps.utils.admin import HOPEModelAdminBase
from hct_mis_api.apps.utils.security import is_root
from hct_mis_api.aurora import models
from hct_mis_api.aurora.celery_tasks import fresh_extract_records_task
from hct_mis_api.aurora.models import Record, Registration
from hct_mis_api.aurora.services.extract_record import extract
from hct_mis_api.aurora.services.flex_registration_service import (
from hct_mis_api.contrib.aurora import models
from hct_mis_api.contrib.aurora.celery_tasks import fresh_extract_records_task
from hct_mis_api.contrib.aurora.models import Record, Registration
from hct_mis_api.contrib.aurora.services.extract_record import extract
from hct_mis_api.contrib.aurora.services.flex_registration_service import (
create_task_for_processing_records,
)
from hct_mis_api.aurora.utils import fetch_records, get_metadata
from hct_mis_api.contrib.aurora.utils import fetch_records, get_metadata


class StatusFilter(ChoicesFieldComboFilter):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# from rest_framework import serializers
# from rest_framework.generics import ListAPIView
#
# from hct_mis_api.aurora.models import AuroraRegistration
# from hct_mis_api.contrib.aurora.models import AuroraRegistration
#
#
# class RegistrationDetailSerializer(serializers.ModelSerializer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@


class Config(AppConfig):
name = "hct_mis_api.aurora"
name = "hct_mis_api.contrib.aurora"

def ready(self) -> None:
from hct_mis_api.aurora.rdi import registry
from hct_mis_api.aurora.services.czech_republic_flex_registration_service import (
from hct_mis_api.contrib.aurora.rdi import registry
from hct_mis_api.contrib.aurora.services.czech_republic_flex_registration_service import (
CzechRepublicFlexRegistration,
)
from hct_mis_api.aurora.services.generic_registration_service import (
from hct_mis_api.contrib.aurora.services.generic_registration_service import (
GenericRegistrationService,
)
from hct_mis_api.aurora.services.sri_lanka_flex_registration_service import (
from hct_mis_api.contrib.aurora.services.sri_lanka_flex_registration_service import (
SriLankaRegistrationService,
)
from hct_mis_api.aurora.services.ukraine_flex_registration_service import (
from hct_mis_api.contrib.aurora.services.ukraine_flex_registration_service import (
Registration2024,
UkraineBaseRegistrationService,
UkraineRegistrationService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
)
from hct_mis_api.apps.utils.logs import log_start_and_end
from hct_mis_api.apps.utils.sentry import sentry_tags
from hct_mis_api.aurora.models import Record, Registration
from hct_mis_api.aurora.services.extract_record import extract
from hct_mis_api.contrib.aurora.models import Record, Registration
from hct_mis_api.contrib.aurora.services.extract_record import extract

if TYPE_CHECKING:
from uuid import UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from hct_mis_api.apps.account.fixtures import BusinessAreaFactory
from hct_mis_api.apps.program.fixtures import ProgramFactory
from hct_mis_api.aurora.models import Organization, Project, Registration
from hct_mis_api.contrib.aurora.models import Organization, Project, Registration

faker = Faker()

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django import forms
from django.core.exceptions import ValidationError

from hct_mis_api.aurora.models import Registration
from hct_mis_api.contrib.aurora.models import Registration


class ProjectForm(forms.ModelForm):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from strategy_field.fields import StrategyField

from hct_mis_api.apps.registration_datahub.utils import combine_collections
from hct_mis_api.aurora.rdi import registry
from hct_mis_api.contrib.aurora.rdi import registry


class AuroraModel(models.Model):
Expand Down
File renamed without changes.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from hct_mis_api.apps.household.models import PendingHousehold, PendingIndividual
from hct_mis_api.apps.registration_data.models import ImportData, RegistrationDataImport
from hct_mis_api.apps.registration_datahub.celery_tasks import rdi_deduplication_task
from hct_mis_api.aurora.celery_tasks import process_flex_records_task
from hct_mis_api.aurora.models import Record, Registration
from hct_mis_api.aurora.rdi import AuroraProcessor
from hct_mis_api.contrib.aurora.celery_tasks import process_flex_records_task
from hct_mis_api.contrib.aurora.models import Record, Registration
from hct_mis_api.contrib.aurora.rdi import AuroraProcessor

if TYPE_CHECKING:
from uuid import UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
PendingIndividualRoleInHousehold,
)
from hct_mis_api.apps.registration_data.models import RegistrationDataImport
from hct_mis_api.aurora.services.base_flex_registration_service import (
from hct_mis_api.contrib.aurora.services.base_flex_registration_service import (
BaseRegistrationService,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any, Iterable

from hct_mis_api.apps.registration_datahub.templatetags.smart_register import is_image
from hct_mis_api.aurora.models import Record
from hct_mis_api.contrib.aurora.models import Record

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
PendingIndividualRoleInHousehold,
)
from hct_mis_api.apps.registration_data.models import RegistrationDataImport
from hct_mis_api.aurora.services.base_flex_registration_service import (
from hct_mis_api.contrib.aurora.services.base_flex_registration_service import (
BaseRegistrationService,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from hct_mis_api.apps.periodic_data_update.utils import populate_pdu_with_null_values
from hct_mis_api.apps.registration_data.models import RegistrationDataImport
from hct_mis_api.apps.utils.age_at_registration import calculate_age_at_registration
from hct_mis_api.aurora.services.base_flex_registration_service import (
from hct_mis_api.contrib.aurora.services.base_flex_registration_service import (
BaseRegistrationService,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
PendingIndividualRoleInHousehold,
)
from hct_mis_api.apps.registration_data.models import RegistrationDataImport
from hct_mis_api.aurora.services.base_flex_registration_service import (
from hct_mis_api.contrib.aurora.services.base_flex_registration_service import (
BaseRegistrationService,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.urls import path

from hct_mis_api.aurora.views import FetchDataView, RegistrationDataView
from hct_mis_api.contrib.aurora.views import FetchDataView, RegistrationDataView

app_name = "aurora"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
from coreapi import codecs
from coreapi.exceptions import NoCodecAvailable

from hct_mis_api.aurora.models import Organization, Project, Record, Registration
from hct_mis_api.contrib.aurora.models import (
Organization,
Project,
Record,
Registration,
)

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from admin_extra_buttons.utils import HttpResponseRedirectToReferrer
from sentry_sdk import set_tag

from hct_mis_api.aurora.models import Registration
from hct_mis_api.aurora.utils import fetch_metadata
from hct_mis_api.contrib.aurora.models import Registration
from hct_mis_api.contrib.aurora.utils import fetch_metadata


class FetchDataView(ProcessFormView):
Expand Down
Empty file.
30 changes: 30 additions & 0 deletions src/hct_mis_api/contrib/vision/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.contrib import admin

from adminfilters.filters import ValueFilter

from hct_mis_api.apps.utils.admin import HOPEModelAdminBase
from hct_mis_api.contrib.vision.models import DownPayment, FundsCommitment


@admin.register(FundsCommitment)
class FundsCommitmentAdmin(HOPEModelAdminBase):
list_display = (
"rec_serial_number",
"business_area",
"funds_commitment_item",
"funds_commitment_number",
"posting_date",
)
list_filter = (
"business_area",
"posting_date",
("business_area", ValueFilter),
)
search_fields = ("rec_serial_number", "vendor_id", "wbs_element", "funds_commitment_number")


@admin.register(DownPayment)
class DownPaymentAdmin(HOPEModelAdminBase):
list_display = ("rec_serial_number", "down_payment_reference", "business_area", "consumed_fc_number")

list_filter = (("business_area", ValueFilter),)
6 changes: 6 additions & 0 deletions src/hct_mis_api/contrib/vision/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class Config(AppConfig):
name = "hct_mis_api.contrib.vision"
verbose_name = "Vision"
25 changes: 25 additions & 0 deletions src/hct_mis_api/contrib/vision/fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import factory.fuzzy
from factory.django import DjangoModelFactory
from pytz import utc

from hct_mis_api.apps.core.models import BusinessArea
from hct_mis_api.contrib.vision.models import FundsCommitment


class FundsCommitmentFactory(DjangoModelFactory):
class Meta:
model = FundsCommitment

rec_serial_number = factory.fuzzy.FuzzyInteger(1000, 99999999)
business_area = factory.LazyAttribute(lambda o: BusinessArea.objects.first().cash_assist_code)
document_type = "DO"
currency_code = factory.Faker("currency_code")

total_open_amount_local = factory.fuzzy.FuzzyDecimal(100.0, 10000.0)
total_open_amount_usd = factory.fuzzy.FuzzyDecimal(100.0, 10000.0)
update_date = factory.Faker(
"date_time_this_decade",
before_now=True,
after_now=False,
tzinfo=utc,
)
Loading

0 comments on commit e9dc18d

Please sign in to comment.