summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py747
1 files changed, 373 insertions, 374 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 219589acf..d900913e1 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -46,8 +46,8 @@ from ishtar_common.utils import cached_label_changed, \
class RemainType(GeneralType):
class Meta:
- verbose_name = _(u"Remain type")
- verbose_name_plural = _(u"Remain types")
+ verbose_name = _("Remain type")
+ verbose_name_plural = _("Remain types")
ordering = ('label',)
@@ -56,19 +56,19 @@ post_delete.connect(post_save_cache, sender=RemainType)
class Period(GeneralType):
- order = models.IntegerField(_(u"Order"))
- start_date = models.IntegerField(_(u"Start date"), null=True, blank=True)
- end_date = models.IntegerField(_(u"End date"), null=True, blank=True)
- parent = models.ForeignKey("Period", verbose_name=_(u"Parent period"),
+ order = models.IntegerField(_("Order"))
+ start_date = models.IntegerField(_("Start date"), null=True, blank=True)
+ end_date = models.IntegerField(_("End date"), null=True, blank=True)
+ parent = models.ForeignKey("Period", verbose_name=_("Parent period"),
on_delete=models.SET_NULL,
blank=True, null=True)
class Meta:
- verbose_name = _(u"Type Period")
- verbose_name_plural = _(u"Types Period")
+ verbose_name = _("Type Period")
+ verbose_name_plural = _("Types Period")
ordering = ('order',)
- def __unicode__(self):
+ def __str__(self):
return self.label
@@ -77,11 +77,11 @@ post_delete.connect(post_save_cache, sender=Period)
class ReportState(GeneralType):
- order = models.IntegerField(_(u"Order"))
+ order = models.IntegerField(_("Order"))
class Meta:
- verbose_name = _(u"Type of report state")
- verbose_name_plural = _(u"Types of report state")
+ verbose_name = _("Type of report state")
+ verbose_name_plural = _("Types of report state")
ordering = ('order',)
@@ -95,11 +95,11 @@ class SiteManager(models.GeoManager):
class RecordQualityType(GeneralType):
- order = models.IntegerField(_(u"Order"))
+ order = models.IntegerField(_("Order"))
class Meta:
- verbose_name = _(u"Type of record quality")
- verbose_name_plural = _(u"Types of record quality")
+ verbose_name = _("Type of record quality")
+ verbose_name_plural = _("Types of record quality")
ordering = ('order',)
@@ -138,7 +138,7 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
DATED_FIELDS = ['sinking_date']
- COL_LABELS = {'towns_label': _(u"Towns")}
+ COL_LABELS = {'towns_label': _("Towns")}
EXTRA_REQUEST_KEYS = {
'towns_label': 'towns',
@@ -148,23 +148,23 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
# alternative names of fields for searches
ALT_NAMES = {
'reference': SearchAltName(
- pgettext_lazy("key for text search", u"reference"),
+ pgettext_lazy("key for text search", "reference"),
'reference__iexact'
),
'name': SearchAltName(
- pgettext_lazy("key for text search", u"name"),
+ pgettext_lazy("key for text search", "name"),
'name__iexact'
),
'periods': SearchAltName(
- pgettext_lazy("key for text search", u"period"),
+ pgettext_lazy("key for text search", "period"),
'periods__label__iexact'
),
'remains': SearchAltName(
- pgettext_lazy("key for text search", u"remain"),
+ pgettext_lazy("key for text search", "remain"),
'remains__label__iexact'
),
'towns': SearchAltName(
- pgettext_lazy("key for text search", u"town"),
+ pgettext_lazy("key for text search", "town"),
'towns__cached_label__iexact'
),
'towns__areas': SearchAltName(
@@ -172,59 +172,59 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
'towns__areas__label__iexact'
),
'comment': SearchAltName(
- pgettext_lazy("key for text search", u"comment"),
+ pgettext_lazy("key for text search", "comment"),
'comment__iexact'
),
'locality_ngi': SearchAltName(
- pgettext_lazy("key for text search", u"locality-ngi"),
+ pgettext_lazy("key for text search", "locality-ngi"),
'locality_ngi__iexact'
),
'locality_cadastral': SearchAltName(
- pgettext_lazy("key for text search", u"locality-cadastral"),
+ pgettext_lazy("key for text search", "locality-cadastral"),
'locality_cadastral__iexact'
),
'shipwreck_name': SearchAltName(
- pgettext_lazy("key for text search", u"shipwreck-name"),
+ pgettext_lazy("key for text search", "shipwreck-name"),
'shipwreck_name__iexact'
),
'oceanographic_service_localisation': SearchAltName(
pgettext_lazy("key for text search",
- u"oceanographic-service-localisation"),
+ "oceanographic-service-localisation"),
'oceanographic_service_localisation__iexact'
),
'shipwreck_code': SearchAltName(
- pgettext_lazy("key for text search", u"shipwreck-code"),
+ pgettext_lazy("key for text search", "shipwreck-code"),
'shipwreck_code__iexact'
),
'sinking_date': SearchAltName(
- pgettext_lazy("key for text search", u"sinking-date"),
+ pgettext_lazy("key for text search", "sinking-date"),
'sinking_date'
),
'discovery_area': SearchAltName(
- pgettext_lazy("key for text search", u"discovery-area"),
+ pgettext_lazy("key for text search", "discovery-area"),
'discovery_area__iexact'
),
'operation': SearchAltName(
- pgettext_lazy("key for text search", u"operation"),
+ pgettext_lazy("key for text search", "operation"),
'operations__cached_label__icontains'
),
'top_operation': SearchAltName(
- pgettext_lazy("key for text search", u"top-operation"),
+ pgettext_lazy("key for text search", "top-operation"),
'top_operation__cached_label__icontains'
),
'drassm_number': SearchAltName(
- pgettext_lazy("key for text search", u"numero-drassm"),
+ pgettext_lazy("key for text search", "numero-drassm"),
'drassm_number__iexact'
),
'affmar_number': SearchAltName(
- pgettext_lazy("key for text search", u"numero-affmar"),
+ pgettext_lazy("key for text search", "numero-affmar"),
'affmar_number__iexact'
),
}
ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES)
UP_MODEL_QUERY = {
- "operation": (pgettext_lazy("key for text search", u"operation"),
+ "operation": (pgettext_lazy("key for text search", "operation"),
'cached_label'),
}
RELATIVE_SESSION_NAMES = [
@@ -234,74 +234,74 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
# objects = SiteManager()
- reference = models.CharField(_(u"Reference"), max_length=200, unique=True)
- name = models.CharField(_(u"Name"), max_length=200,
+ reference = models.CharField(_("Reference"), max_length=200, unique=True)
+ name = models.CharField(_("Name"), max_length=200,
null=True, blank=True)
- periods = models.ManyToManyField(Period, verbose_name=_(u"Periods"),
+ periods = models.ManyToManyField(Period, verbose_name=_("Periods"),
blank=True)
remains = models.ManyToManyField("RemainType", verbose_name=_(u'Remains'),
blank=True)
- towns = models.ManyToManyField(Town, verbose_name=_(u"Towns"),
+ towns = models.ManyToManyField(Town, verbose_name=_("Towns"),
related_name='sites', blank=True)
- comment = models.TextField(_(u"Comment"), null=True, blank=True)
+ comment = models.TextField(_("Comment"), null=True, blank=True)
top_operation = models.ForeignKey("Operation", blank=True, null=True,
- verbose_name=_(u"Top operation"),
+ verbose_name=_("Top operation"),
on_delete=models.SET_NULL)
locality_ngi = models.TextField(
- _(u"National Geographic Institute locality"),
+ _("National Geographic Institute locality"),
null=True, blank=True
)
- locality_cadastral = models.TextField(_(u"Cadastral locality"),
+ locality_cadastral = models.TextField(_("Cadastral locality"),
null=True, blank=True)
collaborators = models.ManyToManyField(
- Person, blank=True, verbose_name=_(u"Collaborators"),
+ Person, blank=True, verbose_name=_("Collaborators"),
related_name='site_collaborator'
)
# underwater
shipwreck_name = models.TextField(
- _(u"Shipwreck name"), null=True, blank=True)
+ _("Shipwreck name"), null=True, blank=True)
oceanographic_service_localisation = models.TextField(
- _(u"Oceanographic service localisation"), null=True, blank=True)
+ _("Oceanographic service localisation"), null=True, blank=True)
shipwreck_code = models.TextField(
- _(u"Shipwreck code"), null=True, blank=True)
+ _("Shipwreck code"), null=True, blank=True)
sinking_date = models.DateField(
- _(u"Sinking date"), null=True, blank=True)
+ _("Sinking date"), null=True, blank=True)
discovery_area = models.TextField(
- _(u"Discovery area"), null=True, blank=True)
- affmar_number = models.CharField(_(u"AffMar number"), max_length=100,
+ _("Discovery area"), null=True, blank=True)
+ affmar_number = models.CharField(_("AffMar number"), max_length=100,
null=True, blank=True)
- drassm_number = models.CharField(_(u"DRASSM number"), max_length=100,
+ drassm_number = models.CharField(_("DRASSM number"), max_length=100,
null=True, blank=True)
documents = models.ManyToManyField(
- Document, related_name="sites", verbose_name=_(u"Documents"),
+ Document, related_name="sites", verbose_name=_("Documents"),
blank=True)
main_image = models.ForeignKey(
Document, related_name='main_image_sites',
on_delete=models.SET_NULL,
- verbose_name=_(u"Main image"), blank=True, null=True)
- cached_label = models.TextField(_(u"Cached name"),
+ verbose_name=_("Main image"), blank=True, null=True)
+ cached_label = models.TextField(_("Cached name"),
null=True, blank=True, db_index=True)
history = HistoricalRecords(bases=[HistoryModel])
class Meta:
- verbose_name = _(u"Archaeological site")
- verbose_name_plural = _(u"Archaeological sites")
+ verbose_name = _("Archaeological site")
+ verbose_name_plural = _("Archaeological sites")
permissions = (
("view_archaeologicalsite",
- u"Can view all Archaeological sites"),
+ "Can view all Archaeological sites"),
("view_own_archaeologicalsite",
- u"Can view own Archaeological site"),
+ "Can view own Archaeological site"),
("add_own_archaeologicalsite",
- u"Can add own Archaeological site"),
+ "Can add own Archaeological site"),
("change_own_archaeologicalsite",
- u"Can change own Archaeological site"),
+ "Can change own Archaeological site"),
("delete_own_archaeologicalsite",
- u"Can delete own Archaeological site"),
+ "Can delete own Archaeological site"),
)
- def __unicode__(self):
+ def __str__(self):
if self.cached_label:
return self.cached_label
self.save()
@@ -309,7 +309,7 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
@property
def short_class_name(self):
- return _(u"SITE")
+ return _("SITE")
@property
def finds(self):
@@ -361,13 +361,13 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
def _generate_cached_label(self):
name = self.reference
if self.name:
- name += u" %s %s" % (settings.JOINT, self.name)
- keys = [('towns', u" - {}"), ('remains', u" - {}"),
- ('periods', u" [{}]")]
+ name += " %s %s" % (settings.JOINT, self.name)
+ keys = [('towns', " - {}"), ('remains', " - {}"),
+ ('periods', " [{}]")]
for k, lbl in keys:
if getattr(self, k).count():
- name += lbl.format(u", ".join([
- unicode(v) for v in getattr(self, k).all()
+ name += lbl.format(", ".join([
+ str(v) for v in getattr(self, k).all()
]))
return name
@@ -382,7 +382,7 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
return [town.label_with_areas for town in self.towns.all()]
def towns_label(self):
- return u" - ".join(self.towns_codes())
+ return " - ".join(self.towns_codes())
def get_town_centroid(self):
q = self.towns.filter(center__isnull=False).annotate(
@@ -406,7 +406,7 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
return q.all()[0].poly
def _get_base_image_path(self):
- return u"{}/{}".format(self.SLUG, self.reference)
+ return "{}/{}".format(self.SLUG, self.reference)
def create_or_update_top_operation(self, create=False):
"""
@@ -420,13 +420,13 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
return
operation_type, created = OperationType.objects.get_or_create(
txt_idx='unknown',
- defaults={'label': _(u"Unknown"), 'available': True,
+ defaults={'label': _("Unknown"), 'available': True,
'order': 999})
- name = unicode(
- _(u"Virtual operation of site: {}")
+ name = str(
+ _("Virtual operation of site: {}")
).format(self.reference)
if self.towns.count():
- name += u' - ' + u", ".join([town.name
+ name += u' - ' + ", ".join([town.name
for town in self.towns.all()])
self.top_operation = Operation.objects.create(
operation_type=operation_type,
@@ -478,16 +478,16 @@ def get_values_town_related(item, prefix, values):
values[prefix + 'towns'] = ''
values[prefix + 'departments'] = ''
values[prefix + 'departments_number'] = ''
- values[prefix + 'towns_count'] = unicode(item.towns.count())
+ values[prefix + 'towns_count'] = str(item.towns.count())
if item.towns.count():
- values[prefix + 'towns'] = u", ".join([
+ values[prefix + 'towns'] = ", ".join([
town.name for town in item.towns.all().order_by('name')])
if settings.COUNTRY == 'fr':
dpts_num = set(
[town.numero_insee[:2] for town in item.towns.all()])
- values[prefix + 'departments_number'] = u", ".join(
+ values[prefix + 'departments_number'] = ", ".join(
list(sorted(dpts_num)))
- values[prefix + 'departments'] = u", ".join(
+ values[prefix + 'departments'] = ", ".join(
[Department.objects.get(number=dpt).label
for dpt in sorted(dpts_num) if Department.objects.filter(
number=dpt).count()])
@@ -579,26 +579,26 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
}
COL_LABELS = {
- 'code_patriarche': u"Code patriarche",
- 'associated_file_short_label': _(u"Associated file (label)"),
- 'operator__name': _(u"Operator name"),
- 'scientist__raw_name': _(u"Scientist (full name)"),
- 'associated_file__external_id': _(u"Associated file (external ID)"),
- 'scientist__title': _(u"Scientist (title)"),
- 'scientist__surname': _(u"Scientist (surname)"),
- 'scientist__name': _(u"Scientist (name)"),
- 'scientist__attached_to__name': _(u"Scientist - Organization (name)"),
- 'in_charge__title': _(u"In charge (title)"),
- 'in_charge__surname': _(u"In charge (surname)"),
- 'in_charge__name': _(u"In charge (name)"),
- 'in_charge__attached_to__name': _(u"In charge - Organization (name)"),
- 'cira_rapporteur__surname': u"Rapporteur CIRA (prénom)",
- 'cira_rapporteur__name': u"Rapporteur CIRA (nom)",
- 'cira_rapporteur__attached_to__name': u"Rapporteur CIRA - "
- u"Organisation (nom)",
- 'archaeological_sites__reference': _(u"Archaeological sites ("
- u"reference)"),
- 'towns_label': _(u"Towns"),
+ 'code_patriarche': "Code patriarche",
+ 'associated_file_short_label': _("Associated file (label)"),
+ 'operator__name': _("Operator name"),
+ 'scientist__raw_name': _("Scientist (full name)"),
+ 'associated_file__external_id': _("Associated file (external ID)"),
+ 'scientist__title': _("Scientist (title)"),
+ 'scientist__surname': _("Scientist (surname)"),
+ 'scientist__name': _("Scientist (name)"),
+ 'scientist__attached_to__name': _("Scientist - Organization (name)"),
+ 'in_charge__title': _("In charge (title)"),
+ 'in_charge__surname': _("In charge (surname)"),
+ 'in_charge__name': _("In charge (name)"),
+ 'in_charge__attached_to__name': _("In charge - Organization (name)"),
+ 'cira_rapporteur__surname': "Rapporteur CIRA (prénom)",
+ 'cira_rapporteur__name': "Rapporteur CIRA (nom)",
+ 'cira_rapporteur__attached_to__name': "Rapporteur CIRA - "
+ "Organisation (nom)",
+ 'archaeological_sites__reference':
+ _("Archaeological sites (reference)"),
+ 'towns_label': _("Towns"),
}
BASE_SEARCH_VECTORS = [
SearchVectorConfig("abstract", "local"),
@@ -646,19 +646,19 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
# alternative names of fields for searches
ALT_NAMES = {
'year': SearchAltName(
- pgettext_lazy("key for text search", u"year"),
+ pgettext_lazy("key for text search", "year"),
'year'
),
'operation_code': SearchAltName(
- pgettext_lazy("key for text search", u"operation-code"),
+ pgettext_lazy("key for text search", "operation-code"),
'operation_code'
),
'code_patriarche': SearchAltName(
- pgettext_lazy("key for text search", u"patriarche"),
+ pgettext_lazy("key for text search", "patriarche"),
'code_patriarche__iexact'
),
'towns': SearchAltName(
- pgettext_lazy("key for text search", u"town"),
+ pgettext_lazy("key for text search", "town"),
'towns__cached_label__iexact'
),
'towns__areas': SearchAltName(
@@ -666,127 +666,127 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
'towns__areas__label__iexact'
),
'parcel': SearchAltName(
- pgettext_lazy("key for text search", u"parcel"),
+ pgettext_lazy("key for text search", "parcel"),
'parcels__cached_label__iexact'
),
'towns__numero_insee__startswith': SearchAltName(
- pgettext_lazy("key for text search", u"department"),
+ pgettext_lazy("key for text search", "department"),
'towns__numero_insee__startswith'
),
'common_name': SearchAltName(
- pgettext_lazy("key for text search", u"name"),
+ pgettext_lazy("key for text search", "name"),
'common_name__iexact'
),
'address': SearchAltName(
- pgettext_lazy("key for text search", u"address"),
+ pgettext_lazy("key for text search", "address"),
'address__iexact'
),
'operation_type': SearchAltName(
- pgettext_lazy("key for text search", u"type"),
+ pgettext_lazy("key for text search", "type"),
'operation_type__label__iexact'
),
'end_date': SearchAltName(
- pgettext_lazy("key for text search", u"is-open"),
+ pgettext_lazy("key for text search", "is-open"),
'end_date__isnull'
),
'in_charge': SearchAltName(
- pgettext_lazy("key for text search", u"in-charge"),
+ pgettext_lazy("key for text search", "in-charge"),
'in_charge__cached_label__iexact'
),
'scientist': SearchAltName(
- pgettext_lazy("key for text search", u"scientist"),
+ pgettext_lazy("key for text search", "scientist"),
'scientist__cached_label__iexact'
),
'operator': SearchAltName(
- pgettext_lazy("key for text search", u"operator"),
+ pgettext_lazy("key for text search", "operator"),
'operator__cached_label__iexact'
),
'remains': SearchAltName(
- pgettext_lazy("key for text search", u"remain"),
+ pgettext_lazy("key for text search", "remain"),
'remains__label__iexact'
),
'periods': SearchAltName(
- pgettext_lazy("key for text search", u"period"),
+ pgettext_lazy("key for text search", "period"),
'periods__label__iexact'
),
'start_before': SearchAltName(
- pgettext_lazy("key for text search", u"start-before"),
+ pgettext_lazy("key for text search", "start-before"),
'start_date__lte'
),
'start_after': SearchAltName(
- pgettext_lazy("key for text search", u"start-after"),
+ pgettext_lazy("key for text search", "start-after"),
'start_date__gte'
),
'end_before': SearchAltName(
- pgettext_lazy("key for text search", u"end-before"),
+ pgettext_lazy("key for text search", "end-before"),
'excavation_end_date__lte'
),
'end_after': SearchAltName(
- pgettext_lazy("key for text search", u"end-after"),
+ pgettext_lazy("key for text search", "end-after"),
'excavation_end_date__gte'
),
'relation_types': SearchAltName(
- pgettext_lazy("key for text search", u"relation-types"),
+ pgettext_lazy("key for text search", "relation-types"),
'relation_types'
),
'comment': SearchAltName(
- pgettext_lazy("key for text search", u"comment"),
+ pgettext_lazy("key for text search", "comment"),
'comment__iexact'
),
'abstract': SearchAltName(
- pgettext_lazy("key for text search", u"abstract"),
+ pgettext_lazy("key for text search", "abstract"),
'abstract__iexact'
),
'scientific_documentation_comment': SearchAltName(
pgettext_lazy("key for text search",
- u"scientific-documentation-comment"),
+ "scientific-documentation-comment"),
'scientific_documentation_comment__iexact'
),
'record_quality_type': SearchAltName(
- pgettext_lazy("key for text search", u"record-quality"),
+ pgettext_lazy("key for text search", "record-quality"),
'record_quality_type__label__iexact'
),
'report_processing': SearchAltName(
pgettext_lazy("key for text search",
- u"report-processing"),
+ "report-processing"),
'report_processing__label__iexact'
),
'virtual_operation': SearchAltName(
pgettext_lazy("key for text search",
- u"virtual-operation"),
+ "virtual-operation"),
'virtual_operation'
),
'archaeological_sites': SearchAltName(
pgettext_lazy("key for text search",
- u"site"),
+ "site"),
'archaeological_sites__cached_label__icontains'
),
'documentation_received': SearchAltName(
- pgettext_lazy("key for text search", u"documentation-received"),
+ pgettext_lazy("key for text search", "documentation-received"),
'documentation_received'
),
'documentation_deadline_before': SearchAltName(
- pgettext_lazy("key for text search", u"documentation-deadline-before"),
+ pgettext_lazy("key for text search", "documentation-deadline-before"),
'documentation_deadline__lte'
),
'documentation_deadline_after': SearchAltName(
- pgettext_lazy("key for text search", u"documentation-deadline-after"),
+ pgettext_lazy("key for text search", "documentation-deadline-after"),
'documentation_deadline__gte'
),
'finds_received': SearchAltName(
- pgettext_lazy("key for text search", u"finds-received"),
+ pgettext_lazy("key for text search", "finds-received"),
'finds_received'
),
'finds_deadline_before': SearchAltName(
- pgettext_lazy("key for text search", u"finds-deadline-before"),
+ pgettext_lazy("key for text search", "finds-deadline-before"),
'finds_deadline__lte'
),
'finds_deadline_after': SearchAltName(
- pgettext_lazy("key for text search", u"finds-deadline-after"),
+ pgettext_lazy("key for text search", "finds-deadline-after"),
'finds_deadline__gte'
),
'drassm_code': SearchAltName(
- pgettext_lazy("key for text search", u"code-drassm"),
+ pgettext_lazy("key for text search", "code-drassm"),
'drassm_code__iexact'
),
}
@@ -800,9 +800,9 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
]
UP_MODEL_QUERY = {
- "site": (pgettext_lazy("key for text search", u"site"),
+ "site": (pgettext_lazy("key for text search", "site"),
'cached_label'),
- "file": (pgettext_lazy("key for text search", u"file"),
+ "file": (pgettext_lazy("key for text search", "file"),
'cached_label'),
}
RELATIVE_SESSION_NAMES = [
@@ -819,151 +819,151 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
]
# fields definition
- creation_date = models.DateField(_(u"Creation date"),
+ creation_date = models.DateField(_("Creation date"),
default=datetime.date.today)
- end_date = models.DateField(_(u"Closing date"), null=True, blank=True)
- start_date = models.DateField(_(u"Start date"), null=True, blank=True)
+ end_date = models.DateField(_("Closing date"), null=True, blank=True)
+ start_date = models.DateField(_("Start date"), null=True, blank=True)
excavation_end_date = models.DateField(
- _(u"Excavation end date"), null=True, blank=True)
- report_delivery_date = models.DateField(_(u"Report delivery date"),
+ _("Excavation end date"), null=True, blank=True)
+ report_delivery_date = models.DateField(_("Report delivery date"),
null=True, blank=True)
scientist = models.ForeignKey(
- Person, blank=True, null=True, verbose_name=_(u"In charge scientist"),
+ Person, blank=True, null=True, verbose_name=_("In charge scientist"),
on_delete=models.SET_NULL,
related_name='operation_scientist_responsability')
operator = models.ForeignKey(
Organization, blank=True, null=True, related_name='operator',
- verbose_name=_(u"Operator"), on_delete=models.SET_NULL)
+ verbose_name=_("Operator"), on_delete=models.SET_NULL)
in_charge = models.ForeignKey(Person, blank=True, null=True,
- verbose_name=_(u"In charge"),
+ verbose_name=_("In charge"),
on_delete=models.SET_NULL,
related_name='operation_responsability')
collaborators = models.ManyToManyField(
- Person, blank=True, verbose_name=_(u"Collaborators"),
+ Person, blank=True, verbose_name=_("Collaborators"),
related_name='operation_collaborator'
)
- year = models.IntegerField(_(u"Year"), null=True, blank=True)
- operation_code = models.IntegerField(_(u"Numeric reference"), null=True,
+ year = models.IntegerField(_("Year"), null=True, blank=True)
+ operation_code = models.IntegerField(_("Numeric reference"), null=True,
blank=True)
associated_file = models.ForeignKey(
'archaeological_files.File',
- related_name='operations', verbose_name=_(u"File"),
+ related_name='operations', verbose_name=_("File"),
on_delete=models.SET_NULL,
blank=True, null=True)
operation_type = models.ForeignKey(OperationType, related_name='+',
- verbose_name=_(u"Operation type"))
- surface = models.IntegerField(_(u"Surface (m2)"), blank=True, null=True)
+ verbose_name=_("Operation type"))
+ surface = models.IntegerField(_("Surface (m2)"), blank=True, null=True)
remains = models.ManyToManyField("RemainType", verbose_name=_(u'Remains'),
blank=True)
- towns = models.ManyToManyField(Town, verbose_name=_(u"Towns"),
+ towns = models.ManyToManyField(Town, verbose_name=_("Towns"),
related_name='operations')
- cost = models.IntegerField(_(u"Cost (euros)"),
+ cost = models.IntegerField(_("Cost (euros)"),
blank=True, null=True) # preventive
- periods = models.ManyToManyField(Period, verbose_name=_(u"Periods"),
+ periods = models.ManyToManyField(Period, verbose_name=_("Periods"),
blank=True)
# preventive
- scheduled_man_days = models.IntegerField(_(u"Scheduled man-days"),
+ scheduled_man_days = models.IntegerField(_("Scheduled man-days"),
blank=True, null=True)
# preventive
- optional_man_days = models.IntegerField(_(u"Optional man-days"),
+ optional_man_days = models.IntegerField(_("Optional man-days"),
blank=True, null=True)
# preventive
- effective_man_days = models.IntegerField(_(u"Effective man-days"),
+ effective_man_days = models.IntegerField(_("Effective man-days"),
blank=True, null=True)
report_processing = models.ForeignKey(
- ReportState, verbose_name=_(u"Report processing"),
+ ReportState, verbose_name=_("Report processing"),
on_delete=models.SET_NULL,
blank=True, null=True)
- old_code = models.CharField(_(u"Old code"), max_length=200, null=True,
+ old_code = models.CharField(_("Old code"), max_length=200, null=True,
blank=True)
## fr
- code_patriarche = models.TextField(u"Code PATRIARCHE", null=True,
+ code_patriarche = models.TextField("Code PATRIARCHE", null=True,
blank=True, unique=True)
# preventive
- fnap_financing = models.FloatField(u"Financement FNAP (%)",
+ fnap_financing = models.FloatField("Financement FNAP (%)",
blank=True, null=True)
# preventive
- fnap_cost = models.IntegerField(u"Financement FNAP (€)",
+ fnap_cost = models.IntegerField("Financement FNAP (€)",
blank=True, null=True)
# preventive diag
zoning_prescription = models.NullBooleanField(
- _(u"Prescription on zoning"), blank=True, null=True)
+ _("Prescription on zoning"), blank=True, null=True)
# preventive diag
large_area_prescription = models.NullBooleanField(
- _(u"Prescription on large area"), blank=True, null=True)
+ _("Prescription on large area"), blank=True, null=True)
geoarchaeological_context_prescription = models.NullBooleanField(
- _(u"Prescription on geoarchaeological context"), blank=True,
+ _("Prescription on geoarchaeological context"), blank=True,
null=True) # preventive diag
cira_rapporteur = models.ForeignKey(
Person, related_name='cira_rapporteur', null=True, blank=True,
- on_delete=models.SET_NULL, verbose_name=u"Rapporteur CIRA")
+ on_delete=models.SET_NULL, verbose_name="Rapporteur CIRA")
negative_result = models.NullBooleanField(
- u"Résultat considéré comme négatif", blank=True, null=True)
- cira_date = models.DateField(u"Date avis CIRA", null=True, blank=True)
- eas_number = models.CharField(u"Numéro de l'EA", max_length=20,
+ "Résultat considéré comme négatif", blank=True, null=True)
+ cira_date = models.DateField("Date avis CIRA", null=True, blank=True)
+ eas_number = models.CharField("Numéro de l'EA", max_length=20,
null=True, blank=True)
## end fr
operator_reference = models.CharField(
- _(u"Operator reference"), max_length=20, null=True, blank=True)
- common_name = models.TextField(_(u"Generic name"), null=True, blank=True)
- address = models.TextField(_(u"Address / Locality"), null=True, blank=True)
- comment = models.TextField(_(u"Comment"), null=True, blank=True)
+ _("Operator reference"), max_length=20, null=True, blank=True)
+ common_name = models.TextField(_("Generic name"), null=True, blank=True)
+ address = models.TextField(_("Address / Locality"), null=True, blank=True)
+ comment = models.TextField(_("Comment"), null=True, blank=True)
scientific_documentation_comment = models.TextField(
- _(u"Comment about scientific documentation"), null=True, blank=True)
+ _("Comment about scientific documentation"), null=True, blank=True)
documents = models.ManyToManyField(
- Document, related_name='operations', verbose_name=_(u"Documents"),
+ Document, related_name='operations', verbose_name=_("Documents"),
blank=True)
main_image = models.ForeignKey(
Document, related_name='main_image_operations',
on_delete=models.SET_NULL,
- verbose_name=_(u"Main image"), blank=True, null=True)
- cached_label = models.CharField(_(u"Cached name"), max_length=500,
+ verbose_name=_("Main image"), blank=True, null=True)
+ cached_label = models.CharField(_("Cached name"), max_length=500,
null=True, blank=True, db_index=True)
archaeological_sites = models.ManyToManyField(
- ArchaeologicalSite, verbose_name=_(u"Archaeological sites"),
+ ArchaeologicalSite, verbose_name=_("Archaeological sites"),
blank=True, related_name='operations')
virtual_operation = models.BooleanField(
- _(u"Virtual operation"),
+ _("Virtual operation"),
default=False, help_text=_(
- u"If checked, it means that this operation have not been "
- u"officialy registered."))
+ "If checked, it means that this operation have not been "
+ "officialy registered."))
record_quality_type = models.ForeignKey(
- RecordQualityType, verbose_name=_(u"Record quality"),
+ RecordQualityType, verbose_name=_("Record quality"),
on_delete=models.SET_NULL,
null=True, blank=True,)
- abstract = models.TextField(_(u"Abstract"), null=True, blank=True)
+ abstract = models.TextField(_("Abstract"), null=True, blank=True)
documentation_deadline = models.DateField(
- _(u"Deadline for submission of the documentation"), blank=True,
+ _("Deadline for submission of the documentation"), blank=True,
null=True)
documentation_received = models.NullBooleanField(
- _(u"Documentation received"), blank=True, null=True)
+ _("Documentation received"), blank=True, null=True)
finds_deadline = models.DateField(
- _(u"Deadline for submission of the finds"), blank=True, null=True)
+ _("Deadline for submission of the finds"), blank=True, null=True)
finds_received = models.NullBooleanField(
- _(u"Finds received"), blank=True, null=True)
+ _("Finds received"), blank=True, null=True)
# underwater
- drassm_code = models.CharField(_(u"DRASSM code"), max_length=100,
+ drassm_code = models.CharField(_("DRASSM code"), max_length=100,
null=True, blank=True)
# judiciary
- seizure_name = models.TextField(_(u"Seizure name"), blank=True, null=True)
- official_report_number = models.TextField(_(u"Official report number"),
+ seizure_name = models.TextField(_("Seizure name"), blank=True, null=True)
+ official_report_number = models.TextField(_("Official report number"),
blank=True, null=True)
- name_of_the_protagonist = models.TextField(_(u"Name of the protagonist"),
+ name_of_the_protagonist = models.TextField(_("Name of the protagonist"),
blank=True, null=True)
history = HistoricalRecords(bases=[HistoryModel])
class Meta:
- verbose_name = _(u"Operation")
- verbose_name_plural = _(u"Operations")
+ verbose_name = _("Operation")
+ verbose_name_plural = _("Operations")
permissions = (
- ("view_operation", u"Can view all Operations"),
- ("view_own_operation", u"Can view own Operation"),
- ("add_own_operation", u"Can add own Operation"),
- ("change_own_operation", u"Can change own Operation"),
- ("delete_own_operation", u"Can delete own Operation"),
- ("close_operation", u"Can close Operation"),
+ ("view_operation", "Can view all Operations"),
+ ("view_own_operation", "Can view own Operation"),
+ ("add_own_operation", "Can add own Operation"),
+ ("change_own_operation", "Can change own Operation"),
+ ("delete_own_operation", "Can delete own Operation"),
+ ("close_operation", "Can close Operation"),
)
ordering = ('cached_label',)
@@ -983,7 +983,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
get_short_menu_class=get_short_menu_class)
return cls._return_get_owns(owns, values, get_short_menu_class)
- def __unicode__(self):
+ def __str__(self):
if self.cached_label or getattr(self, "_label_checked", False):
return self.cached_label
self._label_checked = True
@@ -1005,15 +1005,15 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
@classmethod
def _get_department_code(cls, value):
if not settings.ISHTAR_DPTS:
- return u""
+ return ""
for k, v in settings.ISHTAR_DPTS:
if v.lower() == value:
return k
- return u""
+ return ""
@property
def short_class_name(self):
- return _(u"OPE")
+ return _("OPE")
@property
def external_id(self):
@@ -1023,7 +1023,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
def short_label(self):
if settings.COUNTRY == 'fr':
return self.reference
- return unicode(self)
+ return str(self)
@property
def relation_label(self):
@@ -1041,7 +1041,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
return [town.label_with_areas for town in self.towns.all()]
def towns_label(self):
- return u" - ".join(self.towns_codes())
+ return " - ".join(self.towns_codes())
def has_finds(self):
from archaeological_finds.models import BaseFind
@@ -1055,21 +1055,21 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
profile = get_current_profile()
ref = ""
if self.code_patriarche:
- ref = profile.operation_prefix + unicode(self.code_patriarche)
+ ref = profile.operation_prefix + str(self.code_patriarche)
if not full:
return ref
if self.year and self.operation_code:
if ref:
- ref += u" - "
+ ref += " - "
ref += profile.default_operation_prefix
- ref += u"-".join((unicode(self.year),
- unicode(self.operation_code)))
+ ref += "-".join((str(self.year),
+ str(self.operation_code)))
return ref or "00"
@property
def short_code_patriarche(self):
if not self.code_patriarche:
- return u""
+ return ""
if isinstance(self.code_patriarche, int):
self.code_patriarche = str(self.code_patriarche)
profile = get_current_profile()
@@ -1109,10 +1109,10 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
return True
def _get_base_image_path(self):
- return u"{}/{}/{}".format(self.SLUG, self.year, self.reference)
+ return "{}/{}/{}".format(self.SLUG, self.year, self.reference)
def get_town_label(self):
- lbl = unicode(_('Intercommunal'))
+ lbl = str(_('Intercommunal'))
if self.towns.count() == 1:
lbl = self.towns.values('name').all()[0]['name']
return lbl
@@ -1179,13 +1179,13 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
if can_add_cr:
actions += [
(reverse('operation-qa-contextrecord', args=[self.pk]),
- _(u"Add context record"), "fa fa-plus",
- _(u"context record"), "", True),
+ _("Add context record"), "fa fa-plus",
+ _("context record"), "", True),
]
return actions
- associated_file_short_label_lbl = _(u"Archaeological file")
- full_code_patriarche_lbl = _(u"Code patriarche")
+ associated_file_short_label_lbl = _("Archaeological file")
+ full_code_patriarche_lbl = _("Code patriarche")
@property
def associated_file_short_label(self):
@@ -1199,17 +1199,17 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
Max('operation_code'))["operation_code__max"]
return (max_val + 1) if max_val else 1
- year_index_lbl = _(u"Operation code")
+ year_index_lbl = _("Operation code")
@property
def year_index(self):
if not self.operation_code:
return ""
- lbl = unicode(self.operation_code)
+ lbl = str(self.operation_code)
year = self.year or 0
profile = get_current_profile()
lbl = profile.default_operation_prefix \
- + u"%d-%s%s" % (year, (3 - len(lbl)) * "0", lbl)
+ + "%d-%s%s" % (year, (3 - len(lbl)) * "0", lbl)
return lbl
@property
@@ -1227,8 +1227,8 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
if self.pk:
objs = objs.exclude(pk=self.pk)
if objs.count():
- raise ValidationError(_(u"This operation code already exists for "
- u"this year"))
+ raise ValidationError(_("This operation code already exists for "
+ "this year"))
@property
def surface_ha(self):
@@ -1287,7 +1287,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
@property
def nb_parcels(self):
- _(u"Number of parcels")
+ _("Number of parcels")
nb = 0
if self.associated_file:
nb = self.associated_file.parcels.count()
@@ -1297,7 +1297,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
@property
def nb_acts(self, update=False):
- _(u"Number of administrative acts")
+ _("Number of administrative acts")
return self._get_or_set_stats('_nb_acts', update)
def _nb_acts(self):
@@ -1305,7 +1305,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
@property
def nb_indexed_acts(self, update=False):
- _(u"Number of indexed administrative acts")
+ _("Number of indexed administrative acts")
return self._get_or_set_stats('_nb_indexed_acts', update)
def _nb_indexed_acts(self):
@@ -1313,7 +1313,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
@property
def nb_context_records(self, update=False):
- _(u"Number of context records")
+ _("Number of context records")
return self._get_or_set_stats('_nb_context_records', update)
def _nb_context_records(self):
@@ -1328,7 +1328,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
q = self.context_record.values(
'unit', 'unit__label').distinct().order_by('label')
for res in q.all():
- nbs.append((unicode(res['unit__label'] or "-"),
+ nbs.append((str(res['unit__label'] or "-"),
self.context_record.filter(unit=res['unit']).count()))
return list(set(nbs))
@@ -1342,14 +1342,14 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
'datings__period', 'datings__period__label').distinct().order_by(
'datings__period__order')
for res in q.all():
- nbs.append((unicode(res['datings__period__label'] or "-"),
+ nbs.append((str(res['datings__period__label'] or "-"),
self.context_record.filter(
datings__period=res['datings__period']).count()))
return nbs
@property
def nb_finds(self, update=False):
- _(u"Number of finds")
+ _("Number of finds")
return self._get_or_set_stats('_nb_finds', update)
def _nb_finds(self):
@@ -1373,7 +1373,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
'material_types__label')
for res in q.all():
nbs.append(
- (unicode(res['material_types__label'] or "-"),
+ (str(res['material_types__label'] or "-"),
Find.objects.filter(
base_finds__context_record__operation=self,
upstream_treatment_id__isnull=True,
@@ -1392,9 +1392,9 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
'object_types', 'object_types__label').distinct().order_by(
'object_types__label')
for res in q.all():
- label = unicode(res['object_types__label'])
+ label = str(res['object_types__label'])
if label == 'None':
- label = _(u"No type")
+ label = _("No type")
nbs.append(
(label,
Find.objects.filter(
@@ -1416,7 +1416,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
'datings__period__order')
for res in q.all():
nbs.append(
- (unicode(res['datings__period__label'] or "-"),
+ (str(res['datings__period__label'] or "-"),
Find.objects.filter(
base_finds__context_record__operation=self,
upstream_treatment_id__isnull=True,
@@ -1425,7 +1425,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
@property
def nb_documents(self, update=False):
- _(u"Number of sources")
+ _("Number of sources")
return self._get_or_set_stats('_nb_documents', update)
def _nb_documents(self):
@@ -1455,7 +1455,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
if st not in docs:
docs[st] = 0
docs[st] += q.filter(source_type=st).count()
- docs = [(unicode(SourceType.objects.get(pk=k)), docs[k]) for k in docs]
+ docs = [(str(SourceType.objects.get(pk=k)), docs[k]) for k in docs]
return sorted(docs, key=lambda x: x[0])
@property
@@ -1463,7 +1463,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
return self._get_or_set_stats('_nb_stats_finds_by_ue', update)
def _nb_stats_finds_by_ue(self):
- _(u"Mean")
+ _("Mean")
res, finds = {}, []
for cr in self.context_record.all():
finds.append(cr.base_finds.count())
@@ -1472,7 +1472,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
res['mean'] = float(sum(finds)) / max(len(finds), 1)
res['min'] = min(finds)
res['max'] = max(finds)
- res['mode'] = u" ; ".join([str(m) for m in mode(finds)])
+ res['mode'] = " ; ".join([str(m) for m in mode(finds)])
return res
def save(self, *args, **kwargs):
@@ -1533,8 +1533,8 @@ post_save.connect(operation_post_save, sender=Operation)
class RelationType(GeneralRelationType):
class Meta:
- verbose_name = _(u"Operation relation type")
- verbose_name_plural = _(u"Operation relation types")
+ verbose_name = _("Operation relation type")
+ verbose_name_plural = _("Operation relation types")
ordering = ('order', 'label')
@@ -1547,11 +1547,11 @@ class RecordRelations(GeneralRecordRelations, models.Model):
relation_type = models.ForeignKey(RelationType)
class Meta:
- verbose_name = _(u"Operation record relation")
- verbose_name_plural = _(u"Operation record relations")
+ verbose_name = _("Operation record relation")
+ verbose_name_plural = _("Operation record relations")
ordering = ('left_record', 'relation_type')
permissions = [
- ("view_operationrelation", u"Can view all Operation relations"),
+ ("view_operationrelation", "Can view all Operation relations"),
]
@@ -1578,8 +1578,8 @@ class OperationByDepartment(models.Model):
DROP VIEW operation_department;
"""
- operation = models.ForeignKey(Operation, verbose_name=_(u"Operation"))
- department = models.ForeignKey(Department, verbose_name=_(u"Department"),
+ operation = models.ForeignKey(Operation, verbose_name=_("Operation"))
+ department = models.ForeignKey(Department, verbose_name=_("Department"),
on_delete=models.DO_NOTHING,
blank=True, null=True)
@@ -1594,17 +1594,17 @@ class ActType(GeneralType):
('TF', _(u'Treatment request')),
('T', _(u'Treatment')),
)
- intented_to = models.CharField(_(u"Intended to"), max_length=2,
+ intented_to = models.CharField(_("Intended to"), max_length=2,
choices=TYPE)
- code = models.CharField(_(u"Code"), max_length=10, blank=True, null=True)
+ code = models.CharField(_("Code"), max_length=10, blank=True, null=True)
associated_template = models.ManyToManyField(
DocumentTemplate, blank=True,
- verbose_name=_(u"Associated template"), related_name='acttypes')
- indexed = models.BooleanField(_(u"Indexed"), default=False)
+ verbose_name=_("Associated template"), related_name='acttypes')
+ indexed = models.BooleanField(_("Indexed"), default=False)
class Meta:
- verbose_name = _(u"Act type")
- verbose_name_plural = _(u"Act types")
+ verbose_name = _("Act type")
+ verbose_name_plural = _("Act types")
ordering = ('label',)
@@ -1675,9 +1675,9 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
RELATIVE_SESSION_NAMES = [('operation', 'operation__pk'),
('file', 'associated_file__pk')]
COL_LABELS = {
- 'full_ref': _(u"Ref."), 'signature_date__year': _(u"Year"),
- 'associated_file__cached_label': _(u"Archaeological file"),
- 'operation__cached_label': _(u"Operation"),
+ 'full_ref': _("Ref."), 'signature_date__year': _("Year"),
+ 'associated_file__cached_label': _("Archaeological file"),
+ 'operation__cached_label': _("Operation"),
}
BASE_SEARCH_VECTORS = [
SearchVectorConfig("act_type__label"),
@@ -1694,135 +1694,135 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
# alternative names of fields for searches
ALT_NAMES = {
'year': SearchAltName(
- pgettext_lazy("key for text search", u"year"),
+ pgettext_lazy("key for text search", "year"),
'signature_date__year'
),
'index': SearchAltName(
- pgettext_lazy("key for text search", u"index"),
+ pgettext_lazy("key for text search", "index"),
'index'
),
'ref_sra': SearchAltName(
- pgettext_lazy("key for text search", u"other-ref"),
+ pgettext_lazy("key for text search", "other-ref"),
'ref_sra__iexact'
),
'operation__code_patriarche': SearchAltName(
- pgettext_lazy("key for text search", u"patriarche"),
+ pgettext_lazy("key for text search", "patriarche"),
'operation__code_patriarche'
),
'act_type': SearchAltName(
- pgettext_lazy("key for text search", u"type"),
+ pgettext_lazy("key for text search", "type"),
'act_type__label__iexact'
),
'indexed': SearchAltName(
- pgettext_lazy("key for text search", u"indexed"),
+ pgettext_lazy("key for text search", "indexed"),
'index__isnull'
),
'operation__towns': SearchAltName(
- pgettext_lazy("key for text search", u"operation-town"),
+ pgettext_lazy("key for text search", "operation-town"),
'operation__towns__cached_label__iexact'
),
'associated_file__towns': SearchAltName(
- pgettext_lazy("key for text search", u"file-town"),
+ pgettext_lazy("key for text search", "file-town"),
'associated_file__towns__cached_label__iexact'
),
'parcel': SearchAltName(
- pgettext_lazy("key for text search", u"parcel"),
+ pgettext_lazy("key for text search", "parcel"),
('associated_file__parcels__cached_label__iexact',
'operation__parcels__cached_label__iexact',
'operation__associated_file__parcels__cached_label__iexact'),
),
'operation__towns__numero_insee__startswith': SearchAltName(
- pgettext_lazy("key for text search", u"operation-department"),
+ pgettext_lazy("key for text search", "operation-department"),
'operation__towns__numero_insee__startswith'
),
'associated_file__towns__numero_insee__startswith': SearchAltName(
- pgettext_lazy("key for text search", u"file-department"),
+ pgettext_lazy("key for text search", "file-department"),
'associated_file__towns__numero_insee__startswith'
),
'act_object': SearchAltName(
- pgettext_lazy("key for text search", u"object"),
+ pgettext_lazy("key for text search", "object"),
'act_object__icontains'
),
'signature_date_before': SearchAltName(
- pgettext_lazy("key for text search", u"signature-before"),
+ pgettext_lazy("key for text search", "signature-before"),
'signature_date__lte'
),
'signature_date_after': SearchAltName(
- pgettext_lazy("key for text search", u"signature-after"),
+ pgettext_lazy("key for text search", "signature-after"),
'signature_date__gte'
),
'associated_file__name': SearchAltName(
- pgettext_lazy("key for text search", u"file-name"),
+ pgettext_lazy("key for text search", "file-name"),
'associated_file__name__icontains'
),
'associated_file__general_contractor': SearchAltName(
- pgettext_lazy("key for text search", u"general-contractor"),
+ pgettext_lazy("key for text search", "general-contractor"),
'associated_file__general_contractor__cached_label__iexact'
),
'associated_file__general_contractor__attached_to': SearchAltName(
pgettext_lazy("key for text search",
- u"general-contractor-organization"),
+ "general-contractor-organization"),
'associated_file__general_contractor__attached_to'
'__cached_label__iexact'
),
'associated_file__numeric_reference': SearchAltName(
- pgettext_lazy("key for text search", u"file-reference"),
+ pgettext_lazy("key for text search", "file-reference"),
'associated_file__numeric_reference'
),
'associated_file__year': SearchAltName(
- pgettext_lazy("key for text search", u"file-year"),
+ pgettext_lazy("key for text search", "file-year"),
'associated_file__year'
),
'associated_file__internal_reference': SearchAltName(
- pgettext_lazy("key for text search", u"file-other-reference"),
+ pgettext_lazy("key for text search", "file-other-reference"),
'associated_file__internal_reference__iexact'
),
'associated_file__in_charge': SearchAltName(
- pgettext_lazy("key for text search", u"file-in-charge"),
+ pgettext_lazy("key for text search", "file-in-charge"),
'associated_file__in_charge__cached_label__iexact'
),
'associated_file__permit_reference': SearchAltName(
- pgettext_lazy("key for text search", u"file-permit-reference"),
+ pgettext_lazy("key for text search", "file-permit-reference"),
'associated_file__permit_reference__iexact'
),
'treatment__name': SearchAltName(
- pgettext_lazy("key for text search", u"treatment-name"),
+ pgettext_lazy("key for text search", "treatment-name"),
'treatment__label__icontains'
),
'treatment__other_reference': SearchAltName(
- pgettext_lazy("key for text search", u"treatment-reference"),
+ pgettext_lazy("key for text search", "treatment-reference"),
'treatment__other_reference__icontains'
),
'treatment__year': SearchAltName(
- pgettext_lazy("key for text search", u"treatment-year"),
+ pgettext_lazy("key for text search", "treatment-year"),
'treatment__year'
),
'treatment__index': SearchAltName(
- pgettext_lazy("key for text search", u"treatment-index"),
+ pgettext_lazy("key for text search", "treatment-index"),
'treatment__index'
),
'treatment__treatment_types': SearchAltName(
- pgettext_lazy("key for text search", u"treatment-type"),
+ pgettext_lazy("key for text search", "treatment-type"),
'treatment__treatment_types__label__iexact'
),
'treatment_file__name': SearchAltName(
- pgettext_lazy("key for text search", u"treatment-file-name"),
+ pgettext_lazy("key for text search", "treatment-file-name"),
'treatment_file__name__icontains'
),
'treatment_file__internal_reference': SearchAltName(
- pgettext_lazy("key for text search", u"treatment-file-reference"),
+ pgettext_lazy("key for text search", "treatment-file-reference"),
'treatment_file__internal_reference__icontains'
),
'treatment_file__year': SearchAltName(
- pgettext_lazy("key for text search", u"treatment-file-year"),
+ pgettext_lazy("key for text search", "treatment-file-year"),
'treatment_file__year'
),
'treatment_file__index': SearchAltName(
- pgettext_lazy("key for text search", u"treatment-file-index"),
+ pgettext_lazy("key for text search", "treatment-file-index"),
'treatment_file__index'
),
'treatment_file__type': SearchAltName(
- pgettext_lazy("key for text search", u"treatment-file-type"),
+ pgettext_lazy("key for text search", "treatment-file-type"),
'treatment_file__type__label__iexact'
),
}
@@ -1837,95 +1837,95 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
}
# fields
- act_type = models.ForeignKey(ActType, verbose_name=_(u"Act type"))
+ act_type = models.ForeignKey(ActType, verbose_name=_("Act type"))
in_charge = models.ForeignKey(
Person, blank=True, null=True,
related_name='adminact_operation_in_charge',
- verbose_name=_(u"Person in charge of the operation"),
+ verbose_name=_("Person in charge of the operation"),
on_delete=models.SET_NULL,)
- index = models.IntegerField(verbose_name=_(u"Index"), blank=True,
+ index = models.IntegerField(verbose_name=_("Index"), blank=True,
null=True)
operator = models.ForeignKey(
Organization, blank=True, null=True,
- verbose_name=_(u"Archaeological preventive operator"),
+ verbose_name=_("Archaeological preventive operator"),
related_name='adminact_operator', on_delete=models.SET_NULL)
scientist = models.ForeignKey(
Person, blank=True, null=True,
related_name='adminact_scientist', on_delete=models.SET_NULL,
- verbose_name=_(u"Scientist in charge"))
+ verbose_name=_("Scientist in charge"))
signatory = models.ForeignKey(
Person, blank=True, null=True, related_name='signatory',
- verbose_name=_(u"Signatory"), on_delete=models.SET_NULL,)
+ verbose_name=_("Signatory"), on_delete=models.SET_NULL,)
operation = models.ForeignKey(
Operation, blank=True, null=True,
- related_name='administrative_act', verbose_name=_(u"Operation"))
+ related_name='administrative_act', verbose_name=_("Operation"))
associated_file = models.ForeignKey(
'archaeological_files.File',
blank=True, null=True,
related_name='administrative_act',
- verbose_name=_(u"Archaeological file"))
+ verbose_name=_("Archaeological file"))
treatment_file = models.ForeignKey(
'archaeological_finds.TreatmentFile',
blank=True, null=True,
related_name='administrative_act',
- verbose_name=_(u"Treatment request"))
+ verbose_name=_("Treatment request"))
treatment = models.ForeignKey(
'archaeological_finds.Treatment',
blank=True, null=True,
related_name='administrative_act',
- verbose_name=_(u"Treatment"))
- signature_date = models.DateField(_(u"Signature date"), blank=True,
+ verbose_name=_("Treatment"))
+ signature_date = models.DateField(_("Signature date"), blank=True,
null=True)
- year = models.IntegerField(_(u"Year"), blank=True, null=True)
- act_object = models.TextField(_(u"Object"), max_length=300, blank=True,
+ year = models.IntegerField(_("Year"), blank=True, null=True)
+ act_object = models.TextField(_("Object"), max_length=300, blank=True,
null=True)
if settings.COUNTRY == 'fr':
- ref_sra = models.CharField(u"Référence SRA", max_length=15,
+ ref_sra = models.CharField("Référence SRA", max_length=15,
blank=True, null=True)
departments_label = models.TextField(
- _(u"Departments"), blank=True, null=True,
- help_text=_(u"Cached values get from associated departments"))
+ _("Departments"), blank=True, null=True,
+ help_text=_("Cached values get from associated departments"))
towns_label = models.TextField(
- _(u"Towns"), blank=True, null=True,
- help_text=_(u"Cached values get from associated towns"))
+ _("Towns"), blank=True, null=True,
+ help_text=_("Cached values get from associated towns"))
history = HistoricalRecords()
_prefix = 'adminact_'
class Meta:
ordering = ('year', 'signature_date', 'index', 'act_type')
- verbose_name = _(u"Administrative act")
- verbose_name_plural = _(u"Administrative acts")
+ verbose_name = _("Administrative act")
+ verbose_name_plural = _("Administrative acts")
permissions = (
("view_administrativeact",
- u"Can view all Administrative acts"),
+ "Can view all Administrative acts"),
("view_own_administrativeact",
- u"Can view own Administrative act"),
+ "Can view own Administrative act"),
("add_own_administrativeact",
- u"Can add own Administrative act"),
+ "Can add own Administrative act"),
("change_own_administrativeact",
- u"Can change own Administrative act"),
+ "Can change own Administrative act"),
("delete_own_administrativeact",
- u"Can delete own Administrative act"),
+ "Can delete own Administrative act"),
)
- def __unicode__(self):
+ def __str__(self):
return settings.JOINT.join(
- [unicode(item) for item in [
+ [str(item) for item in [
self.related_item, self.act_object]
if item])
- full_ref_lbl = _(u"Ref.")
+ full_ref_lbl = _("Ref.")
@property
def full_ref(self):
lbl = []
if self.year:
- lbl.append(unicode(self.year))
+ lbl.append(str(self.year))
if self.index:
- lbl.append(u"n°%d" % self.index)
+ lbl.append("n°%d" % self.index)
if settings.COUNTRY == 'fr' and self.ref_sra:
- lbl.append(u"[%s]" % self.ref_sra)
- return u" ".join(lbl)
+ lbl.append("[%s]" % self.ref_sra)
+ return " ".join(lbl)
@property
def associated_filename(self):
@@ -1960,11 +1960,11 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
@classmethod
def _get_department_code(cls, value):
if not settings.ISHTAR_DPTS:
- return u""
+ return ""
for k, v in settings.ISHTAR_DPTS:
if v.lower() == value:
return k
- return u""
+ return ""
@property
def related_item(self):
@@ -1989,14 +1989,13 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
def get_filename(self):
filename = self.related_item.associated_filename
- filename = u"-".join(filename.split('-')[:-1]) # remove date
+ filename = "-".join(filename.split('-')[:-1]) # remove date
if self.act_type.code:
- filename += u"-" + self.act_type.code
+ filename += "-" + self.act_type.code
if self.signature_date and self.index:
- filename += u"-%d-%d" % (self.signature_date.year,
- self.index)
+ filename += "-%d-%d" % (self.signature_date.year, self.index)
if self.signature_date:
- filename += u"-" + self.signature_date.strftime('%Y%m%d')
+ filename += "-" + self.signature_date.strftime('%Y%m%d')
return filename
def publish(self, template_pk=None):
@@ -2027,8 +2026,8 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
conflict = conflict.exclude(pk=self.pk)
if conflict.count():
if self.pk:
- raise ValidationError(_(u"This index already exists for "
- u"this year"))
+ raise ValidationError(_("This index already exists for "
+ "this year"))
else:
self._get_index()
@@ -2044,8 +2043,8 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
def save(self, *args, **kwargs):
if settings.COUNTRY == 'fr':
self.departments_label = self.departments
- self.towns_label = u", ".join(
- list(sorted([unicode(town) for town in self.towns])))
+ self.towns_label = ", ".join(
+ list(sorted([str(town) for town in self.towns])))
force = False
if 'force' in kwargs:
@@ -2102,41 +2101,41 @@ class Parcel(LightHistorizedItem):
associated_file = models.ForeignKey(
'archaeological_files.File',
- related_name='parcels', verbose_name=_(u"File"),
+ related_name='parcels', verbose_name=_("File"),
blank=True, null=True, on_delete=models.SET_NULL)
operation = models.ForeignKey(
Operation, related_name='parcels', blank=True, null=True,
- verbose_name=_(u"Operation"), on_delete=models.SET_NULL)
- year = models.IntegerField(_(u"Year"), blank=True, null=True)
+ verbose_name=_("Operation"), on_delete=models.SET_NULL)
+ year = models.IntegerField(_("Year"), blank=True, null=True)
town = models.ForeignKey(Town, related_name='parcels',
- verbose_name=_(u"Town"))
- section = models.CharField(_(u"Section"), max_length=4,
+ verbose_name=_("Town"))
+ section = models.CharField(_("Section"), max_length=4,
null=True, blank=True)
- parcel_number = models.CharField(_(u"Parcel number"), max_length=6,
+ parcel_number = models.CharField(_("Parcel number"), max_length=6,
null=True, blank=True)
- public_domain = models.BooleanField(_(u"Public domain"), default=False)
- external_id = models.CharField(_(u"External ID"), max_length=100,
+ public_domain = models.BooleanField(_("Public domain"), default=False)
+ external_id = models.CharField(_("External ID"), max_length=100,
null=True, blank=True)
auto_external_id = models.BooleanField(
- _(u"External ID is set automatically"), default=False)
- address = models.TextField(_(u"Address - Locality"), null=True, blank=True)
- cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
+ _("External ID is set automatically"), default=False)
+ address = models.TextField(_("Address - Locality"), null=True, blank=True)
+ cached_label = models.TextField(_("Cached name"), null=True, blank=True,
db_index=True)
class Meta:
- verbose_name = _(u"Parcel")
- verbose_name_plural = _(u"Parcels")
+ verbose_name = _("Parcel")
+ verbose_name_plural = _("Parcels")
ordering = ('year', 'section', 'parcel_number')
@property
def short_label(self):
- items = [unicode(item) for item in [self.section, self.parcel_number]
+ items = [str(item) for item in [self.section, self.parcel_number]
if item]
if self.public_domain:
- items.append(unicode(_(u"Public domain")))
+ items.append(str(_("Public domain")))
return settings.JOINT.join(items)
- def __unicode__(self):
+ def __str__(self):
return self.short_label
def natural_key(self):
@@ -2173,8 +2172,8 @@ class Parcel(LightHistorizedItem):
def _generate_cached_label(self):
if self.public_domain:
- return u"DP"
- return u"{}{}".format(self.section or u"", self.parcel_number or u"")
+ return "DP"
+ return "{}{}".format(self.section or "", self.parcel_number or "")
@classmethod
def grouped_parcels(cls, parcels):
@@ -2189,12 +2188,12 @@ class Parcel(LightHistorizedItem):
grouped[-1].parcel_numbers = []
nb = ""
if parcel.parcel_number:
- nb = u"0" * (12 - len(parcel.parcel_number)) + \
+ nb = "0" * (12 - len(parcel.parcel_number)) + \
parcel.parcel_number
if parcel.public_domain:
if nb:
nb += " "
- nb += unicode(_(u"Public domain"))
+ nb += str(_("Public domain"))
grouped[-1].parcel_numbers.append(nb)
grouped[-1].parcel_numbers.sort()
grouped[-1].parcel_numbers = [strip_zero(n)
@@ -2207,25 +2206,25 @@ class Parcel(LightHistorizedItem):
res = ''
c_town, c_section = '', ''
for idx, parcels in enumerate(parcels):
- if c_town != unicode(parcels.town):
- c_town = unicode(parcels.town)
+ if c_town != str(parcels.town):
+ c_town = str(parcels.town)
c_section = ''
if idx:
res += " ; "
- res += unicode(parcels.town) + u' : '
+ res += str(parcels.town) + u' : '
if c_section:
- res += u" / "
+ res += " / "
c_section = parcels.section
res += parcels.section + u' '
- res += u", ".join(parcels.parcel_numbers)
+ res += ", ".join(parcels.parcel_numbers)
if parcels.year:
- res += " (%s)" % unicode(parcels.year)
+ res += " (%s)" % str(parcels.year)
return res
def long_label(self):
- items = [unicode(self.operation) or
- unicode(self.associated_file) or ""]
- items += [unicode(item) for item in [self.section, self.parcel_number]
+ items = [str(self.operation) or
+ str(self.associated_file) or ""]
+ items += [str(item) for item in [self.section, self.parcel_number]
if item]
return settings.JOINT.join(items)
@@ -2334,18 +2333,18 @@ post_save.connect(parcel_post_save, sender=Parcel)
class ParcelOwner(LightHistorizedItem):
- owner = models.ForeignKey(Person, verbose_name=_(u"Owner"),
+ owner = models.ForeignKey(Person, verbose_name=_("Owner"),
related_name="parcel_owner")
- parcel = models.ForeignKey(Parcel, verbose_name=_(u"Parcel"),
+ parcel = models.ForeignKey(Parcel, verbose_name=_("Parcel"),
related_name='owners')
- start_date = models.DateField(_(u"Start date"))
- end_date = models.DateField(_(u"End date"))
+ start_date = models.DateField(_("Start date"))
+ end_date = models.DateField(_("End date"))
class Meta:
- verbose_name = _(u"Parcel owner")
- verbose_name_plural = _(u"Parcel owners")
+ verbose_name = _("Parcel owner")
+ verbose_name_plural = _("Parcel owners")
- def __unicode__(self):
+ def __str__(self):
return "{}{}{}".format(self.owner, settings.JOINT, self.parcel)
@property
@@ -2377,13 +2376,13 @@ class OperationDashboard:
'closed': {'end_date__isnull': False}
}
filters_label = {
- 'recorded': _(u"Recorded"),
- 'effective': _(u"Effective"),
- 'active': _(u"Active"),
- 'field': _(u"Field completed"),
- 'documented': _(u"Associated report"),
- 'closed': _(u"Closed"),
- 'documented_closed': _(u"Documented and closed"),
+ 'recorded': _("Recorded"),
+ 'effective': _("Effective"),
+ 'active': _("Active"),
+ 'field': _("Field completed"),
+ 'documented': _("Associated report"),
+ 'closed': _("Closed"),
+ 'documented_closed': _("Documented and closed"),
}
self.filters_label = [filters_label[k] for k in self.filters_keys]
self.total = []
@@ -2485,7 +2484,7 @@ class OperationDashboard:
{'date': "date_trunc('month', start_date)"})
self.last_months = []
date = datetime.datetime(now.year, now.month, 1)
- for mt_idx in xrange(12):
+ for mt_idx in range(12):
self.last_months.append(date)
if date.month > 1:
date = datetime.datetime(date.year, date.month - 1, 1)
@@ -2783,7 +2782,7 @@ class OperationDashboard:
.order_by('-nb', 'town__name')[:10]
dct_res['towns'] = []
for r in query:
- dct_res['towns'].append((u"%s (%s)" % (r['town__name'],
+ dct_res['towns'].append(("%s (%s)" % (r['town__name'],
r['town__departement__number']),
r['nb']))
@@ -2797,7 +2796,7 @@ class OperationDashboard:
.order_by('-nb', 'town__name')[:10]
dct_res['towns_surface'] = []
for r in query:
- dct_res['towns_surface'].append((u"%s (%s)" % (
+ dct_res['towns_surface'].append(("%s (%s)" % (
r['town__name'], r['town__departement__number']),
r['nb']))
else:
@@ -2810,16 +2809,16 @@ class OperationDashboard:
.order_by('-nb', 'town__name')[:10]
dct_res['towns_cost'] = []
for r in query:
- dct_res['towns_cost'].append((u"%s (%s)" % (
+ dct_res['towns_cost'].append(("%s (%s)" % (
r['town__name'], r['town__departement__number']),
r['nb']))
class OperationTypeOld(GeneralType):
- order = models.IntegerField(_(u"Order"), default=1)
- preventive = models.BooleanField(_(u"Is preventive"), default=True)
+ order = models.IntegerField(_("Order"), default=1)
+ preventive = models.BooleanField(_("Is preventive"), default=True)
class Meta:
- verbose_name = _(u"Operation type old")
- verbose_name_plural = _(u"Operation types old")
+ verbose_name = _("Operation type old")
+ verbose_name_plural = _("Operation types old")
ordering = ['-preventive', 'order', 'label']