Skip to content

Commit

Permalink
App Datenmanagement: Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gdmhrogut committed Nov 6, 2023
1 parent c4863b7 commit c13e23e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions datenmanagement/models/models_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.contrib.postgres.fields import ArrayField
from django.core.validators import EmailValidator, MaxValueValidator, MinValueValidator, \
RegexValidator, URLValidator
from django.db.models import CASCADE, RESTRICT, SET_NULL, ForeignKey
from django.db.models import CASCADE, RESTRICT, SET_NULL, ForeignKey, OneToOneField
from django.db.models.fields import BooleanField, CharField, DateField, DateTimeField, \
DecimalField, PositiveIntegerField, TextField
from django.db.models.fields.files import FileField, ImageField
Expand Down Expand Up @@ -2942,7 +2942,7 @@ class Kehrbezirke(SimpleModel):
Kehrbezirke
"""

adresse = ForeignKey(
adresse = OneToOneField(
Adressen,
verbose_name='Adresse',
on_delete=CASCADE,
Expand Down
12 changes: 10 additions & 2 deletions datenmanagement/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,8 @@ CREATE TABLE codelisten.bevollmaechtigte_bezirksschornsteinfeger (
erstellt date DEFAULT (now())::date NOT NULL,
auswaertig boolean NOT NULL,
bezirk character(6),
bestellungszeitraum_beginn date NOT NULL,
bestellungszeitraum_ende date NOT NULL,
bestellungszeitraum_beginn date,
bestellungszeitraum_ende date,
vorname character varying(255) NOT NULL,
nachname character varying(255) NOT NULL,
anschrift_strasse character varying(255) NOT NULL,
Expand Down Expand Up @@ -5625,6 +5625,14 @@ ALTER TABLE ONLY fachdaten_adressbezug.hospize_hro
ADD CONSTRAINT hospize_hro_pk PRIMARY KEY (uuid);


--
-- Name: kehrbezirke_hro kehrbezirke_hro_adresse_unique; Type: CONSTRAINT; Schema: fachdaten_adressbezug; Owner: -
--

ALTER TABLE ONLY fachdaten_adressbezug.kehrbezirke_hro
ADD CONSTRAINT kehrbezirke_hro_adresse_unique UNIQUE (adresse);


--
-- Name: kehrbezirke_hro kehrbezirke_hro_pk; Type: CONSTRAINT; Schema: fachdaten_adressbezug; Owner: -
--
Expand Down
6 changes: 0 additions & 6 deletions datenmanagement/tests/test_models_codelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3868,8 +3868,6 @@ class BevollmaechtigteBezirksschornsteinfegerTest(DefaultCodelistTestCase):
create_test_subset_in_classmethod = False
attributes_values_db_initial = {
'auswaertig': False,
'bestellungszeitraum_beginn': VALID_DATE,
'bestellungszeitraum_ende': VALID_DATE,
'vorname': 'Vorname1',
'nachname': 'Nachname1',
'anschrift_strasse': 'Straße1',
Expand All @@ -3882,8 +3880,6 @@ class BevollmaechtigteBezirksschornsteinfegerTest(DefaultCodelistTestCase):
}
attributes_values_view_initial = {
'auswaertig': False,
'bestellungszeitraum_beginn': VALID_DATE,
'bestellungszeitraum_ende': VALID_DATE,
'vorname': 'Vorname3',
'nachname': 'Nachname3',
'anschrift_strasse': 'Straße3',
Expand All @@ -3893,8 +3889,6 @@ class BevollmaechtigteBezirksschornsteinfegerTest(DefaultCodelistTestCase):
}
attributes_values_view_updated = {
'auswaertig': False,
'bestellungszeitraum_beginn': VALID_DATE,
'bestellungszeitraum_ende': VALID_DATE,
'vorname': 'Vorname4',
'nachname': 'Nachname4',
'anschrift_strasse': 'Straße4',
Expand Down
15 changes: 8 additions & 7 deletions datenmanagement/tests/test_models_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -5909,14 +5909,15 @@ class KehrbezirkeTest(DefaultSimpleModelTestCase):
@classmethod
def setUpTestData(cls):
super().setUpTestData()
adresse = Adressen.objects.create(
adresse='Adresse'
adresse1 = Adressen.objects.create(
adresse='Adresse1'
)
adresse2 = Adressen.objects.create(
adresse='Adresse1'
)
bevollmaechtigter_bezirksschornsteinfeger = (
Bevollmaechtigte_Bezirksschornsteinfeger.objects.create(
auswaertig=False,
bestellungszeitraum_beginn=VALID_DATE,
bestellungszeitraum_ende=VALID_DATE,
vorname='Vorname1',
nachname='Nachname1',
anschrift_strasse='Straße1',
Expand All @@ -5926,21 +5927,21 @@ def setUpTestData(cls):
)
)
cls.attributes_values_db_initial = {
'adresse': adresse,
'adresse': adresse1,
'bevollmaechtigter_bezirksschornsteinfeger': bevollmaechtigter_bezirksschornsteinfeger
}
cls.attributes_values_db_updated = {
'vergabedatum': VALID_DATE
}
cls.attributes_values_view_initial = {
'aktiv': True,
'adresse': str(adresse.pk),
'adresse': str(adresse2.pk),
'bevollmaechtigter_bezirksschornsteinfeger': str(
bevollmaechtigter_bezirksschornsteinfeger.pk)
}
cls.attributes_values_view_updated = {
'aktiv': True,
'adresse': str(adresse.pk),
'adresse': str(adresse2.pk),
'bevollmaechtigter_bezirksschornsteinfeger': str(
bevollmaechtigter_bezirksschornsteinfeger.pk),
'vergabedatum': VALID_DATE
Expand Down
5 changes: 5 additions & 0 deletions datenmanagement/views/views_list_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ def prepare_results(self, qs):
if value is not None:
# format foreign keys
if self.columns_with_foreign_key and column in self.columns_with_foreign_key:
# format foreign keys to addresses
if column in {'adresse', 'strasse'}:
data = getattr(getattr(item, column), self.columns_with_foreign_key.get(column))
# format foreign keys as links
elif (
self.fields_with_foreign_key_to_linkify
and column in self.fields_with_foreign_key_to_linkify
Expand All @@ -100,6 +102,9 @@ def prepare_results(self, qs):
) + '" target="_blank" rel="noopener noreferrer" class="required" title="'\
+ foreign_model_title + ' ansehen oder bearbeiten">' + str(
getattr(value, foreign_model_attribute_for_text)) + '</a>'
# take all foreign key values as they are
else:
data = escape(value)
# format numbers
elif self.columns_with_number and column in self.columns_with_number:
if isinstance(value, Decimal) or match(r"^[0-9]+\.[0-9]+$", str(value)):
Expand Down

0 comments on commit c13e23e

Please sign in to comment.