-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import header | ||
|
||
__all__ = ['header'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django.conf import settings | ||
from django.db.models import Q | ||
|
||
from pages import models as pages_models | ||
from shopelectro import models | ||
|
||
|
||
def menu_qs() -> pages_models.PageQuerySet: | ||
return ( | ||
pages_models.Page.objects.active() | ||
.filter( | ||
Q(slug__in=settings.HEADER_LINKS['add']) | ||
& ~Q(slug__in=settings.HEADER_LINKS['exclude']) | ||
| ( | ||
# @todo #974:30m Optimize the header menu query. | ||
# Fetch catalog page for the header menu at the same query. | ||
# root category pages. | ||
Q(parent=pages_models.CustomPage.objects.filter(slug='catalog')) | ||
& Q(related_model_name=models.Category._meta.db_table) | ||
& Q(parent=pages_models.CustomPage.objects.filter(slug='catalog')) | ||
) | ||
) | ||
.order_by('position') | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.test import TestCase, override_settings, tag | ||
|
||
from shopelectro import models, logic | ||
|
||
|
||
@tag('fast') | ||
@override_settings(HEADER_LINKS={'exclude': [], 'add': []}) | ||
class HeaderMenu(TestCase): | ||
fixtures = ['dump.json'] | ||
|
||
def test_roots_are_presented(self): | ||
from_db = set(models.CategoryPage.objects.get_cached_trees()) | ||
from_logic = set(logic.header.menu_qs()) | ||
self.assertEqual(from_db, from_logic) |
4da0030
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
974-ceadb5de
discovered inshopelectro/templatetags/se_extras.py
and submitted as #980. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.4da0030
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
974-1680c064
discovered inshopelectro/logic/header.py
and submitted as #981. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.