]> git.0d.be Git - django-panik-nonstop.git/blobdiff - nonstop/views.py
add links to nonstop home, and handle permissions
[django-panik-nonstop.git] / nonstop / views.py
index 5c1bf3c33e16c06f795e9fb9bcc6f7d7a8bbbe52..376f33bd6b94d8c7af0097c3e8a39a39b75af83e 100644 (file)
@@ -69,6 +69,7 @@ class TrackDetailView(DetailView):
         return ctx
 
     def post(self, request, *args, **kwargs):
+        assert self.request.user.has_perm('nonstop.add_tracks')
         instance = self.get_object()
         old_nonstop_zones = copy.copy(instance.nonstop_zones.all())
         form = TrackMetaForm(request.POST, instance=instance)
@@ -171,6 +172,7 @@ class UploadTracksView(FormView):
     success_url = '.'
 
     def post(self, request, *args, **kwargs):
+        assert self.request.user.has_perm('nonstop.add_tracks')
         form_class = self.get_form_class()
         form = self.get_form(form_class)
         tracks = request.FILES.getlist('tracks')
@@ -228,6 +230,7 @@ class RecentTracksView(ListView):
         return Track.objects.exclude(creation_timestamp__isnull=True).order_by('-creation_timestamp')[:50]
 
     def post(self, request, *args, **kwargs):
+        assert self.request.user.has_perm('nonstop.add_tracks')
         for track_id in request.POST.getlist('track'):
             track = Track.objects.get(id=track_id)
             track.language = request.POST.get('lang-%s' % track_id, '')
@@ -302,6 +305,7 @@ class CleanupView(TemplateView):
         return ctx
 
     def post(self, request, *args, **kwargs):
+        assert self.request.user.has_perm('nonstop.add_tracks')
         count = 0
         for track_id in request.POST.getlist('track'):
             if request.POST.get('remove-%s' % track_id):