add Topik object, wrapper around Page
[django-panik-combo.git] / panikombo / views.py
index 7af24d7..a76ac84 100644 (file)
@@ -1,7 +1,10 @@
+from django.core.urlresolvers import reverse
 from django.db.models import Q
+from django.views.generic.edit import UpdateView
 import django_select2
 
 from emissions.models import SoundFile, Episode
+from .models import Topik
 
 class SoundFilesView(django_select2.views.Select2View):
     def get_results(self, request, terms, page, context):
@@ -30,3 +33,16 @@ class EpisodesView(django_select2.views.Select2View):
         return ('nil', False, ((x.id, fmt(x)) for x in queryset.select_related()))
 
 episodes = EpisodesView.as_view()
+
+
+class TopikEdit(UpdateView):
+    model = Topik
+
+    def get_form_class(self):
+        from .forms import TopikEditForm
+        return TopikEditForm
+
+    def get_success_url(self):
+        return reverse('combo-manager-page-view', kwargs={'pk': self.object.page.id})
+
+topik_edit = TopikEdit.as_view()