Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
84f2dfd
bumps deps django 4.2.14
woutervh Jul 16, 2024
00c7e66
Merge pull request #89 from ScoutsGidsenVL/bump-deps-20240716
woutervh Jul 16, 2024
2b6f1a7
update deps
woutervh Aug 12, 2024
e65cbf2
Merge pull request #105 from ScoutsGidsenVL/update-deps-20240812
woutervh Aug 12, 2024
35e7268
enable django-admin
woutervh Aug 12, 2024
9330bbf
add setting CSRF_TRUSTED_ORIGINS - add to env-vars
woutervh Aug 12, 2024
df04d15
fix error in exception handling
woutervh Aug 12, 2024
178f11c
Bump urllib3 from 1.26.19 to 1.26.20
dependabot[bot] Sep 2, 2024
e0c3a46
Merge pull request #106 from ScoutsGidsenVL/enable-django-admin
woutervh Sep 2, 2024
1024eba
update
woutervh Sep 2, 2024
3a19df2
Merge pull request #117 from ScoutsGidsenVL/update-deps-20240902
woutervh Sep 2, 2024
0d28fc9
Bump ruff from 0.6.3 to 0.6.4
dependabot[bot] Sep 9, 2024
8ce4610
Bump hypothesis from 6.111.2 to 6.112.0
dependabot[bot] Sep 9, 2024
70583a0
Bump boto3 from 1.35.10 to 1.35.14
dependabot[bot] Sep 9, 2024
c506738
Bump pytest-django from 4.8.0 to 4.9.0
dependabot[bot] Sep 9, 2024
cf7ffa9
Merge pull request #122 from ScoutsGidsenVL/dependabot/pip/pytest-dja…
woutervh Sep 10, 2024
0150133
Bump cryptography from 43.0.0 to 43.0.1
dependabot[bot] Sep 10, 2024
a00a523
Merge pull request #121 from ScoutsGidsenVL/dependabot/pip/boto3-1.35.14
woutervh Sep 10, 2024
cfd8ab4
Merge pull request #120 from ScoutsGidsenVL/dependabot/pip/hypothesis…
woutervh Sep 10, 2024
151e8d5
Merge pull request #119 from ScoutsGidsenVL/dependabot/pip/ruff-0.6.4
woutervh Sep 10, 2024
dacb750
Merge pull request #116 from ScoutsGidsenVL/dependabot/pip/urllib3-1.…
woutervh Sep 10, 2024
b0b8951
Merge pull request #123 from ScoutsGidsenVL/dependabot/pip/cryptograp…
woutervh Sep 10, 2024
10fdb63
update packages
woutervh Sep 10, 2024
c1ee989
Merge pull request #124 from ScoutsGidsenVL/update-deps-20240910
woutervh Sep 10, 2024
df2b4ff
update deps
woutervh Oct 31, 2024
c720353
Merge pull request #148 from ScoutsGidsenVL/update-deps-20241031
woutervh Oct 31, 2024
b97415f
update deps 20241104
woutervh Nov 4, 2024
9afe1a0
Merge pull request #152 from ScoutsGidsenVL/update-deps-20241104
woutervh Nov 4, 2024
e139cc7
update deps 20241202
woutervh Dec 2, 2024
646f18f
Merge pull request #168 from ScoutsGidsenVL/update-deps-20241202
woutervh Dec 2, 2024
b5866c7
Bump django from 4.2.16 to 4.2.17
dependabot[bot] Dec 6, 2024
a734059
update deps 20241226
woutervh Dec 26, 2024
22c37c6
Merge pull request #174 from ScoutsGidsenVL/upgrade-20241226
woutervh Dec 26, 2024
a48746d
Merge branch 'staging' into dependabot/pip/django-4.2.17
woutervh Dec 26, 2024
aefaf74
Merge pull request #169 from ScoutsGidsenVL/dependabot/pip/django-4.2.17
woutervh Dec 26, 2024
161f16b
update deps 20250112
woutervh Jan 12, 2025
cb8e6b4
Merge pull request #180 from ScoutsGidsenVL/upgrade-20250112
woutervh Jan 12, 2025
63a5f04
update dependencies
woutervh Feb 25, 2025
fe9c412
Merge pull request #198 from ScoutsGidsenVL/upgrade-deps-20250225
woutervh Feb 25, 2025
d5ea424
update cryptography
woutervh Feb 25, 2025
be82ddd
Merge pull request #199 from ScoutsGidsenVL/update-cryptography
woutervh Feb 25, 2025
cf91ddb
bump dependencies 20250314
woutervh Mar 14, 2025
d3168d6
Merge pull request #209 from ScoutsGidsenVL/update-deps-20250314
woutervh Mar 14, 2025
6f54068
update dependencies 20250322
woutervh Mar 22, 2025
90eb088
Merge pull request #213 from ScoutsGidsenVL/update-deps-20250322
woutervh Mar 22, 2025
41f39cc
run 'ruff format .'
woutervh Mar 22, 2025
acf37ee
run 'ruff format .'
woutervh Mar 22, 2025
459f62a
Merge pull request #214 from ScoutsGidsenVL/ruff-formatting
woutervh Mar 22, 2025
e43463f
remove logging of full email-body
woutervh Mar 22, 2025
ad7e3c7
add raise from to exception
woutervh Mar 22, 2025
104688a
Merge pull request #215 from ScoutsGidsenVL/fix-information-exposure
woutervh Mar 22, 2025
c6b7819
Bump pytest-codecov from 0.6.1 to 0.7.0
dependabot[bot] Mar 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions etc/ipython/profile_default/ipython_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import pathlib as pl
import sys


