Skip to content

Commit

Permalink
Merge branch 'master' into scolson/bsr-pro-fix-flaky-after-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
scolson-pass authored Oct 15, 2024
2 parents 6e62c05 + 92c7eb9 commit 9b18733
Show file tree
Hide file tree
Showing 33 changed files with 338 additions and 755 deletions.
23 changes: 3 additions & 20 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ARG network_mode=default

########## BUILDER ##########

FROM python:3.11-slim AS builder
Expand All @@ -23,8 +22,6 @@ COPY ./pyproject.toml ./poetry.lock ./

ENV PATH=$PATH:/home/pcapi/.local/bin

########## BUILDER PROXY ##########

FROM builder AS builder-proxy

COPY /cacert.pem /cacert.pem
Expand All @@ -41,8 +38,6 @@ RUN python -m venv $VIRTUAL_ENV

RUN REQUESTS_CA_BUNDLE=/cacert.pem PIP_CERT=/cacert.pem CURL_CA_BUNDLE=/cacert.pem poetry install --without dev --no-root

########## BUILDER DEFAULT ##########

FROM builder AS builder-default

RUN pip install poetry
Expand All @@ -57,16 +52,14 @@ RUN python -m venv $VIRTUAL_ENV

RUN poetry install --without dev --no-root

########## DEV BUILDER PROXY ##########
########## DEV BUILDER ##########

FROM builder-${network_mode} AS builder-dev-proxy

RUN poetry check --lock

RUN REQUESTS_CA_BUNDLE=/cacert.pem PIP_CERT=/cacert.pem CURL_CA_BUNDLE=/cacert.pem poetry install --only dev

########## DEV BUILDER DEFAULT ##########

FROM builder-${network_mode} AS builder-dev-default

RUN poetry check --lock
Expand Down Expand Up @@ -154,21 +147,12 @@ ENTRYPOINT exec ./entrypoint.sh

######### CONSOLE #########

FROM lib-dev AS pcapi-console-proxy

COPY /cacert.pem /usr/local/share/ca-certificates/cacert.pem
ENV REQUESTS_CA_BUNDLE=/usr/local/share/ca-certificates/cacert.pem
ENV PIP_CERT=/usr/local/share/ca-certificates/cacert.pem
ENV CURL_CA_BUNDLE=/usr/local/share/ca-certificates/cacert.pem

FROM lib-dev AS pcapi-console-default

FROM pcapi-console-${network_mode} AS pcapi-console
FROM pcapi AS pcapi-console

USER root

RUN apt update && apt install --no-install-recommends -y curl less gnupg2 && \
curl -s https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/pgsql.gpg && \
curl -s https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/pgsql.gpg && \
echo "deb [signed-by=/etc/apt/trusted.gpg.d/pgsql.gpg] http://apt.postgresql.org/pub/repos/apt/ `. /etc/os-release && \
echo $VERSION_CODENAME`-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
Expand All @@ -180,7 +164,6 @@ RUN apt update && apt install --no-install-recommends -y curl less gnupg2 && \

USER pcapi


######### TESTS #########

FROM api-flask AS pcapi-tests
Expand Down
73 changes: 39 additions & 34 deletions api/poetry.lock

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

6 changes: 3 additions & 3 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jinja2 = "3.1.4"
libsass = "0.23.0"
markupsafe = "3.0.1"
openpyxl = "^3.1.5"
pgcli = "^4.1.0"
phonenumberslite = "==8.13.*"
pillow = ">=8.1.1"
prometheus-flask-exporter = "^0.23.1"
Expand Down Expand Up @@ -76,7 +77,7 @@ werkzeug = "2.0.3"
wtforms = "3.1.2"
wtforms-sqlalchemy = "0.4.1"
xlsxwriter = "^3.2.0"
zeep = "4.2.1"
zeep = "4.3.0"

[tool.poetry.group.dev]
optional = true
Expand All @@ -88,8 +89,7 @@ debugpy = "^1.8.7"
djlint = "1.35.2"
fakeredis = "^2.25.1"
isort = "^5.13.2"
mypy = "1.11.2"
pgcli = "^4.1.0"
mypy = "1.12.0"
pylint = "3.3.1"
pylint-pydantic = "^0.3.2"
pytest = "^8.3.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class AllocineMovieCompany(pydantic.BaseModel):
name: str | None = pydantic.Field(alias="company")

@pydantic.field_validator("name", mode="before")
def get_company_from_name(cls, company: dict | None) -> str:
def get_company_from_name(cls, company: dict | None) -> str | None:
return company["name"] if company else None


Expand Down
12 changes: 0 additions & 12 deletions api/src/pcapi/core/educational/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from pcapi.core.object_storage import store_public_object
from pcapi.models import Base
from pcapi.models import Model
from pcapi.models import feature
from pcapi.models import offer_mixin
from pcapi.models.accessibility_mixin import AccessibilityMixin
from pcapi.models.pc_object import PcObject
Expand Down Expand Up @@ -1314,17 +1313,6 @@ class CollectiveStock(PcObject, Base, Model):

priceDetail = sa.Column(sa.Text, nullable=True)

@property
def pricing_datetime(self) -> datetime:
field = self.pricingDatetimeField()
return getattr(self, field.name)

@classmethod
def pricingDatetimeField(cls) -> sa.Column:
if feature.FeatureToggle.USE_END_DATE_FOR_COLLECTIVE_PRICING.is_active():
return cls.endDatetime
return cls.beginningDatetime

