2017-05-30 20:44:30 +02:00
|
|
|
from kfet.models import Article
|
|
|
|
|
|
|
|
|
2017-06-12 01:51:10 +02:00
|
|
|
def get_articles(request=None):
|
2017-05-30 20:44:30 +02:00
|
|
|
articles = (
|
2018-10-06 12:35:49 +02:00
|
|
|
Article.objects.filter(is_sold=True, hidden=False)
|
|
|
|
.select_related("category")
|
|
|
|
.order_by("category__name", "name")
|
2017-05-30 20:44:30 +02:00
|
|
|
)
|
|
|
|
pressions, others = [], []
|
|
|
|
for article in articles:
|
2018-10-06 12:35:49 +02:00
|
|
|
if article.category.name == "Pression":
|
2017-05-30 20:44:30 +02:00
|
|
|
pressions.append(article)
|
|
|
|
else:
|
|
|
|
others.append(article)
|
2018-10-06 12:35:49 +02:00
|
|
|
return {"pressions": pressions, "articles": others}
|