summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorErnesto Rico Schmidt <ernesto@ontolabs.com>2020-09-09 22:11:28 (GMT)
committerErnesto Rico Schmidt <ernesto@ontolabs.com>2020-09-09 22:11:28 (GMT)
commit4947b756d7fae0a8f1fb108e198e15b600e12da0 (patch)
tree601bf17385a86dab25d97e85ba149058cec155cd /program
parent45c7b5cd9b2c2d4c987372f391b6cc7d1922ae10 (diff)
Optimize imports. Format
Diffstat (limited to 'program')
-rw-r--r--program/admin.py11
-rw-r--r--program/forms.py2
-rw-r--r--program/models.py16
-rw-r--r--program/urls.py32
-rw-r--r--program/utils.py8
-rw-r--r--program/views.py3
6 files changed, 38 insertions, 34 deletions
diff --git a/program/admin.py b/program/admin.py
index 413531e..a5e266a 100644
--- a/program/admin.py
+++ b/program/admin.py
@@ -1,10 +1,10 @@
+from datetime import date, datetime, timedelta
+
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
-from models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Host, Note, ProgramSlot, Show, TimeSlot
-from forms import MusicFocusForm
-
-from datetime import date, datetime, timedelta
+from .forms import MusicFocusForm
+from .models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Host, Note, ProgramSlot, Show, TimeSlot
class ActivityFilter(admin.SimpleListFilter):
@@ -128,10 +128,12 @@ class ProgramSlotAdmin(admin.ModelAdmin):
else:
message = _("%s program slots were renewed until %s") % (renewed, until)
self.message_user(request, message)
+
renew.short_description = _("Renew selected program slots")
def get_show_name(self, obj):
return obj.show.name
+
get_show_name.admin_order_field = 'show'
get_show_name.short_description = "Show"
@@ -166,6 +168,7 @@ class ShowAdmin(admin.ModelAdmin):
return super(ShowAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
+
admin.site.register(BroadcastFormat, BroadcastFormatAdmin)
admin.site.register(MusicFocus, MusicFocusAdmin)
admin.site.register(ShowInformation, ShowInformationAdmin)
diff --git a/program/forms.py b/program/forms.py
index 9bfb7ad..97e5326 100644
--- a/program/forms.py
+++ b/program/forms.py
@@ -1,5 +1,5 @@
-from django.forms import ModelForm, ValidationError
from django.core.files.images import get_image_dimensions
+from django.forms import ModelForm, ValidationError
from program.models import MusicFocus, ShowInformation, ShowTopic
diff --git a/program/models.py b/program/models.py
index 8630b35..206aee5 100644
--- a/program/models.py
+++ b/program/models.py
@@ -1,17 +1,16 @@
+from datetime import date, datetime, time, timedelta
+
+from dateutil.relativedelta import relativedelta
+from dateutil.rrule import rrule
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist, ValidationError, MultipleObjectsReturned
-from django.urls import reverse
from django.db import models
from django.db.models import Q
+from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
-
from tinymce import models as tinymce_models
-from datetime import date, datetime, time, timedelta
-from dateutil.relativedelta import relativedelta
-from dateutil.rrule import rrule
-
-from utils import get_automation_id_choices
+from .utils import get_automation_id_choices
class BroadcastFormat(models.Model):
@@ -234,7 +233,8 @@ class Show(models.Model):
hosts = models.ManyToManyField(Host, blank=True, related_name='shows', verbose_name=_("Hosts"))
owners = models.ManyToManyField(User, blank=True, related_name='shows', verbose_name=_("Owners"))
broadcastformat = models.ForeignKey(BroadcastFormat, related_name='shows', verbose_name=_("Broadcast format"))
- showinformation = models.ManyToManyField(ShowInformation, blank=True, related_name='shows', verbose_name=_("Show information"))
+ showinformation = models.ManyToManyField(ShowInformation, blank=True, related_name='shows',
+ verbose_name=_("Show information"))
showtopic = models.ManyToManyField(ShowTopic, blank=True, related_name='shows', verbose_name=_("Show topic"))
musicfocus = models.ManyToManyField(MusicFocus, blank=True, related_name='shows', verbose_name=_("Music focus"))
name = models.CharField(_("Name"), max_length=255)
diff --git a/program/urls.py b/program/urls.py
index abd6543..d588a8c 100644
--- a/program/urls.py
+++ b/program/urls.py
@@ -1,27 +1,29 @@
+import os
+
from django.conf import settings
from django.conf.urls import url
from django.views.decorators.cache import cache_page
from django.views.static import serve
-import views
-import os
+from .views import DayScheduleView, WeekScheduleView, CurrentShowBoxView, HostListView, HostDetailView, RecommendationsListView, \
+ RecommendationsBoxView, ShowListView, ShowDetailView, TimeSlotDetailView, StylesView
PROGRAM_SITE_MEDIA = os.path.join(os.path.dirname(__file__), '../site_media')
urlpatterns = [
- url(r'^today/?$', views.DayScheduleView.as_view()),
- url(r'^week/?$', views.WeekScheduleView.as_view()),
- url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/?$', views.DayScheduleView.as_view()),
- url(r'^(?P<year>\d{4})/(?P<week>\d{1,2})/?$', views.WeekScheduleView.as_view()),
- url(r'^current_box/?$', cache_page(60)(views.CurrentShowBoxView.as_view())),
- url(r'^hosts/?$', views.HostListView.as_view()),
- url(r'^hosts/(?P<pk>\d+)/?$', views.HostDetailView.as_view(), name='host-detail'),
- url(r'^tips/?$', views.RecommendationsListView.as_view()),
- url(r'^tips_box/?$', views.RecommendationsBoxView.as_view()),
- url(r'^shows/?$', views.ShowListView.as_view()),
- url(r'^shows/(?P<slug>[\w-]+)/?$', views.ShowDetailView.as_view(), name='show-detail'),
- url(r'^(?P<pk>\d+)/?$', views.TimeSlotDetailView.as_view(), name='timeslot-detail'),
- url(r'^styles.css$', views.StylesView.as_view())
+ url(r'^today/?$', DayScheduleView.as_view()),
+ url(r'^week/?$', WeekScheduleView.as_view()),
+ url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/?$', DayScheduleView.as_view()),
+ url(r'^(?P<year>\d{4})/(?P<week>\d{1,2})/?$', WeekScheduleView.as_view()),
+ url(r'^current_box/?$', cache_page(60)(CurrentShowBoxView.as_view())),
+ url(r'^hosts/?$', HostListView.as_view()),
+ url(r'^hosts/(?P<pk>\d+)/?$', HostDetailView.as_view(), name='host-detail'),
+ url(r'^tips/?$', RecommendationsListView.as_view()),
+ url(r'^tips_box/?$', RecommendationsBoxView.as_view()),
+ url(r'^shows/?$', ShowListView.as_view()),
+ url(r'^shows/(?P<slug>[\w-]+)/?$', ShowDetailView.as_view(), name='show-detail'),
+ url(r'^(?P<pk>\d+)/?$', TimeSlotDetailView.as_view(), name='timeslot-detail'),
+ url(r'^styles.css$', StylesView.as_view())
]
if settings.DEBUG:
diff --git a/program/utils.py b/program/utils.py
index 1a81766..f38f6f3 100644
--- a/program/utils.py
+++ b/program/utils.py
@@ -1,10 +1,10 @@
-from django.conf import settings
-
+import bisect
import json
import urllib
-import bisect
-from os.path import join
from datetime import datetime, date, timedelta
+from os.path import join
+
+from django.conf import settings
def get_automation_id_choices():
diff --git a/program/views.py b/program/views.py
index f6fc7c7..0a4e0ad 100644
--- a/program/views.py
+++ b/program/views.py
@@ -8,9 +8,8 @@ from django.views.generic.base import TemplateView
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
-from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot, Host
-
from program.utils import tofirstdayinisoweek, get_cached_shows
+from .models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot, Host
class HostListView(ListView):