Compare commits

...

4 Commits
1.14 ... 1.14.2

Author SHA1 Message Date
6c6b3293fb Merge pull request '# Bcc mail sending' (#527) from 526_BCC_mail_sending into master
Reviewed-on: #527
2026-01-21 14:46:45 +00:00
09246616aa # Bcc mail sending
* extends mailer class with bcc based mailing
* switches all team based mail sending (multiple mail adresses) to bcc based mailing
* adds smaller versions of tech-croc error images for 4xx and 5xx errors for faster rendering
2026-01-21 15:46:21 +01:00
f146aa983a Merge pull request '# Boost geometry conflict message fetch' (#523) from 503_Improve_performance_on_geometry_conflict_message into master
Reviewed-on: #523
2026-01-14 08:03:01 +00:00
60e9430542 # Boost geometry conflict message fetch
* reduces runtime of geometry conflict info message generating to ~45% to prior runtime
2026-01-14 09:02:41 +01:00
7 changed files with 43 additions and 18 deletions

View File

@@ -103,9 +103,12 @@ class Geometry(BaseResource):
resolved_conflicts = all_conflicted_by_conflicts.exclude(id__in=still_conflicting_conflicts) resolved_conflicts = all_conflicted_by_conflicts.exclude(id__in=still_conflicting_conflicts)
resolved_conflicts.delete() resolved_conflicts.delete()
def get_data_objects(self): def get_data_objects(self, limit_to_attrs: list = None):
""" Getter for all objects which are related to this geometry """ Getter for all objects which are related to this geometry
Using the limit_to_attrs we can limit the amount of returned data directly onto the data object attributes
we want to have. Reduces memory consumption and runtime.
Returns: Returns:
objs (list): The list of objects objs (list): The list of objects
""" """
@@ -121,6 +124,9 @@ class Geometry(BaseResource):
set_objs = _set.filter( set_objs = _set.filter(
deleted=None deleted=None
) )
if limit_to_attrs:
objs += set_objs.values_list(*limit_to_attrs, flat=True)
else:
objs += set_objs objs += set_objs
# ... but we need a special treatment for compensations, since they can be deleted directly OR inherit their # ... but we need a special treatment for compensations, since they can be deleted directly OR inherit their
@@ -128,8 +134,10 @@ class Geometry(BaseResource):
comp_objs = self.compensation_set.filter( comp_objs = self.compensation_set.filter(
Q(deleted=None) & Q(intervention__deleted=None) Q(deleted=None) & Q(intervention__deleted=None)
) )
if limit_to_attrs:
objs += comp_objs.values_list(*limit_to_attrs, flat=True)
else:
objs += comp_objs objs += comp_objs
return objs return objs
def get_data_object(self): def get_data_object(self):

View File

@@ -677,19 +677,23 @@ class GeoReferencedMixin(models.Model):
return request return request
instance_objs = [] instance_objs = []
needed_data_object_attrs = [
"identifier"
]
conflicts = self.geometry.conflicts_geometries.iterator() conflicts = self.geometry.conflicts_geometries.iterator()
for conflict in conflicts: for conflict in conflicts:
instance_objs += conflict.affected_geometry.get_data_objects() # Only check the affected geometry of this conflict, since we know the conflicting geometry is self.geometry
instance_objs += conflict.affected_geometry.get_data_objects(needed_data_object_attrs)
conflicts = self.geometry.conflicted_by_geometries.iterator() conflicts = self.geometry.conflicted_by_geometries.iterator()
for conflict in conflicts: for conflict in conflicts:
instance_objs += conflict.conflicting_geometry.get_data_objects() # Only check the conflicting geometry of this conflict, since we know the affected geometry is self.geometry
instance_objs += conflict.conflicting_geometry.get_data_objects(needed_data_object_attrs)
add_message = len(instance_objs) > 0 add_message = len(instance_objs) > 0
if add_message: if add_message:
instance_identifiers = [x.identifier for x in instance_objs] instance_identifiers = ", ".join(instance_objs)
instance_identifiers = ", ".join(instance_identifiers)
message_str = GEOMETRY_CONFLICT_WITH_TEMPLATE.format(instance_identifiers) message_str = GEOMETRY_CONFLICT_WITH_TEMPLATE.format(instance_identifiers)
messages.info(request, message_str) messages.info(request, message_str)
return request return request

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@@ -5,7 +5,7 @@ Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 09.11.20 Created on: 09.11.20
""" """
from django.core.mail import send_mail from django.core.mail import send_mail, EmailMultiAlternatives
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@@ -45,6 +45,19 @@ class Mailer:
auth_password=self.auth_password auth_password=self.auth_password
) )
def send_via_bcc(self, recipient_list: list, subject: str, msg: str):
"""
Sends a mail with subject and message where recipients will be masked via bcc
"""
email_obj = EmailMultiAlternatives(
subject,
msg,
self.from_mail,
bcc=recipient_list,
)
email_obj.attach_alternative(msg, "text/html")
return email_obj.send(fail_silently=self.fail_silently)
def send_mail_shared_access_removed(self, obj, user, municipals_names): def send_mail_shared_access_removed(self, obj, user, municipals_names):
""" Send a mail if user has no access to the object anymore """ Send a mail if user has no access to the object anymore
@@ -115,7 +128,7 @@ class Mailer:
} }
msg = render_to_string("email/sharing/shared_access_given_team.html", context) msg = render_to_string("email/sharing/shared_access_given_team.html", context)
user_mail_address = users_to_notify.values_list("email", flat=True) user_mail_address = users_to_notify.values_list("email", flat=True)
self.send( self.send_via_bcc(
user_mail_address, user_mail_address,
_("{} - Shared access given").format(obj.identifier), _("{} - Shared access given").format(obj.identifier),
msg msg
@@ -141,7 +154,7 @@ class Mailer:
} }
msg = render_to_string("email/sharing/shared_access_removed_team.html", context) msg = render_to_string("email/sharing/shared_access_removed_team.html", context)
user_mail_address = users_to_notify.values_list("email", flat=True) user_mail_address = users_to_notify.values_list("email", flat=True)
self.send( self.send_via_bcc(
user_mail_address, user_mail_address,
_("{} - Shared access removed").format(obj.identifier), _("{} - Shared access removed").format(obj.identifier),
msg msg
@@ -167,7 +180,7 @@ class Mailer:
} }
msg = render_to_string("email/recording/shared_data_unrecorded_team.html", context) msg = render_to_string("email/recording/shared_data_unrecorded_team.html", context)
user_mail_address = users_to_notify.values_list("email", flat=True) user_mail_address = users_to_notify.values_list("email", flat=True)
self.send( self.send_via_bcc(
user_mail_address, user_mail_address,
_("{} - Shared data unrecorded").format(obj.identifier), _("{} - Shared data unrecorded").format(obj.identifier),
msg msg
@@ -193,7 +206,7 @@ class Mailer:
} }
msg = render_to_string("email/recording/shared_data_recorded_team.html", context) msg = render_to_string("email/recording/shared_data_recorded_team.html", context)
user_mail_address = users_to_notify.values_list("email", flat=True) user_mail_address = users_to_notify.values_list("email", flat=True)
self.send( self.send_via_bcc(
user_mail_address, user_mail_address,
_("{} - Shared data recorded").format(obj.identifier), _("{} - Shared data recorded").format(obj.identifier),
msg msg
@@ -219,7 +232,7 @@ class Mailer:
} }
msg = render_to_string("email/checking/shared_data_checked_team.html", context) msg = render_to_string("email/checking/shared_data_checked_team.html", context)
user_mail_address = users_to_notify.values_list("email", flat=True) user_mail_address = users_to_notify.values_list("email", flat=True)
self.send( self.send_via_bcc(
user_mail_address, user_mail_address,
_("{} - Shared data checked").format(obj.identifier), _("{} - Shared data checked").format(obj.identifier),
msg msg
@@ -244,7 +257,7 @@ class Mailer:
} }
msg = render_to_string("email/other/deduction_changed_team.html", context) msg = render_to_string("email/other/deduction_changed_team.html", context)
user_mail_address = users_to_notify.values_list("email", flat=True) user_mail_address = users_to_notify.values_list("email", flat=True)
self.send( self.send_via_bcc(
user_mail_address, user_mail_address,
_("{} - Deduction changed").format(obj.identifier), _("{} - Deduction changed").format(obj.identifier),
msg msg
@@ -270,7 +283,7 @@ class Mailer:
} }
msg = render_to_string("email/deleting/shared_data_deleted_team.html", context) msg = render_to_string("email/deleting/shared_data_deleted_team.html", context)
user_mail_address = users_to_notify.values_list("email", flat=True) user_mail_address = users_to_notify.values_list("email", flat=True)
self.send( self.send_via_bcc(
user_mail_address, user_mail_address,
_("{} - Shared data deleted").format(obj.identifier), _("{} - Shared data deleted").format(obj.identifier),
msg msg

View File

@@ -5,7 +5,7 @@
<div class="jumbotron"> <div class="jumbotron">
<div class="row"> <div class="row">
<div class="col-auto"> <div class="col-auto">
<img src="{% static 'images/error_imgs/croc_technician_400.png' %}" style="max-width: 150px"> <img src="{% static 'images/error_imgs/croc_technician_400_sm.png' %}" style="max-width: 150px">
</div> </div>
<div class="col-sm-12 col-md-9 col-lg-9 col-xl-10"> <div class="col-sm-12 col-md-9 col-lg-9 col-xl-10">
<h1 class="display-4">{% fa5_icon 'question-circle' %}400</h1> <h1 class="display-4">{% fa5_icon 'question-circle' %}400</h1>

View File

@@ -5,7 +5,7 @@
<div class="jumbotron"> <div class="jumbotron">
<div class="row"> <div class="row">
<div class="col-auto"> <div class="col-auto">
<img src="{% static 'images/error_imgs/croc_technician_500.png' %}" style="max-width: 150px"> <img src="{% static 'images/error_imgs/croc_technician_500_sm.png' %}" style="max-width: 150px">
</div> </div>
<div class="col-sm-12 col-md-9 col-lg-9 col-xl-10"> <div class="col-sm-12 col-md-9 col-lg-9 col-xl-10">
<h1 class="display-4">{% fa5_icon 'fire-alt' %} 500</h1> <h1 class="display-4">{% fa5_icon 'fire-alt' %} 500</h1>