@property
def isBookable(self) -> bool:
return not self.isExpired and self.collectiveOffer.isReleased and not self.isSoldOut
Expand Down
4 changes: 2 additions & 2 deletions api/src/pcapi/core/finance/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def get_pricing_ordering_date(
if isinstance(booking, bookings_models.Booking):
eventDatetime = booking.stock.beginningDatetime
else:
eventDatetime = booking.collectiveStock.pricing_datetime
eventDatetime = booking.collectiveStock.endDatetime
# IMPORTANT: if you change this, you must also adapt the SQL query
# in `core.offerers.api.link_venue_to_pricing_point()`
return max(
Expand Down Expand Up @@ -909,7 +909,7 @@ def _generate_cashflows(batch: models.CashflowBatch) -> None:
),
sa.and_(
models.Pricing.collectiveBookingId.is_not(None),
educational_models.CollectiveStock.pricingDatetimeField() < batch.cutoff,
educational_models.CollectiveStock.endDatetime < batch.cutoff,
),
models.FinanceEvent.bookingFinanceIncidentId.is_not(None),
),
Expand Down
2 changes: 1 addition & 1 deletion api/src/pcapi/core/offerers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def link_venue_to_pricing_point(
If it had, then it will raise an error, unless the force_link parameter is True, in exceptional circumstances.
"""
validation.check_venue_can_be_linked_to_pricing_point(venue, pricing_point_id)
collective_stock_datetime = educational_models.CollectiveStock.pricingDatetimeField().name
collective_stock_datetime = educational_models.CollectiveStock.endDatetime.name
if not timestamp:
timestamp = datetime.utcnow()
current_link = models.VenuePricingPointLink.query.filter(
Expand Down
3 changes: 0 additions & 3 deletions api/src/pcapi/core/offerers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,9 +1004,6 @@ class Offerer(

_street = Column("street", Text(), nullable=True)

hasNewNavUsers: sa_orm.Mapped["bool | None"] = sa_orm.query_expression()
hasOldNavUsers: sa_orm.Mapped["bool | None"] = sa_orm.query_expression()

def __init__(self, street: str | None = None, **kwargs: typing.Any) -> None:
if street:
self.street = street # type: ignore[method-assign]
Expand Down
4 changes: 2 additions & 2 deletions api/src/pcapi/models/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ class FeatureToggle(enum.Enum):
"Activer la recherche par similarité pour les structures et lieux dans le backoffice"
)
WIP_BENEFICIARY_EXTRACT_TOOL = "Activer l'extraction de données personnelles (RGPD)"
USE_END_DATE_FOR_COLLECTIVE_PRICING = "Utiliser la date de fin du stock collectif comme date de valorisation."
WIP_ENABLE_OFFER_ADDRESS = "Activer l'association des offres à des adresses."
WIP_SPLIT_OFFER = "Activer le nouveau parcours de création/édition d'offre individuelle"
WIP_SUGGESTED_SUBCATEGORIES = "Activer les sous-catégories suggérées par IA lors de la création d'offre"
WIP_EAN_CREATION = "Activer la création d'offre par EAN"
WIP_OFFERER_STATS_V2 = "Activer la nouvelle version de la page de statistiques / revenus d'une structure"
ENABLE_COLLECTIVE_OFFERS_EXPIRATION = "Activer la mise en avant des offres collectives sur le point d'expirer"
ENABLE_COLLECTIVE_NEW_STATUSES = "Activer les nouveaux statuts des offres collectives"
WIP_CONNECT_AS_EXTENDED = "Activer les redirections automatiques avec connect-as"
Expand Down Expand Up @@ -190,7 +190,6 @@ def nameKey(self) -> str:
FeatureToggle.ID_CHECK_ADDRESS_AUTOCOMPLETION,
FeatureToggle.LOG_EMS_CINEMAS_AVAILABLE_FOR_SYNC,
FeatureToggle.SYNCHRONIZE_TITELIVE_API_MUSIC_PRODUCTS,
FeatureToggle.USE_END_DATE_FOR_COLLECTIVE_PRICING,
FeatureToggle.WIP_BENEFICIARY_EXTRACT_TOOL,
FeatureToggle.WIP_CONNECT_AS_EXTENDED,
FeatureToggle.WIP_DISABLE_CANCEL_BOOKING_NOTIFICATION,
Expand All @@ -204,6 +203,7 @@ def nameKey(self) -> str:
FeatureToggle.WIP_ENABLE_NEW_HASHING_ALGORITHM,
FeatureToggle.WIP_ENABLE_OFFER_ADDRESS,
FeatureToggle.WIP_ENABLE_REMINDER_MARKETING_MAIL_METADATA_DISPLAY,
FeatureToggle.WIP_OFFERER_STATS_V2,
FeatureToggle.WIP_SPLIT_OFFER,
FeatureToggle.WIP_SUGGESTED_SUBCATEGORIES,
FeatureToggle.WIP_UBBLE_V2,
Expand Down
4 changes: 0 additions & 4 deletions api/src/pcapi/routes/backoffice/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,10 +880,6 @@ def format_modified_info_name(info_name: str) -> str:
return "Abonné aux emails marketing"
case "notificationSubscriptions.marketing_push":
return "Abonné aux notifications push"
case "pro_new_nav_state.newNavDate":
return "Date de passage sur la nouvelle interface Pro"
case "pro_new_nav_state.eligibilityDate":
return "Date d'éligibilité à la nouvelle interface Pro"
case "confidenceRule.confidenceLevel":
return "Validation des offres"
case "offererAddress.addressId":
Expand Down
Loading

0 comments on commit 9b18733

Please sign in to comment.