fix bugs on signals

This commit is contained in:
bkfox 2016-11-14 13:35:15 +01:00
parent 45268cd699
commit b8d6c435d2
103 changed files with 47 additions and 32 deletions

0
LICENSE Normal file → Executable file
View File

0
Manifest.in Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
__init__.py Normal file → Executable file
View File

0
aircox/README.md Normal file → Executable file
View File

View File

@ -81,7 +81,7 @@ class ProgramAdmin(NameableAdmin):
schedule.boolean = True
schedule.short_description = _("Schedule")
list_display = ('id', 'name', 'active', 'schedule', 'sync')
list_display = ('id', 'name', 'active', 'schedule', 'sync', 'station')
fields = NameableAdmin.fields + [ 'active', 'station','sync' ]
inlines = [ ScheduleInline, StreamInline ]

0
aircox/apps.py Normal file → Executable file
View File

0
aircox/connector.py Normal file → Executable file
View File

0
aircox/controllers.py Normal file → Executable file
View File

0
aircox/locale/fr/LC_MESSAGES/django.po Normal file → Executable file
View File

0
aircox/management/__init__.py Normal file → Executable file
View File

0
aircox/management/commands/__init__.py Normal file → Executable file
View File

0
aircox/management/commands/diffusions_monitor.py Normal file → Executable file
View File

0
aircox/management/commands/import_playlist.py Normal file → Executable file
View File

0
aircox/management/commands/sounds_monitor.py Normal file → Executable file
View File

0
aircox/management/commands/sounds_quality_check.py Normal file → Executable file
View File

0
aircox/management/commands/streamer.py Normal file → Executable file
View File

5
aircox/signals.py Normal file → Executable file
View File

