summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models_imports.py357
1 files changed, 180 insertions, 177 deletions
diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py
index 4170ea1e2..7fdee8ce3 100644
--- a/ishtar_common/models_imports.py
+++ b/ishtar_common/models_imports.py
@@ -69,13 +69,13 @@ class ImportModelManager(models.Manager):
class ImporterModel(models.Model):
- name = models.CharField(_(u"Name"), max_length=200)
- klass = models.CharField(_(u"Class name"), max_length=200, unique=True)
+ name = models.CharField(_("Name"), max_length=200)
+ klass = models.CharField(_("Class name"), max_length=200, unique=True)
objects = ImportModelManager()
class Meta:
- verbose_name = _(u"Model")
- verbose_name_plural = _(u"Models")
+ verbose_name = _("Model")
+ verbose_name_plural = _("Models")
ordering = ('name',)
def __str__(self):
@@ -94,30 +94,30 @@ class ImporterType(models.Model):
"""
Description of a table to be mapped with ishtar database
"""
- name = models.CharField(_(u"Name"), max_length=200)
- slug = models.SlugField(_(u"Slug"), unique=True, max_length=100)
- description = models.CharField(_(u"Description"), blank=True, null=True,
+ name = models.CharField(_("Name"), max_length=200)
+ slug = models.SlugField(_("Slug"), unique=True, max_length=100)
+ description = models.CharField(_("Description"), blank=True, null=True,
max_length=500)
- users = models.ManyToManyField('IshtarUser', verbose_name=_(u"Users"),
+ users = models.ManyToManyField('IshtarUser', verbose_name=_("Users"),
blank=True)
associated_models = models.ForeignKey(
- ImporterModel, verbose_name=_(u"Associated model"),
+ ImporterModel, verbose_name=_("Associated model"),
on_delete=models.SET_NULL,
related_name='+', blank=True, null=True)
created_models = models.ManyToManyField(
- ImporterModel, verbose_name=_(u"Models that can accept new items"),
- blank=True, help_text=_(u"Leave blank for no restrictions"),
+ ImporterModel, verbose_name=_("Models that can accept new items"),
+ blank=True, help_text=_("Leave blank for no restrictions"),
related_name='+')
- is_template = models.BooleanField(_(u"Can be exported"), default=False)
- unicity_keys = models.CharField(_(u"Unicity keys (separator \";\")"),
+ is_template = models.BooleanField(_("Can be exported"), default=False)
+ unicity_keys = models.CharField(_("Unicity keys (separator \";\")"),
blank=True, null=True, max_length=500)
- available = models.BooleanField(_(u"Available"), default=True)
+ available = models.BooleanField(_("Available"), default=True)
objects = ImporterTypeManager()
SERIALIZATION_EXCLUDE = ["users"]
class Meta:
- verbose_name = _(u"Importer - Type")
- verbose_name_plural = _(u"Importer - Types")
+ verbose_name = _("Importer - Type")
+ verbose_name_plural = _("Importer - Types")
ordering = ('name',)
def natural_key(self):
@@ -309,11 +309,11 @@ class ImporterDefault(models.Model):
Targets of default values in an import
"""
importer_type = models.ForeignKey(ImporterType, related_name='defaults')
- target = models.CharField(u"Target", max_length=500)
+ target = models.CharField("Target", max_length=500)
class Meta:
- verbose_name = _(u"Importer - Default")
- verbose_name_plural = _(u"Importer - Defaults")
+ verbose_name = _("Importer - Default")
+ verbose_name_plural = _("Importer - Defaults")
unique_together = ('importer_type', 'target')
objects = ImporterDefaultManager()
@@ -325,7 +325,7 @@ class ImporterDefault(models.Model):
@property
def keys(self):
- return tuple(t for t in self.target.split('__') if t not in (u"-", u""))
+ return tuple(t for t in self.target.split('__') if t not in ("-", ""))
@property
def associated_model(self):
@@ -337,8 +337,8 @@ class ImporterDefault(models.Model):
values = {}
for default_value in self.default_values.all():
target = default_value.target
- if target == u"-":
- target = u""
+ if target == "-":
+ target = ""
values[target] = default_value.get_value()
return values
@@ -356,13 +356,13 @@ class ImporterDefaultValues(models.Model):
"""
default_target = models.ForeignKey(ImporterDefault,
related_name='default_values')
- target = models.CharField(u"Target", max_length=500)
- value = models.CharField(u"Value", max_length=500)
+ target = models.CharField("Target", max_length=500)
+ value = models.CharField("Value", max_length=500)
objects = ImporterDefaultValuesManager()
class Meta:
- verbose_name = _(u"Importer - Default value")
- verbose_name_plural = _(u"Importer - Default values")
+ verbose_name = _("Importer - Default value")
+ verbose_name_plural = _("Importer - Default values")
unique_together = ('default_target', 'target')
def natural_key(self):
@@ -408,10 +408,10 @@ class ImporterColumn(models.Model):
"""
Import file column description
"""
- label = models.CharField(_(u"Label"), blank=True, null=True,
+ label = models.CharField(_("Label"), blank=True, null=True,
max_length=200)
importer_type = models.ForeignKey(ImporterType, related_name='columns')
- col_number = models.IntegerField(_(u"Column number"), default=1)
+ col_number = models.IntegerField(_("Column number"), default=1)
description = models.TextField(_("Description"), blank=True, null=True)
regexp_pre_filter = models.ForeignKey(
"Regexp", blank=True, null=True, on_delete=models.SET_NULL,
@@ -419,17 +419,17 @@ class ImporterColumn(models.Model):
value_format = models.ForeignKey(
"ValueFormater", blank=True, null=True, on_delete=models.SET_NULL,
)
- required = models.BooleanField(_(u"Required"), default=False)
+ required = models.BooleanField(_("Required"), default=False)
export_field_name = models.CharField(
- _(u"Export field name"), blank=True, null=True, max_length=200,
- help_text=_(u"Fill this field if the field name is ambiguous for "
- u"export. For instance: concatenated fields.")
+ _("Export field name"), blank=True, null=True, max_length=200,
+ help_text=_("Fill this field if the field name is ambiguous for "
+ "export. For instance: concatenated fields.")
)
objects = ImporterColumnManager()
class Meta:
- verbose_name = _(u"Importer - Column")
- verbose_name_plural = _(u"Importer - Columns")
+ verbose_name = _("Importer - Column")
+ verbose_name_plural = _("Importer - Columns")
ordering = ('importer_type', 'col_number')
unique_together = ('importer_type', 'col_number')
@@ -463,19 +463,19 @@ class ImporterDuplicateField(models.Model):
Direct copy of result in other fields
"""
column = models.ForeignKey(ImporterColumn, related_name='duplicate_fields')
- field_name = models.CharField(_(u"Field name"), blank=True, null=True,
+ field_name = models.CharField(_("Field name"), blank=True, null=True,
max_length=200)
- force_new = models.BooleanField(_(u"Force creation of new items"),
+ force_new = models.BooleanField(_("Force creation of new items"),
default=False)
- concat = models.BooleanField(_(u"Concatenate with existing"),
+ concat = models.BooleanField(_("Concatenate with existing"),
default=False)
- concat_str = models.CharField(_(u"Concatenate character"), max_length=5,
+ concat_str = models.CharField(_("Concatenate character"), max_length=5,
blank=True, null=True)
objects = ImporterDuplicateFieldManager()
class Meta:
- verbose_name = _(u"Importer - Duplicate field")
- verbose_name_plural = _(u"Importer - Duplicate fields")
+ verbose_name = _("Importer - Duplicate field")
+ verbose_name_plural = _("Importer - Duplicate fields")
ordering = ('column', 'field_name')
unique_together = ('column', 'field_name')
@@ -507,21 +507,21 @@ class Regexp(models.Model):
class ValueFormater(models.Model):
- name = models.CharField(_(u"Name"), max_length=100, unique=True)
- slug = models.SlugField(_(u"Slug"), unique=True, max_length=100)
- description = models.TextField(_(u"Description"), blank=True, null=True)
+ name = models.CharField(_("Name"), max_length=100, unique=True)
+ slug = models.SlugField(_("Slug"), unique=True, max_length=100)
+ description = models.TextField(_("Description"), blank=True, null=True)
format_string = models.CharField(
- _(u"Format string"), max_length=100,
- help_text=_(u"A string used to format a value using the Python "
- u"\"format()\" method. The site https://pyformat.info/ "
- u"provide good examples of usage. Only one \"{}\" entry "
- u"is managed. The input is assumed to be a string.")
+ _("Format string"), max_length=100,
+ help_text=_("A string used to format a value using the Python "
+ "\"format()\" method. The site https://pyformat.info/ "
+ "provide good examples of usage. Only one \"{}\" entry "
+ "is managed. The input is assumed to be a string.")
)
objects = SlugModelManager()
class Meta:
- verbose_name = _(u"Importer - Value format")
- verbose_name_plural = _(u"Importer - Value formats")
+ verbose_name = _("Importer - Value format")
+ verbose_name_plural = _("Importer - Value formats")
def __str__(self):
return self.name
@@ -551,20 +551,20 @@ class ImportTarget(models.Model):
Ishtar database target for a column
"""
column = models.ForeignKey(ImporterColumn, related_name='targets')
- target = models.CharField(u"Target", max_length=500)
+ target = models.CharField("Target", max_length=500)
formater_type = models.ForeignKey("FormaterType")
- force_new = models.BooleanField(_(u"Force creation of new items"),
+ force_new = models.BooleanField(_("Force creation of new items"),
default=False)
- concat = models.BooleanField(_(u"Concatenate with existing"),
+ concat = models.BooleanField(_("Concatenate with existing"),
default=False)
- concat_str = models.CharField(_(u"Concatenate character"), max_length=5,
+ concat_str = models.CharField(_("Concatenate character"), max_length=5,
blank=True, null=True)
- comment = models.TextField(_(u"Comment"), blank=True, null=True)
+ comment = models.TextField(_("Comment"), blank=True, null=True)
objects = ImportTargetManager()
class Meta:
- verbose_name = _(u"Importer - Target")
- verbose_name_plural = _(u"Importer - Targets")
+ verbose_name = _("Importer - Target")
+ verbose_name_plural = _("Importer - Targets")
unique_together = ('column', 'target')
def __str__(self):
@@ -576,7 +576,7 @@ class ImportTarget(models.Model):
return self.target[:50]
desc = self.column.description
desc = desc[0].lower() + desc[1:]
- return u"{} - {}".format(self.target[:50], desc)
+ return "{} - {}".format(self.target[:50], desc)
def natural_key(self):
return self.column.importer_type.slug, self.column.col_number, \
@@ -603,8 +603,8 @@ class ImportTarget(models.Model):
return [('', '--' * 8)]
if self.formater_type.formater_type == 'StrToBoolean':
return [('', '--' * 8),
- ('True', _(u"True")),
- ('False', _(u"False"))]
+ ('True', _("True")),
+ ('False', _("False"))]
if not self.associated_model or not hasattr(self.associated_model,
'get_types'):
return []
@@ -615,16 +615,16 @@ class TargetKeyGroup(models.Model):
"""
Group of target keys for imports.
"""
- name = models.TextField(_(u"Name"), unique=True)
- all_user_can_use = models.BooleanField(_(u"All users can use it"),
+ name = models.TextField(_("Name"), unique=True)
+ all_user_can_use = models.BooleanField(_("All users can use it"),
default=False)
- all_user_can_modify = models.BooleanField(_(u"All users can modify it"),
+ all_user_can_modify = models.BooleanField(_("All users can modify it"),
default=False)
- available = models.BooleanField(_(u"Available"), default=True)
+ available = models.BooleanField(_("Available"), default=True)
class Meta:
- verbose_name = _(u"Importer - Target key group")
- verbose_name_plural = _(u"Importer - Target key groups")
+ verbose_name = _("Importer - Target key group")
+ verbose_name_plural = _("Importer - Target key groups")
def __str__(self):
return self.name
@@ -651,12 +651,12 @@ class TargetKey(models.Model):
class Meta:
unique_together = ('target', 'key', 'associated_user',
'associated_import',)
- verbose_name = _(u"Importer - Target key")
- verbose_name_plural = _(u"Importer - Targets keys")
+ verbose_name = _("Importer - Target key")
+ verbose_name_plural = _("Importer - Targets keys")
ordering = ('target', 'key')
def __str__(self):
- return u" - ".join([str(self.target), self.key[:50]])
+ return " - ".join([str(self.target), self.key[:50]])
def column_nb(self):
# for the admin
@@ -707,68 +707,71 @@ class TargetKey(models.Model):
v.add_key(self.key, **keys)
return obj
+
TARGET_MODELS = [
- ('OrganizationType', _(u"Organization type")),
- ('ishtar_common.models.OrganizationType', _(u"Organization type")),
- ('ishtar_common.models.PersonType', _(u"Person type")),
- ('TitleType', _(u"Title")),
- ('SourceType', _(u"Source type")),
- ('AuthorType', _(u"Author type")),
- ('Format', _(u"Format")),
- ('archaeological_operations.models.OperationType', _(u"Operation type")),
- ('archaeological_operations.models.Period', _(u"Period")),
- ('archaeological_operations.models.ReportState', _(u"Report state")),
- ('archaeological_operations.models.RemainType', _(u"Remain type")),
- ('archaeological_context_records.models.Unit', _(u"Unit")),
+ ('OrganizationType', _("Organization type")),
+ ('ishtar_common.models.OrganizationType', _("Organization type")),
+ ('ishtar_common.models.PersonType', _("Person type")),
+ ('TitleType', _("Title")),
+ ('SourceType', _("Source type")),
+ ('AuthorType', _("Author type")),
+ ('Format', _("Format")),
+ ('archaeological_operations.models.OperationType', _("Operation type")),
+ ('archaeological_operations.models.Period', _("Period")),
+ ('archaeological_operations.models.ReportState', _("Report state")),
+ ('archaeological_operations.models.RemainType', _("Remain type")),
+ ('archaeological_operations.models.RelationType',
+ _("Operation relation type")),
+ ('archaeological_context_records.models.Unit', _("Unit")),
('archaeological_context_records.models.ActivityType',
- _(u"Activity type")),
+ _("Activity type")),
('archaeological_context_records.models.DocumentationType',
- _(u"Documentation type")),
+ _("Documentation type")),
("archaeological_context_records.models.DatingQuality",
- _(u"Dating quality")),
- ('archaeological_finds.models.MaterialType', _(u"Material")),
+ _("Dating quality")),
+ ('archaeological_finds.models.MaterialType', _("Material")),
('archaeological_finds.models.ConservatoryState',
- _(u"Conservatory state")),
- ('archaeological_warehouse.models.ContainerType', _(u"Container type")),
+ _("Conservatory state")),
+ ('archaeological_warehouse.models.ContainerType', _("Container type")),
('archaeological_warehouse.models.WarehouseDivision',
- _(u"Warehouse division")),
- ('archaeological_warehouse.models.WarehouseType', _(u"Warehouse type")),
- ('archaeological_finds.models.TreatmentType', _(u"Treatment type")),
+ _("Warehouse division")),
+ ('archaeological_warehouse.models.WarehouseType', _("Warehouse type")),
+ ('archaeological_finds.models.TreatmentType', _("Treatment type")),
('archaeological_finds.models.TreatmentEmergencyType',
- _(u"Treatment emergency type")),
- ('archaeological_finds.models.ObjectType', _(u"Object type")),
- ('archaeological_finds.models.IntegrityType', _(u"Integrity type")),
+ _("Treatment emergency type")),
+ ('archaeological_finds.models.ObjectType', _("Object type")),
+ ('archaeological_finds.models.IntegrityType', _("Integrity type")),
('archaeological_finds.models.RemarkabilityType',
- _(u"Remarkability type")),
- ('archaeological_finds.models.AlterationType', _(u"Alteration type")),
+ _("Remarkability type")),
+ ('archaeological_finds.models.AlterationType', _("Alteration type")),
('archaeological_finds.models.AlterationCauseType',
- _(u"Alteration cause type")),
- ('archaeological_finds.models.BatchType', _(u"Batch type")),
- ('archaeological_finds.models.CheckedType', _(u"Checked type")),
+ _("Alteration cause type")),
+ ('archaeological_finds.models.BatchType', _("Batch type")),
+ ('archaeological_finds.models.CheckedType', _("Checked type")),
('archaeological_finds.models.MaterialTypeQualityType',
- _(u"Material type quality")),
+ _("Material type quality")),
('archaeological_context_records.models.IdentificationType',
_("Identification type")),
('archaeological_context_records.models.RelationType',
- _(u"Context record relation type")),
- ('SpatialReferenceSystem', _(u"Spatial reference system")),
- ('SupportType', _(u"Support type")),
- ('TitleType', _(u"Title type")),
+ _("Context record relation type")),
+ ('SpatialReferenceSystem', _("Spatial reference system")),
+ ('SupportType', _("Support type")),
+ ('TitleType', _("Title type")),
]
TARGET_MODELS_KEYS = [tm[0] for tm in TARGET_MODELS]
IMPORTER_TYPES = (
- ('IntegerFormater', _(u"Integer")),
- ('FloatFormater', _(u"Float")),
- ('UnicodeFormater', _(u"String")),
- ('DateFormater', _(u"Date")),
- ('TypeFormater', _(u"Type")),
- ('YearFormater', _(u"Year")),
- ('InseeFormater', _(u"INSEE code")),
- ('StrToBoolean', _(u"String to boolean")),
- ('FileFormater', pgettext_lazy("filesystem", u"File")),
- ('UnknowType', _(u"Unknow type"))
+ ('IntegerFormater', _("Integer")),
+ ('FloatFormater', _("Float")),
+ ('UnicodeFormater', _("String")),
+ ('DateFormater', _("Date")),
+ ('TypeFormater', _("Type")),
+ ('YearFormater', _("Year")),
+ ('InseeFormater', _("INSEE code")),
+ ('StrToBoolean', _("String to boolean")),
+ ('FileFormater', pgettext_lazy("filesystem", "File")),
+ ('UnknowType', _("Unknow type"))
)
IMPORTER_TYPES_DCT = {
@@ -785,9 +788,9 @@ IMPORTER_TYPES_DCT = {
}
DATE_FORMATS = (
- ('%Y', _(u"4 digit year. e.g.: \"2015\"")),
- ('%Y/%m/%d', _(u"4 digit year/month/day. e.g.: \"2015/02/04\"")),
- ('%d/%m/%Y', _(u"Day/month/4 digit year. e.g.: \"04/02/2015\"")),
+ ('%Y', _("4 digit year. e.g.: \"2015\"")),
+ ('%Y/%m/%d', _("4 digit year/month/day. e.g.: \"2015/02/04\"")),
+ ('%d/%m/%Y', _("Day/month/4 digit year. e.g.: \"04/02/2015\"")),
)
IMPORTER_TYPES_CHOICES = {'TypeFormater': TARGET_MODELS,
@@ -801,17 +804,17 @@ class FormaterTypeManager(models.Manager):
class FormaterType(models.Model):
- formater_type = models.CharField(u"Formater type", max_length=20,
+ formater_type = models.CharField("Formater type", max_length=20,
choices=IMPORTER_TYPES)
- options = models.CharField(_(u"Options"), max_length=500, blank=True,
+ options = models.CharField(_("Options"), max_length=500, blank=True,
null=True)
- many_split = models.CharField(_(u"Split character(s)"), max_length=10,
+ many_split = models.CharField(_("Split character(s)"), max_length=10,
blank=True, null=True)
objects = FormaterTypeManager()
class Meta:
- verbose_name = _(u"Importer - Formater type")
- verbose_name_plural = _(u"Importer - Formater types")
+ verbose_name = _("Importer - Formater type")
+ verbose_name_plural = _("Importer - Formater types")
unique_together = ('formater_type', 'options', 'many_split')
ordering = ('formater_type', 'options')
@@ -819,7 +822,7 @@ class FormaterType(models.Model):
return self.formater_type, self.options, self.many_split
def __str__(self):
- return u" - ".join(
+ return " - ".join(
[str(dict(IMPORTER_TYPES)[self.formater_type])
if self.formater_type in IMPORTER_TYPES_DCT else ''] +
[getattr(self, k) for k in ('options', 'many_split')
@@ -867,17 +870,17 @@ class FormaterType(models.Model):
IMPORT_STATE = (
- ("C", _(u"Created")),
- ("AP", _(u"Analyse in progress")),
- ("A", _(u"Analysed")),
- ("HQ", _(u"Check modified in queue")),
- ("IQ", _(u"Import in queue")),
- ("HP", _(u"Check modified in progress")),
- ("IP", _(u"Import in progress")),
- ("PI", _(u"Partially imported")),
- ("FE", _(u"Finished with errors")),
- ("F", _(u"Finished")),
- ("AC", _(u"Archived")),
+ ("C", _("Created")),
+ ("AP", _("Analyse in progress")),
+ ("A", _("Analysed")),
+ ("HQ", _("Check modified in queue")),
+ ("IQ", _("Import in queue")),
+ ("HP", _("Check modified in progress")),
+ ("IP", _("Import in progress")),
+ ("PI", _("Partially imported")),
+ ("FE", _("Finished with errors")),
+ ("F", _("Finished")),
+ ("AC", _("Archived")),
)
IMPORT_STATE_DCT = dict(IMPORT_STATE)
@@ -916,62 +919,62 @@ class Import(models.Model):
_("Imported file"), upload_to="upload/imports/%Y/%m/", max_length=220,
help_text=max_size_help())
imported_images = models.FileField(
- _(u"Associated images (zip file)"), upload_to="upload/imports/%Y/%m/",
+ _("Associated images (zip file)"), upload_to="upload/imports/%Y/%m/",
blank=True, null=True, max_length=220, help_text=max_size_help())
associated_group = models.ForeignKey(
TargetKeyGroup, blank=True, null=True,
on_delete=models.SET_NULL,
- help_text=_(u"If a group is selected, target key saved in this group "
- u"will be used.")
+ help_text=_("If a group is selected, target key saved in this group "
+ "will be used.")
)
- encoding = models.CharField(_(u"Encoding"), choices=ENCODINGS,
+ encoding = models.CharField(_("Encoding"), choices=ENCODINGS,
default=u'utf-8', max_length=15)
csv_sep = models.CharField(
- _(u"CSV separator"), choices=CSV_SEPS, default=u',', max_length=1,
- help_text=_(u"Separator for CSV file. Standard is comma but Microsoft "
- u"Excel do not follow this standard and use semi-colon.")
+ _("CSV separator"), choices=CSV_SEPS, default=u',', max_length=1,
+ help_text=_("Separator for CSV file. Standard is comma but Microsoft "
+ "Excel do not follow this standard and use semi-colon.")
)
skip_lines = models.IntegerField(
- _(u"Skip lines"), default=1,
- help_text=_(u"Number of header lines in your file (can be 0)."))
+ _("Skip lines"), default=1,
+ help_text=_("Number of header lines in your file (can be 0)."))
error_file = models.FileField(
- _(u"Error file"), upload_to="upload/imports/%Y/%m/",
+ _("Error file"), upload_to="upload/imports/%Y/%m/",
blank=True, null=True, max_length=255, help_text=max_size_help())
result_file = models.FileField(
- _(u"Result file"), upload_to="upload/imports/%Y/%m/",
+ _("Result file"), upload_to="upload/imports/%Y/%m/",
blank=True, null=True, max_length=255, help_text=max_size_help())
match_file = models.FileField(
- _(u"Match file"), upload_to="upload/imports/%Y/%m/", blank=True,
+ _("Match file"), upload_to="upload/imports/%Y/%m/", blank=True,
null=True, max_length=255, help_text=max_size_help())
- state = models.CharField(_(u"State"), max_length=2, choices=IMPORT_STATE,
+ state = models.CharField(_("State"), max_length=2, choices=IMPORT_STATE,
default=u'C')
conservative_import = models.BooleanField(
- _(u"Conservative import"), default=False,
+ _("Conservative import"), default=False,
help_text=_(u'If set to true, do not overload existing values.'))
creation_date = models.DateTimeField(
- _(u"Creation date"), auto_now_add=True, blank=True, null=True)
- end_date = models.DateTimeField(_(u"End date"), auto_now_add=True,
+ _("Creation date"), auto_now_add=True, blank=True, null=True)
+ end_date = models.DateTimeField(_("End date"), auto_now_add=True,
blank=True, null=True, editable=False)
seconds_remaining = models.IntegerField(
- _(u"Remaining seconds"), blank=True, null=True, editable=False)
- current_line = models.IntegerField(_(u"Current line"), blank=True,
+ _("Remaining seconds"), blank=True, null=True, editable=False)
+ current_line = models.IntegerField(_("Current line"), blank=True,
null=True)
- number_of_line = models.IntegerField(_(u"Number of line"), blank=True,
+ number_of_line = models.IntegerField(_("Number of line"), blank=True,
null=True)
imported_line_numbers = models.TextField(
- _(u"Imported line numbers"), blank=True, null=True,
+ _("Imported line numbers"), blank=True, null=True,
validators=[validate_comma_separated_integer_list]
)
- changed_checked = models.BooleanField(_(u"Changed have been checked"),
+ changed_checked = models.BooleanField(_("Changed have been checked"),
default=False)
changed_line_numbers = models.TextField(
- _(u"Changed line numbers"), blank=True, null=True,
+ _("Changed line numbers"), blank=True, null=True,
validators=[validate_comma_separated_integer_list]
)
class Meta:
- verbose_name = _(u"Import")
- verbose_name_plural = _(u"Imports")
+ verbose_name = _("Import")
+ verbose_name_plural = _("Imports")
def __str__(self):
return "{} | {}".format(self.name or "-", self.importer_type)
@@ -1011,7 +1014,7 @@ class Import(models.Model):
except UnicodeDecodeError:
pass # try the next encoding
except csv.Error:
- raise ImporterError(_(u"Error in the CSV file."))
+ raise ImporterError(_("Error in the CSV file."))
self.number_of_line = nb
self.save()
return nb
@@ -1078,29 +1081,29 @@ class Import(models.Model):
profile = IshtarSiteProfile.get_current_profile()
actions = []
if self.state == 'C':
- actions.append(('A', _(u"Analyse")))
+ actions.append(('A', _("Analyse")))
if self.state in ('A', 'PI'):
- actions.append(('A', _(u"Re-analyse")))
- actions.append(('I', _(u"Launch import")))
+ actions.append(('A', _("Re-analyse")))
+ actions.append(('I', _("Launch import")))
if profile.experimental_feature:
if self.changed_checked:
- actions.append(('IS', _(u"Step by step import")))
- actions.append(('CH', _(u"Re-check for changes")))
+ actions.append(('IS', _("Step by step import")))
+ actions.append(('CH', _("Re-check for changes")))
else:
- actions.append(('CH', _(u"Check for changes")))
+ actions.append(('CH', _("Check for changes")))
if self.state in ('F', 'FE'):
- actions.append(('A', _(u"Re-analyse")))
- actions.append(('I', _(u"Re-import")))
+ actions.append(('A', _("Re-analyse")))
+ actions.append(('I', _("Re-import")))
if profile.experimental_feature:
if self.changed_checked:
- actions.append(('IS', _(u"Step by step re-import")))
- actions.append(('CH', _(u"Re-check for changes")))
+ actions.append(('IS', _("Step by step re-import")))
+ actions.append(('CH', _("Re-check for changes")))
else:
- actions.append(('CH', _(u"Check for changes")))
- actions.append(('AC', _(u"Archive")))
+ actions.append(('CH', _("Check for changes")))
+ actions.append(('AC', _("Archive")))
if self.state == 'AC':
- actions.append(('A', _(u"Unarchive")))
- actions.append(('D', _(u"Delete")))
+ actions.append(('A', _("Unarchive")))
+ actions.append(('D', _("Delete")))
return actions
@property
@@ -1151,7 +1154,7 @@ class Import(models.Model):
except UnicodeDecodeError:
pass # try the next encoding
except csv.Error:
- raise ImporterError(_(u"Error in the CSV file."))
+ raise ImporterError(_("Error in the CSV file."))
if tmpdir:
shutil.rmtree(tmpdir)
return []
@@ -1249,7 +1252,7 @@ class Import(models.Model):
return self.importation(request=request, session_key=session_key)
put_session_message(
session_key,
- str(_(u"Import {} added to the queue")).format(self.name),
+ str(_("Import {} added to the queue")).format(self.name),
"info")
self.state = 'IQ'
self.end_date = datetime.datetime.now()
@@ -1271,7 +1274,7 @@ class Import(models.Model):
self.data_table, user=self.user,
line_to_process=line_to_process, simulate=simulate)
except IOError:
- error_message = str(_(u"Error on imported file: {}")).format(
+ error_message = str(_("Error on imported file: {}")).format(
self.imported_file)
importer.errors = [error_message]
if session_key:
@@ -1306,7 +1309,7 @@ class Import(models.Model):
error_file,
ContentFile(importer.get_csv_errors().encode('utf-8'))
)
- msg = str(_(u"Import {} finished with errors")).format(
+ msg = str(_("Import {} finished with errors")).format(
self.name)
msg_cls = "warning"
else:
@@ -1315,7 +1318,7 @@ class Import(models.Model):
else:
self.state = 'F'
self.error_file = None
- msg = str(_(u"Import {} finished with no errors")).format(
+ msg = str(_("Import {} finished with no errors")).format(
self.name)
msg_cls = "primary"
if session_key and request: