Merge pull request '139_Improve_parcel_reference' (#141) from 139_Improve_parcel_reference into master
Reviewed-on: SGD-Nord/konova#141
This commit is contained in:
commit
59ff1c79a8
@ -134,7 +134,7 @@ class CompensationTable(BaseTable, TableRenderMixin):
|
||||
|
||||
"""
|
||||
parcels = value.get_underlying_parcels().values_list(
|
||||
"gmrkng",
|
||||
"parcel_group__name",
|
||||
flat=True
|
||||
).distinct()
|
||||
html = render_to_string(
|
||||
@ -295,7 +295,7 @@ class EcoAccountTable(BaseTable, TableRenderMixin):
|
||||
|
||||
"""
|
||||
parcels = value.get_underlying_parcels().values_list(
|
||||
"gmrkng",
|
||||
"parcel_group__name",
|
||||
flat=True
|
||||
).distinct()
|
||||
html = render_to_string(
|
||||
|
@ -104,7 +104,7 @@ class EmaTable(BaseTable, TableRenderMixin):
|
||||
|
||||
"""
|
||||
parcels = value.get_underlying_parcels().values_list(
|
||||
"gmrkng",
|
||||
"parcel_group__name",
|
||||
flat=True
|
||||
).distinct()
|
||||
html = render_to_string(
|
||||
|
@ -131,7 +131,7 @@ class InterventionTable(BaseTable, TableRenderMixin):
|
||||
|
||||
"""
|
||||
parcels = value.get_underlying_parcels().values_list(
|
||||
"gmrkng",
|
||||
"parcel_group__name",
|
||||
flat=True
|
||||
).distinct()
|
||||
html = render_to_string(
|
||||
|
@ -7,7 +7,7 @@ Created on: 22.07.21
|
||||
"""
|
||||
from django.contrib import admin
|
||||
|
||||
from konova.models import Geometry, Deadline, GeometryConflict, Parcel, District
|
||||
from konova.models import Geometry, Deadline, GeometryConflict, Parcel, District, Municipal, ParcelGroup
|
||||
from konova.utils.message_templates import COMPENSATION_REMOVED_TEMPLATE
|
||||
from user.models import UserAction
|
||||
|
||||
@ -22,7 +22,7 @@ class GeometryAdmin(admin.ModelAdmin):
|
||||
class ParcelAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"id",
|
||||
"gmrkng",
|
||||
"parcel_group",
|
||||
"flr",
|
||||
"flrstck_nnr",
|
||||
"flrstck_zhlr",
|
||||
@ -32,9 +32,27 @@ class ParcelAdmin(admin.ModelAdmin):
|
||||
|
||||
class DistrictAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"name",
|
||||
"key",
|
||||
"id",
|
||||
]
|
||||
|
||||
|
||||
class MunicipalAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"name",
|
||||
"key",
|
||||
"district",
|
||||
"id",
|
||||
]
|
||||
|
||||
|
||||
class ParcelGroupAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"name",
|
||||
"key",
|
||||
"municipal",
|
||||
"id",
|
||||
"gmnd",
|
||||
"krs",
|
||||
]
|
||||
|
||||
|
||||
@ -105,5 +123,7 @@ class BaseObjectAdmin(BaseResourceAdmin):
|
||||
#admin.site.register(Geometry, GeometryAdmin)
|
||||
#admin.site.register(Parcel, ParcelAdmin)
|
||||
#admin.site.register(District, DistrictAdmin)
|
||||
#admin.site.register(Municipal, MunicipalAdmin)
|
||||
#admin.site.register(ParcelGroup, ParcelGroupAdmin)
|
||||
#admin.site.register(GeometryConflict, GeometryConflictAdmin)
|
||||
#admin.site.register(Deadline, DeadlineAdmin)
|
||||
|
@ -145,26 +145,20 @@ class GeoReferencedTableFilterMixin(django_filters.FilterSet):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def _filter_parcel_reference(self, queryset, name, value, filter_value) -> QuerySet:
|
||||
""" Filters the parcel entries by a given filter_value.
|
||||
|
||||
filter_value may already include further filter annotations like 'xy__icontains'
|
||||
def _filter_parcel_reference(self, queryset, filter_q) -> QuerySet:
|
||||
""" Filters the parcel entries by a given filter_q
|
||||
|
||||
Args:
|
||||
queryset ():
|
||||
name ():
|
||||
value ():
|
||||
filter_value ():
|
||||
queryset (QuerySet): The queryset
|
||||
filter_q (Q): The Q-style filter expression
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
_filter = {
|
||||
filter_value: value
|
||||
}
|
||||
matching_parcels = Parcel.objects.filter(
|
||||
**_filter
|
||||
filter_q
|
||||
)
|
||||
|
||||
related_geoms = matching_parcels.values(
|
||||
"geometries"
|
||||
).distinct()
|
||||
@ -185,8 +179,9 @@ class GeoReferencedTableFilterMixin(django_filters.FilterSet):
|
||||
|
||||
"""
|
||||
matching_districts = District.objects.filter(
|
||||
krs__icontains=value
|
||||
)
|
||||
Q(name__icontains=value) |
|
||||
Q(key__icontains=value)
|
||||
).distinct()
|
||||
matching_parcels = Parcel.objects.filter(
|
||||
district__in=matching_districts
|
||||
)
|
||||
@ -209,7 +204,10 @@ class GeoReferencedTableFilterMixin(django_filters.FilterSet):
|
||||
Returns:
|
||||
|
||||
"""
|
||||
queryset = self._filter_parcel_reference(queryset, name, value, "gmrkng__icontains")
|
||||
queryset = self._filter_parcel_reference(
|
||||
queryset,
|
||||
Q(parcel_group__name__icontains=value) | Q(parcel_group__key__icontains=value),
|
||||
)
|
||||
return queryset
|
||||
|
||||
def filter_parcel(self, queryset, name, value) -> QuerySet:
|
||||
@ -224,7 +222,10 @@ class GeoReferencedTableFilterMixin(django_filters.FilterSet):
|
||||
|
||||
"""
|
||||
value = value.replace("-", "")
|
||||
queryset = self._filter_parcel_reference(queryset, name, value, "flr")
|
||||
queryset = self._filter_parcel_reference(
|
||||
queryset,
|
||||
Q(flr=value),
|
||||
)
|
||||
return queryset
|
||||
|
||||
def filter_parcel_counter(self, queryset, name, value) -> QuerySet:
|
||||
@ -239,7 +240,10 @@ class GeoReferencedTableFilterMixin(django_filters.FilterSet):
|
||||
|
||||
"""
|
||||
value = value.replace("-", "")
|
||||
queryset = self._filter_parcel_reference(queryset, name, value, "flrstck_zhlr")
|
||||
queryset = self._filter_parcel_reference(
|
||||
queryset,
|
||||
Q(flrstck_zhlr=value)
|
||||
)
|
||||
return queryset
|
||||
|
||||
def filter_parcel_number(self, queryset, name, value) -> QuerySet:
|
||||
@ -254,7 +258,10 @@ class GeoReferencedTableFilterMixin(django_filters.FilterSet):
|
||||
|
||||
"""
|
||||
value = value.replace("-", "")
|
||||
queryset = self._filter_parcel_reference(queryset, name, value, "flrstck_nnr")
|
||||
queryset = self._filter_parcel_reference(
|
||||
queryset,
|
||||
Q(flrstck_nnr=value),
|
||||
)
|
||||
return queryset
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@ from compensation.models import CompensationState, Compensation, EcoAccount, Com
|
||||
from ema.models import Ema
|
||||
from intervention.models import Intervention
|
||||
from konova.management.commands.setup import BaseKonovaCommand
|
||||
from konova.models import Deadline, Geometry, Parcel, District
|
||||
from konova.models import Deadline, Geometry, Parcel, District, Municipal, ParcelGroup
|
||||
from user.models import UserActionLogEntry, UserAction
|
||||
|
||||
|
||||
@ -271,13 +271,26 @@ class Command(BaseKonovaCommand):
|
||||
self._write_success("No unused states found.")
|
||||
self._break_line()
|
||||
|
||||
def __sanitize_parcel_sub_type(self, cls):
|
||||
unrelated_entries = cls.objects.filter(
|
||||
parcels=None,
|
||||
)
|
||||
num_unrelated_entries = unrelated_entries.count()
|
||||
cls_name = cls.__name__
|
||||
if num_unrelated_entries > 0:
|
||||
self._write_error(f"Found {num_unrelated_entries} unrelated {cls_name} entries. Delete now...")
|
||||
unrelated_entries.delete()
|
||||
self._write_success(f"Unrelated {cls_name} deleted.")
|
||||
else:
|
||||
self._write_success(f"No unrelated {cls_name} found.")
|
||||
|
||||
def sanitize_parcels_and_districts(self):
|
||||
""" Removes unattached parcels and districts
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self._write_warning("=== Sanitize parcels and districts ===")
|
||||
self._write_warning("=== Sanitize administrative spatial references ===")
|
||||
unrelated_parcels = Parcel.objects.filter(
|
||||
geometries=None,
|
||||
)
|
||||
@ -289,16 +302,12 @@ class Command(BaseKonovaCommand):
|
||||
else:
|
||||
self._write_success("No unrelated parcels found.")
|
||||
|
||||
unrelated_districts = District.objects.filter(
|
||||
parcels=None,
|
||||
)
|
||||
num_unrelated_districts = unrelated_districts.count()
|
||||
if num_unrelated_districts > 0:
|
||||
self._write_error(f"Found {num_unrelated_districts} unrelated district entries. Delete now...")
|
||||
unrelated_districts.delete()
|
||||
self._write_success("Unrelated districts deleted.")
|
||||
else:
|
||||
self._write_success("No unrelated districts found.")
|
||||
|
||||
self._break_line()
|
||||
sub_types = [
|
||||
District,
|
||||
Municipal,
|
||||
ParcelGroup
|
||||
]
|
||||
for sub_type in sub_types:
|
||||
self.__sanitize_parcel_sub_type(sub_type)
|
||||
|
||||
self._break_line()
|
71
konova/migrations/0006_auto_20220411_0835.py
Normal file
71
konova/migrations/0006_auto_20220411_0835.py
Normal file
@ -0,0 +1,71 @@
|
||||
# Generated by Django 3.1.3 on 2022-04-11 06:35
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('konova', '0005_auto_20220216_0856'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Municipal',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('key', models.IntegerField(blank=True, help_text='Represents Gemeindeschlüssel', null=True)),
|
||||
('name', models.CharField(blank=True, help_text='Gemeinde', max_length=1000, null=True)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='district',
|
||||
old_name='krs',
|
||||
new_name='name',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='district',
|
||||
name='gmnd',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='parcel',
|
||||
name='gmrkng',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='district',
|
||||
name='key',
|
||||
field=models.IntegerField(blank=True, help_text='Represents Kreisschlüssel', null=True),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ParcelGroup',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('key', models.IntegerField(blank=True, help_text='Represents Gemarkungsschlüssel', null=True)),
|
||||
('name', models.CharField(blank=True, help_text='Gemarkung', max_length=1000, null=True)),
|
||||
('municipal', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='konova.municipal')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='municipal',
|
||||
name='district',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='konova.district'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='parcel',
|
||||
name='municipal',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='parcels', to='konova.municipal'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='parcel',
|
||||
name='parcel_group',
|
||||
field=models.ForeignKey(blank=True, help_text='Gemarkung', null=True, on_delete=django.db.models.deletion.SET_NULL, to='konova.parcelgroup'),
|
||||
),
|
||||
]
|
28
konova/migrations/0007_auto_20220411_0848.py
Normal file
28
konova/migrations/0007_auto_20220411_0848.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Generated by Django 3.1.3 on 2022-04-11 06:48
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('konova', '0006_auto_20220411_0835'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='district',
|
||||
name='key',
|
||||
field=models.CharField(blank=True, help_text='Represents Kreisschlüssel', max_length=255, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='municipal',
|
||||
name='key',
|
||||
field=models.CharField(blank=True, help_text='Represents Gemeindeschlüssel', max_length=255, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='parcelgroup',
|
||||
name='key',
|
||||
field=models.CharField(blank=True, help_text='Represents Gemarkungsschlüssel', max_length=255, null=True),
|
||||
),
|
||||
]
|
48
konova/migrations/0008_auto_20220411_0914.py
Normal file
48
konova/migrations/0008_auto_20220411_0914.py
Normal file
@ -0,0 +1,48 @@
|
||||
# Generated by Django 3.1.3 on 2022-04-11 07:14
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('konova', '0007_auto_20220411_0848'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='municipal',
|
||||
name='key',
|
||||
field=models.CharField(blank=True, help_text='Represents Kreisschlüssel', max_length=255, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='municipal',
|
||||
name='name',
|
||||
field=models.CharField(blank=True, help_text='Kreis', max_length=1000, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='parcel',
|
||||
name='flr',
|
||||
field=models.IntegerField(blank=True, help_text='Flur', null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='parcel',
|
||||
name='flrstck_nnr',
|
||||
field=models.IntegerField(blank=True, help_text='Flurstücksnenner', null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='parcel',
|
||||
name='flrstck_zhlr',
|
||||
field=models.IntegerField(blank=True, help_text='Flurstückszähler', null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='parcelgroup',
|
||||
name='key',
|
||||
field=models.CharField(blank=True, help_text='Represents Kreisschlüssel', max_length=255, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='parcelgroup',
|
||||
name='name',
|
||||
field=models.CharField(blank=True, help_text='Kreis', max_length=1000, null=True),
|
||||
),
|
||||
]
|
19
konova/migrations/0009_auto_20220411_1004.py
Normal file
19
konova/migrations/0009_auto_20220411_1004.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.1.3 on 2022-04-11 08:04
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('konova', '0008_auto_20220411_0914'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='parcel',
|
||||
name='parcel_group',
|
||||
field=models.ForeignKey(blank=True, help_text='Gemarkung', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='parcels', to='konova.parcelgroup'),
|
||||
),
|
||||
]
|
@ -99,7 +99,7 @@ class Geometry(BaseResource):
|
||||
Returns:
|
||||
|
||||
"""
|
||||
from konova.models import Parcel, District, ParcelIntersection
|
||||
from konova.models import Parcel, District, ParcelIntersection, Municipal, ParcelGroup
|
||||
parcel_fetcher = ParcelWFSFetcher(
|
||||
geometry_id=self.id,
|
||||
)
|
||||
@ -115,16 +115,28 @@ class Geometry(BaseResource):
|
||||
# which needs to be deleted and just keep the numerical values
|
||||
## THIS CAN BE REMOVED IN THE FUTURE, WHEN 'Flur' WON'T OCCUR ANYMORE!
|
||||
flr_val = fetched_parcel["ave:flur"].replace("Flur ", "")
|
||||
district = District.objects.get_or_create(
|
||||
key=fetched_parcel["ave:kreisschl"],
|
||||
name=fetched_parcel["ave:kreis"],
|
||||
)[0]
|
||||
municipal = Municipal.objects.get_or_create(
|
||||
key=fetched_parcel["ave:gmdschl"],
|
||||
name=fetched_parcel["ave:gemeinde"],
|
||||
district=district,
|
||||
)[0]
|
||||
parcel_group = ParcelGroup.objects.get_or_create(
|
||||
key=fetched_parcel["ave:gemaschl"],
|
||||
name=fetched_parcel["ave:gemarkung"],
|
||||
municipal=municipal,
|
||||
)[0]
|
||||
parcel_obj = Parcel.objects.get_or_create(
|
||||
gmrkng=fetched_parcel["ave:gemarkung"],
|
||||
district=district,
|
||||
municipal=municipal,
|
||||
parcel_group=parcel_group,
|
||||
flr=flr_val,
|
||||
flrstck_nnr=fetched_parcel['ave:flstnrnen'],
|
||||
flrstck_zhlr=fetched_parcel['ave:flstnrzae'],
|
||||
)[0]
|
||||
district = District.objects.get_or_create(
|
||||
gmnd=fetched_parcel["ave:gemeinde"],
|
||||
krs=fetched_parcel["ave:kreis"],
|
||||
)[0]
|
||||
parcel_obj.district = district
|
||||
parcel_obj.updated_on = _now
|
||||
parcel_obj.save()
|
||||
@ -155,9 +167,10 @@ class Geometry(BaseResource):
|
||||
parcels = self.parcels.filter(
|
||||
parcelintersection__calculated_on__isnull=False,
|
||||
).prefetch_related(
|
||||
"district"
|
||||
"district",
|
||||
"municipal",
|
||||
).order_by(
|
||||
"gmrkng",
|
||||
"municipal__name",
|
||||
)
|
||||
|
||||
return parcels
|
||||
|
@ -10,8 +10,64 @@ from django.db import models
|
||||
from konova.models import UuidModel
|
||||
|
||||
|
||||
class AdministrativeSpatialReference(models.Model):
|
||||
key = models.CharField(
|
||||
max_length=255,
|
||||
help_text="Represents Kreisschlüssel",
|
||||
null=True,
|
||||
blank=True
|
||||
)
|
||||
name = models.CharField(
|
||||
max_length=1000,
|
||||
help_text="Kreis",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.key})"
|
||||
|
||||
@property
|
||||
def table_str(self):
|
||||
return f"{self.name} ({self.key})"
|
||||
|
||||
|
||||
class District(UuidModel, AdministrativeSpatialReference):
|
||||
""" The model District refers to "Kreis"
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class Municipal(UuidModel, AdministrativeSpatialReference):
|
||||
""" The model Municipal refers to "Gemeinde"
|
||||
|
||||
"""
|
||||
district = models.ForeignKey(
|
||||
District,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
|
||||
class ParcelGroup(UuidModel, AdministrativeSpatialReference):
|
||||
""" The model ParcelGroup refers to "Gemarkung", which is defined as a loose group of parcels
|
||||
|
||||
"""
|
||||
municipal = models.ForeignKey(
|
||||
Municipal,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
|
||||
class Parcel(UuidModel):
|
||||
""" The Parcel model holds administrative data on the covered properties.
|
||||
""" The Parcel model holds administrative data on covered properties.
|
||||
|
||||
Due to the unique but relevant naming of the administrative data, we have to use these namings as field
|
||||
names in german. Any try to translate them to English result in strange or insufficient translations.
|
||||
@ -24,59 +80,34 @@ class Parcel(UuidModel):
|
||||
"""
|
||||
geometries = models.ManyToManyField("konova.Geometry", blank=True, related_name="parcels", through='ParcelIntersection')
|
||||
district = models.ForeignKey("konova.District", on_delete=models.SET_NULL, null=True, blank=True, related_name="parcels")
|
||||
gmrkng = models.CharField(
|
||||
max_length=1000,
|
||||
municipal = models.ForeignKey("konova.Municipal", on_delete=models.SET_NULL, null=True, blank=True, related_name="parcels")
|
||||
parcel_group = models.ForeignKey(
|
||||
"konova.ParcelGroup",
|
||||
on_delete=models.SET_NULL,
|
||||
help_text="Gemarkung",
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name="parcels"
|
||||
)
|
||||
flrstck_nnr = models.CharField(
|
||||
max_length=1000,
|
||||
flr = models.IntegerField(
|
||||
help_text="Flur",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
flrstck_nnr = models.IntegerField(
|
||||
help_text="Flurstücksnenner",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
flrstck_zhlr = models.CharField(
|
||||
max_length=1000,
|
||||
flrstck_zhlr = models.IntegerField(
|
||||
help_text="Flurstückszähler",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
flr = models.CharField(
|
||||
max_length=1000,
|
||||
help_text="Flur",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
updated_on = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.gmrkng} | {self.flr} | {self.flrstck_zhlr} | {self.flrstck_nnr}"
|
||||
|
||||
|
||||
class District(UuidModel):
|
||||
""" The model District holds more coarse information, such as Kreis, Verbandsgemeinde and Gemeinde.
|
||||
|
||||
There might be the case that a geometry lies on a hundred Parcel entries but only on one District entry.
|
||||
Therefore a geometry can have a lot of relations to Parcel entries but only a few or only a single one to one
|
||||
District.
|
||||
|
||||
"""
|
||||
gmnd = models.CharField(
|
||||
max_length=1000,
|
||||
help_text="Gemeinde",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
krs = models.CharField(
|
||||
max_length=1000,
|
||||
help_text="Kreis",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.gmnd} | {self.krs}"
|
||||
return f"{self.parcel_group} | {self.flr} | {self.flrstck_zhlr} | {self.flrstck_nnr}"
|
||||
|
||||
|
||||
class ParcelIntersection(UuidModel):
|
||||
|
@ -1,15 +1,36 @@
|
||||
{% load i18n %}
|
||||
{% load i18n l10n %}
|
||||
<div class="table-container w-100 scroll-300">
|
||||
{% if parcels|length == 0 %}
|
||||
<article class="alert alert-info">
|
||||
{% trans 'Parcels can not be calculated, since no geometry is given.' %}
|
||||
</article>
|
||||
{% else %}
|
||||
<table class="table table-hover">
|
||||
<table id="upper-spatial-table" class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{% trans 'Kreis' %}</th>
|
||||
<th scope="col">{% trans 'Gemarkung' %}</th>
|
||||
<th scope="col">{% trans 'Municipal' %}</th>
|
||||
<th scope="col">{% trans 'Municipal key' %}</th>
|
||||
<th scope="col">{% trans 'District' %}</th>
|
||||
<th scope="col">{% trans 'District key' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for municipal in municipals %}
|
||||
<tr>
|
||||
<td>{{municipal.name}}</td>
|
||||
<td>{{municipal.key|unlocalize}}</td>
|
||||
<td>{{municipal.district.name}}</td>
|
||||
<td>{{municipal.district.key|unlocalize}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table id="lower-spatial-table" class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{% trans 'Parcel group' %}</th>
|
||||
<th scope="col">{% trans 'Parcel group key' %}</th>
|
||||
<th scope="col">{% trans 'Parcel' %}</th>
|
||||
<th scope="col">{% trans 'Parcel counter' %}</th>
|
||||
<th scope="col">{% trans 'Parcel number' %}</th>
|
||||
@ -18,11 +39,11 @@
|
||||
<tbody>
|
||||
{% for parcel in parcels %}
|
||||
<tr>
|
||||
<td>{{parcel.district.krs|default_if_none:"-"}}</td>
|
||||
<td>{{parcel.gmrkng|default_if_none:"-"}}</td>
|
||||
<td>{{parcel.flr|default_if_none:"-"}}</td>
|
||||
<td>{{parcel.flrstck_zhlr|default_if_none:"-"}}</td>
|
||||
<td>{{parcel.flrstck_nnr|default_if_none:"-"}}</td>
|
||||
<td>{{parcel.parcel_group.name|default_if_none:"-"}}</td>
|
||||
<td>{{parcel.parcel_group.key|default_if_none:"-"}}</td>
|
||||
<td>{{parcel.flr|default_if_none:"-"|unlocalize}}</td>
|
||||
<td>{{parcel.flrstck_zhlr|default_if_none:"-"|unlocalize}}</td>
|
||||
<td>{{parcel.flrstck_nnr|default_if_none:"-"|unlocalize}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div hx-trigger="every 2s" hx-get="{% url 'geometry-parcels' geom_form.instance.geometry.id %}" title="{% trans 'Loading...' %}">
|
||||
<div hx-trigger="every 2s" hx-get="{% url 'geometry-parcels' geom_form.instance.geometry.id %}">
|
||||
<div class="row justify-content-center">
|
||||
<span class="spinner-border rlp-r-inv" role="status"></span>
|
||||
</div>
|
||||
|
@ -17,7 +17,7 @@ from compensation.models import Compensation, EcoAccount
|
||||
from intervention.models import Intervention
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import any_group_check
|
||||
from konova.models import Deadline, Geometry
|
||||
from konova.models import Deadline, Geometry, Municipal
|
||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
||||
from news.models import ServerMessage
|
||||
from konova.settings import SSO_SERVER_BASE
|
||||
@ -130,8 +130,12 @@ def get_geom_parcels(request: HttpRequest, id: str):
|
||||
status_code = 200
|
||||
|
||||
if parcels_available or no_geometry_given:
|
||||
parcels = parcels.order_by("-municipal", "flr", "flrstck_zhlr", "flrstck_nnr")
|
||||
municipals = parcels.order_by("municipal").distinct("municipal").values("municipal__id")
|
||||
municipals = Municipal.objects.filter(id__in=municipals)
|
||||
context = {
|
||||
"parcels": parcels,
|
||||
"municipals": municipals,
|
||||
}
|
||||
html = render_to_string(template, context, request)
|
||||
return HttpResponse(html, status=status_code)
|
||||
|
Binary file not shown.
@ -26,7 +26,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-03-03 12:08+0100\n"
|
||||
"POT-Creation-Date: 2022-04-11 09:07+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -1588,6 +1588,7 @@ msgid "Search for file number"
|
||||
msgstr "Nach Aktenzeichen suchen"
|
||||
|
||||
#: konova/filters/mixins.py:85
|
||||
#: konova/templates/konova/includes/parcel_table.html:11
|
||||
msgid "District"
|
||||
msgstr "Kreis"
|
||||
|
||||
@ -1600,7 +1601,7 @@ msgid "Search for parcel gmrkng"
|
||||
msgstr "Nach Gemarkung suchen"
|
||||
|
||||
#: konova/filters/mixins.py:111
|
||||
#: konova/templates/konova/includes/parcel_table.html:13
|
||||
#: konova/templates/konova/includes/parcel_table.html:34
|
||||
msgid "Parcel"
|
||||
msgstr "Flur"
|
||||
|
||||
@ -1609,7 +1610,7 @@ msgid "Search for parcel"
|
||||
msgstr "Nach Flur suchen"
|
||||
|
||||
#: konova/filters/mixins.py:124
|
||||
#: konova/templates/konova/includes/parcel_table.html:14
|
||||
#: konova/templates/konova/includes/parcel_table.html:35
|
||||
msgid "Parcel counter"
|
||||
msgstr "Flurstückzähler"
|
||||
|
||||
@ -1618,7 +1619,7 @@ msgid "Search for parcel counter"
|
||||
msgstr "Nach Flurstückzähler suchen"
|
||||
|
||||
#: konova/filters/mixins.py:138
|
||||
#: konova/templates/konova/includes/parcel_table.html:15
|
||||
#: konova/templates/konova/includes/parcel_table.html:36
|
||||
msgid "Parcel number"
|
||||
msgstr "Flurstücknenner"
|
||||
|
||||
@ -1759,22 +1760,30 @@ msgstr ""
|
||||
"Flurstücke können nicht berechnet werden, da keine Geometrie eingegeben "
|
||||
"wurde."
|
||||
|
||||
#: konova/templates/konova/includes/parcel_table.html:11
|
||||
msgid "Kreis"
|
||||
msgstr "Kreis"
|
||||
|
||||
#: konova/templates/konova/includes/parcel_table.html:12
|
||||
msgid "Gemarkung"
|
||||
msgid "District key"
|
||||
msgstr "Kreisschlüssel"
|
||||
|
||||
#: konova/templates/konova/includes/parcel_table.html:13
|
||||
msgid "Municipal"
|
||||
msgstr "Gemeinde"
|
||||
|
||||
#: konova/templates/konova/includes/parcel_table.html:14
|
||||
msgid "Municipal key"
|
||||
msgstr "Gemeindeschlüssel"
|
||||
|
||||
#: konova/templates/konova/includes/parcel_table.html:32
|
||||
msgid "Parcel group"
|
||||
msgstr "Gemarkung"
|
||||
|
||||
#: konova/templates/konova/includes/parcel_table.html:33
|
||||
msgid "Parcel group key"
|
||||
msgstr "Gemarkungsschlüssel"
|
||||
|
||||
#: konova/templates/konova/includes/parcels.html:7
|
||||
msgid "Spatial reference"
|
||||
msgstr "Raumreferenz"
|
||||
|
||||
#: konova/templates/konova/includes/parcels.html:11
|
||||
msgid "Loading..."
|
||||
msgstr "Lade..."
|
||||
|
||||
#: konova/templates/konova/includes/quickstart/compensations.html:20
|
||||
#: konova/templates/konova/includes/quickstart/ecoaccounts.html:20
|
||||
#: konova/templates/konova/includes/quickstart/interventions.html:20
|
||||
@ -4189,5 +4198,14 @@ msgstr ""
|
||||
msgid "Unable to connect to qpid with SASL mechanism %s"
|
||||
msgstr ""
|
||||
|
||||
#~ msgid "Kreis"
|
||||
#~ msgstr "Kreis"
|
||||
|
||||
#~ msgid "Gemarkung"
|
||||
#~ msgstr "Gemarkung"
|
||||
|
||||
#~ msgid "Loading..."
|
||||
#~ msgstr "Lade..."
|
||||
|
||||
#~ msgid "Who handles the eco-account"
|
||||
#~ msgstr "Wer für die Herrichtung des Ökokontos verantwortlich ist"
|
||||
|
Loading…
Reference in New Issue
Block a user