@ -12,6 +12,7 @@ import aircox.utils as utils
@receiver(post_save, sender=models.Schedule)
def schedule_post_saved(sender, instance, created, *args, **kwargs):
# TODO: case instance.program has changed
if not instance.program.sync:
return
@ -19,8 +20,12 @@ def schedule_post_saved(sender, instance, created, *args, **kwargs):
if not initial or not instance.changed(['date','duration', 'frequency']):
return
if not initial.get('date') or not initial.get('duration') or not initial.get('frequency'):
return
# old schedule and timedelta
old_sched = models.Schedule(
program = instance.program,
date = initial['date'],
duration = initial['duration'],
frequency = initial['frequency'],

0
aircox/static/aircox/css/layout.css Normal file → Executable file
View File

0
aircox/templates/aircox/config/liquidsoap.liq Normal file → Executable file
View File

0
aircox/templates/aircox/controllers/base_site.html Normal file → Executable file
View File

0
aircox/templates/aircox/controllers/monitor.html Normal file → Executable file
View File

20
aircox/templates/aircox/controllers/stats.html Normal file → Executable file
View File

@ -1,12 +1,14 @@
{% extends "aircox/controllers/base_site.html" %}
{% extends "admin/base_site.html" %}
{# {% extends "aircox/controllers/base_site.html" %} #}
{% load i18n %}
{% block title %}
<h1>Statistics of the stations</h1>
{% trans "Statistics of the stations" %}
{% endblock %}
{% block content %}
<div id='stats'>
<div id='content'>
<h1>{% trans "Statistics of the stations" %}</h1>
{# TODO here #}
<form action="?" method="GET">
@ -58,10 +60,10 @@
{% endfor %}
<tr class="bottom">
<td>{{ stats.date|date:'d/m/Y' }}</td>
<td>{% trans "Total" %}</td>
<th>{{ stats.date|date:'d/m/Y' }}</th>
<th>{% trans "Total" %}</th>
{# TODO: translation block #}
<td>
<th>
{% with stats.items|length as items_count %}
{% with stats.count as tracks_count %}
{% blocktrans %}
@ -69,11 +71,11 @@
{% endblocktrans %}
{% endwith %}
{% endwith %}
</td>
<td>{% for tag, count, average in stats.tags %}
</th>
<th>{% for tag, count, average in stats.tags %}
<span>{{ tag }}: <b>{{ average|floatformat }}%</b> ({{ count }})<br>
{% endfor %}
</td>
</th>
</tr>
</table>
</section>

0
aircox/urls.py Normal file → Executable file
View File

0
aircox/utils.py Normal file → Executable file
View File

0
aircox_cms/__init__.py Normal file → Executable file
View File

0
aircox_cms/admin.py Normal file → Executable file
View File

0
aircox_cms/apps.py Normal file → Executable file
View File

0
aircox_cms/forms.py Normal file → Executable file
View File

0
aircox_cms/locale/fr/LC_MESSAGES/django.po Normal file → Executable file
View File

0
aircox_cms/management/commands/programs_to_cms.py Normal file → Executable file
View File

0
aircox_cms/models.py Normal file → Executable file
View File

31
aircox_cms/sections.py Normal file → Executable file
View 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
View 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
View File

0
aircox_cms/static/aircox_cms/css/layout.css Normal file → Executable file
View File

0
aircox_cms/static/aircox_cms/css/theme.css Normal file → Executable file
View File

0
aircox_cms/static/aircox_cms/images/LICENSE.TXT Normal file → Executable file
View File

0
aircox_cms/static/aircox_cms/images/README.md Normal file → Executable file
View File

0
aircox_cms/static/aircox_cms/images/add.png Normal file → Executable file
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

0
aircox_cms/static/aircox_cms/js/player.js Normal file → Executable file
View File

0
aircox_cms/static/aircox_cms/js/utils.js Normal file → Executable file
View File

0
aircox_cms/templates/aircox_cms/base_site.html Normal file → Executable file
View File

0
aircox_cms/templates/aircox_cms/dated_list_page.html Normal file → Executable file
View File

0
aircox_cms/templates/aircox_cms/diffusion_page.html Normal file → Executable file
View File

0
aircox_cms/templates/aircox_cms/dynamic_list_page.html Normal file → Executable file
View File

0
aircox_cms/templates/aircox_cms/event_page.html Normal file → Executable file
View File

0
aircox_cms/templates/aircox_cms/program_page.html Normal file → Executable file
View File

0
aircox_cms/templates/aircox_cms/publication.html Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

0
aircox_cms/templates/aircox_cms/snippets/comments.html Normal file → Executable file
View File

View File

View File

0
aircox_cms/templates/aircox_cms/snippets/list.html Normal file → Executable file
View File

View File

0
aircox_cms/templates/aircox_cms/snippets/player.html Normal file → Executable file
View File

View File

0
aircox_cms/templatetags/aircox_cms.py Normal file → Executable file
View File

0
aircox_cms/tests.py Normal file → Executable file
View File

0
aircox_cms/utils.py Normal file → Executable file
View File

0
aircox_cms/views.py Normal file → Executable file
View File

0
aircox_cms/wagtail_hooks.py Normal file → Executable file
View File

0
data/logo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
data/logo.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

0
docs/technicians.md Normal file → Executable file
View File

0
instance/__init__.py Normal file → Executable file
View File

1
instance/base_settings.py Normal file → Executable file
View File

@ -32,6 +32,7 @@ except:
# Application definition
INSTALLED_APPS = (
'jet',
'wagtail.wagtailforms',
'wagtail.wagtailredirects',
'wagtail.wagtailembeds',

0
instance/dev.py Normal file → Executable file
View File

0
instance/prod.py Normal file → Executable file
View File

0
instance/sample_settings.py Normal file → Executable file
View File

1
instance/urls.py Normal file → Executable file
View File

@ -26,6 +26,7 @@ import aircox.urls
urlpatterns = [
url(r'^jet/', include('jet.urls', 'jet')),
url(r'^admin/', include(admin.site.urls)),
url(r'^aircox/', include(aircox.urls.urls)),

0
instance/wsgi.py Normal file → Executable file
View File

0
notes.md Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More