Skip to content

Commit

Permalink
fix: don't expect entities to have {start|end}_date_written fields
Browse files Browse the repository at this point in the history
Those are part of TempEntityClass which we don't require anymore to be
used.

Closes: #405
  • Loading branch information
b1rger committed Nov 13, 2023
1 parent 190e5f3 commit 4952af2
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions apis_core/apis_entities/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,33 +191,37 @@ def sort_fields_list(field_names, entity_name):
instance = getattr(self, "instance", None)
if instance != None:

if instance.start_date_written:
self.fields[
"start_date_written"
].help_text = DateParser.get_date_help_text_from_dates(
single_date=instance.start_date,
single_start_date=instance.start_start_date,
single_end_date=instance.start_end_date,
single_date_written=instance.start_date_written,
)
else:
self.fields[
"start_date_written"
].help_text = DateParser.get_date_help_text_default()

if instance.end_date_written:
self.fields[
"end_date_written"
].help_text = DateParser.get_date_help_text_from_dates(
single_date=instance.end_date,
single_start_date=instance.end_start_date,
single_end_date=instance.end_end_date,
single_date_written=instance.end_date_written,
)
else:
self.fields[
"end_date_written"
].help_text = DateParser.get_date_help_text_default()
# same as above, part of TempEntityClass
if "start_date_written" in self.fields:
if instance.start_date_written:
self.fields[
"start_date_written"
].help_text = DateParser.get_date_help_text_from_dates(
single_date=instance.start_date,
single_start_date=instance.start_start_date,
single_end_date=instance.start_end_date,
single_date_written=instance.start_date_written,
)
else:
self.fields[
"start_date_written"
].help_text = DateParser.get_date_help_text_default()

# same as above, part of TempEntityClass
if "end_date_written" in self.fields:
if instance.end_date_written:
self.fields[
"end_date_written"
].help_text = DateParser.get_date_help_text_from_dates(
single_date=instance.end_date,
single_start_date=instance.end_start_date,
single_end_date=instance.end_end_date,
single_date_written=instance.end_date_written,
)
else:
self.fields[
"end_date_written"
].help_text = DateParser.get_date_help_text_default()

def save(self, *args, **kwargs):
obj = super(GenericEntitiesForm, self).save(*args, **kwargs)
Expand Down

0 comments on commit 4952af2

Please sign in to comment.