Skip to content

Commit

Permalink
Feature/pdct 1244 remove references to familydocumenttype (#178)
Browse files Browse the repository at this point in the history
* Bump db client to 3.8.9

* Bump to 2.10.14

* Remove document types from config

* Remove document type from DTO

* Fix test
  • Loading branch information
katybaulch authored Jul 18, 2024
1 parent de56ec3 commit 8f94807
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 26 deletions.
1 change: 0 additions & 1 deletion app/model/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
class DocumentConfig(BaseModel):
"""Everything you need to know about documents."""

types: Sequence[str]
variants: Sequence[str]


Expand Down
3 changes: 0 additions & 3 deletions app/model/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class DocumentReadDTO(BaseModel):
corpus_type: str
variant_name: Optional[str]
status: DocumentStatus
type: Optional[str]
slug: str
created: datetime
last_modified: datetime
Expand All @@ -37,7 +36,6 @@ class DocumentWriteDTO(BaseModel):

# From FamilyDocument
variant_name: Optional[str]
type: Optional[str]
metadata: Json

title: str
Expand All @@ -51,7 +49,6 @@ class DocumentCreateDTO(BaseModel):
# From FamilyDocument
family_import_id: str
variant_name: Optional[str] = None
type: Optional[str] = None
metadata: Json

# From PhysicalDocument
Expand Down
8 changes: 1 addition & 7 deletions app/repository/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any, Sequence

from db_client.models.base import AnyModel
from db_client.models.dfce.family import FamilyDocumentType, Variant
from db_client.models.dfce.family import Variant
from db_client.models.dfce.geography import Geography
from db_client.models.document.physical_document import Language
from db_client.models.organisation import Corpus, CorpusType, Organisation
Expand Down Expand Up @@ -92,12 +92,6 @@ def get(db: Session, user: UserContext) -> ConfigReadDTO:

# Now Document config
doc_config = DocumentConfig(
types=[
doc_type.name
for doc_type in db.query(FamilyDocumentType)
.order_by(FamilyDocumentType.name)
.all()
],
variants=[
variant.variant_name
for variant in db.query(Variant).order_by(Variant.variant_name).all()
Expand Down
3 changes: 0 additions & 3 deletions app/repository/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def _dto_to_family_document_dict(dto: DocumentCreateDTO) -> dict:
"family_import_id": dto.family_import_id,
"physical_document_id": 0,
"variant_name": dto.variant_name,
"document_type": dto.type,
"valid_metadata": dto.metadata,
}

Expand Down Expand Up @@ -139,7 +138,6 @@ def _doc_to_dto(doc_query_return: ReadObj) -> DocumentReadDTO:
corpus_type=str(corpus_type.name),
variant_name=str(fdoc.variant_name) if fdoc.variant_name is not None else None,
status=cast(DocumentStatus, fdoc.document_status),
type=str(fdoc.document_type) if fdoc.document_type is not None else None,
created=cast(datetime, fdoc.created),
last_modified=cast(datetime, fdoc.last_modified),
slug=str(fdoc.slugs[0].name if len(fdoc.slugs) > 0 else ""),
Expand Down Expand Up @@ -288,7 +286,6 @@ def update(db: Session, import_id: str, document: DocumentWriteDTO) -> bool:
.where(FamilyDocument.import_id == original_fd.import_id)
.values(
variant_name=new_values["variant_name"],
document_type=new_values["type"],
valid_metadata=new_values["metadata"],
),
]
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "admin_backend"
version = "2.10.13"
version = "2.10.14"
description = ""
authors = ["CPR-dev-team <[email protected]>"]
packages = [{ include = "app" }, { include = "tests" }]
Expand Down Expand Up @@ -29,7 +29,7 @@ boto3 = "^1.28.46"
moto = "^4.2.2"
types-sqlalchemy = "^1.4.53.38"
urllib3 = "^1.26.17"
db-client = { git = "https://github.com/climatepolicyradar/navigator-db-client.git", tag = "v3.8.8" }
db-client = { git = "https://github.com/climatepolicyradar/navigator-db-client.git", tag = "v3.8.9" }

[tool.poetry.dev-dependencies]
pre-commit = "^2.17.0"
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_get_config_has_expected_shape(
assert len(data["languages"]) == EXPECTED_LANGUAGES

assert isinstance(data["document"], dict)
assert set(data["document"].keys()) == set(["types", "variants"])
assert set(data["document"].keys()) == set(["variants"])


def test_get_config_has_correct_number_corpora_super(
Expand Down Expand Up @@ -247,7 +247,7 @@ def test_config_documents(client: TestClient, data_db: Session, user_header_toke
#
# Documents..
assert "roles" not in data["document"].keys()
assert "Action Plan" in data["document"]["types"]
assert "types" not in data["document"].keys()
assert "Translation" in data["document"]["variants"]


Expand Down
4 changes: 0 additions & 4 deletions tests/integration_tests/setup_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
"corpus_type": "Intl. agreements",
"variant_name": "Original Language",
"status": "Created",
"type": "Law",
"metadata": {"role": ["MAIN"], "type": ["Law"]},
"slug": "",
"title": "big title1",
Expand All @@ -156,7 +155,6 @@
"corpus_type": "Intl. agreements",
"variant_name": "Original Language",
"status": "Created",
"type": "Law",
"metadata": {"role": ["MAIN"], "type": ["Law"]},
"slug": "",
"title": "title2",
Expand All @@ -173,7 +171,6 @@
"corpus_type": "Laws and Policies",
"variant_name": "Original Language",
"status": "Created",
"type": "Law",
"metadata": {"role": ["MAIN"], "type": ["Law"]},
"slug": "",
"title": "title3",
Expand Down Expand Up @@ -490,7 +487,6 @@ def _setup_document_data(test_db: Session, configure_empty: bool = False) -> Non
import_id=data["import_id"],
variant_name=data["variant_name"],
document_status=data["status"],
document_type=data["type"], # TODO Remove PDCT-1244
valid_metadata=data["metadata"],
)
test_db.add(fd)
Expand Down

0 comments on commit 8f94807

Please sign in to comment.