Skip to content

Commit

Permalink
(PC-32555)[API] feat: remove unused dsApplicationId from serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
vroullier-pass committed Nov 6, 2024
1 parent aa7f7e9 commit dee21cc
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 62 deletions.
26 changes: 0 additions & 26 deletions api/src/pcapi/core/offerers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,19 +501,6 @@ def store_timezone(self) -> None:
else get_postal_code_timezone(self.managingOfferer.postalCode)
)

@property
def demarchesSimplifieesApplicationId(self) -> int | None:
if not self.bankInformation:
return None

if self.bankInformation.status not in (
finance_models.BankInformationStatus.DRAFT,
finance_models.BankInformationStatus.ACCEPTED,
):
return None

return self.bankInformation.applicationId

@property
def last_collective_dms_application(self) -> educational_models.CollectiveDmsApplication | None:
if self.collectiveDmsApplications:
Expand Down Expand Up @@ -1016,19 +1003,6 @@ def street(self, value: str | None) -> None:
def street(cls): # pylint: disable=no-self-argument
return cls._address

@property
def demarchesSimplifieesApplicationId(self) -> str | None:
if not self.bankInformation:
return None

if self.bankInformation.status not in (
finance_models.BankInformationStatus.DRAFT,
finance_models.BankInformationStatus.ACCEPTED,
):
return None

return self.bankInformation.applicationId