def is_venv():
# Get base/real prefix, or sys.prefix if there is none.
base_prefix = getattr(sys, "base_prefix", None) or getattr(sys, "real_prefix", None) or sys.prefix
return sys.prefix != base_prefix


if is_venv():
# use a cache-folder inside the virtualenv-project.
prefix = pl.Path(sys.prefix)
Expand Down
1 change: 1 addition & 0 deletions etc/ipython/profile_default/startup/10-logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
return-statements are not allowed.

"""

print(f"\nRunning {__file__}")

import logging
Expand Down
1 change: 1 addition & 0 deletions etc/ipython/profile_default/startup/20-django.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
return-statements are not allowed.

"""

print(f"\nRunning {__file__}")


Expand Down
782 changes: 400 additions & 382 deletions etc/requirements.txt

Large diffs are not rendered by default.

1,417 changes: 780 additions & 637 deletions poetry.lock

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ packages = [
]

[tool.poetry.dependencies]
python = ">=3.9,<3.10"
# python = ">=3.9,<3.10"
python = ">=3.9,!=3.9.0,!=3.9.1,<3.10"
boto3 = ">=1.30"
django = ">=4.2,<5.0"
dj-email-url = ">=1.0"
Expand All @@ -71,7 +72,7 @@ psycopg2-binary = ">=2.9"
pyjwt = ">=2.3"
PyYAML = ">=6.0"
# scouts-auth = {git = "ssh://git@gitlab.inuits.io:2224/boro/scouts_auth.git", rev = "master"} # @TODO
urllib3= "1.26.19"
urllib3= "1.26.20"


[tool.poetry.group.dev.dependencies]
Expand Down Expand Up @@ -120,4 +121,7 @@ DJANGO_SETTINGS_MODULE = "verzekeringen_api.settings"
# https://docs.astral.sh/ruff/configuration
cache-dir = "var/cache/ruff"
exclude = ["**/migrations/*.py"]
line-length = 120
line-length = 120

[tool.ruff.format]
preview = true
782 changes: 400 additions & 382 deletions requirements.txt

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ def test_settings():
from django.conf import settings

assert settings.DEBUG is True

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InuitsEquipmentService:

@transaction.atomic
def inuits_equipment_create(
self, inuits_equipment: InuitsEquipment, created_by: settings.AUTH_USER_MODEL
self, inuits_equipment: InuitsEquipment, created_by: settings.AUTH_USER_MODEL
) -> InuitsEquipment:
# Check if the instance already exists
create = True
Expand Down Expand Up @@ -52,9 +52,7 @@ def inuits_equipment_create(
)

