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 | 47 | self.object.topic = topic |
48 | 48 | self.object.save() |
49 | 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 | 57 | super(CreateLink, self).createNotification(message="created a Link at "+ self.object.topic.name, actor=self.request.user, |
54 | 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 | 126 | context['link'] = self.object |
123 | 127 | context["topic"] = self.object.topic |
124 | 128 | return context |
125 | - | |
129 | + | |
126 | 130 | def get_success_url(self): |
127 | 131 | self.log_context['link_id'] = self.object.id |
128 | 132 | self.log_context['link_name'] = self.object.name |
... | ... | @@ -231,7 +235,7 @@ class ViewLink(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DetailView): |
231 | 235 | context = {} |
232 | 236 | link = Link.objects.get(slug = self.kwargs.get('slug')) |
233 | 237 | context['link'] = link |
234 | - | |
238 | + | |
235 | 239 | self.log_context['link_id'] = link.id |
236 | 240 | self.log_context['link_name'] = link.name |
237 | 241 | self.log_context['topic_id'] = link.topic.id |
... | ... | @@ -248,7 +252,7 @@ class ViewLink(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DetailView): |
248 | 252 | self.log_context['timestamp_start'] = str(int(time.time())) |
249 | 253 | |
250 | 254 | super(ViewLink, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) |
251 | - | |
255 | + | |
252 | 256 | return context |
253 | 257 | |
254 | 258 | def get_success_url(self): | ... | ... |