Skip to content

Commit

Permalink
App BEMAS: unbekannte Betreiberverhältnisse ausgezeichnet; Autocomple…
Browse files Browse the repository at this point in the history
…tion-Selects an Bootstrap 5 angepasst
  • Loading branch information
gdmhrogut committed Sep 1, 2023
1 parent fe9fec0 commit ec54f56
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bemas/models/models_objectclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def __str__(self):
return str(self.sector) + operator + ' (' + shorten_string(self.description) + ')'

def sector_and_operator(self):
operator = ''
operator = ' unbekannte Betreiberverhältnisse'
if self.operator_organization:
operator = ' (Betreiberin: ' + str(self.operator_organization) + ')'
elif self.operator_person:
Expand Down
15 changes: 8 additions & 7 deletions bemas/templates/bemas/generic-objectclass-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<link rel="stylesheet" type="text/css" href="{% static 'datenmanagement/css/form-desktop.css' %}">
{% endif %}
<link rel="stylesheet" type="text/css" href="{% static 'select2/select2.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'select2-bootstrap-5-theme/select2-bootstrap-5-theme.min.css' %}">
{% endblock %}

{% block scripts %}
Expand Down Expand Up @@ -250,13 +251,13 @@ <h2><i class="fas fa-{{ objectclass_name|lower|get_icon }}"></i> <em>{{ objectcl
});

// handle certain select fields: convert them to autocomplete fields
$('select#id_organization').select2();
$('select#id_person').select2();
$('select#id_operator_organization').select2();
$('select#id_operator_person').select2();
$('select#id_originator').select2();
$('select#id_complainers_organizations').select2();
$('select#id_complainers_persons').select2();
$('select#id_organization').select2({ theme: 'bootstrap-5' });
$('select#id_person').select2({ theme: 'bootstrap-5' });
$('select#id_operator_organization').select2({ theme: 'bootstrap-5' });
$('select#id_operator_person').select2({ theme: 'bootstrap-5' });
$('select#id_originator').select2({ theme: 'bootstrap-5' });
$('select#id_complainers_organizations').select2({ theme: 'bootstrap-5' });
$('select#id_complainers_persons').select2({ theme: 'bootstrap-5' });

// currently not needed due to conversion of multiple select fields to autocomplete fields
/* $('select[multiple]').each(function () {
Expand Down
2 changes: 2 additions & 0 deletions bemas/templates/bemas/generic-objectclass-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ <h4 class="mt-3">
{% endfor %}
{% if objectclass_name == 'Organization' %}
<th class="no-sort">Ansprechpartner:in(nen)</th>
{% elif objectclass_name == 'Originator' %}
<th class="no-sort">Betreiberverhältnisse</th>
{% elif objectclass_name == 'Complaint' %}
<th class="no-sort">Beschwerdeführung</th>
{% endif %}
Expand Down
26 changes: 24 additions & 2 deletions bemas/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ def prepare_results(self, qs):
item_pk = getattr(item, self.model._meta.pk.name)
address_handled = False
for column in self.columns:
# handle non-geometry related fields and non-search content fields only!
if not is_geometry_field(column.__class__) and not column.name == 'search_content':
# handle non-geometry related fields, non-search content fields
# and non-operator related fields only!
if (
not is_geometry_field(column.__class__)
and not column.name == 'search_content'
and not column.name.startswith('operator_')
):
data = None
value = getattr(item, column.name)
# codelist specific column "icon"
Expand Down Expand Up @@ -139,6 +144,23 @@ def prepare_results(self, qs):
Contact, contact, contact.name_and_function()
)
item_data.append(data)
# object class originator:
# add column which lists operator(s)
elif issubclass(self.model, Originator):
data = ''
operator_organization = getattr(item, 'operator_organization')
if operator_organization:
data = generate_foreign_key_link_simplified(Organization, operator_organization)
operator_person = getattr(item, 'operator_person')
if operator_person:
data += '<br>' if operator_organization else ''
data += generate_foreign_key_link_simplified(Person, operator_person)
# designate anonymous complaint if necessary
if not data:
data = '<em><i class="fas fa-' + \
get_icon_from_settings('originator_without_operator') + \
'"></i> unbekannte Betreiberverhältnisse</em>'
item_data.append(data)
# object class complaint:
# add column which lists complainer(s)
elif issubclass(self.model, Complaint):
Expand Down
9 changes: 7 additions & 2 deletions bemas/views/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,13 @@ def add_table_context_elements(context, model, kwargs=None):
address_handled = False
for field in model._meta.fields:
if not field.name.startswith('address_'):
# handle non-geometry related fields and non-search content fields only!
if not is_geometry_field(field.__class__) and not field.name == 'search_content':
# handle non-geometry related fields, non-search content fields
# and non-operator related fields only!
if (
not is_geometry_field(field.__class__)
and not field.name == 'search_content'
and not field.name.startswith('operator_')
):
column_titles.append(field.verbose_name)
# handle addresses
elif field.name.startswith('address_') and not address_handled:
Expand Down
2 changes: 2 additions & 0 deletions datenwerft/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
('proj4leaflet', BASE_DIR / 'node_modules/proj4leaflet/src'),
('select2', BASE_DIR / 'node_modules/select2/dist/css'),
('select2', BASE_DIR / 'node_modules/select2/dist/js'),
('select2-bootstrap-5-theme', BASE_DIR / 'node_modules/select2-bootstrap-5-theme/dist'),
('wicket', BASE_DIR / 'node_modules/wicket'),
('hilfe', BASE_DIR / 'hilfe/build/html'),
('css', BASE_DIR / 'datenwerft/static/css'),
Expand Down Expand Up @@ -220,6 +221,7 @@
'ok': 'circle-check',
'organization': 'building',
'originator': 'industry',
'originator_without_operator': 'question',
'orphaned_data': 'ghost',
'person': 'user',
'save': 'floppy-disk',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"proj4": "^2.9.0",
"proj4leaflet": "^1.0.2",
"select2": "^4.1.0-rc.0",
"select2-bootstrap-5-theme": "^1.3.0",
"stylelint": "^14.16.1",
"stylelint-config-standard": "^29.0.0",
"wicket": "^1.3.8"
Expand Down

0 comments on commit ec54f56

Please sign in to comment.