]> git.parisson.com Git - teleforma.git/commitdiff
fix no period, fix document.save
authorGuillaume Pellerin <yomguy@parisson.com>
Mon, 15 Jul 2013 08:10:20 +0000 (10:10 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Mon, 15 Jul 2013 08:10:20 +0000 (10:10 +0200)
teleforma/models/core.py
teleforma/views/core.py

index a3edc5695c388449ec66470d3bc52b9bee2e7e5b..ad4f4039f9b3dbb329425d1116b8ce68da35f303 100644 (file)
@@ -490,9 +490,10 @@ class Document(MediaBase):
         return  ' - '.join([unicode(self.course), unicode(types), self.title ])
 
     def save(self, **kwargs):
-        super(Document, self).save(**kwargs)
-        self.course.save()
+        if not self.is_annal:
+            self.course.save()
         self.set_mime_type()
+        super(Document, self).save(**kwargs)
 
     class Meta(MetaCore):
         db_table = app_label + '_' + 'document'
index e15a2f8c2a12b0af3e6f6cb5fe843ed722bd50e7..5366172b218717af4c46330672c5e2863bc8e045 100644 (file)
@@ -192,10 +192,11 @@ class PeriodAccessMixin(View):
 
     def get_context_data(self, **kwargs):
         context = super(PeriodAccessMixin, self).get_context_data(**kwargs)
-        period = Period.objects.filter(id=int(self.kwargs['period_id']))
-        if period:
-            self.period = period[0]
-        context['period'] = self.period
+        if 'period_id' in self.kwargs.keys():
+            period = Period.objects.filter(id=int(self.kwargs['period_id']))
+            if period:
+                self.period = period[0]
+            context['period'] = self.period
         return context
 
     def render_to_response(self, context):