Update code

This commit is contained in:
Iacopo Spalletti 2016-06-05 22:50:26 +02:00
parent 3c4eebdd02
commit eab9083d90
No known key found for this signature in database
GPG key ID: BDCBC2EB289F60C6
3 changed files with 11 additions and 7 deletions

View file

@ -34,18 +34,17 @@ class Liveblog(AbstractText):
verbose_name_plural = _('liveblog entries')
def save(self, no_signals=False, *args, **kwargs):
if not self.pk:
self.position = 0
saved = super(Liveblog, self).save(*args, **kwargs)
if self.publish:
self.send()
order = CMSPlugin.objects.filter(placeholder=self.placeholder).order_by('placeholder', 'path').values_list('pk', flat=True)
order = CMSPlugin.objects.filter(placeholder=self.placeholder).order_by('placeholder', '-path').values_list('pk', flat=True)
reorder_plugins(self.placeholder, None, self.language, order)
return saved
@property
def liveblog_group(self):
post = Post.objects.language(self.language).filter(liveblog=self.placeholder).first()
if post:
return post.liveblog_group
def render(self):
@ -61,6 +60,7 @@ class Liveblog(AbstractText):
'creation_date': self.creation_date.strftime(DATE_FORMAT),
'changed_date': self.changed_date.strftime(DATE_FORMAT),
}
if self.liveblog_group:
Group(self.liveblog_group).send({
'text': json.dumps(notification),
})

View file

@ -21,6 +21,9 @@
</div>
{% endif %}
{% endspaceless %}
{% if view.liveblog_enabled %}
{% include "liveblog/includes/post_detail.html" %}
{% endif %}
{% if post.app_config.use_placeholder %}
<div class="blog-content">{% render_placeholder post.content %}</div>
{% else %}

View file

@ -58,6 +58,7 @@ class BaseBlogView(AppConfigMixin, ViewUrlMixin):
except ImportError:
return False
class BaseBlogListView(BaseBlogView):
context_object_name = 'post_list'
base_template_name = 'post_list.html'