Skip to content

Commit

Permalink
Simplify EDTFField init; add direct_input_field to deconstruct()
Browse files Browse the repository at this point in the history
  • Loading branch information
ColeDCrawford committed Jun 11, 2024
1 parent b3205af commit 7a99f12
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions edtf/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,12 @@ def __init__(
**kwargs,
):
kwargs["max_length"] = 2000
(
self.natural_text_field,
self.direct_input_field,
self.lower_strict_field,
self.upper_strict_field,
self.lower_fuzzy_field,
self.upper_fuzzy_field,
) = (
natural_text_field,
direct_input_field,
lower_strict_field,
upper_strict_field,
lower_fuzzy_field,
upper_fuzzy_field,
)
self.natural_text_field = natural_text_field
self.direct_input_field = direct_input_field
self.lower_strict_field = lower_strict_field
self.upper_strict_field = upper_strict_field
self.lower_fuzzy_field = lower_fuzzy_field
self.upper_fuzzy_field = upper_fuzzy_field
super().__init__(verbose_name, name, **kwargs)

description = (
Expand All @@ -74,6 +65,8 @@ def deconstruct(self):
name, path, args, kwargs = super().deconstruct()
if self.natural_text_field:
kwargs["natural_text_field"] = self.natural_text_field
if self.direct_input_field:
kwargs["direct_input_field"] = self.direct_input_field

for attr in DATE_ATTRS:
field = f"{attr}_field"
Expand Down Expand Up @@ -152,7 +145,7 @@ def update_values(self, instance, *args, **kwargs):
):
edtf = parse_edtf(
edtf_string, fail_silently=True
) # potetial ParseException if invalid; should this be raised?
) # potential ParseException if invalid; should this be raised?
else:
edtf = existing_value
else:
Expand Down

0 comments on commit 7a99f12

Please sign in to comment.