Repository: fidals/shopelectro

Issue:
Change imported objects prefix styles
Task origins [from this comment](https://github.com/fidals/shopelectro/pull/541#discussion_r212349277).

Rename `caTag` to CaTag or RfTag. Do this renaming for all over the code.

We have no either convention or linter rule about it.
But we have practiced for all over the code. Example from the same module:
`from ecommerce.models import Order as ecOrder`


Discussion:
Lowercase first letter seems good for me. Because it's module name. And modules are always not capitalized.

But rf seems as good idea for me.

So, i suggest this: `caTag` -> `rfTag`

@duker33 a class name [should be ](https://www.python.org/dev/peps/pep-0008/#class-names) started by uppercase letter
@artemiy312 , `rfTag` is variable name, if we want to be strict there :)
But "class *MyClass*" is class name.
We have pycodetyle linter on, and he says nothing about it.

But if we'll throw away this purity, i think RfTag is bad UX decision. When i see capitalized `Rf`, i'll think about refarm project as about last option. I can think about `roofed tag` or smth.
Lowercase `rf` says, that it's prefix, but not sensitive part of the class name
@artemiy312 , let's close this discussion
@duker33 
rfTag is not variable name. An imported class is still a class, so we should name it respectively. Show it:
```python
In [10]: from logging import StreamHandler

In [11]: from logging import StreamHandler as sh

In [12]: type(StreamHandler)
Out[12]: type

In [13]: type(sh)
Out[13]: type

In [14]: StreamHandler is sh
Out[14]: True
```

>i think RfTag is bad UX decision

If we import `RfSomething` from `refarm_site`, then it is definitely not `RoofedSomething`, isn't it?
And we are not talking about UX, but about code style for a class name, that has certain rules

I leave the right to choose for you :)
i think we'll just import parent modules and use them as prefixes

Resolving patch:
diff --git a/shopelectro/models.py b/shopelectro/models.py
--- a/shopelectro/models.py
+++ b/shopelectro/models.py
@@ -9,8 +9,8 @@
 from django.utils.translation import ugettext_lazy as _
 
 from catalog import models as catalog_models
-from ecommerce.models import Order as ecOrder
-from pages.models import CustomPage, ModelPage, Page, SyncPageMixin, PageManager, PageQuerySet
+from ecommerce import models as ecommerce_models
+from pages import models as pages_models
 
 
 def randomize_slug(slug: str) -> str:
@@ -31,11 +31,13 @@ def get_categories_tree_with_pictures(self) -> 'SECategoryQuerySet':
         return categories_with_pictures.get_ancestors(include_self=True)
 
 
-class SECategoryManager(catalog_models.CategoryManager.from_queryset(SECategoryQuerySet)):
+class SECategoryManager(
+    catalog_models.CategoryManager.from_queryset(SECategoryQuerySet)
+):
     pass
 
 
-class Category(catalog_models.AbstractCategory, SyncPageMixin):
+class Category(catalog_models.AbstractCategory, pages_models.SyncPageMixin):
 
     objects = SECategoryManager()
     # pages.models.Page.objects_ field. It has the same problem.
@@ -44,7 +46,7 @@ class Category(catalog_models.AbstractCategory, SyncPageMixin):
 
     @classmethod
     def get_default_parent(cls):
-        return CustomPage.objects.filter(slug='catalog').first()
+        return pages_models.CustomPage.objects.filter(slug='catalog').first()
 
     @property
     def image(self):
@@ -55,7 +57,7 @@ def get_absolute_url(self):
         return reverse('category', args=(self.page.slug,))
 
 
-class Product(catalog_models.AbstractProduct, SyncPageMixin):
+class Product(catalog_models.AbstractProduct, pages_models.SyncPageMixin):
 
     # That's why we are needed to explicitly add objects manager here
     # because of Django special managers behaviour.
@@ -140,7 +142,7 @@ def _default_payment():
     return settings.PAYMENT_OPTIONS[0][0]
 
 
-class Order(ecOrder):
+class Order(ecommerce_models.Order):
     address = models.TextField(blank=True, default='')
     payment_type = models.CharField(
         max_length=255,
@@ -180,22 +182,27 @@ def set_positions(self, cart):
         return self
 
 
-class CategoryPage(ModelPage):
+class CategoryPage(pages_models.ModelPage):
     """Create proxy model for Admin."""
 
-    class Meta(ModelPage.Meta):  # Ignore PycodestyleBear (E303)
+    class Meta(pages_models.ModelPage.Meta):  # Ignore PycodestyleBear (E303)
         proxy = True
 
-    objects = ModelPage.create_model_page_managers(Category)
+    # noinspection PyTypeChecker
+    objects = pages_models.ModelPage.create_model_page_managers(Category)
 
 
-class ProductPage(ModelPage):
+class ProductPage(pages_models.ModelPage):
     """Create proxy model for Admin."""
 
-    class Meta(ModelPage.Meta):  # Ignore PycodestyleBear (E303)
+    class Meta(pages_models.ModelPage.Meta):  # Ignore PycodestyleBear (E303)
         proxy = True
 
-    objects = ModelPage.create_model_page_managers(Product)
+    # noinspection PyTypeChecker
+    objects = (
+        pages_models.ModelPage
+        .create_model_page_managers(Product)
+    )
 
 
 class TagGroup(catalog_models.TagGroup):
@@ -212,20 +219,11 @@ class Tag(catalog_models.Tag):
     )
 
 
-class ExcludedModelTPageQuerySet(PageQuerySet):
+class ExcludedModelTPageQuerySet(pages_models.PageQuerySet):
     def exclude_type(self):
-        return self.exclude(type=Page.MODEL_TYPE)
-
-
-class ExcludedModelTPageManager(
-    models.Manager.from_queryset(ExcludedModelTPageQuerySet)
-):
-
-    def get_queryset(self):
-        return super().get_queryset().exclude_type()
+        return self.exclude(type=pages_models.Page.MODEL_TYPE)
 
 
-# @todo #rf169:30m Fix model.Manager bad inheritance
 #  Now we have this problem:
 #  ```
 #  In [2]: type(ExcludedModelTPage.objects.all())
@@ -234,9 +232,17 @@ def get_queryset(self):
 #  But should be `pages.models.PageQuerySet`.
 #  Or just rm all excluded staff
 #  in favor on direct excluded filter using.
-class ExcludedModelTPage(Page):
+class ExcludedModelTPageManager(
+    models.Manager.from_queryset(ExcludedModelTPageQuerySet)
+):
+
+    def get_queryset(self):
+        return super().get_queryset().exclude(type=pages_models.Page.MODEL_TYPE)
+
+
+class ExcludedModelTPage(pages_models.Page):
 
-    class Meta(Page.Meta):  # Ignore PycodestyleBear (E303)
+    class Meta(pages_models.Page.Meta):  # Ignore PycodestyleBear (E303)
         proxy = True
 
     objects = ExcludedModelTPageManager()


Test patch: