We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
tests_selenium.py:976: Resurrect test `test_cart_page_open`
The puzzle `473-5159ab9c` from #473 has to be resolved:

https://github.com/fidals/shopelectro/blob/f7dc2793dc5c7eddb2e68a68368337d77ba3139e/shopelectro/tests/tests_selenium.py#L976-L976

The puzzle was created by duker33 on 08-Aug-18. 

Estimate: 15 minutes,     

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is _removed_ from the source code. Here is more about [PDD](http://www.yegor256.com/2009/03/04/pdd.html) and [about me](http://www.yegor256.com/2017/04/05/pdd-in-action.html).

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `shopelectro/models.py`
Content:
```
1 import random
2 import string
3 import typing
4 from uuid import uuid4
5 
6 from django.conf import settings
7 from django.db import models
8 from django.urls import reverse
9 from django.utils.translation import ugettext_lazy as _
10 import mptt
11 
12 from catalog import models as catalog_models
13 from ecommerce import models as ecommerce_models
14 from pages import models as pages_models
15 
16 
17 def randomize_slug(slug: str) -> str:
18     slug_hash = ''.join(
19         random.choices(string.ascii_lowercase, k=settings.SLUG_HASH_SIZE)
20     )
21     return f'{slug}_{slug_hash}'
22 
23 
24 class SECategoryQuerySet(catalog_models.CategoryQuerySet):
25     def get_categories_tree_with_pictures(self) -> 'SECategoryQuerySet':
26         categories_with_pictures = (
27             self
28             .filter(products__page__images__isnull=False)
29             .distinct()
30         )
31 
32         return categories_with_pictures.get_ancestors(include_self=True)
33 
34 
35 class SECategoryManager(
36     catalog_models.CategoryManager.from_queryset(SECategoryQuerySet)
37 ):
38     pass
39 
40 
41 class Category(catalog_models.AbstractCategory, pages_models.SyncPageMixin):
42 
43     objects = SECategoryManager()
44     uuid = models.UUIDField(default=uuid4, editable=False)
45 
46     @classmethod
47     def get_default_parent(cls):
48         return pages_models.CustomPage.objects.filter(slug='catalog').first()
49 
50     @property
51     def image(self):
52         products = self.products.all()
53         return products[0].image if products else None
54 
55     def get_absolute_url(self):
56         return reverse('category', args=(self.page.slug,))
57 
58 
59 class Product(catalog_models.AbstractProduct, pages_models.SyncPageMixin):
60 
61     # That's why we are needed to explicitly add objects manager here
62     # because of Django special managers behaviour.
63     # Se se#480 for details.
64     objects = catalog_models.ProductManager()
65 
66     category = models.ForeignKey(
67         Category,
68         on_delete=models.CASCADE,
69         null=True,
70         related_name='products',
71         verbose_name=_('category'),
72     )
73 
74     tags = models.ManyToManyField(
75         'Tag',
76         related_name='products',
77         blank=True,
78         verbose_name=_('tags'),
79     )
80 
81     vendor_code = models.SmallIntegerField(verbose_name=_('vendor_code'))
82     uuid = models.UUIDField(default=uuid4, editable=False)
83     purchase_price = models.FloatField(
84         default=0, verbose_name=_('purchase_price'))
85     wholesale_small = models.FloatField(
86         default=0, verbose_name=_('wholesale_small'))
87     wholesale_medium = models.FloatField(
88         default=0, verbose_name=_('wholesale_medium'))
89     wholesale_large = models.FloatField(
90         default=0, verbose_name=_('wholesale_large'))
91 
92     def get_absolute_url(self):
93         return reverse('product', args=(self.vendor_code,))
94 
95     @property
96     def average_rate(self):
97         """Return rounded to first decimal averaged rating."""
98         rating = self.product_feedbacks.aggregate(
99             avg=models.Avg('rating')).get('avg', 0)
100         return round(rating, 1)
101 
102     @property
103     def feedback_count(self):
104         return self.product_feedbacks.count()
105 
106     @property
107     def feedback(self):
108         return self.product_feedbacks.all().order_by('-date')
109 
110     def get_params(self):
111         return Tag.objects.filter_by_products([self]).get_group_tags_pairs()
112 
113     def get_brand_name(self) -> str:
114         brand: typing.Optional['Tag'] = Tag.objects.get_brands([self]).get(self)
115         return brand.name if brand else ''
116 
117 
118 class ProductFeedback(models.Model):
119     product = models.ForeignKey(
120         Product, on_delete=models.CASCADE, null=True,
121         related_name='product_feedbacks'
122     )
123 
124     date = models.DateTimeField(
125         auto_now=True, db_index=True, verbose_name=_('date'))
126     name = models.CharField(
127         max_length=255, db_index=True, verbose_name=_('name'))
128     rating = models.PositiveSmallIntegerField(
129         default=1, db_index=True, verbose_name=_('rating'))
130     dignities = models.TextField(
131         default='', blank=True, verbose_name=_('dignities'))
132     limitations = models.TextField(
133         default='', blank=True, verbose_name=_('limitations'))
134     general = models.TextField(
135         default='', blank=True, verbose_name=_('limitations'))
136 
137 
138 def _default_payment():
139     """Default payment option is first element of first tuple in options."""
140     assert settings.PAYMENT_OPTIONS[0][0], 'No payment options!'
141     return settings.PAYMENT_OPTIONS[0][0]
142 
143 
144 class Order(ecommerce_models.Order):
145     address = models.TextField(blank=True, default='')
146     payment_type = models.CharField(
147         max_length=255,
148         choices=settings.PAYMENT_OPTIONS,
149         default=_default_payment()
150     )
151     comment = models.TextField(blank=True, default='')
152     # total price - total purchase price
153     revenue = models.FloatField(default=0, null=True, verbose_name=_('revenue'))
154 
155     @property
156     def payment_type_name(self):
157         """Return name for an order's payment option."""
158         return next(
159             name for option, name in settings.PAYMENT_OPTIONS
160             if self.payment_type == option
161         )
162 
163     def set_positions(self, cart):
164         """
165         Save cart's state into Order instance.
166 
167         @todo #589:60m Create Cart model.
168          See details here: https://github.com/fidals/shopelectro/pull/590#discussion_r222544672
169         """
170         self.revenue = cart.total_revenue()
171         self.save()
172         for id_, position in cart:
173             self.positions.create(
174                 order=self,
175                 product_id=id_,
176                 vendor_code=position['vendor_code'],
177                 name=position['name'],
178                 price=position['price'],
179                 quantity=position['quantity'],
180             )
181         return self
182 
183 
184 class CategoryPage(pages_models.ModelPage):
185     """Create proxy model for Admin."""
186 
187     class Meta(pages_models.ModelPage.Meta):  # Ignore PycodestyleBear (E303)
188         proxy = True
189 
190     # noinspection PyTypeChecker
191     objects = pages_models.ModelPage.create_model_page_managers(Category)
192 
193 
194 class ProductPage(pages_models.ModelPage):
195     """Create proxy model for Admin."""
196 
197     class Meta(pages_models.ModelPage.Meta):  # Ignore PycodestyleBear (E303)
198         proxy = True
199 
200     # noinspection PyTypeChecker
201     objects = (
202         pages_models.ModelPage
203         .create_model_page_managers(Product)
204     )
205 
206 
207 class TagGroup(catalog_models.TagGroup):
208     pass
209 
210 
211 class TagQuerySet(catalog_models.TagQuerySet):
212     pass
213 
214 
215 class Tag(catalog_models.Tag):
216     group = models.ForeignKey(
217         TagGroup, on_delete=models.CASCADE, null=True, related_name='tags',
218     )
219
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/shopelectro/models.py b/shopelectro/models.py
--- a/shopelectro/models.py
+++ b/shopelectro/models.py
@@ -7,7 +7,6 @@
 from django.db import models
 from django.urls import reverse
 from django.utils.translation import ugettext_lazy as _
-import mptt
 
 from catalog import models as catalog_models
 from ecommerce import models as ecommerce_models

{"golden_diff": "diff --git a/shopelectro/models.py b/shopelectro/models.py\n--- a/shopelectro/models.py\n+++ b/shopelectro/models.py\n@@ -7,7 +7,6 @@\n from django.db import models\n from django.urls import reverse\n from django.utils.translation import ugettext_lazy as _\n-import mptt\n \n from catalog import models as catalog_models\n from ecommerce import models as ecommerce_models\n", "issue": "tests_selenium.py:976: Resurrect test `test_cart_page_open`\nThe puzzle `473-5159ab9c` from #473 has to be resolved:\n\nhttps://github.com/fidals/shopelectro/blob/f7dc2793dc5c7eddb2e68a68368337d77ba3139e/shopelectro/tests/tests_selenium.py#L976-L976\n\nThe puzzle was created by duker33 on 08-Aug-18. \n\nEstimate: 15 minutes,     \n\nIf you have any technical questions, don't ask me, submit new tickets instead. The task will be \"done\" when the problem is fixed and the text of the puzzle is _removed_ from the source code. Here is more about [PDD](http://www.yegor256.com/2009/03/04/pdd.html) and [about me](http://www.yegor256.com/2017/04/05/pdd-in-action.html).\n", "before_files": [{"content": "import random\nimport string\nimport typing\nfrom uuid import uuid4\n\nfrom django.conf import settings\nfrom django.db import models\nfrom django.urls import reverse\nfrom django.utils.translation import ugettext_lazy as _\nimport mptt\n\nfrom catalog import models as catalog_models\nfrom ecommerce import models as ecommerce_models\nfrom pages import models as pages_models\n\n\ndef randomize_slug(slug: str) -> str:\n    slug_hash = ''.join(\n        random.choices(string.ascii_lowercase, k=settings.SLUG_HASH_SIZE)\n    )\n    return f'{slug}_{slug_hash}'\n\n\nclass SECategoryQuerySet(catalog_models.CategoryQuerySet):\n    def get_categories_tree_with_pictures(self) -> 'SECategoryQuerySet':\n        categories_with_pictures = (\n            self\n            .filter(products__page__images__isnull=False)\n            .distinct()\n        )\n\n        return categories_with_pictures.get_ancestors(include_self=True)\n\n\nclass SECategoryManager(\n    catalog_models.CategoryManager.from_queryset(SECategoryQuerySet)\n):\n    pass\n\n\nclass Category(catalog_models.AbstractCategory, pages_models.SyncPageMixin):\n\n    objects = SECategoryManager()\n    uuid = models.UUIDField(default=uuid4, editable=False)\n\n    @classmethod\n    def get_default_parent(cls):\n        return pages_models.CustomPage.objects.filter(slug='catalog').first()\n\n    @property\n    def image(self):\n        products = self.products.all()\n        return products[0].image if products else None\n\n    def get_absolute_url(self):\n        return reverse('category', args=(self.page.slug,))\n\n\nclass Product(catalog_models.AbstractProduct, pages_models.SyncPageMixin):\n\n    # That's why we are needed to explicitly add objects manager here\n    # because of Django special managers behaviour.\n    # Se se#480 for details.\n    objects = catalog_models.ProductManager()\n\n    category = models.ForeignKey(\n        Category,\n        on_delete=models.CASCADE,\n        null=True,\n        related_name='products',\n        verbose_name=_('category'),\n    )\n\n    tags = models.ManyToManyField(\n        'Tag',\n        related_name='products',\n        blank=True,\n        verbose_name=_('tags'),\n    )\n\n    vendor_code = models.SmallIntegerField(verbose_name=_('vendor_code'))\n    uuid = models.UUIDField(default=uuid4, editable=False)\n    purchase_price = models.FloatField(\n        default=0, verbose_name=_('purchase_price'))\n    wholesale_small = models.FloatField(\n        default=0, verbose_name=_('wholesale_small'))\n    wholesale_medium = models.FloatField(\n        default=0, verbose_name=_('wholesale_medium'))\n    wholesale_large = models.FloatField(\n        default=0, verbose_name=_('wholesale_large'))\n\n    def get_absolute_url(self):\n        return reverse('product', args=(self.vendor_code,))\n\n    @property\n    def average_rate(self):\n        \"\"\"Return rounded to first decimal averaged rating.\"\"\"\n        rating = self.product_feedbacks.aggregate(\n            avg=models.Avg('rating')).get('avg', 0)\n        return round(rating, 1)\n\n    @property\n    def feedback_count(self):\n        return self.product_feedbacks.count()\n\n    @property\n    def feedback(self):\n        return self.product_feedbacks.all().order_by('-date')\n\n    def get_params(self):\n        return Tag.objects.filter_by_products([self]).get_group_tags_pairs()\n\n    def get_brand_name(self) -> str:\n        brand: typing.Optional['Tag'] = Tag.objects.get_brands([self]).get(self)\n        return brand.name if brand else ''\n\n\nclass ProductFeedback(models.Model):\n    product = models.ForeignKey(\n        Product, on_delete=models.CASCADE, null=True,\n        related_name='product_feedbacks'\n    )\n\n    date = models.DateTimeField(\n        auto_now=True, db_index=True, verbose_name=_('date'))\n    name = models.CharField(\n        max_length=255, db_index=True, verbose_name=_('name'))\n    rating = models.PositiveSmallIntegerField(\n        default=1, db_index=True, verbose_name=_('rating'))\n    dignities = models.TextField(\n        default='', blank=True, verbose_name=_('dignities'))\n    limitations = models.TextField(\n        default='', blank=True, verbose_name=_('limitations'))\n    general = models.TextField(\n        default='', blank=True, verbose_name=_('limitations'))\n\n\ndef _default_payment():\n    \"\"\"Default payment option is first element of first tuple in options.\"\"\"\n    assert settings.PAYMENT_OPTIONS[0][0], 'No payment options!'\n    return settings.PAYMENT_OPTIONS[0][0]\n\n\nclass Order(ecommerce_models.Order):\n    address = models.TextField(blank=True, default='')\n    payment_type = models.CharField(\n        max_length=255,\n        choices=settings.PAYMENT_OPTIONS,\n        default=_default_payment()\n    )\n    comment = models.TextField(blank=True, default='')\n    # total price - total purchase price\n    revenue = models.FloatField(default=0, null=True, verbose_name=_('revenue'))\n\n    @property\n    def payment_type_name(self):\n        \"\"\"Return name for an order's payment option.\"\"\"\n        return next(\n            name for option, name in settings.PAYMENT_OPTIONS\n            if self.payment_type == option\n        )\n\n    def set_positions(self, cart):\n        \"\"\"\n        Save cart's state into Order instance.\n\n        @todo #589:60m Create Cart model.\n         See details here: https://github.com/fidals/shopelectro/pull/590#discussion_r222544672\n        \"\"\"\n        self.revenue = cart.total_revenue()\n        self.save()\n        for id_, position in cart:\n            self.positions.create(\n                order=self,\n                product_id=id_,\n                vendor_code=position['vendor_code'],\n                name=position['name'],\n                price=position['price'],\n                quantity=position['quantity'],\n            )\n        return self\n\n\nclass CategoryPage(pages_models.ModelPage):\n    \"\"\"Create proxy model for Admin.\"\"\"\n\n    class Meta(pages_models.ModelPage.Meta):  # Ignore PycodestyleBear (E303)\n        proxy = True\n\n    # noinspection PyTypeChecker\n    objects = pages_models.ModelPage.create_model_page_managers(Category)\n\n\nclass ProductPage(pages_models.ModelPage):\n    \"\"\"Create proxy model for Admin.\"\"\"\n\n    class Meta(pages_models.ModelPage.Meta):  # Ignore PycodestyleBear (E303)\n        proxy = True\n\n    # noinspection PyTypeChecker\n    objects = (\n        pages_models.ModelPage\n        .create_model_page_managers(Product)\n    )\n\n\nclass TagGroup(catalog_models.TagGroup):\n    pass\n\n\nclass TagQuerySet(catalog_models.TagQuerySet):\n    pass\n\n\nclass Tag(catalog_models.Tag):\n    group = models.ForeignKey(\n        TagGroup, on_delete=models.CASCADE, null=True, related_name='tags',\n    )\n", "path": "shopelectro/models.py"}], "after_files": [{"content": "import random\nimport string\nimport typing\nfrom uuid import uuid4\n\nfrom django.conf import settings\nfrom django.db import models\nfrom django.urls import reverse\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom catalog import models as catalog_models\nfrom ecommerce import models as ecommerce_models\nfrom pages import models as pages_models\n\n\ndef randomize_slug(slug: str) -> str:\n    slug_hash = ''.join(\n        random.choices(string.ascii_lowercase, k=settings.SLUG_HASH_SIZE)\n    )\n    return f'{slug}_{slug_hash}'\n\n\nclass SECategoryQuerySet(catalog_models.CategoryQuerySet):\n    def get_categories_tree_with_pictures(self) -> 'SECategoryQuerySet':\n        categories_with_pictures = (\n            self\n            .filter(products__page__images__isnull=False)\n            .distinct()\n        )\n\n        return categories_with_pictures.get_ancestors(include_self=True)\n\n\nclass SECategoryManager(\n    catalog_models.CategoryManager.from_queryset(SECategoryQuerySet)\n):\n    pass\n\n\nclass Category(catalog_models.AbstractCategory, pages_models.SyncPageMixin):\n\n    objects = SECategoryManager()\n    uuid = models.UUIDField(default=uuid4, editable=False)\n\n    @classmethod\n    def get_default_parent(cls):\n        return pages_models.CustomPage.objects.filter(slug='catalog').first()\n\n    @property\n    def image(self):\n        products = self.products.all()\n        return products[0].image if products else None\n\n    def get_absolute_url(self):\n        return reverse('category', args=(self.page.slug,))\n\n\nclass Product(catalog_models.AbstractProduct, pages_models.SyncPageMixin):\n\n    # That's why we are needed to explicitly add objects manager here\n    # because of Django special managers behaviour.\n    # Se se#480 for details.\n    objects = catalog_models.ProductManager()\n\n    category = models.ForeignKey(\n        Category,\n        on_delete=models.CASCADE,\n        null=True,\n        related_name='products',\n        verbose_name=_('category'),\n    )\n\n    tags = models.ManyToManyField(\n        'Tag',\n        related_name='products',\n        blank=True,\n        verbose_name=_('tags'),\n    )\n\n    vendor_code = models.SmallIntegerField(verbose_name=_('vendor_code'))\n    uuid = models.UUIDField(default=uuid4, editable=False)\n    purchase_price = models.FloatField(\n        default=0, verbose_name=_('purchase_price'))\n    wholesale_small = models.FloatField(\n        default=0, verbose_name=_('wholesale_small'))\n    wholesale_medium = models.FloatField(\n        default=0, verbose_name=_('wholesale_medium'))\n    wholesale_large = models.FloatField(\n        default=0, verbose_name=_('wholesale_large'))\n\n    def get_absolute_url(self):\n        return reverse('product', args=(self.vendor_code,))\n\n    @property\n    def average_rate(self):\n        \"\"\"Return rounded to first decimal averaged rating.\"\"\"\n        rating = self.product_feedbacks.aggregate(\n            avg=models.Avg('rating')).get('avg', 0)\n        return round(rating, 1)\n\n    @property\n    def feedback_count(self):\n        return self.product_feedbacks.count()\n\n    @property\n    def feedback(self):\n        return self.product_feedbacks.all().order_by('-date')\n\n    def get_params(self):\n        return Tag.objects.filter_by_products([self]).get_group_tags_pairs()\n\n    def get_brand_name(self) -> str:\n        brand: typing.Optional['Tag'] = Tag.objects.get_brands([self]).get(self)\n        return brand.name if brand else ''\n\n\nclass ProductFeedback(models.Model):\n    product = models.ForeignKey(\n        Product, on_delete=models.CASCADE, null=True,\n        related_name='product_feedbacks'\n    )\n\n    date = models.DateTimeField(\n        auto_now=True, db_index=True, verbose_name=_('date'))\n    name = models.CharField(\n        max_length=255, db_index=True, verbose_name=_('name'))\n    rating = models.PositiveSmallIntegerField(\n        default=1, db_index=True, verbose_name=_('rating'))\n    dignities = models.TextField(\n        default='', blank=True, verbose_name=_('dignities'))\n    limitations = models.TextField(\n        default='', blank=True, verbose_name=_('limitations'))\n    general = models.TextField(\n        default='', blank=True, verbose_name=_('limitations'))\n\n\ndef _default_payment():\n    \"\"\"Default payment option is first element of first tuple in options.\"\"\"\n    assert settings.PAYMENT_OPTIONS[0][0], 'No payment options!'\n    return settings.PAYMENT_OPTIONS[0][0]\n\n\nclass Order(ecommerce_models.Order):\n    address = models.TextField(blank=True, default='')\n    payment_type = models.CharField(\n        max_length=255,\n        choices=settings.PAYMENT_OPTIONS,\n        default=_default_payment()\n    )\n    comment = models.TextField(blank=True, default='')\n    # total price - total purchase price\n    revenue = models.FloatField(default=0, null=True, verbose_name=_('revenue'))\n\n    @property\n    def payment_type_name(self):\n        \"\"\"Return name for an order's payment option.\"\"\"\n        return next(\n            name for option, name in settings.PAYMENT_OPTIONS\n            if self.payment_type == option\n        )\n\n    def set_positions(self, cart):\n        \"\"\"\n        Save cart's state into Order instance.\n\n        @todo #589:60m Create Cart model.\n         See details here: https://github.com/fidals/shopelectro/pull/590#discussion_r222544672\n        \"\"\"\n        self.revenue = cart.total_revenue()\n        self.save()\n        for id_, position in cart:\n            self.positions.create(\n                order=self,\n                product_id=id_,\n                vendor_code=position['vendor_code'],\n                name=position['name'],\n                price=position['price'],\n                quantity=position['quantity'],\n            )\n        return self\n\n\nclass CategoryPage(pages_models.ModelPage):\n    \"\"\"Create proxy model for Admin.\"\"\"\n\n    class Meta(pages_models.ModelPage.Meta):  # Ignore PycodestyleBear (E303)\n        proxy = True\n\n    # noinspection PyTypeChecker\n    objects = pages_models.ModelPage.create_model_page_managers(Category)\n\n\nclass ProductPage(pages_models.ModelPage):\n    \"\"\"Create proxy model for Admin.\"\"\"\n\n    class Meta(pages_models.ModelPage.Meta):  # Ignore PycodestyleBear (E303)\n        proxy = True\n\n    # noinspection PyTypeChecker\n    objects = (\n        pages_models.ModelPage\n        .create_model_page_managers(Product)\n    )\n\n\nclass TagGroup(catalog_models.TagGroup):\n    pass\n\n\nclass TagQuerySet(catalog_models.TagQuerySet):\n    pass\n\n\nclass Tag(catalog_models.Tag):\n    group = models.ForeignKey(\n        TagGroup, on_delete=models.CASCADE, null=True, related_name='tags',\n    )\n", "path": "shopelectro/models.py"}]}