Skip to content

Commit

Permalink
Merge branch 'develop' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeejoee authored Sep 21, 2024
2 parents b8e2d1c + 7b9b09b commit 6881447
Show file tree
Hide file tree
Showing 27 changed files with 578 additions and 399 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ ARG DJANGO_RELEASE_NAME
ARG SENTRY_RELEASE_NAME
ARG SENTRY_RELEASE_ENVIRONMENT

ARG PYTHON_IMAGE=python:3.12.6-alpine3.20

#
# wiki renderer image
#
Expand Down Expand Up @@ -91,7 +93,7 @@ RUN \
#

# venv builder
FROM python:3.11.3-alpine3.17 as web-venv-builder
FROM ${PYTHON_IMAGE} as web-venv-builder

ARG POETRY_EXPORT_ARGS

Expand All @@ -113,7 +115,7 @@ RUN poetry export --without-hashes ${POETRY_EXPORT_ARGS} -o /tmp/requirements.tx
RUN --mount=type=cache,target=/root/.cache/pip /venv/bin/pip install -r /tmp/requirements.txt

# base runtime image
FROM python:3.11.3-alpine3.17 as web-base
FROM ${PYTHON_IMAGE} as web-base

COPY --from=web-venv-builder /venv /venv

Expand Down
42 changes: 23 additions & 19 deletions charts/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
{{- include "fiesta.labels" . | nindent 4 }}
{{- include "fiesta.componentLabels" "web" | nindent 4 }}
spec:
replicas: 3
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
Expand Down Expand Up @@ -37,24 +37,28 @@ spec:
- containerPort: {{ .Values.web.port }}
protocol: TCP
name: web
{{/* readinessProbe:*/}}
{{/* initialDelaySeconds: 5*/}}
{{/* */}}{{/* httpget doesn't work, timeouted */}}
{{/* exec:*/}}
{{/* command:*/}}
{{/* - wget*/}}
{{/* - 'http://localhost:{{ .Values.web.port }}/!/web'*/}}
{{/* - --header*/}}
{{/* - 'Host: {{ .Values.ingress.host | quote }}'*/}}
{{/* livenessProbe:*/}}
{{/* initialDelaySeconds: 5*/}}
{{/* periodSeconds: 20*/}}
{{/* exec:*/}}
{{/* command:*/}}
{{/* - wget*/}}
{{/* - 'http://localhost:{{ .Values.web.port }}/!/web'*/}}
{{/* - --header*/}}
{{/* - 'Host: {{ .Values.ingress.host | quote }}'*/}}
readinessProbe:
initialDelaySeconds: 3
# httpget doesn't work, timeouted
exec:
command:
- wget
- 'http://localhost:{{ .Values.web.port }}/!/web'
- --header
- 'Host: {{ .Values.ingress.host }}'
- -O
- /dev/null
livenessProbe:
initialDelaySeconds: 3
periodSeconds: 20
exec:
command:
- wget
- 'http://localhost:{{ .Values.web.port }}/!/web'
- --header
- 'Host: {{ .Values.ingress.host }}'
- -O
- /dev/null
envFrom:
- secretRef:
name: {{ .Values.web.secretName }}
Expand Down
2 changes: 1 addition & 1 deletion docs
Submodule docs updated from ac4e17 to 31f325
3 changes: 1 addition & 2 deletions fiesta/apps/accounts/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from django_htmx.http import HttpResponseClientRedirect


class SocialAccountAdapter(DefaultSocialAccountAdapter):
...
class SocialAccountAdapter(DefaultSocialAccountAdapter): ...


class AccountAdapter(DefaultAccountAdapter):
Expand Down
3 changes: 1 addition & 2 deletions fiesta/apps/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,4 @@ def get_queryset(self, request):


@admin.register(EmailAddress)
class FiestaEmailAddressAdmin(EmailAddressAdmin):
... # to have it in accounts admin
class FiestaEmailAddressAdmin(EmailAddressAdmin): ... # to have it in accounts admin
6 changes: 2 additions & 4 deletions fiesta/apps/buddy_system/views/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,10 @@ def get_request_queryset(cls, request: HttpRequest):
return request.membership.section.buddy_system_requests


class IssuerPictureServeView(ServeFilesFromBuddiesMixin, BaseIssuerPictureServeView):
...
class IssuerPictureServeView(ServeFilesFromBuddiesMixin, BaseIssuerPictureServeView): ...


class MatcherPictureServeView(
ServeFilesFromBuddiesMixin,
BaseMatcherPictureServeView,
):
...
): ...
1 change: 0 additions & 1 deletion fiesta/apps/dashboard/models/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class DashboardConfiguration(BasePluginConfiguration):
...

class Meta:
verbose_name = _("dashboard configuration")
Expand Down
5 changes: 1 addition & 4 deletions fiesta/apps/events/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ class State(models.TextChoices):


def has_permission_for_cover_photo_view(request: HttpRequest, name: str) -> bool: # TODO
if request.user.is_authenticated:
return True

return False
return request.user.is_authenticated


class Event(BaseTimestampedModel):
Expand Down
7 changes: 2 additions & 5 deletions fiesta/apps/events/models/price_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ def is_available(self, variant: PriceVariant, user: User):
if to_ is not None and to_ != "" and to_ > datetime.now(UTC):
return False

if variant.type == self.STANDARD or (
return variant.type == self.STANDARD or (
variant.type == self.WITH_ESN_CARD
and user.profile_or_none is not None
and user.profile.is_esn_card_holder()
):
return True

return False
)


class PriceVariant(BaseModel):
Expand Down
5 changes: 5 additions & 0 deletions fiesta/apps/fiestarequests/forms/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class Meta:
def clean_matcher(self):
matcher: User = self.cleaned_data["matcher"]

if not matcher.profile_or_none:
raise ValidationError(
_("This user has not completed their profile. Please ask them to do so before matching.")
)

if not matcher.profile_or_none.faculty:
raise ValidationError(_("This user has not set their faculty. Please ask them to do so or do it yourself."))

Expand Down
3 changes: 1 addition & 2 deletions fiesta/apps/fiestarequests/matching_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ def can_member_match(self, membership: SectionMembership) -> bool:
def on_created_request(
self,
request: BuddyRequest,
) -> None:
...
) -> None: ...

@classmethod
def _base_filter(cls, membership: SectionMembership) -> Q:
Expand Down
1 change: 0 additions & 1 deletion fiesta/apps/fiestatables/views/htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ def get_context_data(self, **kwargs):
except EmptyPage:
if self.request.GET.get("page"):
...
...
1 change: 0 additions & 1 deletion fiesta/apps/pages/models/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class PagesConfiguration(BasePluginConfiguration):
...

class Meta:
verbose_name = _("pages configuration")
Expand Down
6 changes: 2 additions & 4 deletions fiesta/apps/pickup_system/views/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ def get_request_queryset(cls, request: HttpRequest):
return request.membership.section.pickup_system_requests


class IssuerPictureServeView(ServeFilesFromPickupsMixin, BaseIssuerPictureServeView):
...
class IssuerPictureServeView(ServeFilesFromPickupsMixin, BaseIssuerPictureServeView): ...


class MatcherPictureServeView(
ServeFilesFromPickupsMixin,
BaseMatcherPictureServeView,
):
...
): ...
2 changes: 1 addition & 1 deletion fiesta/apps/plugins/models/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __str__(self):

def clean(self):
# cannot use isinstance, since children are allowed to create
if type(self) == BasePluginConfiguration:
if type(self) == BasePluginConfiguration: # noqa: E721
raise ValidationError(_("Base plugin configuration cannot be saved directly, only children."))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _check_for_plugin(self, plugin: Plugin):
# }

match plugin.app_config:
case (BuddySystemConfig() | PickupSystemConfig()):
case BuddySystemConfig() | PickupSystemConfig():
self._check_field_dependency(
plugin=plugin,
field_value=sections_conf.required_faculty,
Expand Down
7 changes: 2 additions & 5 deletions fiesta/apps/sections/views/mixins/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ def test_func(self):
# !membership OR (membership.section==in_space_of_section)
return False

if not self.test_membership(membership=membership):
# right section, but without sufficient role
return False

return True
return self.test_membership(membership=membership)
# False = right section, but without sufficient role

def test_membership(self, membership: SectionMembership) -> bool:
raise NotImplementedError("To be overriden")
Expand Down
5 changes: 3 additions & 2 deletions fiesta/apps/utils/models/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def get_array_display(instance):
for value in getattr(instance, self.attname)
]

if "get_%s_display" % self.name not in cls.__dict__:
method_name = f"get_{self.name}_display"
if method_name not in cls.__dict__:
setattr(
cls,
"get_%s_display" % self.name,
method_name,
get_array_display,
)
1 change: 1 addition & 0 deletions fiesta/fiesta/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""

from __future__ import annotations

from django.core.asgi import get_asgi_application
Expand Down
1 change: 1 addition & 0 deletions fiesta/fiesta/checks/fiesta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Checks related to project, usually to keep codestyle."""

from __future__ import annotations

import django
Expand Down
3 changes: 1 addition & 2 deletions fiesta/fiesta/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class Base(
TemplatesConfigMixin,
AdminConfigMixin,
Configuration,
):
...
): ...


class Development(Base):
Expand Down
17 changes: 14 additions & 3 deletions fiesta/fiesta/settings/logging.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from configurations.values import SecretValue, Value
from sentry_sdk.integrations.django import DjangoIntegration


class LoggingConfigMixin:
Expand Down Expand Up @@ -76,10 +77,20 @@ def post_setup(cls):
if cls.SENTRY_DSN:
sentry_sdk.init(
dsn=cls.SENTRY_DSN,
# sample only 10% of events to reduce incoming data
traces_sample_rate=0.1,
profiles_sample_rate=0.1,
# sample only 50 % of events to reduce incoming data
# currently about 6M spans per peak month
traces_sample_rate=0.5,
profiles_sample_rate=0.5,
environment=cls.ENVIRONMENT_NAME,
release=cls.RELEASE_NAME,
enable_tracing=True,
send_default_pii=True,
auto_enabling_integrations=True,
auto_session_tracking=True,
integrations=[
DjangoIntegration(
# include spans from caches
cache_spans=True,
),
],
)
1 change: 1 addition & 0 deletions fiesta/fiesta/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
"""

from __future__ import annotations

from django.core.wsgi import get_wsgi_application
Expand Down
Loading

0 comments on commit 6881447

Please sign in to comment.