Skip to content

Commit

Permalink
App Datenmanagement: neues Datenthema Kehrbezirke
Browse files Browse the repository at this point in the history
  • Loading branch information
gdmhrogut committed Oct 27, 2023
1 parent 3597382 commit 174e7da
Show file tree
Hide file tree
Showing 12 changed files with 436 additions and 123 deletions.
9 changes: 9 additions & 0 deletions datenmanagement/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ class BasemodelMeta:
# which shall appear as columns in the table of the list view of this model
# in exactly this order, with their respective labels, i.e. column headers (as values)
list_fields = None
# String:
# name of the field appearing in ``list_fields``
# which shall be considered as an address string
# and thus be created from the respective model fields
list_field_with_address_string = None
# String:
# name of the field of this model
# which shall be used as a fallback when address strings cannot be used
list_field_with_address_string_fallback_field = None
# List of strings:
# names of those fields of this model appearing in ``list_fields``
# whose values are of a numeric data type and which must therefore be treated accordingly
Expand Down
61 changes: 53 additions & 8 deletions datenmanagement/models/models_codelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@ class Adressen(Metamodel):
Adressen
"""

gemeinde = CharField(
'Gemeinde',
max_length=255,
editable=False
)
gemeindeteil = CharField(
'Gemeindeteil',
max_length=255,
editable=False
)
strasse = CharField(
'Straße',
max_length=255,
editable=False
)
hausnummer = CharField(
'Hausnummer',
max_length=4,
editable=False
)
postleitzahl = CharField(
'Postleitzahl',
max_length=5,
editable=False
)
adresse = CharField(
'Adresse',
max_length=255,
Expand All @@ -35,13 +60,20 @@ class Adressen(Metamodel):

class Meta(Metamodel.Meta):
db_table = 'basisdaten\".\"adressenliste_datenwerft'
ordering = ['adresse']
ordering = [
'gemeinde', 'gemeindeteil', 'adresse'
]
verbose_name = 'Adresse'
verbose_name_plural = 'Adressen'

class BasemodelMeta(Metamodel.BasemodelMeta):
description = 'Adressen in Mecklenburg-Vorpommern'
list_fields = {
'gemeinde': 'Gemeinde',
'gemeindeteil': 'Gemeindeteil',
'strasse': 'Straße',
'hausnummer': 'Hausnummer',
'postleitzahl': 'Postleitzahl',
'adresse': 'Adresse'
}

Expand All @@ -54,6 +86,16 @@ class Strassen(Metamodel):
Straßen
"""

gemeinde = CharField(
'Gemeinde',
max_length=255,
editable=False
)
gemeindeteil = CharField(
'Gemeindeteil',
max_length=255,
editable=False
)
strasse = CharField(
'Straße',
max_length=255,
Expand All @@ -62,13 +104,17 @@ class Strassen(Metamodel):

class Meta(Metamodel.Meta):
db_table = 'basisdaten\".\"strassenliste_datenwerft'
ordering = ['strasse']
ordering = [
'gemeinde', 'gemeindeteil', 'strasse'
]
verbose_name = 'Straße'
verbose_name_plural = 'Straßen'

class BasemodelMeta(Metamodel.BasemodelMeta):
description = 'Straßen in Mecklenburg-Vorpommern'
list_fields = {
'gemeinde': 'Gemeinde',
'gemeindeteil': 'Gemeindeteil',
'strasse': 'Straße'
}

Expand Down Expand Up @@ -122,7 +168,7 @@ class Meta(Metamodel.Meta):
verbose_name_plural = 'Gemeindeteile'

class BasemodelMeta(Metamodel.BasemodelMeta):
description = 'Gemeindeteile in Mecklenburg-Vorpommern'
description = 'Gemeindeteile in der Hanse- und Universitätsstadt Rostock'
as_overlay = True
list_fields = {
'gemeindeteil': 'Gemeindeteil'
Expand Down Expand Up @@ -260,9 +306,7 @@ class Ansprechpartner_Baustellen(Codelist):
class Meta(Codelist.Meta):
db_table = 'codelisten\".\"ansprechpartner_baustellen'
ordering = [
'nachname',
'vorname',
'email'
'nachname', 'vorname', 'email'
]
verbose_name = 'Ansprechpartner:in bei einer Baustelle'
verbose_name_plural = 'Ansprechpartner:innen bei Baustellen'
Expand Down Expand Up @@ -776,8 +820,7 @@ class Bevollmaechtigte_Bezirksschornsteinfeger(Codelist):
class Meta(Codelist.Meta):
db_table = 'codelisten\".\"bevollmaechtigte_bezirksschornsteinfeger'
ordering = [
'nachname',
'vorname'
'nachname', 'vorname'
]
verbose_name = 'bevollmächtigter Bezirksschornsteinfeger'
verbose_name_plural = 'bevollmächtigte Bezirksschornsteinfeger'
Expand All @@ -796,6 +839,8 @@ class BasemodelMeta(Codelist.BasemodelMeta):
'telefon_mobil': 'Telefon (mobil)',
'email': 'E-Mail-Adresse'
}
list_field_with_address_string = 'anschrift'
list_field_with_address_string_fallback_field = 'anschrift_strasse'
list_fields_with_date = ['bestellungszeitraum_beginn', 'bestellungszeitraum_ende']

def __str__(self):
Expand Down
79 changes: 75 additions & 4 deletions datenmanagement/models/models_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
Arten_Feldsportanlagen, Arten_Feuerwachen, Arten_Fliessgewaesser, Arten_Hundetoiletten, \
Arten_Fallwildsuchen_Kontrollen, Arten_Meldedienst_flaechenhaft, Arten_Meldedienst_punkthaft, \
Arten_Parkmoeglichkeiten, Arten_Pflegeeinrichtungen, Arten_Poller, Arten_Toiletten, \
Betriebsarten, Betriebszeiten, Bewirtschafter_Betreiber_Traeger_Eigentuemer, \
Gebaeudearten_Meldedienst_punkthaft, Gebaeudebauweisen, Gebaeudefunktionen, \
Geschlechter_Kadaverfunde, Haefen, Hersteller_Poller, Materialien_Denksteine, \
Ordnungen_Fliessgewaesser, Personentitel, Quartiere, Sportarten, \
Betriebsarten, Betriebszeiten, Bevollmaechtigte_Bezirksschornsteinfeger, \
Bewirtschafter_Betreiber_Traeger_Eigentuemer, Gebaeudearten_Meldedienst_punkthaft, \
Gebaeudebauweisen, Gebaeudefunktionen, Geschlechter_Kadaverfunde, Haefen, Hersteller_Poller, \
Materialien_Denksteine, Ordnungen_Fliessgewaesser, Personentitel, Quartiere, Sportarten, \
Status_Baudenkmale_Denkmalbereiche, Status_Poller, Tierseuchen, Typen_Abfallbehaelter, \
Typen_Erdwaermesonden, Typen_Kleinklaeranlagen, Typen_Poller, \
Verbuende_Ladestationen_Elektrofahrzeuge, Zustaende_Kadaverfunde, \
Expand Down Expand Up @@ -2937,6 +2937,77 @@ def __str__(self):
return str(self.tierseuche) + ' mit Zeitpunkt ' + zeitpunkt_str + ', '


class Kehrbezirke(SimpleModel):
"""
Kehrbezirke
"""

adresse = ForeignKey(
Adressen,
verbose_name='Adresse',
on_delete=CASCADE,
db_column='adresse',
to_field='uuid',
related_name='%(app_label)s_%(class)s_adressen'
)
bevollmaechtigter_bezirksschornsteinfeger = ForeignKey(
Bevollmaechtigte_Bezirksschornsteinfeger,
verbose_name=' bevollmächtigter Bezirksschornsteinfeger',
on_delete=RESTRICT,
db_column='bevollmaechtigter_bezirksschornsteinfeger',
to_field='uuid',
related_name='%(app_label)s_%(class)s_bevollmaechtigte_bezirksschornsteinfeger'
)
vergabedatum = DateField(
'Vergabedatum',
blank=True,
null=True
)

class Meta(SimpleModel.Meta):
db_table = 'fachdaten_adressbezug\".\"kehrbezirke_hro'
verbose_name = 'Kehrbezirk'
verbose_name_plural = 'Kehrbezirke'

class BasemodelMeta(SimpleModel.BasemodelMeta):
description = 'Kehrbezirke der bevollmächtigten Bezirksschornsteinfeger ' \
'in der Hanse- und Universitätsstadt Rostock'
address_type = 'Adresse'
address_mandatory = True
list_fields = {
'aktiv': 'aktiv?',
'adresse_gemeinde': 'Gemeinde',
'adresse_gemeindeteil': 'Gemeindeteil',
'adresse_strasse': 'Straße',
'adresse_hausnummer': 'Hausnummer',
'adresse_postleitzahl': 'Postleitzahl',
'bevollmaechtigter_bezirksschornsteinfeger': 'bevollmächtigter Bezirksschornsteinfeger',
'vergabedatum': 'Vergabedatum'
}
list_fields_with_date = ['vergabedatum']
list_fields_with_foreign_key = {
'bevollmaechtigter_bezirksschornsteinfeger': 'nachname'
}

def __str__(self):
return str(self.adresse) + ' zu ' + str(self.bevollmaechtigter_bezirksschornsteinfeger)

def adresse_gemeinde(self):
return str(self.adresse.gemeinde)

def adresse_gemeindeteil(self):
return str(self.adresse.gemeindeteil)

def adresse_strasse(self):
return str(self.adresse.strasse)

def adresse_hausnummer(self):
return str(self.adresse.hausnummer)

def adresse_postleitzahl(self):
return str(self.adresse.postleitzahl)


class Kindertagespflegeeinrichtungen(SimpleModel):
"""
Kindertagespflegeeinrichtungen
Expand Down
2 changes: 1 addition & 1 deletion datenmanagement/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3000,7 +3000,7 @@ CREATE TABLE fachdaten_adressbezug.kehrbezirke_hro (
id_zielsystem character varying(255),
aktiv boolean DEFAULT true NOT NULL,
deaktiviert date,
adresse uuid,
adresse uuid NOT NULL,
bevollmaechtigter_bezirksschornsteinfeger uuid NOT NULL,
vergabedatum date
);
Expand Down
60 changes: 31 additions & 29 deletions datenmanagement/static/datenmanagement/js/cartographicHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,36 +501,38 @@ function showAddressSearchResults(json, addressType, searchField, addressUuidFie
// copy the text of the result into the search field
searchField.val($(this).children('strong').text());
}
// zoom map to result
let resultingFeatureGeometry = json.features[$(this).data('feature')].geometry;
if (resultingFeatureGeometry.type === 'Point') {
resultingFeatureGeometry.coordinates = proj4('EPSG:25833', 'EPSG:4326', resultingFeatureGeometry.coordinates);
window.featureGeometry = resultingFeatureGeometry;
currMap.fitBounds([
[
featureGeometry.coordinates[1],
featureGeometry.coordinates[0]
],
[
featureGeometry.coordinates[1],
featureGeometry.coordinates[0]
]
]);
} else {
for (let i = 0; i < resultingFeatureGeometry.coordinates[0].length; i++) {
resultingFeatureGeometry.coordinates[0][i] = proj4('EPSG:25833', 'EPSG:4326', resultingFeatureGeometry.coordinates[0][i]);
// zoom map to result (only if there is a map at all, though)
if (typeof currMap !== 'undefined') {
let resultingFeatureGeometry = json.features[$(this).data('feature')].geometry;
if (resultingFeatureGeometry.type === 'Point') {
resultingFeatureGeometry.coordinates = proj4('EPSG:25833', 'EPSG:4326', resultingFeatureGeometry.coordinates);
window.featureGeometry = resultingFeatureGeometry;
currMap.fitBounds([
[
featureGeometry.coordinates[1],
featureGeometry.coordinates[0]
],
[
featureGeometry.coordinates[1],
featureGeometry.coordinates[0]
]
]);
} else {
for (let i = 0; i < resultingFeatureGeometry.coordinates[0].length; i++) {
resultingFeatureGeometry.coordinates[0][i] = proj4('EPSG:25833', 'EPSG:4326', resultingFeatureGeometry.coordinates[0][i]);
}
window.featureGeometry = resultingFeatureGeometry;
currMap.fitBounds([
[
featureGeometry.coordinates[0][0][1],
featureGeometry.coordinates[0][1][0]
],
[
featureGeometry.coordinates[0][2][1],
featureGeometry.coordinates[0][0][0]
]
]);
}
window.featureGeometry = resultingFeatureGeometry;
currMap.fitBounds([
[
featureGeometry.coordinates[0][0][1],
featureGeometry.coordinates[0][1][0]
],
[
featureGeometry.coordinates[0][2][1],
featureGeometry.coordinates[0][0][0]
]
]);
}
});
}
62 changes: 34 additions & 28 deletions datenmanagement/static/datenmanagement/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,48 +246,54 @@ function setFinalArrayFields() {
* @function
* @name setFinalGeometry
*
* ügets map geometry and writes it to geometry field
* gets map geometry and writes it to geometry field
*/
function setFinalGeometry() {
let jsonGeometrie;
if (currMap.pm.getGeomanDrawLayers().length < 1) {
let coordinates = [];
if (window.geometryType === 'Point')
coordinates = [0, 0];
else if (window.geometryType === 'Polygon')
coordinates = [[]];
jsonGeometrie = {
'type': window.geometryType,
'coordinates': coordinates
};
} else {
if (window.geometryType === 'MultiPolygon' || window.geometryType === 'MultiPoint' || window.geometryType === 'MultiLineString') {
// the map geometry part (only if there is a map at all, though)
if (typeof currMap !== 'undefined') {
let jsonGeometrie;
if (currMap.pm.getGeomanDrawLayers().length < 1) {
let coordinates = [];
let temp;
currMap.pm.getGeomanDrawLayers().forEach(function (layer) {
temp = layer.toGeoJSON().geometry;
if (temp.type.search('Multi') > -1) {
for (let i = 0; i < temp.coordinates.length; i++) {
coordinates.push(temp.coordinates[i]);
}
} else {
coordinates.push(temp.coordinates);
}
});
if (window.geometryType === 'Point')
coordinates = [0, 0];
else if (window.geometryType === 'Polygon')
coordinates = [[]];
jsonGeometrie = {
'type': window.geometryType,
'coordinates': coordinates,
'coordinates': coordinates
};
} else {
jsonGeometrie = currMap.pm.getGeomanDrawLayers()[0].toGeoJSON().geometry;
if (window.geometryType === 'MultiPolygon' || window.geometryType === 'MultiPoint' || window.geometryType === 'MultiLineString') {
let coordinates = [];
let temp;
currMap.pm.getGeomanDrawLayers().forEach(function (layer) {
temp = layer.toGeoJSON().geometry;
if (temp.type.search('Multi') > -1) {
for (let i = 0; i < temp.coordinates.length; i++) {
coordinates.push(temp.coordinates[i]);
}
} else {
coordinates.push(temp.coordinates);
}
});
jsonGeometrie = {
'type': window.geometryType,
'coordinates': coordinates,
};
} else {
jsonGeometrie = currMap.pm.getGeomanDrawLayers()[0].toGeoJSON().geometry;
}
}
$('#id_geometrie').val(JSON.stringify(jsonGeometrie));
}
$('#id_geometrie').val(JSON.stringify(jsonGeometrie));
// the address part (only if there is an address related field at all, though)
if (window.addressUuidField && $.trim(window.searchField.val()).length) {
// keep current address, street or district temporarily
window.addressTempField.val(window.searchField.val());
console.log(window.addressTempField.val());
// sets reference from field with UUID of the referenced address, street or district
window.searchField.val(window.addressUuidField.val());
console.log(window.searchField.val());
}
}

Expand Down
Loading

0 comments on commit 174e7da

Please sign in to comment.