Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c6b3293fb | |||
| 09246616aa | |||
| f146aa983a | |||
| 60e9430542 |
@@ -103,9 +103,12 @@ class Geometry(BaseResource):
|
||||
resolved_conflicts = all_conflicted_by_conflicts.exclude(id__in=still_conflicting_conflicts)
|
||||
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
|
||||
|
||||
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:
|
||||
objs (list): The list of objects
|
||||
"""
|
||||
@@ -121,6 +124,9 @@ class Geometry(BaseResource):
|
||||
set_objs = _set.filter(
|
||||
deleted=None
|
||||
)
|
||||
if limit_to_attrs:
|
||||
objs += set_objs.values_list(*limit_to_attrs, flat=True)
|
||||
else:
|
||||
objs += set_objs
|
||||
|
||||
# ... 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(
|
||||
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
|
||||
|
||||
return objs
|
||||
|
||||
def get_data_object(self):
|
||||
|
||||
@@ -677,19 +677,23 @@ class GeoReferencedMixin(models.Model):
|
||||
return request
|
||||
|
||||
instance_objs = []
|
||||
needed_data_object_attrs = [
|
||||
"identifier"
|
||||
]
|
||||
conflicts = self.geometry.conflicts_geometries.iterator()
|
||||
|
||||
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()
|
||||
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
|
||||
if add_message:
|
||||
instance_identifiers = [x.identifier for x in instance_objs]
|
||||
instance_identifiers = ", ".join(instance_identifiers)
|
||||
instance_identifiers = ", ".join(instance_objs)
|
||||
message_str = GEOMETRY_CONFLICT_WITH_TEMPLATE.format(instance_identifiers)
|
||||
messages.info(request, message_str)
|
||||
return request
|
||||
|
||||
BIN
konova/static/images/error_imgs/croc_technician_400_sm.png
Normal file
BIN
konova/static/images/error_imgs/croc_technician_400_sm.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
BIN
konova/static/images/error_imgs/croc_technician_500_sm.png
Normal file
BIN
konova/static/images/error_imgs/croc_technician_500_sm.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
@@ -5,7 +5,7 @@ Contact: michel.peltriaux@sgdnord.rlp.de
|
||||
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.utils.translation import gettext_lazy as _
|
||||
|
||||
@@ -45,6 +45,19 @@ class Mailer:
|
||||
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):
|
||||
""" 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)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared access given").format(obj.identifier),
|
||||
msg
|
||||
@@ -141,7 +154,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/sharing/shared_access_removed_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared access removed").format(obj.identifier),
|
||||
msg
|
||||
@@ -167,7 +180,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/recording/shared_data_unrecorded_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared data unrecorded").format(obj.identifier),
|
||||
msg
|
||||
@@ -193,7 +206,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/recording/shared_data_recorded_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared data recorded").format(obj.identifier),
|
||||
msg
|
||||
@@ -219,7 +232,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/checking/shared_data_checked_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared data checked").format(obj.identifier),
|
||||
msg
|
||||
@@ -244,7 +257,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/other/deduction_changed_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Deduction changed").format(obj.identifier),
|
||||
msg
|
||||
@@ -270,7 +283,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/deleting/shared_data_deleted_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared data deleted").format(obj.identifier),
|
||||
msg
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="jumbotron">
|
||||
<div class="row">
|
||||
<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 class="col-sm-12 col-md-9 col-lg-9 col-xl-10">
|
||||
<h1 class="display-4">{% fa5_icon 'question-circle' %}400</h1>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="jumbotron">
|
||||
<div class="row">
|
||||
<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 class="col-sm-12 col-md-9 col-lg-9 col-xl-10">
|
||||
<h1 class="display-4">{% fa5_icon 'fire-alt' %} 500</h1>
|
||||
|
||||
Reference in New Issue
Block a user