Skip to content

Commit

Permalink
Self-review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemijRodionov committed Nov 3, 2018
1 parent e909cd7 commit 71b896d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion catalog/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def products(self):
products = (
products
.filter(tags__in=tags)
# See the catalog.context.products.ProductsByTags
# See the ProductQuerySet.tagged
# for detail about `distinct` and `order_by` above
.distinct(*self.get_undirected_sorting_options())
.order_by(*self.get_undirected_sorting_options())
Expand Down
5 changes: 1 addition & 4 deletions catalog/context/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
from .products import Products
from .tags import Tags

# @todo #183:120m Implement Template and PaginatedProducts context classes.
# @todo #183:120m Implement Page, PaginatedProducts, ProductBrands, ProductsImages context classes.
2 changes: 1 addition & 1 deletion catalog/context/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def context(self) -> typing.Dict[str, typing.Any]:

class Contexts(Context):

def __init__(self, contexts: typing.List[Context]):
def __init__(self, *contexts: typing.List[Context]):
self.contexts = contexts

def context(self):
Expand Down
4 changes: 2 additions & 2 deletions catalog/context/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.db.models import QuerySet

from catalog.context.context import Products, Tags, Category
from catalog.context.context import Products, Tags
from catalog.models import AbstractCategory


Expand All @@ -29,7 +29,7 @@ def qs(self):
def context(self):
return {
**super().context(),
'sorting_index': _sorting_index,
'sorting_index': self._sorting_index,
}


Expand Down
7 changes: 3 additions & 4 deletions catalog/context/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ class ParsedTags(Tags):

def __init__(self, tags: Tags, req_kwargs):
self._tags = tags
self._req_kwargs = req_kwargs
self._raw_tags = req_kwargs.get('tags')

def qs(self):
raw_tags = self._kwargs.get('tags')
if not raw_tags:
if not self._raw_tags:
self._tags.none()
return self._tags.parsed(raw_tags)
return self._tags.parsed(self._raw_tags)


class Checked404Tags(Tags):
Expand Down

0 comments on commit 71b896d

Please sign in to comment.