Skip to content
Snippets Groups Projects
Commit 7c62e201 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch 'fix/lint' into 'master'

Fix lint

See merge request !127
parents 46224a77 d2e4c8f7
No related branches found
No related tags found
1 merge request!127Fix lint
Pipeline #137861 failed
...@@ -63,13 +63,18 @@ class ImportTemplate(ExtensibleModel): ...@@ -63,13 +63,18 @@ class ImportTemplate(ExtensibleModel):
), ),
) )
@property class Meta:
def parsed_separator(self): ordering = ["name"]
return codecs.escape_decode(bytes(self.separator, "utf-8"))[0].decode("utf-8") verbose_name = _("Import template")
verbose_name_plural = _("Import templates")
constraints = [
models.UniqueConstraint(
fields=("site_id", "name"), name="unique_template_name_per_site"
),
]
@property def __str__(self):
def parsed_quotechar(self): return self.verbose_name
return codecs.escape_decode(bytes(self.quotechar, "utf-8"))[0].decode("utf-8")
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if not self.content_type.model == "person": if not self.content_type.model == "person":
...@@ -78,6 +83,14 @@ class ImportTemplate(ExtensibleModel): ...@@ -78,6 +83,14 @@ class ImportTemplate(ExtensibleModel):
self.group_type = None self.group_type = None
super().save(*args, **kwargs) super().save(*args, **kwargs)
@property
def parsed_separator(self):
return codecs.escape_decode(bytes(self.separator, "utf-8"))[0].decode("utf-8")
@property
def parsed_quotechar(self):
return codecs.escape_decode(bytes(self.quotechar, "utf-8"))[0].decode("utf-8")
@classmethod @classmethod
def update_or_create( def update_or_create(
cls, cls,
...@@ -146,19 +159,6 @@ class ImportTemplate(ExtensibleModel): ...@@ -146,19 +159,6 @@ class ImportTemplate(ExtensibleModel):
fields=fields, fields=fields,
) )
def __str__(self):
return self.verbose_name
class Meta:
ordering = ["name"]
verbose_name = _("Import template")
verbose_name_plural = _("Import templates")
constraints = [
models.UniqueConstraint(
fields=("site_id", "name"), name="unique_template_name_per_site"
),
]
class ImportTemplateField(ExtensibleModel): class ImportTemplateField(ExtensibleModel):
index = models.IntegerField(verbose_name=_("Index")) index = models.IntegerField(verbose_name=_("Index"))
...@@ -180,6 +180,15 @@ class ImportTemplateField(ExtensibleModel): ...@@ -180,6 +180,15 @@ class ImportTemplateField(ExtensibleModel):
verbose_name=_("Django template to generate virtual field from"), blank=True verbose_name=_("Django template to generate virtual field from"), blank=True
) )
class Meta:
ordering = ["template", "index"]
unique_together = ["template", "index"]
verbose_name = _("Import template field")
verbose_name_plural = _("Import template fields")
def __str__(self):
return f"{self.template}/{self.index}: {self.field_type}"
@property @property
def field_type_class(self): def field_type_class(self):
field_type = field_type_registry.get_from_name(self.field_type) field_type = field_type_registry.get_from_name(self.field_type)
...@@ -194,12 +203,6 @@ class ImportTemplateField(ExtensibleModel): ...@@ -194,12 +203,6 @@ class ImportTemplateField(ExtensibleModel):
): ):
raise ValidationError(_("You are not allowed to use this field type in this model.")) raise ValidationError(_("You are not allowed to use this field type in this model."))
class Meta:
ordering = ["template", "index"]
unique_together = ["template", "index"]
verbose_name = _("Import template field")
verbose_name_plural = _("Import template fields")
class ImportJob(ExtensibleModel): class ImportJob(ExtensibleModel):
"""Job definition for one import, to track import history and files.""" """Job definition for one import, to track import history and files."""
...@@ -223,3 +226,6 @@ class ImportJob(ExtensibleModel): ...@@ -223,3 +226,6 @@ class ImportJob(ExtensibleModel):
class Meta: class Meta:
verbose_name = _("Import job") verbose_name = _("Import job")
verbose_name_plural = _("Import jobs") verbose_name_plural = _("Import jobs")
def __str__(self):
return f"{self.template}#{self.pk}"
...@@ -169,10 +169,7 @@ def import_csv( ...@@ -169,10 +169,7 @@ def import_csv(
# Determine available fields for finding existing instances # Determine available fields for finding existing instances
get_dict = {} get_dict = {}
match_field_priority = 0 match_field_priority = 0
for ( for column_name, field_type in sorted(
column_name,
field_type,
) in sorted(
filter(lambda f: isinstance(f[1], MatchFieldType), field_types.items()), filter(lambda f: isinstance(f[1], MatchFieldType), field_types.items()),
key=lambda f: f[1].priority, key=lambda f: f[1].priority,
): ):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment