fix bugs on signals
0
aircox_cms/__init__.py
Normal file → Executable file
0
aircox_cms/admin.py
Normal file → Executable file
0
aircox_cms/apps.py
Normal file → Executable file
0
aircox_cms/forms.py
Normal file → Executable file
0
aircox_cms/locale/fr/LC_MESSAGES/django.po
Normal file → Executable file
0
aircox_cms/management/commands/programs_to_cms.py
Normal file → Executable file
0
aircox_cms/models.py
Normal file → Executable file
31
aircox_cms/sections.py
Normal file → Executable file
@ -202,13 +202,29 @@ class ListBase(models.Model):
|
||||
], heading=_('sorting'))
|
||||
]
|
||||
|
||||
def __get_related(self, qs):
|
||||
related = self.related and self.related.specific
|
||||
|
||||
if self.siblings:
|
||||
qs = qs.sibling_of(related)
|
||||
else:
|
||||
qs = qs.descendant_of(related)
|
||||
|
||||
date = related.date if hasattr(related, 'date') else \
|
||||
related.first_published_at
|
||||
if self.date_filter == self.DateFilter.before_related:
|
||||
qs = qs.filter(date__lt = date)
|
||||
elif self.date_filter == self.DateFilter.after_related:
|
||||
qs = qs.filter(date__gte = date)
|
||||
return qs
|
||||
|
||||
|
||||
def get_queryset(self):
|
||||
"""
|
||||
Get queryset based on the arguments. This class is intended to be
|
||||
reusable by other classes if needed.
|
||||
"""
|
||||
from aircox_cms.models import Publication
|
||||
related = self.related and self.related.specific
|
||||
|
||||
# model
|
||||
if self.model:
|
||||
@ -218,18 +234,9 @@ class ListBase(models.Model):
|
||||
qs = qs.live().not_in_menu()
|
||||
|
||||
# related
|
||||
if related:
|
||||
if self.siblings:
|
||||
qs = qs.sibling_of(related)
|
||||
else:
|
||||
qs = qs.descendant_of(related)
|
||||
if self.related:
|
||||
qs = self.__get_related(qs)
|
||||
|
||||
date = related.date if hasattr(related, 'date') else \
|
||||
related.first_published_at
|
||||
if self.date_filter == self.DateFilter.before_related:
|
||||
qs = qs.filter(date__lt = date)
|
||||
elif self.date_filter == self.DateFilter.after_related:
|
||||
qs = qs.filter(date__gte = date)
|
||||
# date
|
||||
date = tz.now()
|
||||
if self.date_filter == self.DateFilter.previous:
|
||||
|
19
aircox_cms/signals.py
Normal file → Executable file
@ -83,7 +83,7 @@ def station_post_saved(sender, instance, created, *args, **kwargs):
|
||||
section.add_item(sections.SectionList(
|
||||
count = 15,
|
||||
url_text = _('All programs'),
|
||||
model = ContentType.objects.get_for_model(ProgramPage),
|
||||
model = ContentType.objects.get_for_model(models.ProgramPage),
|
||||
related = programs,
|
||||
))
|
||||
|
||||
@ -131,12 +131,10 @@ def program_post_saved(sender, instance, created, *args, **kwargs):
|
||||
|
||||
@receiver(pre_delete, sender=aircox.Program)
|
||||
def program_post_deleted(sender, instance, *args, **kwargs):
|
||||
if not instance.page.count() or (
|
||||
instance.page.first().specific.body or
|
||||
Page.objects.descendant_of(instance).count()
|
||||
):
|
||||
return
|
||||
instance.page.delete()
|
||||
for page in instance.page.all():
|
||||
if page.specific.body or Page.objects.descendant_of(page).count():
|
||||
continue
|
||||
page.delete()
|
||||
|
||||
|
||||
@receiver(post_save, sender=aircox.Diffusion)
|
||||
@ -153,8 +151,9 @@ def diffusion_post_saved(sender, instance, created, *args, **kwargs):
|
||||
|
||||
@receiver(pre_delete, sender=aircox.Program)
|
||||
def diffusion_post_deleted(sender, instance, *args, **kwargs):
|
||||
if not instance.page.count() or instance.page.first().specific.body:
|
||||
return
|
||||
instance.page.delete()
|
||||
for page in instance.page.all():
|
||||
if page.specific.body or Page.objects.descendant_of(page).count():
|
||||
continue
|
||||
page.delete()
|
||||
|
||||
|
||||
|
0
aircox_cms/static/aircox_cms/css/cms.css
Normal file → Executable file
0
aircox_cms/static/aircox_cms/css/layout.css
Normal file → Executable file
0
aircox_cms/static/aircox_cms/css/theme.css
Normal file → Executable file
0
aircox_cms/static/aircox_cms/images/LICENSE.TXT
Normal file → Executable file
0
aircox_cms/static/aircox_cms/images/README.md
Normal file → Executable file
0
aircox_cms/static/aircox_cms/images/add.png
Normal file → Executable file
Before Width: | Height: | Size: 327 B After Width: | Height: | Size: 327 B |
0
aircox_cms/static/aircox_cms/images/clock.png
Normal file → Executable file
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
0
aircox_cms/static/aircox_cms/images/comments.png
Normal file → Executable file
Before Width: | Height: | Size: 701 B After Width: | Height: | Size: 701 B |
0
aircox_cms/static/aircox_cms/images/facebook.png
Normal file → Executable file
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 545 B |
0
aircox_cms/static/aircox_cms/images/feed.png
Normal file → Executable file
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
0
aircox_cms/static/aircox_cms/images/gplus.png
Normal file → Executable file
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
0
aircox_cms/static/aircox_cms/images/grow.png
Normal file → Executable file
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
0
aircox_cms/static/aircox_cms/images/home.png
Normal file → Executable file
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
0
aircox_cms/static/aircox_cms/images/list.png
Normal file → Executable file
Before Width: | Height: | Size: 391 B After Width: | Height: | Size: 391 B |
0
aircox_cms/static/aircox_cms/images/listen.png
Normal file → Executable file
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
0
aircox_cms/static/aircox_cms/images/loading.png
Normal file → Executable file
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
0
aircox_cms/static/aircox_cms/images/mail.png
Normal file → Executable file
Before Width: | Height: | Size: 952 B After Width: | Height: | Size: 952 B |
0
aircox_cms/static/aircox_cms/images/on_air.png
Normal file → Executable file
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
0
aircox_cms/static/aircox_cms/images/pause.png
Normal file → Executable file
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 311 B |
0
aircox_cms/static/aircox_cms/images/play.png
Normal file → Executable file
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
0
aircox_cms/static/aircox_cms/images/search.png
Normal file → Executable file
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
0
aircox_cms/static/aircox_cms/images/share.png
Normal file → Executable file
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
0
aircox_cms/static/aircox_cms/images/tiles_large.png
Normal file → Executable file
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 316 B |
0
aircox_cms/static/aircox_cms/images/tumblr.png
Normal file → Executable file
Before Width: | Height: | Size: 696 B After Width: | Height: | Size: 696 B |
0
aircox_cms/static/aircox_cms/images/twitter.png
Normal file → Executable file
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |