Compare commits
No commits in common. "ea0bde27e702b8235508e39eb53459610482c9c4" and "7f660c3db99325240e5d1fc6ecebe339273db804" have entirely different histories.
ea0bde27e7
...
7f660c3db9
2 changed files with 3 additions and 11 deletions
|
|
@ -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.core.exceptions import ValidationError
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.functions import ExtractWeek, ExtractYear
|
from django.db.models.functions import ExtractWeek, ExtractYear
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
@ -49,10 +48,6 @@ class Item(models.Model):
|
||||||
self.get_hue()
|
self.get_hue()
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def clean(self):
|
|
||||||
if '/m/' not in self.url:
|
|
||||||
raise ValidationError("You can only use mobile urls(/m/)")
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '%s (%s)' % (self.title, self.url)
|
return '%s (%s)' % (self.title, self.url)
|
||||||
|
|
||||||
|
|
@ -106,14 +101,12 @@ class Item(models.Model):
|
||||||
return week, archive
|
return week, archive
|
||||||
|
|
||||||
def get_week(self):
|
def get_week(self):
|
||||||
return int(self.published.strftime('%W')) if self.published else None
|
return int(self.published.strftime('%W'))
|
||||||
|
|
||||||
def get_year(self):
|
def get_year(self):
|
||||||
return int(self.published.strftime('%Y')) if self.published else None
|
return int(self.published.strftime('%Y'))
|
||||||
|
|
||||||
def get_monday(self):
|
def get_monday(self):
|
||||||
if not self.published:
|
|
||||||
return None
|
|
||||||
d = '%s-W%s' % (self.get_year(), self.get_week())
|
d = '%s-W%s' % (self.get_year(), self.get_week())
|
||||||
return datetime.strptime(d + '-1', "%Y-W%W-%w").strftime('%Y-%m-%d')
|
return datetime.strptime(d + '-1', "%Y-W%W-%w").strftime('%Y-%m-%d')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,9 @@ html, body {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
i, em {
|
i {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
header, footer {
|
header, footer {
|
||||||
max-width: 1000px;
|
max-width: 1000px;
|
||||||
padding-top: 16px;
|
padding-top: 16px;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue