Move sentry dependency to optional dependencies

Fixes #72
This commit is contained in:
Sonny Bakker 2021-01-17 21:26:20 +01:00
parent d2a1fd7f3a
commit 4496972205
3 changed files with 336 additions and 273 deletions

595
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -24,10 +24,13 @@ psycopg2-binary = "^2.8.5"
gunicorn = "^20.0.4"
python-dotenv = "^0.12.0"
django = ">=3.0.7"
sentry-sdk = "^0.15.1"
sentry-sdk = {version = "^0.15.1", optional = true}
ftfy = "^5.8"
requests_oauthlib = "^1.3.0"
[tool.poetry.extras]
sentry = ["sentry_sdk"]
[tool.poetry.dev-dependencies]
factory-boy = "^2.12.0"
freezegun = "^0.3.15"

View file

@ -12,7 +12,14 @@ class RulesWidget(CheckboxSelectMultiple):
def create_option(self, *args, **kwargs):
option = super().create_option(*args, **kwargs)
instance = self.choices.queryset.get(pk=option["value"])
# see https://docs.djangoproject.com/en/3.1/releases/3.1/#id1
try:
pk = int(option["value"])
except TypeError:
pk = option["value"].value
instance = self.choices.queryset.get(pk=pk)
if self.category and instance.category:
option["selected"] = self.category.pk == instance.category.pk