Skip to content
Snippets Groups Projects
Commit d5f4d261 authored by Albert Feghaly's avatar Albert Feghaly
Browse files

Allow missing fields in payload when uploading

parent 035680da
No related branches found
No related tags found
2 merge requests!111Populate /secure/my-sharegroups/ with the same groups that are available to a...,!110Resolve "Allow file upload through servlet with no dataset id"
......@@ -355,23 +355,25 @@ class DataFileUploadServletView(LoginRequiredMixin, ActivePageViewMixin, CreateV
def form_valid(self, form):
formcd = form.cleaned_data
uploaded_by = self.request.user.profile
if self.request.user.is_staff and form.cleaned_data.get('as_user'):
uploaded_by = form.cleaned_data.get('as_user')
if self.request.user.is_staff and formcd.get('as_user'):
uploaded_by = formcd.get('as_user')
file = DataFile(uploaded_by=uploaded_by,
file=self.request.FILES['file'])
if form.cleaned_data.get('annotations'):
file.annotations = form.cleaned_data['annotations']
if 'annotations' in formcd and formcd.get('annotations'):
file.annotations = formcd['annotations']
if form.cleaned_data.get('lab'):
file.lab = form.cleaned_data['lab']
if 'lab' in formcd and formcd.get('lab'):
file.lab = formcd['lab']
file.save()
dataset = form.cleaned_data.get('dataset')
if dataset:
if 'dataset' in formcd and formcd.get('dataset'):
dataset = formcd.get('dataset')
dataset.files.add(file)
dataset.save()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment