Frank Becker avatar Frank Becker committed 9b3c9c6

started in-show view

Comments (0)

Files changed (2)

src/submitter/urls.py

 from submitter.views import news_per_category, news_per_show, \
         news_entry_create_and_update, entry_category_create_and_update, \
         news_entry_as_json, news_entries_as_json, news_entries_per_show, \
-        penta_shows_as_json, news_per_next_show, print_news_per_show
+        penta_shows_as_json, news_per_next_show, print_news_per_show, InShowView
 from auth.generic import limited_delete_object
 from tagging.views import tagged_object_list
 from voting.views import vote_on_object
     (r'^news-per-show/(?P<show_slug>[-\w]+)/print$', print_news_per_show),
 )
 
+urlpatterns += patterns(
+    '',
+    url(r'^in-show/(?P<show_slug>[-\w]+)/$', InShowView.as_view(),
+        name="in_show_view"),
+    )
+
 # NewsCategory()
 category_entry_info_dict = dict(
     queryset=EntryCategory.objects.all(),

src/submitter/views.py

 from django.shortcuts import render_to_response, get_object_or_404, \
         get_list_or_404
 from django.views.generic import list_detail
+from django.views.generic import ListView
 from django.contrib.auth.decorators import login_required, user_passes_test
 from django.core import serializers
 from django.template import RequestContext
     "Return a list of shows that have a production_data later than now"
     return PentaShow.objects.filter(
         production_date__gte=datetime.datetime.now()).order_by(
-            'production_date')
+        'production_date')
+
+
+class InShowView(ListView):
+    """Return HTTP response of all NewsEntry() per PentaShow()
+    That will become the in show view. For now it's more or less
+    duplicated news_per_show as class based generic view
+    """
+    context_object_name = "object_list"
+
+    next_shows = get_next_shows()
+    if not next_shows:
+        raise Http404
+    penta_show = next_shows[0]
+    filters = {'show': penta_show, 'status': 1}
+    queryset = NewsEntry.objects.filter(**filters)
+    template_name = "submitter/in_show_list.html"
+
+    def get_context_data(self, **kwargs):
+        context = super(InShowView, self).get_context_data(**kwargs)
+        context['show'] = self.penta_show
+        context['count'] = NewsEntry.objects.filter(**self.filters).count()
+        context['tag_filters'] = self.filters
+
 
 def news_per_next_show(request):
     """Show all news for the upcoming pentaradio show
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.