if create:
logger.debug(
"INUITS EQUIPMENT WILL BE CREATED: %s (%s)", inuits_equipment, type(inuits_equipment).__name__
)
logger.debug("INUITS EQUIPMENT WILL BE CREATED: %s (%s)", inuits_equipment, type(inuits_equipment).__name__)
inuits_equipment = InuitsEquipment(
nature=inuits_equipment.nature,
description=inuits_equipment.description,
Expand All @@ -72,7 +70,7 @@ def inuits_equipment_create(

@transaction.atomic
def linked_equipment_create(
self, insurance: EquipmentInsurance, inuits_equipment: InuitsEquipment, created_by: settings.AUTH_USER_MODEL
self, insurance: EquipmentInsurance, inuits_equipment: InuitsEquipment, created_by: settings.AUTH_USER_MODEL
) -> Equipment:
"""
Creates an Equipment instance.
Expand All @@ -91,9 +89,9 @@ def linked_equipment_create(

@transaction.atomic
def equipment_create(
self,
insurance: EquipmentInsurance,
inuits_equipment: InuitsEquipment,
self,
insurance: EquipmentInsurance,
inuits_equipment: InuitsEquipment,
) -> Equipment:
equipment = Equipment(
inuits_id=inuits_equipment.id,
Expand All @@ -112,7 +110,7 @@ def equipment_create(
birth_date=inuits_equipment.owner_member.birth_date,
email=inuits_equipment.owner_member.email,
membership_number=inuits_equipment.owner_member.membership_number,
group_admin_id=inuits_equipment.owner_member.group_admin_id
group_admin_id=inuits_equipment.owner_member.group_admin_id,
)
equipment.full_clean()
equipment.save()
Expand All @@ -121,11 +119,11 @@ def equipment_create(

@transaction.atomic
def inuits_equipment_update(
self,
*,
inuits_equipment: InuitsEquipment,
updated_inuits_equipment: InuitsEquipment,
updated_by: settings.AUTH_USER_MODEL,
self,
*,
inuits_equipment: InuitsEquipment,
updated_inuits_equipment: InuitsEquipment,
updated_by: settings.AUTH_USER_MODEL,
) -> InuitsEquipment:
# logger.debug("UPDATED EQUIPMENT: %s", updated_inuits_equipment)
if inuits_equipment.equals(updated_inuits_equipment):
Expand All @@ -146,14 +144,10 @@ def inuits_equipment_update(
else inuits_equipment.total_value
)
inuits_equipment.owner_non_member = (
updated_inuits_equipment.owner_non_member
if updated_inuits_equipment.owner_non_member
else None
updated_inuits_equipment.owner_non_member if updated_inuits_equipment.owner_non_member else None
)
inuits_equipment.owner_member = (
updated_inuits_equipment.owner_member.group_admin_id
if updated_inuits_equipment.owner_member
else None
updated_inuits_equipment.owner_member.group_admin_id if updated_inuits_equipment.owner_member else None
)
if updated_inuits_equipment.owner_group:
if isinstance(updated_inuits_equipment.owner_group, AbstractScoutsGroup):
Expand All @@ -180,26 +174,34 @@ def inuits_equipment_update(

@transaction.atomic
def equipment_update(
self,
*,
equipment: Equipment,
updated_equipment: InuitsEquipment,
self,
*,
equipment: Equipment,
updated_equipment: InuitsEquipment,
) -> Equipment:
# equipment.insurance = insurance
equipment.nature = (
updated_equipment.nature if updated_equipment.nature else equipment.nature
)
equipment.nature = updated_equipment.nature if updated_equipment.nature else equipment.nature
equipment.description = (
updated_equipment.description if updated_equipment.description else equipment.description
)
equipment.total_value = (
updated_equipment.total_value if updated_equipment.total_value else equipment.total_value
)
owner_non_member = NonMember.objects.all().filter(inuits_id=updated_equipment.owner_non_member.id).last() if updated_equipment.owner_non_member else None
equipment.owner_non_member = (
owner_non_member
owner_non_member = (
NonMember.objects.all().filter(inuits_id=updated_equipment.owner_non_member.id).last()
if updated_equipment.owner_non_member
else None
)
equipment.owner_non_member = owner_non_member
owner_member = (
Member.objects.filter(
group_admin_id=updated_equipment.owner_member
if isinstance(updated_equipment.owner_member, str)
else updated_equipment.owner_member.group_admin_id
).last()
if updated_equipment.owner_member
else None
)
owner_member = Member.objects.filter(group_admin_id=updated_equipment.owner_member if isinstance(updated_equipment.owner_member, str) else updated_equipment.owner_member.group_admin_id).last() if updated_equipment.owner_member else None
equipment.owner_member = owner_member

equipment.owner_group = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

class InsuranceDraftQuerySet(models.QuerySet):
def allowed(self, user):

user_groups: str = []
for scouts_group in user.scouts_groups:
user_groups.append(scouts_group.number)

return self.filter(data__scouts_group__group_admin_id__in=user_groups)


class InsuranceDraftManager(models.Manager):
def get_queryset(self):
return InsuranceDraftQuerySet(self.model, using=self._db)
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@


class InsuranceClaimsPermission(permissions.BasePermission):

def has_object_permission(self, request, view, obj):
if request.user.has_role_administrator():
return True
raise PermissionDenied({"message":"You don't have permission to access",
"object_id": obj.id})

raise PermissionDenied({"message": "You don't have permission to access", "object_id": obj.id})
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def create(self, validated_data: dict) -> InsuranceClaim:
if "attachments" in self.context: # checking if key is in context
files: MultiValueDict = self.context["attachments"]
for file in files.getlist("file"):
print('@@@@@FILE@@@@@: ', file)
print("@@@@@FILE@@@@@: ", file)
InsuranceClaimAttachment.objects.create(insurance_claim=insurance_claim, file=file)

return insurance_claim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


class InuitsEventInsuranceSerializer(EventInsuranceSerializer):

participant_list_file = serializers.SerializerMethodField(required=False, allow_null=True)

class Meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class ActivityInsuranceAttachmentService:

file_service: StorageService = default_storage

def store_attachment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@


class EventInsuranceAttachmentService:

file_service: StorageService = default_storage

def store_attachment(
self, *, uploaded_file: File, insurance: EventInsuranceAttachment
) -> EventInsuranceAttachment:
def store_attachment(self, *, uploaded_file: File, insurance: EventInsuranceAttachment) -> EventInsuranceAttachment:
"""Stores the uploaded attachment as a file."""

name, extension = os.path.splitext(uploaded_file.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,38 @@


class InsuranceClaimService:

report_service = InsuranceClaimReportService()
attachment_service = InsuranceClaimAttachmentService()
mail_service = InuitsInsuranceMailService()

@transaction.atomic
def create(
self,
*,
group_group_admin_id: str,
created_by: settings.AUTH_USER_MODEL,
date_of_accident: datetime = None,
declarant_city: str = "",
file=None,
bank_account: str = "",
activity: str = "",
activity_type: str = "",
used_transport: str = "",
damage_type: str = "",
description: str = "",
involved_party_description: str = "",
involved_party_name: str = "",
involved_party_birthdate: date = None,
official_report_description: str = "",
pv_number: str = "",
witness_name: str = "",
witness_description: str = "",
leadership_description: str = "",
victim: InuitsClaimVictim,
witness: bool = None,
involved_party: bool = None,
official_report: bool = None,
leadership: bool = None

self,
*,
group_group_admin_id: str,
created_by: settings.AUTH_USER_MODEL,
date_of_accident: datetime = None,
declarant_city: str = "",
file=None,
bank_account: str = "",
activity: str = "",
activity_type: str = "",
used_transport: str = "",
damage_type: str = "",
description: str = "",
involved_party_description: str = "",
involved_party_name: str = "",
involved_party_birthdate: date = None,
official_report_description: str = "",
pv_number: str = "",
witness_name: str = "",
witness_description: str = "",
leadership_description: str = "",
victim: InuitsClaimVictim,
witness: bool = None,
involved_party: bool = None,
official_report: bool = None,
leadership: bool = None,
) -> InsuranceClaim:
# validate if person has rights to create claim for this group
if group_group_admin_id not in (group.group_admin_id for group in created_by.scouts_groups):
Expand Down Expand Up @@ -83,7 +81,7 @@ def create(
involved_party=involved_party,
official_report=official_report,
leadership=leadership,
attachment_name=file.get("file").name if file.get("file", None) else None
attachment_name=file.get("file").name if file.get("file", None) else None,
)

claim.full_clean()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def inuits_equipment_insurance_create(
insurance.total_cost = self._calculate_total_cost(insurance)
insurance.full_clean()
insurance.save()
self.base_insurance_service.handle_insurance_created(insurance, created_by=base_insurance_fields.get("created_by"))
self.base_insurance_service.handle_insurance_created(
insurance, created_by=base_insurance_fields.get("created_by")
)

return insurance

Expand All @@ -59,7 +61,12 @@ def inuits_equipment_insurance_update(self, *, insurance: EquipmentInsurance, **
insurance.nature = fields.get("nature", insurance.nature)
insurance.postal_code = fields.get("postal_code", None)
insurance.city = fields.get("city", None)
insurance.country = fields.get("country", insurance.country if insurance.country and insurance.city is None and insurance.postal_code is None else None)
insurance.country = fields.get(
"country",
insurance.country
if insurance.country and insurance.city is None and insurance.postal_code is None
else None,
)

insurance.full_clean()
insurance.save()
Expand Down Expand Up @@ -100,9 +107,7 @@ def _update_equipment(
insurance=insurance, inuits_equipment=inuits_equipment, created_by=created_by
)

equipment = self.equipment_service.equipment_update(
equipment=equipment, updated_equipment=inuits_equipment
)
equipment = self.equipment_service.equipment_update(equipment=equipment, updated_equipment=inuits_equipment)

updated_insurance_equipment_list.append(equipment)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def inuits_temporary_insurance_create(
insurance.full_clean()
insurance.save()

self.base_insurance_service.handle_insurance_created(insurance, created_by=base_insurance_fields.get("responsible_member"))
self.base_insurance_service.handle_insurance_created(
insurance, created_by=base_insurance_fields.get("responsible_member")
)

return insurance

Expand Down
Loading