Skip to content

Commit

Permalink
Merge pull request #395 from open-contracting/362-translate-more-enums
Browse files Browse the repository at this point in the history
feat: add meta endpoint
  • Loading branch information
yolile authored Aug 24, 2024
2 parents 766b7c6 + b07cc7f commit bad7f28
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 21 deletions.
1 change: 1 addition & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
app.include_router(applications.router)
app.include_router(guest.applications.router)
app.include_router(guest.emails.router)
app.include_router(guest.meta.router)
app.include_router(downloads.router)
app.include_router(lenders.router)
app.include_router(statistics.router)
Expand Down
10 changes: 5 additions & 5 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ class BorrowerSector(StrEnum):


class CreditType(StrEnum):
LOAN = "LOAN"
CREDIT_LINE = "CREDIT_LINE"
LOAN = i("LOAN")
CREDIT_LINE = i("CREDIT_LINE")


class BorrowerType(StrEnum):
NATURAL_PERSON = "NATURAL_PERSON"
LEGAL_PERSON = "LEGAL_PERSON"
NATURAL_PERSON = i("NATURAL_PERSON")
LEGAL_PERSON = i("LEGAL_PERSON")


class StatisticType(StrEnum):
Expand All @@ -346,7 +346,7 @@ class LenderBase(SQLModel):
#: .. seealso:: :attr:`~app.settings.Settings.progress_to_remind_started_applications`
sla_days: int | None
#: Additional HTML content to include in a :attr:`app.models.MessageType.APPROVED_APPLICATION` message, if the
#: "additional_comments" key in the application's :attr:`app.models.APplication.lender_approved_data` isn't set.
#: "additional_comments" key in the application's :attr:`app.models.Application.lender_approved_data` isn't set.
default_pre_approval_message: str = Field(default="")


Expand Down
2 changes: 1 addition & 1 deletion app/routers/guest/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import applications, emails # noqa: F401
from . import applications, emails, meta # noqa: F401
32 changes: 32 additions & 0 deletions app/routers/guest/meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from fastapi import APIRouter

from app import models
from app.i18n import _

router = APIRouter()


@router.get(
"/meta",
tags=["meta"],
)
async def get_settings_by_domain() -> dict[str, list[dict[str, str]]]:
"""
Get the keys and localized descriptions of constants, where a constant can be:
- BorrowerDocumentType
- BorrowerSector
- BorrowerSize
- BorrowerType
:return: A dict of constants with their keys and localized values.
"""
constants = {}
for domain in (
"BorrowerDocumentType",
"BorrowerSector",
"BorrowerSize",
"BorrowerType",
):
constants[domain] = [{"label": _(name), "value": name} for name in getattr(models, domain)]
return constants
10 changes: 4 additions & 6 deletions docs/frontend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ Credere frontend's ``src/constants/index.ts`` constants should match ``app.model
- Frontend
* - ApplicationStatus
- APPLICATION_STATUS
* - BorrowerType
- BORROWER_TYPE
* - BorrowerSize.NOT_INFORMED
- DEFAULT_BORROWER_SIZE
* - BorrowerDocumentType.SIGNED_CONTRACT
- SIGNED_CONTRACT_DOCUMENT_TYPE
* - CreditType
- CREDIT_PRODUCT_TYPE
* - BorrowerDocumentType
- DOCUMENTS_TYPE
* - BorrowerSize
- MSME_TYPES
* - StatisticCustomRange
- STATISTICS_DATE_FILTER
* - UserType
Expand Down
49 changes: 40 additions & 9 deletions locale/es/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-08-23 14:39-0400\n"
"POT-Creation-Date: 2024-08-24 12:58-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: es\n"
Expand Down Expand Up @@ -148,45 +148,60 @@ msgstr "Opción de crédito alternativa"
msgid "Application updated"
msgstr "Aplicación actualizada"

#: app/main.py:30
#: app/main.py:31
msgid "An unexpected error occurred"
msgstr "Ocurrió un error inesperado"

#: app/models.py:130
msgid "INCORPORATION_DOCUMENT"
msgstr "Documento de incorporación"
msgstr "Certificado de incorporación de tu empresa"

#: app/models.py:131
msgid "SUPPLIER_REGISTRATION_DOCUMENT"
msgstr "Documento de registro de proveedor"
msgstr "Registro Único de Proponentes (RUP) de su empresa"

#: app/models.py:132
msgid "BANK_NAME"
msgstr "Nombre del banco"

#: app/models.py:133
msgid "BANK_CERTIFICATION_DOCUMENT"
msgstr "Certificado bancario"
msgstr ""
"Certificado Bancario de la empresa: Documento debe estar firmado y con "
"emisión menor a 3 meses."

#: app/models.py:134
msgid "FINANCIAL_STATEMENT"
msgstr "Estados financieros"
msgstr ""
"Documento de Estados Financieros de su empresa: A corte del último "
"trimestre y del corte anual y el anterior (ejemplo; si estamos en "
"Septiembre, la información disponible estaría a Junio 2023 y a Diciembre "
"2022 y Diciembre 2021). Si no se tiene disponible la información a corte "
"parcial del trimestre, se recibe pero puede llegar a ser solicitada más "
"adelante por la institución financiera."

#: app/models.py:135
msgid "SIGNED_CONTRACT"
msgstr "Contrato firmado"

#: app/models.py:136
msgid "SHAREHOLDER_COMPOSITION"
msgstr "Composición accionaria"
msgstr ""
"Documento de Composición Accionaria: Debe enviarse completo, hasta llegar"
" al beneficiario final con concentración mayor al 5 por ciento."

#: app/models.py:137
msgid "CHAMBER_OF_COMMERCE"
msgstr "Cámara de comercio"
msgstr ""
"Documento de Registro de la Cámara de Comercio: Documento debe estar "
"firmado y con emisión menor a 3 meses."

#: app/models.py:138
msgid "THREE_LAST_BANK_STATEMENT"
msgstr "Últimos tres extractos bancarios"
msgstr ""
"Extractos Bancarios de los últimos 3 meses: De la o las cuentas "
"principales de la empresa. El documento deber ser emitido por el banco y "
"deber ser enviado SIN alterar."

#: app/models.py:163
msgid "PENDING"
Expand Down Expand Up @@ -339,6 +354,22 @@ msgstr ""
msgid "actividades_organizaciones_extraterritoriales"
msgstr "Actividades de organizaciones y entidades extraterritoriales"

#: app/models.py:319
msgid "LOAN"
msgstr "Préstamo"

#: app/models.py:320
msgid "CREDIT_LINE"
msgstr "Línea de crédito"

#: app/models.py:324
msgid "NATURAL_PERSON"
msgstr "Persona natural"

#: app/models.py:325
msgid "LEGAL_PERSON"
msgstr "Persona jurídica"

#: app/util.py:55
#, python-format
msgid "%(model_name)s not found"
Expand Down

0 comments on commit bad7f28

Please sign in to comment.