Compare commits
No commits in common. "4c69a332af81b387cff2f8d32e00e808d6f86f95" and "6efa5b7900dcbcb7d1462404102d68f1b44308bd" have entirely different histories.
4c69a332af
...
6efa5b7900
3 changed files with 2 additions and 10 deletions
|
|
@ -7,7 +7,6 @@ import lxml.html
|
|||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
from django.db.models.functions import ExtractWeek, ExtractYear
|
||||
from django.urls import reverse
|
||||
from django.utils.timesince import timesince
|
||||
|
||||
|
|
@ -65,6 +64,7 @@ class Item(models.Model):
|
|||
cal = now.date().isocalendar()
|
||||
monday = now.date() - timedelta(days=now.date().isocalendar().weekday - 1)
|
||||
monday = timezone.datetime(monday.year, monday.month, monday.day, tzinfo=now.tzinfo)
|
||||
print(monday)
|
||||
first_post = qs.filter(published__gt=monday).first()
|
||||
if first_post and first_post.published < now:
|
||||
week = qs.filter(published__gt=monday)
|
||||
|
|
@ -76,11 +76,7 @@ class Item(models.Model):
|
|||
else:
|
||||
last_monday = monday - timedelta(days=7)
|
||||
week = qs.filter(published__gt=last_monday)
|
||||
archive = (qs
|
||||
.exclude(id__in=week)
|
||||
.annotate(year=ExtractYear('published'))
|
||||
.annotate(week=ExtractWeek('published'))
|
||||
)
|
||||
archive = qs.exclude(id__in=week)
|
||||
return week, archive
|
||||
|
||||
def get_absolute_url(self):
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from django.conf import settings
|
|||
from django.utils import timezone
|
||||
|
||||
from ..signalbot import rpc
|
||||
from ..telegrambot import rpc as telegram_rpc
|
||||
from ..celery import app
|
||||
from . import models
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
{% for item in items %}
|
||||
{% ifchanged item.week %}
|
||||
<h2>{{ item.year }} week {{ item.week }}</h2>
|
||||
{% endifchanged %}
|
||||
{% include "listitem.html" with item=item %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue