mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-17 21:48:02 +00:00
Handle export upload errors gracefully. Fixes issue #53
This commit is contained in:
@@ -816,12 +816,16 @@ class UploadLibravatarExportView(SuccessMessageMixin, FormView):
|
|||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
data = self.request.FILES['export_file']
|
data = self.request.FILES['export_file']
|
||||||
|
try:
|
||||||
items = libravatar_read_gzdata(data.read())
|
items = libravatar_read_gzdata(data.read())
|
||||||
# DEBUG print(items)
|
# DEBUG print(items)
|
||||||
return render(self.request, 'choose_libravatar_export.html', {
|
return render(self.request, 'choose_libravatar_export.html', {
|
||||||
'emails': items['emails'],
|
'emails': items['emails'],
|
||||||
'photos': items['photos'],
|
'photos': items['photos'],
|
||||||
})
|
})
|
||||||
|
except Exception as e:
|
||||||
|
messages.error(self.request, _('Unable to parse file: %s' % e))
|
||||||
|
return HttpResponseRedirect(reverse_lazy('upload_export'))
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(login_required, name='dispatch')
|
@method_decorator(login_required, name='dispatch')
|
||||||
|
|||||||
Reference in New Issue
Block a user