Compare commits

..

No commits in common. "4c69a332af81b387cff2f8d32e00e808d6f86f95" and "6efa5b7900dcbcb7d1462404102d68f1b44308bd" have entirely different histories.

3 changed files with 2 additions and 10 deletions

View file

@ -7,7 +7,6 @@ import lxml.html
from django.conf import settings from django.conf import settings
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.db import models from django.db import models
from django.db.models.functions import ExtractWeek, ExtractYear
from django.urls import reverse from django.urls import reverse
from django.utils.timesince import timesince from django.utils.timesince import timesince
@ -65,6 +64,7 @@ class Item(models.Model):
cal = now.date().isocalendar() cal = now.date().isocalendar()
monday = now.date() - timedelta(days=now.date().isocalendar().weekday - 1) monday = now.date() - timedelta(days=now.date().isocalendar().weekday - 1)
monday = timezone.datetime(monday.year, monday.month, monday.day, tzinfo=now.tzinfo) monday = timezone.datetime(monday.year, monday.month, monday.day, tzinfo=now.tzinfo)
print(monday)
first_post = qs.filter(published__gt=monday).first() first_post = qs.filter(published__gt=monday).first()
if first_post and first_post.published < now: if first_post and first_post.published < now:
week = qs.filter(published__gt=monday) week = qs.filter(published__gt=monday)
@ -76,11 +76,7 @@ class Item(models.Model):
else: else:
last_monday = monday - timedelta(days=7) last_monday = monday - timedelta(days=7)
week = qs.filter(published__gt=last_monday) week = qs.filter(published__gt=last_monday)
archive = (qs archive = qs.exclude(id__in=week)
.exclude(id__in=week)
.annotate(year=ExtractYear('published'))
.annotate(week=ExtractWeek('published'))
)
return week, archive return week, archive
def get_absolute_url(self): def get_absolute_url(self):

View file

@ -8,7 +8,6 @@ from django.conf import settings
from django.utils import timezone from django.utils import timezone
from ..signalbot import rpc from ..signalbot import rpc
from ..telegrambot import rpc as telegram_rpc
from ..celery import app from ..celery import app
from . import models from . import models

View file

@ -1,9 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
{% for item in items %} {% for item in items %}
{% ifchanged item.week %}
<h2>{{ item.year }} week {{ item.week }}</h2>
{% endifchanged %}
{% include "listitem.html" with item=item %} {% include "listitem.html" with item=item %}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}