Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dataclasses for normalization #6

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
277 changes: 158 additions & 119 deletions src/ngohub/core.py

Large diffs are not rendered by default.

Empty file added src/ngohub/models/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions src/ngohub/models/checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from dataclasses import dataclass
from typing import Dict, Union

from ngohub.models.organization import OrganizationApplication


@dataclass
class CheckOrganizationUserApplication:
user: Union[Dict, None]
application: Union[OrganizationApplication, None]
has_access: Union[bool, None]

def __init__(self) -> None:
self.user = None
self.application = None
self.has_access = None
5 changes: 5 additions & 0 deletions src/ngohub/models/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dataclasses import dataclass


@dataclass
class BaseDataclass: ...
19 changes: 19 additions & 0 deletions src/ngohub/models/locations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from dataclasses import dataclass
from datetime import datetime


@dataclass
class City:
id: int
name: str
county_id: int
created_on: datetime


@dataclass
class County:
id: int
name: str
abbreviation: str
region_id: int
created_on: datetime
10 changes: 10 additions & 0 deletions src/ngohub/models/nomenclatures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from dataclasses import dataclass
from datetime import datetime


@dataclass
class Domain:
id: int
name: str
created_on: datetime
updated_on: datetime
197 changes: 197 additions & 0 deletions src/ngohub/models/organization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
from dataclasses import dataclass
from datetime import datetime
from typing import List

from ngohub.models.core import BaseDataclass
from ngohub.models.locations import City, County
from ngohub.models.nomenclatures import Domain


@dataclass
class OrganizationContact(BaseDataclass):
email: str
phone: str
full_name: str


@dataclass
class OrganizationLegalReprezentative(BaseDataclass):
id: int
created_on: datetime
updated_on: datetime
full_name: str
email: str
phone: str
role: str


@dataclass
class OrganizationDirector(BaseDataclass):
id: int
created_on: datetime
updated_on: datetime
full_name: str
email: str
phone: str
role: str


@dataclass
class OrganizationReportFile(BaseDataclass):
id: int
created_on: datetime
updated_on: datetime
year: int
status: str


@dataclass
class OrganizationReports(OrganizationReportFile):
number_of_volunteers: int
number_of_contractors: int
report: str


@dataclass
class OrganizationPartners(OrganizationReportFile):
number_of_partners: int
path: str


@dataclass
class OrganizationInvestors(OrganizationReportFile):
number_of_investors: int
path: str


@dataclass
class OrganizationGeneral(BaseDataclass):
id: str
created_on: datetime
updated_on: datetime
name: str
alias: str
type: str
email: str
phone: str
year_created: str
cui: str
association_registry_number: str
association_registry_part: str
association_registry_section: str
association_registry_issuer_id: str
national_registry_number: str
raf_number: str
short_description: str
description: str
address: str
logo: str
website: str
facebook: str
instagram: str
twitter: str
linkedin: str
tiktok: str
donation_website: str
redirect_link: str
donation_sms: str
donation_keyword: str
contact: OrganizationContact
organization_address: str
city: City
county: County
organization_city: str
organization_county: str
association_registry_issuer: str


@dataclass
class OrganizationActivity(BaseDataclass):
id: int
created_on: datetime
updated_on: datetime
area: str
is_part_of_federation: bool
is_part_of_coalition: bool
is_part_of_international_organization: bool
international_organization_name: str
is_social_service_viable: bool
offers_grants: bool
is_public_interest_organization: bool
has_branches: bool
federations: List[str]
coalitions: List[str]
domains: List[Domain]
cities: List[str]
branches: List[str]
regions: List[str]


@dataclass
class OrganizationLegal(BaseDataclass):
id: int
created_on: datetime
updated_on: datetime
others: str
organization_statute: str
non_political_affiliation_file: str
balance_sheet_file: str
legal_reprezentative: OrganizationLegalReprezentative
directors: List[OrganizationDirector]


@dataclass
class OrganizationFinancial(BaseDataclass):
id: int
created_on: datetime
updated_on: datetime
type: str
number_of_employees: int
year: int
total: int
status: str
report_status: str
synced_anaf: bool
data: str


@dataclass
class OrganizationReport(BaseDataclass):
id: int
created_on: datetime
updated_on: datetime
reports: List[OrganizationReports]
partners: List[OrganizationPartners]
investors: List[OrganizationInvestors]


@dataclass
class Organization(BaseDataclass):
id: int
created_on: datetime
updated_on: datetime
status: str
general_data: OrganizationGeneral
activity_data: OrganizationActivity
legal_data: OrganizationLegal
financial_data: List[OrganizationFinancial]
report_data: OrganizationReport


@dataclass
class Application(BaseDataclass):
id: int
name: str


@dataclass
class OrganizationApplication(Application):
logo: str
short_description: str
login_link: str
website: str
status: str
ngo_status: str
created_on: datetime
type: str
application_label: str
9 changes: 9 additions & 0 deletions src/ngohub/models/public.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from dataclasses import dataclass

from ngohub.models.core import BaseDataclass


@dataclass
class Version(BaseDataclass):
version: str
revision: str
16 changes: 16 additions & 0 deletions src/ngohub/models/user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from dataclasses import dataclass
from datetime import datetime


@dataclass
class User:
id: int
created_on: datetime
updated_on: datetime
cognito_id: str
name: str
email: str
phone: str
role: str
status: str
organization_id: int
22 changes: 0 additions & 22 deletions src/ngohub/normalization/helpers.py

This file was deleted.

Loading