Permalink
Browse files

Intermediate commit

  • Loading branch information...
1 parent fe88871 commit b06f06e2b8fc20be4bc9a94e853e72614e4c4b21 @ostronom ostronom committed Jan 8, 2013
Showing with 43 additions and 3 deletions.
  1. +34 −2 zavtra/content/models.py
  2. +9 −1 zavtra/content/views.py
View
@@ -57,6 +57,11 @@ def zeitung_rubric(self):
zeitung = Rubric.fetch_rubric('zeitung')
return self.pk in map(lambda w: w.pk, zeitung)
+ @property
+ def wod_rubric(self):
+ wod = Rubric.fetch_rubric('wod')
+ return self.pk in map(lambda w: w.pk, wod)
+
@staticmethod
def fetch_rubric(slug):
def get_rubric():
@@ -135,6 +140,10 @@ def from_zeitung(self):
return self.rubric.zeitung_rubric
@property
+ def from_wod(self):
+ return self.rubric.wod_rubric
+
+ @property
def issue_number(self):
if self.from_zeitung:
pt = self.published_at.date()
@@ -166,7 +175,7 @@ def other_issue_articles(self):
@staticmethod
def get_current_issue_date_range():
- now = datetime.now().date() - 14 * oneday # DEBUG
+ now = datetime.now().date() - 28 * oneday # DEBUG
wstart = now - oneday*(now.weekday() + 5)
if now.weekday() >= 2:
wstart += 7*oneday
@@ -182,4 +191,27 @@ def get_current_issue_number():
def get_current_issue():
return Article.zeitung.\
filter(published_at__range = Article.get_current_issue_date_range()).\
- order_by('rubric__position','-published_at')
+ order_by('rubric__position','-published_at')
+
+
+class ExpertComment(models.Model):
+ expert = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=u'Эксперт')
+ article = models.ForeignKey(Article, verbose_name=u'Статья', related_name='expert_comments')
+ comment = models.TextField(verbose_name=u'Текст')
+ position = models.PositiveIntegerField(verbose_name=u'Позиция')
+
+ class Meta:
+ ordering = ['-position']
+ verbose_name = u'Комментарий эксперта'
+ verbose_name_plural = u'Комментарии экспертов'
+
+
+class DailyQuote(models.Model):
+ class Meta:
+ ordering = ['-day']
+ verbose_name = u'Цитата дня'
+ verbose_name_plural = u'Цитаты дня'
+
+ quote = models.TextField(verbose_name=u'Цитата')
+ source = models.ForeignKey(Article, verbose_name=u'Источник цитаты')
+ day = models.DateField(verbose_name=u'День', unique=True, default=lambda: datetime.now())
View
@@ -9,7 +9,13 @@
class ArticleView(DetailView):
- template_name = 'content/article_detail.jhtml'
+
+ @property
+ def template_name(self):
+ if self.object.from_wod:
+ return 'content/wod_article.jhtml'
+ else:
+ return 'content/article_detail.jhtml'
def get_queryset(self):
return Article.objects.select_related()
@@ -23,6 +29,8 @@ class RubricView(ListView):
def template_name(self):
if self.rubric.zeitung_rubric:
return 'content/zeitung_rubric_detail.jhtml'
+ elif self.rubric.wod_rubric:
+ return 'content/wod.jhtml'
else:
return 'content/site_rubric_detail.jhtml'

0 comments on commit b06f06e

Please sign in to comment.