Commit ae19851d authored by Patrick's avatar Patrick

Mptt - parler following the doc of parler

parent 0b91a36c
...@@ -26,6 +26,11 @@ class LUT_ProductionModeQuerySet(TranslatableQuerySet): ...@@ -26,6 +26,11 @@ class LUT_ProductionModeQuerySet(TranslatableQuerySet):
class LUT_ProductionModeManager(TreeManager, TranslatableManager): class LUT_ProductionModeManager(TreeManager, TranslatableManager):
queryset_class = LUT_ProductionModeQuerySet queryset_class = LUT_ProductionModeQuerySet
def get_queryset(self):
# This is the safest way to combine both get_queryset() calls
# supporting all Django versions and MPTT 0.7.x versions
return self.queryset_class(self.model, using=self._db).order_by(self.tree_id_attr, self.left_attr)
@python_2_unicode_compatible @python_2_unicode_compatible
class LUT_ProductionMode(MPTTModel, TranslatableModel): class LUT_ProductionMode(MPTTModel, TranslatableModel):
...@@ -43,7 +48,8 @@ class LUT_ProductionMode(MPTTModel, TranslatableModel): ...@@ -43,7 +48,8 @@ class LUT_ProductionMode(MPTTModel, TranslatableModel):
objects = LUT_ProductionModeManager() objects = LUT_ProductionModeManager()
def __str__(self): def __str__(self):
return self.short_name # return self.short_name
return self.safe_translation_getter('short_name', any_language=True)
class Meta: class Meta:
verbose_name = _("production mode") verbose_name = _("production mode")
...@@ -57,6 +63,11 @@ class LUT_DeliveryPointQuerySet(TranslatableQuerySet): ...@@ -57,6 +63,11 @@ class LUT_DeliveryPointQuerySet(TranslatableQuerySet):
class LUT_DeliveryPointManager(TreeManager, TranslatableManager): class LUT_DeliveryPointManager(TreeManager, TranslatableManager):
queryset_class = LUT_DeliveryPointQuerySet queryset_class = LUT_DeliveryPointQuerySet
def get_queryset(self):
# This is the safest way to combine both get_queryset() calls
# supporting all Django versions and MPTT 0.7.x versions
return self.queryset_class(self.model, using=self._db).order_by(self.tree_id_attr, self.left_attr)
@python_2_unicode_compatible @python_2_unicode_compatible
class LUT_DeliveryPoint(MPTTModel, TranslatableModel): class LUT_DeliveryPoint(MPTTModel, TranslatableModel):
...@@ -91,7 +102,8 @@ class LUT_DeliveryPoint(MPTTModel, TranslatableModel): ...@@ -91,7 +102,8 @@ class LUT_DeliveryPoint(MPTTModel, TranslatableModel):
objects = LUT_DeliveryPointManager() objects = LUT_DeliveryPointManager()
def __str__(self): def __str__(self):
return self.short_name # return self.short_name
return self.safe_translation_getter('short_name', any_language=True)
class Meta: class Meta:
verbose_name = _("delivery point") verbose_name = _("delivery point")
...@@ -105,19 +117,25 @@ class LUT_DepartmentForCustomerQuerySet(TranslatableQuerySet): ...@@ -105,19 +117,25 @@ class LUT_DepartmentForCustomerQuerySet(TranslatableQuerySet):
class LUT_DepartmentForCustomerManager(TreeManager, TranslatableManager): class LUT_DepartmentForCustomerManager(TreeManager, TranslatableManager):
queryset_class = LUT_DepartmentForCustomerQuerySet queryset_class = LUT_DepartmentForCustomerQuerySet
def get_queryset(self):
# This is the safest way to combine both get_queryset() calls
# supporting all Django versions and MPTT 0.7.x versions
return self.queryset_class(self.model, using=self._db).order_by(self.tree_id_attr, self.left_attr)
@python_2_unicode_compatible @python_2_unicode_compatible
class LUT_DepartmentForCustomer(MPTTModel, TranslatableModel): class LUT_DepartmentForCustomer(MPTTModel, TranslatableModel):
parent = TreeForeignKey('self', null=True, blank=True, related_name='children') parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
is_active = models.BooleanField(_("is_active"), default=True)
translations = TranslatedFields( translations = TranslatedFields(
short_name=models.CharField(_("short_name"), max_length=50, db_index=True, unique=True, default=EMPTY_STRING), short_name=models.CharField(_("short_name"), max_length=50, db_index=True, unique=True, default=EMPTY_STRING),
description=HTMLField(_("description"), configuration='CKEDITOR_SETTINGS_MODEL2', blank=True, default=EMPTY_STRING), description=HTMLField(_("description"), configuration='CKEDITOR_SETTINGS_MODEL2', blank=True, default=EMPTY_STRING),
) )
is_active = models.BooleanField(_("is_active"), default=True)
objects = LUT_ProductionModeManager() objects = LUT_ProductionModeManager()
def __str__(self): def __str__(self):
return self.short_name # return self.short_name
return self.safe_translation_getter('short_name', any_language=True)
class Meta: class Meta:
verbose_name = _("department for customer") verbose_name = _("department for customer")
...@@ -131,6 +149,11 @@ class LUT_PermanenceRoleQuerySet(TranslatableQuerySet): ...@@ -131,6 +149,11 @@ class LUT_PermanenceRoleQuerySet(TranslatableQuerySet):
class LUT_PermanenceRoleManager(TreeManager, TranslatableManager): class LUT_PermanenceRoleManager(TreeManager, TranslatableManager):
queryset_class = LUT_PermanenceRoleQuerySet queryset_class = LUT_PermanenceRoleQuerySet
def get_queryset(self):
# This is the safest way to combine both get_queryset() calls
# supporting all Django versions and MPTT 0.7.x versions
return self.queryset_class(self.model, using=self._db).order_by(self.tree_id_attr, self.left_attr)
@python_2_unicode_compatible @python_2_unicode_compatible
class LUT_PermanenceRole(MPTTModel, TranslatableModel): class LUT_PermanenceRole(MPTTModel, TranslatableModel):
...@@ -146,7 +169,8 @@ class LUT_PermanenceRole(MPTTModel, TranslatableModel): ...@@ -146,7 +169,8 @@ class LUT_PermanenceRole(MPTTModel, TranslatableModel):
objects = LUT_ProductionModeManager() objects = LUT_ProductionModeManager()
def __str__(self): def __str__(self):
return self.short_name # return self.short_name
return self.safe_translation_getter('short_name', any_language=True)
class Meta: class Meta:
verbose_name = _("permanence role") verbose_name = _("permanence role")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment