Commit 1c8a523a44f488f118f1fbba8accf505ebd1f60c
1 parent
b80fe06e
Exists in
master
and in
5 other branches
Fix'd [Issue:#404]
Showing
1 changed file
with
9 additions
and
5 deletions
Show diff stats
links/views.py
@@ -47,8 +47,12 @@ class CreateLink(LoginRequiredMixin, HasRoleMixin, LogMixin, NotificationMixin, | @@ -47,8 +47,12 @@ class CreateLink(LoginRequiredMixin, HasRoleMixin, LogMixin, NotificationMixin, | ||
47 | self.object.topic = topic | 47 | self.object.topic = topic |
48 | self.object.save() | 48 | self.object.save() |
49 | self.link = Link.objects.get(slug = self.object.slug) | 49 | self.link = Link.objects.get(slug = self.object.slug) |
50 | - self.formato,self.baixado = get_images(self.link.link_url,self.link.slug) | ||
51 | - self.caminho = 'links/static/images/%s'%(self.link.slug)+'%s'%(self.formato) | 50 | + try: |
51 | + self.formato,self.baixado = get_images(self.link.link_url,self.link.slug) | ||
52 | + self.caminho = 'links/static/images/%s'%(self.link.slug)+'%s'%(self.formato) | ||
53 | + except Exception: | ||
54 | + self.baixado = False | ||
55 | + | ||
52 | 56 | ||
53 | super(CreateLink, self).createNotification(message="created a Link at "+ self.object.topic.name, actor=self.request.user, | 57 | super(CreateLink, self).createNotification(message="created a Link at "+ self.object.topic.name, actor=self.request.user, |
54 | resource_name=self.object.name, resource_link= reverse('course:view_topic', args=[self.object.topic.slug]), | 58 | resource_name=self.object.name, resource_link= reverse('course:view_topic', args=[self.object.topic.slug]), |
@@ -122,7 +126,7 @@ class DeleteLink(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DeleteView) | @@ -122,7 +126,7 @@ class DeleteLink(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DeleteView) | ||
122 | context['link'] = self.object | 126 | context['link'] = self.object |
123 | context["topic"] = self.object.topic | 127 | context["topic"] = self.object.topic |
124 | return context | 128 | return context |
125 | - | 129 | + |
126 | def get_success_url(self): | 130 | def get_success_url(self): |
127 | self.log_context['link_id'] = self.object.id | 131 | self.log_context['link_id'] = self.object.id |
128 | self.log_context['link_name'] = self.object.name | 132 | self.log_context['link_name'] = self.object.name |
@@ -231,7 +235,7 @@ class ViewLink(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DetailView): | @@ -231,7 +235,7 @@ class ViewLink(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DetailView): | ||
231 | context = {} | 235 | context = {} |
232 | link = Link.objects.get(slug = self.kwargs.get('slug')) | 236 | link = Link.objects.get(slug = self.kwargs.get('slug')) |
233 | context['link'] = link | 237 | context['link'] = link |
234 | - | 238 | + |
235 | self.log_context['link_id'] = link.id | 239 | self.log_context['link_id'] = link.id |
236 | self.log_context['link_name'] = link.name | 240 | self.log_context['link_name'] = link.name |
237 | self.log_context['topic_id'] = link.topic.id | 241 | self.log_context['topic_id'] = link.topic.id |
@@ -248,7 +252,7 @@ class ViewLink(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DetailView): | @@ -248,7 +252,7 @@ class ViewLink(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DetailView): | ||
248 | self.log_context['timestamp_start'] = str(int(time.time())) | 252 | self.log_context['timestamp_start'] = str(int(time.time())) |
249 | 253 | ||
250 | super(ViewLink, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | 254 | super(ViewLink, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) |
251 | - | 255 | + |
252 | return context | 256 | return context |
253 | 257 | ||
254 | def get_success_url(self): | 258 | def get_success_url(self): |