@hybrid_property
def departementCode(self) -> str:
return postal_code_utils.PostalCode(self.postalCode).get_departement_code()
Expand Down
2 changes: 0 additions & 2 deletions api/src/pcapi/core/offerers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ def get_filtered_venues(
.join(models.UserOfferer, models.UserOfferer.offererId == models.Offerer.id)
.options(sqla_orm.joinedload(models.Venue.managingOfferer))
.options(sqla_orm.joinedload(models.Venue.collectiveDomains))
.options(sqla_orm.joinedload(models.Venue.reimbursement_point_links))
.options(sqla_orm.joinedload(models.Venue.bankInformation))
.options(sqla_orm.joinedload(models.Venue.accessibilityProvider))
.options(sqla_orm.joinedload(models.Venue.offererAddress).joinedload(models.OffererAddress.address))
)
Expand Down
3 changes: 1 addition & 2 deletions api/src/pcapi/routes/pro/venues.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def get_venue(venue_id: int) -> venues_serialize.GetVenueResponseModel:
venue = (
models.Venue.query.filter(models.Venue.id == venue_id)
.options(sqla_orm.joinedload(models.Venue.contact))
.options(sqla_orm.joinedload(models.Venue.bankInformation))
.options(sqla_orm.joinedload(models.Venue.managingOfferer).joinedload(models.Offerer.bankInformation))
.options(sqla_orm.joinedload(models.Venue.managingOfferer))
.options(
sqla_orm.selectinload(models.Venue.pricing_point_links).joinedload(
models.VenuePricingPointLink.pricingPoint
Expand Down
4 changes: 0 additions & 4 deletions api/src/pcapi/routes/serialization/offerers_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class GetOffererVenueResponseModel(BaseModel, AccessibilityComplianceMixin):
city: str | None
comment: str | None
departementCode: str | None
demarchesSimplifieesApplicationId: int | None
hasCreatedOffer: bool
hasAdageId: bool
isVirtual: bool
Expand Down Expand Up @@ -84,7 +83,6 @@ class GetOffererResponseModel(BaseModel):
apiKey: OffererApiKey
city: str
dateCreated: datetime
demarchesSimplifieesApplicationId: str | None
hasAvailablePricingPoints: bool
hasDigitalVenueAtLeastOneOffer: bool
isValidated: bool
Expand Down Expand Up @@ -116,8 +114,6 @@ def from_orm(cls, row: Row) -> "GetOffererResponseModel":
}
venues = (
offerers_models.Venue.query.filter_by(managingOffererId=offerer.id)
.options(sqla_orm.joinedload(offerers_models.Venue.reimbursement_point_links))
.options(sqla_orm.joinedload(offerers_models.Venue.bankInformation))
.options(sqla_orm.joinedload(offerers_models.Venue.collectiveDmsApplications))
.options(sqla_orm.joinedload(offerers_models.Venue.venueProviders))
.options(sqla_orm.joinedload(offerers_models.Venue.googlePlacesInfo))
Expand Down
2 changes: 0 additions & 2 deletions api/src/pcapi/routes/serialization/venues_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class Config:
class GetVenueManagingOffererResponseModel(BaseModel):
city: str
dateCreated: datetime
demarchesSimplifieesApplicationId: str | None
id: int
isValidated: bool
name: str
Expand Down Expand Up @@ -246,7 +245,6 @@ class GetVenueResponseModel(base.BaseVenueResponse, AccessibilityComplianceMixin
banId: str | None
bookingEmail: str | None
comment: str | None
demarchesSimplifieesApplicationId: str | None
departementCode: str | None
dmsToken: str
managingOfferer: GetVenueManagingOffererResponseModel
Expand Down
37 changes: 17 additions & 20 deletions api/tests/routes/pro/get_offerer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_basics(self, client):
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venue
num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
Expand All @@ -71,7 +71,6 @@ def test_basics(self, client):
"apiKey": {"maxAllowed": 5, "prefixes": ["testenv_prefix", "testenv_prefix2"]},
"city": offerer.city,
"dateCreated": format_into_utc_date(offerer.dateCreated),
"demarchesSimplifieesApplicationId": None,
"hasAvailablePricingPoints": True,
"hasDigitalVenueAtLeastOneOffer": False,
"hasValidBankAccount": False,
Expand Down Expand Up @@ -112,7 +111,6 @@ def test_basics(self, client):
for a in venue.collectiveDmsApplications
],
"comment": venue.comment,
"demarchesSimplifieesApplicationId": venue.demarchesSimplifieesApplicationId,
"departementCode": venue.departementCode,
"hasAdageId": bool(venue.adageId),
"hasCreatedOffer": venue.has_individual_offers or venue.has_collective_offers,
Expand Down Expand Up @@ -191,7 +189,7 @@ def test_serialize_venue_offer_created_flag(self, client):
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -223,7 +221,7 @@ def test_offerer_has_non_free_offer(self, client):
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -252,7 +250,7 @@ def test_offerer_has_inactive_non_free_offer(self, client):
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -283,7 +281,7 @@ def test_offerer_has_inactive_non_free_collective_offer(self, client):
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -315,7 +313,7 @@ def test_offerer_has_non_free_collective_offer(self, client):
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -345,7 +343,7 @@ def test_offerer_has_free_offer(self, client):
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -377,7 +375,7 @@ def test_offerer_has_free_collective_offer(self, client):
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = client.get(f"/offerers/{offerer_id}")
Expand All @@ -403,7 +401,7 @@ def test_we_dont_display_anything_if_offerer_dont_have_any_bank_accounts_nor_ven
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = http_client.get(f"/offerers/{offerer.id}")
Expand Down Expand Up @@ -441,7 +439,7 @@ def test_client_can_now_if_the_offerer_have_any_valid_bank_account(self, client)
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = http_client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -501,7 +499,7 @@ def test_client_can_know_which_venues_have_non_free_offers_without_bank_accounts
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = http_client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -535,7 +533,7 @@ def test_client_can_know_if_offerer_have_any_pending_bank_accounts(self, client)
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = http_client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -567,7 +565,7 @@ def test_client_can_know_if_offerer_has_any_pending_bank_account(self, client):
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = http_client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -597,7 +595,7 @@ def test_client_can_know_if_have_any_pending_bank_accounts_draft_included(self,
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = http_client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -643,7 +641,7 @@ def test_client_can_know_which_venues_have_non_free_offers_without_bank_accounts
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = http_client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -677,7 +675,7 @@ def test_user_can_know_if_each_managed_venues_has_venue_provider(self, client):
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -718,7 +716,7 @@ def test_offerer_properties_rely_only_on_the_offerer_data(self, client):
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information

num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = client.get(f"/offerers/{offerer_id}")
Expand Down Expand Up @@ -781,7 +779,6 @@ def test_user_can_correctly_see_if_there_is_venues_without_bank_account_left(sel
num_queries += 1 # check offerer has non free offers
num_queries += 1 # select venue_id
num_queries += 1 # select offerer_address
num_queries += 1 # select bank_information
num_queries += 1 # select venues_id with active offers
with testing.assert_num_queries(num_queries):
response = http_client.get(f"/offerers/{offerer_id}")
Expand Down
2 changes: 0 additions & 2 deletions api/tests/routes/pro/get_venue_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def when_user_has_rights_on_managing_offerer(self, client, db_session):
},
"reimbursementPointId": venue_currently_used_for_reimbursement.id,
"dateCreated": format_into_utc_date(venue.dateCreated),
"demarchesSimplifieesApplicationId": venue.demarchesSimplifieesApplicationId,
"departementCode": venue.departementCode,
"description": venue.description,
"dmsToken": "PRO-" + venue.dmsToken,
Expand Down Expand Up @@ -140,7 +139,6 @@ def when_user_has_rights_on_managing_offerer(self, client, db_session):
"managingOfferer": {
"city": venue.managingOfferer.city,
"dateCreated": format_into_utc_date(venue.managingOfferer.dateCreated),
"demarchesSimplifieesApplicationId": venue.managingOfferer.demarchesSimplifieesApplicationId,
"id": venue.managingOfferer.id,
"isValidated": venue.managingOfferer.isValidated,
"name": venue.managingOfferer.name,
Expand Down
1 change: 0 additions & 1 deletion pro/src/apiClient/v1/models/GetOffererResponseModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export type GetOffererResponseModel = {
apiKey: OffererApiKey;
city: string;
dateCreated: string;
demarchesSimplifieesApplicationId?: string | null;
hasActiveOffer: boolean;
hasAvailablePricingPoints: boolean;
hasBankAccountWithPendingCorrections: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export type GetOffererVenueResponseModel = {
city?: string | null;
collectiveDmsApplications: Array<DMSApplicationForEAC>;
comment?: string | null;
demarchesSimplifieesApplicationId?: number | null;
departementCode?: string | null;
hasAdageId: boolean;
hasCreatedOffer: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export type GetVenueManagingOffererResponseModel = {
allowedOnAdage: boolean;
city: string;
dateCreated: string;
demarchesSimplifieesApplicationId?: string | null;
id: number;
isValidated: boolean;
name: string;
Expand Down
1 change: 0 additions & 1 deletion pro/src/apiClient/v1/models/GetVenueResponseModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export type GetVenueResponseModel = {
comment?: string | null;
contact?: VenueContactModel | null;
dateCreated: string;
demarchesSimplifieesApplicationId?: string | null;
departementCode?: string | null;
description?: string | null;
dmsToken: string;
Expand Down

0 comments on commit dee21cc

Please sign in to comment.