Compare commits
8 Commits
1.23
...
906d6335ff
| Author | SHA1 | Date | |
|---|---|---|---|
| 906d6335ff | |||
| 6772ddb5c8 | |||
| ea1276e40b | |||
| ee4701f63f | |||
| 87e4ee726c | |||
| cbe309f114 | |||
| 2aa625a6ac | |||
| d39e758df4 |
@@ -1,5 +1,6 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from api.models import ExternalIdentifier
|
||||
from api.models.token import APIUserToken, OAuthToken
|
||||
|
||||
|
||||
@@ -28,6 +29,17 @@ class OAuthTokenAdmin(admin.ModelAdmin):
|
||||
"refresh_token",
|
||||
]
|
||||
|
||||
class ExternalIdentifierAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"external_id",
|
||||
"internal_id",
|
||||
"created",
|
||||
]
|
||||
search_fields = [
|
||||
"external_id",
|
||||
"internal_id",
|
||||
]
|
||||
|
||||
admin.site.register(APIUserToken, APITokenAdmin)
|
||||
admin.site.register(OAuthToken, OAuthTokenAdmin)
|
||||
admin.site.register(ExternalIdentifier, ExternalIdentifierAdmin)
|
||||
|
||||
@@ -156,6 +156,8 @@ class AbstractModelAPISerializer:
|
||||
if isinstance(geojson, dict):
|
||||
geojson = json.dumps(geojson)
|
||||
geometry = geos.fromstr(geojson)
|
||||
if not geometry.valid:
|
||||
raise ValueError(f"Invalid geometry: {geometry.valid_reason}")
|
||||
is_4326 = Geometry.is_valid_4326(geometry)
|
||||
if not is_4326:
|
||||
raise ValueError("Geometry not in EPSG:4326 (WGS84). Unknown spatial reference system.")
|
||||
|
||||
@@ -30,17 +30,45 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Available' %}</th>
|
||||
<td>
|
||||
{{available_total|floatformat:2}} / {{obj.deductable_surface|default_if_none:0.00|floatformat:2}} m²
|
||||
{% with available as value %}
|
||||
{% include 'konova/widgets/progressbar.html' %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Deductions for' %}</th>
|
||||
<td class="align-middle">
|
||||
{% for deduction in deductions %}
|
||||
<a href="{% url 'intervention:report' deduction.intervention__id %}">
|
||||
{{deduction.intervention__identifier}} - {{deduction.intervention__title}}
|
||||
</a>
|
||||
<br>
|
||||
{% empty %}
|
||||
{% trans 'None' %}
|
||||
{% endfor %}
|
||||
<table class="table table-hover">
|
||||
<th scope="col">
|
||||
{% translate 'Intervention' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% translate 'Amount' %}
|
||||
</th>
|
||||
{% for deduction in deductions %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'intervention:report' deduction.intervention__id %}">
|
||||
{{deduction.intervention__identifier}} - {{deduction.intervention__title}}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ deduction.surface|floatformat:2 }} m²</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td>
|
||||
{% translate 'None' %}
|
||||
</td>
|
||||
<td>
|
||||
/
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -66,7 +66,15 @@ class EcoAccountPublicReportView(AbstractPublicReportView):
|
||||
deductions = acc.deductions.all() \
|
||||
.distinct("intervention") \
|
||||
.select_related("intervention") \
|
||||
.values_list("intervention__id", "intervention__identifier", "intervention__title", named=True)
|
||||
.values_list("intervention__id",
|
||||
"intervention__identifier",
|
||||
"intervention__title",
|
||||
"surface",
|
||||
named=True)
|
||||
|
||||
# Calculate rest of available surface for deductions
|
||||
available_total = acc.deductable_rest
|
||||
available_relative = acc.get_deductable_rest_relative()
|
||||
|
||||
context = {
|
||||
"obj": acc,
|
||||
@@ -86,6 +94,8 @@ class EcoAccountPublicReportView(AbstractPublicReportView):
|
||||
"actions": actions,
|
||||
"deductions": deductions,
|
||||
"tables_scrollable": False,
|
||||
"available": available_relative,
|
||||
"available_total": available_total,
|
||||
TAB_TITLE_IDENTIFIER: tab_title,
|
||||
}
|
||||
context = BaseContext(request, context).context
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from intervention.models import Intervention, Responsibility, Legal, Revocation, InterventionDocument
|
||||
from intervention.models import Intervention
|
||||
from konova.admin import AbstractDocumentAdmin, BaseObjectAdmin
|
||||
|
||||
|
||||
|
||||
+1
-3
@@ -7,10 +7,7 @@ Created on: 22.07.21
|
||||
"""
|
||||
from django.contrib import admin
|
||||
|
||||
from konova.models import Geometry, Deadline, GeometryConflict, Parcel, District, Municipal, ParcelGroup, Resubmission
|
||||
from konova.sub_settings.lanis_settings import DEFAULT_SRID_RLP
|
||||
from konova.utils.message_templates import COMPENSATION_REMOVED_TEMPLATE
|
||||
from user.models import UserAction
|
||||
|
||||
|
||||
class GeometryAdmin(admin.ModelAdmin):
|
||||
@@ -123,6 +120,7 @@ class BaseResourceAdmin(admin.ModelAdmin):
|
||||
|
||||
class BaseObjectAdmin(BaseResourceAdmin, DeletableObjectMixinAdmin):
|
||||
search_fields = [
|
||||
"id",
|
||||
"identifier",
|
||||
"title",
|
||||
]
|
||||
|
||||
@@ -146,6 +146,33 @@ class BaseObject(BaseResource, DeletableObjectMixin):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def delete(self, using=None, keep_parents=False):
|
||||
""" Base deleting of a BaseObject instance
|
||||
|
||||
Args:
|
||||
using:
|
||||
keep_parents:
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.__delete_external_identifier()
|
||||
super().delete(using, keep_parents)
|
||||
|
||||
def __delete_external_identifier(self):
|
||||
""" Checks on existing external identifier linking and drops them
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
from api.models import ExternalIdentifier
|
||||
try:
|
||||
external_identifier = ExternalIdentifier.objects.filter(internal_id=self.id)
|
||||
external_identifier.delete()
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def set_status_messages(self, request: HttpRequest):
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
"""
|
||||
Author: Michel Peltriaux
|
||||
Created on: 16.07.26
|
||||
|
||||
"""
|
||||
@@ -0,0 +1,5 @@
|
||||
"""
|
||||
Author: Michel Peltriaux
|
||||
Created on: 16.07.26
|
||||
|
||||
"""
|
||||
Reference in New Issue
Block a user