Skip to content

Commit

Permalink
App BEMAS: Anpassungen Objektklasse Journalereignisse; externe Biblio…
Browse files Browse the repository at this point in the history
…theken aktualisiert
  • Loading branch information
gdmhrogut committed Apr 4, 2024
1 parent abb5f38 commit aabcc52
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
12 changes: 6 additions & 6 deletions bemas/models/models_objectclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.contrib.gis.db.models.fields import PointField
from django.contrib.postgres.fields import ArrayField
from django.core.validators import EmailValidator, RegexValidator
from django.db.models import ForeignKey, ManyToManyField, CASCADE, PROTECT
from django.db.models import F, ForeignKey, ManyToManyField, CASCADE, PROTECT
from django.db.models.fields import BigIntegerField, CharField, DateField, DateTimeField, TextField
from django.db.models.signals import m2m_changed
from django.utils import timezone
Expand Down Expand Up @@ -640,8 +640,7 @@ class Event(Objectclass):
description = NullTextField(
verbose_name='Beschreibung',
blank=True,
null=True,
validators=standard_validators
null=True
)
dms_link = CharField(
verbose_name=' d.3',
Expand All @@ -658,7 +657,7 @@ class Event(Objectclass):

class Meta(Objectclass.Meta):
db_table = 'event'
ordering = ['-complaint__id', '-date']
ordering = ['-complaint__id', F('date').desc(nulls_last=True)]
verbose_name = 'Journalereignis'
verbose_name_plural = 'Journalereignisse'

Expand All @@ -677,8 +676,9 @@ def type_of_event_and_complaint(self):
return str(self.type_of_event) + ' (Beschwerde: ' + str(self.complaint) + ')'

def type_of_event_and_created_at(self):
return str(self.type_of_event) + ' vom ' + self.created_at.strftime('%d.%m.%Y') + \
(' (' + shorten_string(self.description) + ')' if self.description else '')
date_str = ' vom ' + self.date.strftime('%d.%m.%Y') if self.date else ' (ohne Datum)'
description_str = ': ' + shorten_string(self.description) if self.description else ''
return str(self.type_of_event) + date_str + description_str

def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
# store search content in designated field
Expand Down
30 changes: 16 additions & 14 deletions bemas/views/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,22 @@ def add_table_context_elements(context, model, kwargs=None):
if field.name not in model.BasemodelMeta.table_exclusion_fields:
included_fields.append(field)
for field_name in model._meta.ordering:
# determine order direction and clean field name
if field_name.startswith('-'):
order_direction = 'desc'
cleaned_field_name = field_name[1:]
else:
order_direction = 'asc'
cleaned_field_name = field_name
# determine index of field
order_index = 0
for index, field in enumerate(included_fields):
if field.name == cleaned_field_name:
order_index = index
break
initial_order.append([order_index, order_direction])
# skip OrderBy objects
if not field_name.__class__.__name__ == 'OrderBy':
# determine order direction and clean field name
if field_name.startswith('-'):
order_direction = 'desc'
cleaned_field_name = field_name[1:]
else:
order_direction = 'asc'
cleaned_field_name = field_name
# determine index of field
order_index = 0
for index, field in enumerate(included_fields):
if field.name == cleaned_field_name:
order_index = index
break
initial_order.append([order_index, order_direction])
context['initial_order'] = initial_order
if issubclass(model, Codelist):
context['tabledata_url'] = reverse('bemas:codelists_' + model.__name__.lower() + '_tabledata')
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dependencies": {
"@eslint/create-config": "^0.4.6",
"@fortawesome/fontawesome-free": "^6.5.1",
"@fortawesome/fontawesome-free": "^6.5.2",
"@geoman-io/leaflet-geoman-free": "^2.16.0",
"bootstrap": "^5.3.3",
"eslint": "^8.57.0",
Expand All @@ -12,7 +12,7 @@
"leaflet.locatecontrol": "^0.76.1",
"leaflet.markercluster": "^1.5.3",
"martinez-polygon-clipping": "^0.7.3",
"proj4": "^2.10.0",
"proj4": "^2.11.0",
"proj4leaflet": "^1.0.2",
"select2": "^4.1.0-rc.0",
"select2-bootstrap-5-theme": "^1.3.0",
Expand Down

0 comments on commit aabcc52

Please sign in to comment.