Commit d391a43b authored by felix.herrmann's avatar felix.herrmann
Browse files

Merge branch '136-upload-process-wizard' into 'master'

Resolve "upload process wizard"

Closes #136

See merge request !231
parents f9cc6134 0012f268
......@@ -511,6 +511,7 @@ def edit_metadata(request, ds_uuid):
target = "Dataset Metadata"
manpage = get_man_page("edit-dataset-metadata")
ds = DataSet.objects.get(uuid=ds_uuid)
if ds.is_frozen():
if ds.pub_request_pending() and request.user in ds.get_curators():
pass
......@@ -521,6 +522,7 @@ def edit_metadata(request, ds_uuid):
return handler403(request)
ds_creators = DataSetCreator.objects.filter(dataset=ds)
next_url = request.session[str(ds_uuid) + "wp"]
if ds_creators.count() == 0:
extra = 1
......@@ -561,6 +563,9 @@ def edit_metadata(request, ds_uuid):
action.send(
request.user, verb="edited metadata of", target=ds,
)
if next_url:
return redirect(next_url)
else:
err = form.errors.as_data()
......@@ -588,6 +593,7 @@ def edit_metadata(request, ds_uuid):
"target": target,
"manpage": manpage,
"help_texts": help_texts,
"next_url": next_url,
},
)
......@@ -821,26 +827,13 @@ def edit_datafiles(request, ds_uuid):
return handler403(request)
manpage = get_man_page("manage-datafiles")
control_args = {
"title": "Files",
"type": "datafile",
"outer_panel": False,
"edit_url": "dddatasets:prep_edit_datafile",
"add_url": "dddatasets:prep_edit_datafile",
"list_url": "dddatasets:prep_edit_datafiles",
"delete_url": "dddatasets:prep_edit_datafile",
"object_id": ds.uuid,
"add_text": "Add new data file...",
"object_type": "datafile",
"object_text": "Add Datafiles",
"download_url": "dddatasets:datafile_download",
"objects": ds.get_datafiles(),
}
next_url = request.session[str(ds_uuid) + "wp"]
return render(
request,
"dddatasets/prep/dataset_edit_datafiles.html",
{"ds": ds, "control_args": control_args, "manpage": manpage},
{"ds": ds, "manpage": manpage, "next_url": next_url},
)
......@@ -870,6 +863,8 @@ def edit_datafile(request, ds_uuid, df_uuid=None):
if not check_perms("edit_dsmo", request.user, ds.dataset_management_object):
return handler403(request)
next_url = request.session[str(ds_uuid) + "wp"]
# DELETE
if request.method == "DELETE":
if not check_perms("edit_dsmo", request.user, ds.dataset_management_object):
......@@ -895,21 +890,27 @@ def edit_datafile(request, ds_uuid, df_uuid=None):
form = DataFileUploadForm(request.POST, request.FILES, instance=datafile)
if form.is_valid():
orig_name = datafile.file.name
filePath = handle_uploaded_file(datafile.file, df_uuid)
if request.FILES:
orig_name = datafile.file.name
filePath = handle_uploaded_file(datafile.file, df_uuid)
datafile.file = filePath
datafile.name = orig_name
datafile.data_file_type = form.cleaned_data["data_file_type"]
datafile.file = filePath
datafile.name = orig_name
datafile.save()
return edit_datafiles(request, ds_uuid)
return edit_datafiles(request, ds_uuid)
else:
updated = False
form_err = form.errors.as_data()
else:
# POST should always have an df_uuid
return edit_datafiles(request, ds_uuid)
else:
# Get
df_uuid = request.GET.get("df_uuid")
if df_uuid:
# Edit
datafile = DataFile.objects.get(uuid=df_uuid, dataset=ds)
form = DataFileUploadForm(instance=datafile)
else:
if not check_perms("edit_dsmo", request.user, ds.dataset_management_object):
......@@ -932,6 +933,7 @@ def edit_datafile(request, ds_uuid, df_uuid=None):
"updated": updated,
"ds_uuid": ds_uuid,
"df_uuid": df_uuid,
"next_url": next_url,
},
)
......@@ -1013,6 +1015,7 @@ def edit_publication(request, ds_uuid, ds_pub_uuid=None):
"user": request.user,
"form_err": form_err,
"updated": updated,
"next_url": request.session.get(str(ds_uuid) + "wp"),
},
)
......@@ -1056,7 +1059,12 @@ def edit_publications(request, ds_uuid):
return render(
request,
"dddatasets/prep/dataset_edit_publications.html",
{"ds": ds, "control_args": control_args, "manpage": manpage},
{
"ds": ds,
"control_args": control_args,
"manpage": manpage,
"next_url": request.session.get(str(ds_uuid) + "wp"),
},
)
......@@ -1109,6 +1117,7 @@ def edit_dsa(request, ds_uuid):
"user": request.user,
"form_err": form_err,
"updated": updated,
"next_url": request.session.get(str(ds_uuid) + "wp"),
},
)
......@@ -1149,7 +1158,12 @@ def edit_versions(request, ds_uuid):
return render(
request,
"dddatasets/prep/dataset_edit_versions.html",
{"ds": ds, "control_args": control_args, "manpage": manpage},
{
"ds": ds,
"control_args": control_args,
"manpage": manpage,
"next_url": request.session.get(str(ds_uuid) + "wp"),
},
)
......@@ -1230,6 +1244,8 @@ def edit_publish_check(request, ds_uuid):
if ds.is_frozen():
return redirect("dddatasets:prep_edit_versions", ds_uuid=ds.uuid,)
request.session[str(ds_uuid) + "wp"] = request.path
# validate dataset fields
errors = list()
try:
......@@ -1263,6 +1279,8 @@ def edit_publish_datafiles(request, ds_uuid):
if ds.is_frozen():
return redirect("dddatasets:prep_edit_versions", ds_uuid=ds.uuid,)
request.session[str(ds_uuid) + "wp"] = request.path
return render(
request,
"dddatasets/prep/_dataset_edit_publish_datafiles.html",
......@@ -1279,6 +1297,8 @@ def edit_publish_license(request, ds_uuid):
return HttpResponse(_("Access denied"))
# check_perms_403("admin_dataset", request.user, ds.dataset_management_object)
request.session[str(ds_uuid) + "wp"] = request.path
return render(
request,
"dddatasets/prep/_dataset_edit_publish_license.html",
......@@ -1296,6 +1316,8 @@ def edit_publish_copyright(request, ds_uuid):
# check_perms_403("admin_dataset", request.user, ds.dataset_management_object)
if ds.is_frozen():
return redirect("dddatasets:prep_edit_versions", ds_uuid=ds.uuid,)
request.session[str(ds_uuid) + "wp"] = request.path
copyright_declaration_page = get_man_page("dataset-copyright-declaration")
target = _("Dataset Copyright Declaration")
......@@ -1348,6 +1370,8 @@ def edit_publish_final_fetch(request, ds_uuid, task):
if ds.published:
return redirect("dddatasets:prep_edit_versions", ds_uuid=ds.uuid,)
request.session[str(ds_uuid) + "wp"] = request.path
if fetch(task):
messages.success(request, "Collection created successfully.")
isFetched = bool(fetch(task))
......@@ -1369,6 +1393,7 @@ def edit_publish_final_upload(request, ds_uuid):
return HttpResponse(_("Access denied"))
# check_perms_403("admin_dataset", request.user, ds.dataset_management_object)
request.session[str(ds_uuid) + "wp"] = request.path
# check if ds is published NOT frozen
if ds.published:
return redirect("dddatasets:prep_edit_versions", ds_uuid=ds.uuid,)
......@@ -1606,6 +1631,7 @@ def edit_publish_access(request, ds_uuid):
"manpage": manpage,
"search_type": search_type,
"form": form,
"next_url": request.session.get(str(ds_uuid) + "wp"),
},
)
......
......@@ -18,7 +18,9 @@
{% endblock comments %}
{% block sidebar%}{% endblock sidebar %}
{% endblock ic-content %}
......@@ -8,13 +8,19 @@
<div class="col-md-8">
<label>File*</label>
<div id="dropzone-{{ df_uuid }}" class="dropzone smallskip"></div>
{% if form.instance.id %}<p>{% trans "Attached file" %}: {{ form.instance }}</p>{% endif %}
</div>
{% crispy form %}
<div class="col-md-12">
<button class="btn btn-primary" type="submit" id="ds-datafile-upload-{{ df_uuid }}">Save {{ target }}<i class="ic-indicator fa fa-spinner fa-spin" style="display:none"></i></button>
{% if next_url %}
<button class="btn btn-primary right" ic-get-from="{{ next_url }}" ic-push-url="true" ic-target="#ds-content">{% trans 'Back to Wizard' %}</button>
{% endif %}
</div>
</div>
</form>
......
{% extends request.is_intercooler|yesno:"blank.html,dddatasets/_base_datasets_edit.html" %}
{% load static i18n core_tags %}
<h5 class="card-title">{% trans 'Check Dataset Fields' %}: {% if errors %} {% trans 'Issues detected' %}{% else %} {% trans 'Success' %} {% endif %}</h5>
<p class="card-text" id="check-text">
{% if errors %}
<p>{% trans 'Dataset is not ready for publishing' %}</p>
<p>
{% trans 'Please fill in all required fields in dataset description and metadata and start this publishing wizard again afterwards' %}:
<ul>
{% for entry in errors %}
{% for field, messages in entry %}
{% for message in messages %}
<li>{{ field}}: {{ message }}</li>
{% block ic-content %}
<div id="ds-content">
{% block dataset-nav %}
{% include 'dddatasets/prep/_dataset_header.html' with ds=ds type='versions' %}
{% endblock dataset-nav %}
{% if manpage %}
{% include 'dddatasets/_manual_page.html' with manpage=manpage %}
{% endif %}
<h1>{{ message }}</h1>
<div class="card smallskip">
<div class="card-header">
<span class="pubcard-header">{% trans 'Publish Dataset' %} {{ ds.shorttitle }}, v{{ ds.version }}</span>
<span class="float-sm-right">{% trans 'Step' %} 1 {% trans 'of' %} 6</span>
</div>
<div class="card-body" id="check-text">
<h5 class="card-title">{% trans 'Check Dataset Fields' %}: {% if errors %} {% trans 'Issues detected' %}{% else %} {% trans 'Success' %} {% endif %}</h5>
<p class="card-text" id="check-text">
{% if errors %}
<p>{% trans 'Dataset is not ready for publishing' %}</p>
<p>
{% trans 'Please fill in all required fields in dataset description and metadata and start this publishing wizard again afterwards' %}:
<ul>
{% for entry in errors %}
{% for field, messages in entry %}
{% for message in messages %}
<li>{{ field}}: {{ message }}</li>
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
</ul>
</p>
<button class="btn btn-primary" ic-get-from="{% url 'dddatasets:prep_edit' ds.uuid %}" ic-target="#ds-content">{% trans "Edit Dataset" %}</button>
<button class="btn btn-outline-primary" ic-get-from="{% url 'dddatasets:prep_edit_versions' ds.uuid %}" ic-target="#ds-content">{% trans "Cancel" %}</button>
{% else %}
<p>{% trans 'Dataset is ready for publishing' %}.</p>
<button class="btn btn-primary" ic-get-from="{% url 'dddatasets:prep_edit_publish_datafiles' ds.uuid %}" ic-target="#ds-content">{% trans 'Next step: Check Files and Access Model' %}</button>
<button class="btn btn-outline-primary" ic-get-from="{% url 'dddatasets:prep_edit_versions' ds.uuid %}" ic-target="#ds-content">{% trans "Cancel" %}</button>
{% endif %}
</p>
</ul>
</p>
<button class="btn btn-primary" ic-get-from="{% url 'dddatasets:prep_edit_metadata' ds.uuid %}" ic-target="#ds-content">{% trans "Edit Dataset" %}</button>
<button class="btn btn-outline-primary" ic-get-from="{% url 'dddatasets:prep_edit_versions' ds.uuid %}" ic-target="#ds-content">{% trans "Cancel" %}</button>
{% else %}
<p>{% trans 'Dataset is ready for publishing' %}.</p>
<button class="btn btn-primary" ic-get-from="{% url 'dddatasets:prep_edit_publish_datafiles' ds.uuid %}" ic-target="#ds-content">{% trans 'Next step: Check Files and Access Model' %}</button>
<button class="btn btn-outline-primary" ic-get-from="{% url 'dddatasets:prep_edit_versions' ds.uuid %}" ic-target="#ds-content">{% trans "Cancel" %}</button>
{% endif %}
</p>
</div>
</div>
{% endblock %}
......@@ -29,7 +29,7 @@
<p>{% trans "The first step is a check if all required fields are set on the dataset. If not, you will be redirected to the edit pages." %}</p>
<button class="btn btn-primary" ic-get-from="{% url 'dddatasets:prep_edit_publish_check' ds.uuid %}" ic-target="#check-text">{% trans 'Check dataset' %}</button>
<button class="btn btn-primary" ic-get-from="{% url 'dddatasets:prep_edit_publish_check' ds.uuid %}" ic-target="#ds-content">{% trans 'Check dataset' %}</button>
<button class="btn btn-outline-primary" ic-get-from="{% url 'dddatasets:prep_edit_versions' ds.uuid %}" ic-target="#ds-content">{% trans "Cancel" %}</button>
</p>
</div>
......
......@@ -21,8 +21,6 @@
<i class="fas fa-tags"></i> {% trans "Additional categories" %}: {% if ds.get_categories %}{% for field in ds.get_categories.all %}{{ field|title }}{% if not forloop.last %}, {% endif %}{% endfor %}{% else %}–{% endif %}
</div>
{# dataset prep nav #}
{% include 'dddatasets/prep/_nav_datasets.html' with ds=ds type=type %}
......
......@@ -15,32 +15,34 @@
</div>
<h2>
{% trans "Files" %}
{% if manpage %}
{% include 'dddatasets/_manual_page.html' with manpage=manpage %}
{% endif %}
</h2>
{# existing data files #}
{% if ds.get_datafiles %}
{% for file in ds.get_datafiles %}
{% include 'dddatasets/_file_card.html' with fileicon='images/file-pdf.svg' fileurl='dddatasets:files_download' fileuuid=file.uuid dsuuid=ds.uuid filename=file.name filetype=file.get_data_file_type_display %}
{% for df in ds.get_datafiles %}
{% include 'dddatasets/_file_card.html' with fileicon='images/file-pdf.svg' fileurl='dddatasets:files_download' fileuuid=df.uuid dsuuid=ds.uuid filename=df.name filetype=df.get_data_file_type_display %}
<div class="smallskip text-right">
{# edit button #}
<button type="button" class="btn btn-outline-primary" ic-get-from="{% url 'dddatasets:prep_edit_datafile' ds.uuid file.uuid %}" ic-target="#file-edit-{{ file.uuid}}" data-toggle="collapse" data-target="#file-edit-{{ file.uuid}}" aria-expanded="false" aria-controls="file-edit-{{ file.uuid}}" data-id="{{ file.uuid}}" id="#file-edit-{{ file.uuid}}-dropzone">{% trans "Edit" %}</button>
<button type="button" class="btn btn-outline-primary" ic-get-from="{% url 'dddatasets:prep_edit_datafile' ds.uuid df.uuid %}" ic-target="#file-edit-{{ df.uuid}}" data-toggle="collapse" data-target="#file-edit-{{ df.uuid}}" aria-expanded="false" aria-controls="file-edit-{{ df.uuid}}" data-id="{{ df.uuid}}" id="#file-edit-{{ df.uuid}}-dropzone">{% trans "Edit" %}</button>
{# delete button #}
<button type="button" class="btn btn-outline-primary" data-toggle="modal" data-target="#confirmModal{{file.uuid}}" ic-target="#confirmModal-target-span" title="{% trans "Delete" %}">
<button type="button" class="btn btn-outline-primary" data-toggle="modal" data-target="#confirmModal{{df.uuid}}" ic-target="#confirmModal-target-span" title="{% trans "Delete" %}">
{% trans "Delete" %}
</button>
</div>
<div id="file-edit-{{ file.uuid}}"></div>
<div id="file-edit-{{ df.uuid}}"></div>
{# Modal to confirm project delete #}
{% include "core/_confirm_modal.html" with objecttype="file" objectid=file.uuid dsid=ds.uuid objectname=file delete_url="dddatasets:prep_edit_datafile" edit_url="dddatasets:prep_edit_datafile" target=target ictarget="#ds-content" %}
{% include "core/_confirm_modal.html" with objecttype="file" objectid=df.uuid dsid=ds.uuid objectname=df delete_url="dddatasets:prep_edit_datafile" edit_url="dddatasets:prep_edit_datafile" target=target ictarget="#ds-content" %}
{% endfor %}
{% endif %}
<h4>{% trans "Add a File" %}</h4>
{# add button #}
<div class="ic-datafile-add" ic-get-from="{% url 'dddatasets:prep_edit_datafile' ds.uuid %}" ic-trigger-on="load"></div>
<div class="ic-datafile-add" ic-get-from="{% url 'dddatasets:prep_edit_datafile' ds.uuid %}" ic-trigger-on="scrolled-into-view" ic-deps="ignore" ></div>
</div>
</div>
{% endblock ic-content %}
......@@ -18,7 +18,7 @@
{% endif %}
</h2>
<div id="dataset-metadata-form">
{% include 'core/_edit_form.html' with ds=ds form=form formset=formset user=user updated=updated err=err target=target ictarget="ds-content" %}
{% include 'core/_edit_form.html' with ds=ds form=form formset=formset user=user updated=updated err=err target=target ictarget="ds-content" with_next_url=True %}
</div>
</div>
</div>
......
......@@ -103,10 +103,12 @@
</div>
</div>
</div>
{# manage users for restricted access #}
{% if ds.data_access == 'RA' %}
{% if publish_right %}
<div class="col-md-12">
<div>
{% if ds.get_ra_with_perms %}
<h4>{% trans "Users with access to the published dataset" %}</h4>
<div id="user-list">
......@@ -150,6 +152,8 @@
</div>
{% endif %}
<hr>
<h3>{% trans "Choose the license" %}</h3>
......@@ -214,9 +218,9 @@
</div>
</div>
</div>
{% if next_url %}
<button class="btn btn-primary smallskip" ic-get-from="{{ next_url }}" ic-push-url="true" ic-target="#ds-content">{% trans 'Back to Wizard' %}</button>
{% endif %}
</div>
</div>
{% endblock ic-content %}
......@@ -5,7 +5,7 @@
{% block ic-content %}
<div id="ds-content">
{% block dataset-nav %}
{% include 'dddatasets/prep/_dataset_header.html' with ds=ds type='versions' %}
{% include 'dddatasets/prep/_dataset_header.html' with ds=ds type='versions' next_url=next_url %}
{% endblock dataset-nav %}
{% if manpage %}
......
......@@ -82,6 +82,10 @@
<a href="{% url 'dddatasets:prep_dsa_pdf' ds.uuid %}" target="_blank">
<button type="button" class="btn btn-primary"{% if not ds.dsa.pdf %}disabled{% endif %}>{% trans "PDF" %}</button>
</a>
{% if next_url %}
<button class="btn btn-primary" ic-get-from="{{ next_url }}" ic-push-url="true" ic-target="#ds-content">{% trans 'Back to Wizard' %}</button>
{% endif %}
</div>
</form>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment