Skip to content

Commit

Permalink
small refactoring stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
gromdimon committed Jun 29, 2023
1 parent 27d9b18 commit 6084a30
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 54 deletions.
2 changes: 1 addition & 1 deletion docs_manual/source/api_irodsinfo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ API Views

.. currentmodule:: irodsinfo.views_api

.. autoclass:: IrodsConfigRetrieveAPIView
.. autoclass:: IrodsEnvRetrieveAPIView


Versioning
Expand Down
5 changes: 4 additions & 1 deletion docs_manual/source/app_samplesheets_irods_delete.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ user will be informed of rejection.
carefully.


Multiple Requests Accepting and Rejecting
Accepting and Rejecting Multiple Requests
=========================================

In addition to accepting or rejecting requests one by one, you can also accept
Expand All @@ -112,3 +112,6 @@ the request list. Once you have selected the requests, click the
:guilabel:`Request Operations` dropdown and select either
:guilabel:`Accept Selected` or :guilabel:`Reject Selected`.

.. warning::

The requests for entire collections must be accepted or rejected individually.
5 changes: 1 addition & 4 deletions samplesheets/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,11 @@ def clean(self):
class IrodsRequestAcceptForm(forms.Form):
"""Form accepting an iRODS delete request."""

confirm = forms.BooleanField(
required=True,
)
confirm = forms.BooleanField(required=True)

def __init__(self, *args, **kwargs):
num_requests = kwargs.pop('num_requests', None)
super().__init__(*args, **kwargs)

self.fields['confirm'].label = 'I accept the iRODS delete request'
if num_requests > 1:
self.fields['confirm'].label += 's'
Expand Down
4 changes: 2 additions & 2 deletions samplesheets/static/samplesheets/js/irods_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ $(document).ready(function () {
}
// Uncheck "Select All" if any checkbox is unchecked
if (checkedCheckboxes.length < $('.sodar-ss-checkbox-item').length) {
$('#sodar-ss-check-all').prop('checked', false);
$('#sodar-ss-request-check-all').prop('checked', false);
} else {
$('#sodar-ss-check-all').prop('checked', true);
$('#sodar-ss-request-check-all').prop('checked', true);
}
});
});
Expand Down
42 changes: 18 additions & 24 deletions samplesheets/templates/samplesheets/irods_request_accept_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@


<div class="container-fluid sodar-subtitle-container">
{% if irods_request_data|length == 1 %}
{% if request_objects|length == 1 %}
<h3>Accept iRODS Delete Request</h3>
{% else %}
<h3>Accept {{ irods_request_data|length }} iRODS Delete Requests</h3>
<h3>Accept {{ request_objects|length }} iRODS Delete Requests</h3>
{% endif %}
</div>

<div class="container-fluid sodar-page-container">
{% if irods_request_data %}
{% if request_objects %}
<div class="alert alert-danger">
<strong>Warning:</strong> Accepting {% if irods_request_data|length == 1 %}a request{% else %}requests{% endif %}
<strong>Warning:</strong> Accepting {% if request_objects|length == 1 %}a request{% else %}requests{% endif %}
will delete the associated data objects from iRODS.
This can <strong>not</strong> be undone without administrator assistance!
</div>
Expand All @@ -40,35 +40,29 @@ <h3>Accept {{ irods_request_data|length }} iRODS Delete Requests</h3>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form | crispy }}
{% if irods_request_data|length %}
{% if request_objects|length %}
<input type="hidden" name="irods_requests" id="irods_requests" value="{{ irods_request_uuids }}"/>
{% endif %}
<div class="row">
<div class="btn-group ml-auto">
<a role="button" class="btn btn-secondary"
href="{% url 'samplesheets:irods_requests' project=project.sodar_uuid %}">
<i class="iconify" data-icon="mdi:arrow-left-circle"></i> Cancel
</a>
<button type="submit" class="btn btn-danger" id="sodar-ss-btn-delete-submit">
<i class="iconify" data-icon="mdi:check-bold"></i> Accept
</button>
</div>
</div>
</form>
{% else %}
<div class="row">
<div class="alert alert-danger">
<strong>Error:</strong> No iRODS delete request found with the given UUID.
</div>
</div>
<div class="row">
<div class="ml-auto btn-group">
<a role="button" class="btn btn-secondary"
href="{% url 'samplesheets:irods_requests' project=project.sodar_uuid %}">
<i class="iconify" data-icon="mdi:arrow-left-circle"></i> Cancel
</a>
</div>
</div>
{% endif %}
<div class="row">
<div class="ml-auto btn-group">
<a role="button" class="btn btn-secondary"
href="{% url 'samplesheets:irods_requests' project=project.sodar_uuid %}">
<i class="iconify" data-icon="mdi:arrow-left-circle"></i> Cancel
</a>
{% if request_objects|length %}
<button type="submit" class="btn btn-danger" id="sodar-ss-btn-delete-submit">
<i class="iconify" data-icon="mdi:check-bold"></i> Accept
</button>
{% endif %}
</div>
</div>
</div>
{% endblock projectroles_extend %}
4 changes: 2 additions & 2 deletions samplesheets/templates/samplesheets/irods_requests.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ <h3>iRODS Delete Requests</h3>
{% if irods_webdav_enabled %}
<th></th>
{% endif %}
<th id="sodar-ss-list-header-select">
<th id="sodar-ss-request-header-select">
{% if can_manage_request %}
<input class="sodar-checkbox" type="checkbox"
onchange="checkAll(this)" name="check_all"
id="sodar-ss-check-all" title="Check/uncheck all" />
id="sodar-ss-request-check-all" title="Check/uncheck all" />
{% endif %}
</th>
</tr>
Expand Down
15 changes: 7 additions & 8 deletions samplesheets/tests/test_views_taskflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ def test_render(self):
),
{'confirm': True},
)
self.assertEqual(response.context['irods_request_data'][0], obj)
self.assertEqual(response.context['request_objects'][0], obj)

def test_render_coll(self):
"""Test rendering IrodsRequestAcceptView with a collection request"""
Expand Down Expand Up @@ -1515,7 +1515,7 @@ def test_render_coll(self):
),
{'confirm': True},
)
self.assertEqual(response.context['irods_request_data'][0], obj)
self.assertEqual(response.context['request_objects'][0], obj)

def test_accept(self):
"""Test accepting a delete request"""
Expand Down Expand Up @@ -1891,13 +1891,13 @@ def test_render(self):
)
),
)
self.assertEqual(len(response.context['irods_request_data']), 2)
self.assertEqual(len(response.context['request_objects']), 2)
self.assertEqual(
response.context['irods_request_data'][0],
response.context['request_objects'][0],
IrodsDataRequest.objects.first(),
)
self.assertEqual(
response.context['irods_request_data'][1],
response.context['request_objects'][1],
IrodsDataRequest.objects.last(),
)

Expand Down Expand Up @@ -1934,12 +1934,11 @@ def test_render_coll(self):
)
self.assertEqual(response.status_code, 200)
self.assertEqual(
response.context['irods_request_data'][0],
response.context['request_objects'][0],
IrodsDataRequest.objects.first(),
)
self.assertEqual(
response.context['affected_object_paths'][0],
coll_path,
response.context['affected_object_paths'][0], coll_path
)

def test_accept(self):
Expand Down
18 changes: 6 additions & 12 deletions samplesheets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2578,7 +2578,7 @@ def get_context_data(self, *args, **kwargs):
obj = IrodsDataRequest.objects.filter(
sodar_uuid=self.kwargs['irodsdatarequest']
).first()
context_data['irods_request_data'] = []
context_data['request_objects'] = []
affected_object_paths = [obj.path]
irods_backend = get_backend_api('omics_irods')
is_collection = obj.is_collection()
Expand All @@ -2593,7 +2593,7 @@ def get_context_data(self, *args, **kwargs):
irods, coll
)
affected_object_paths += [o.path for o in affected_objects]
context_data['irods_request_data'].append(obj)
context_data['request_objects'].append(obj)
context_data['affected_object_paths'] = sorted(
list(set(affected_object_paths))
)
Expand Down Expand Up @@ -2674,7 +2674,7 @@ def get_form_kwargs(self):

def get_context_data(self, *args, **kwargs):
context_data = super().get_context_data(*args, **kwargs)
context_data['irods_request_data'] = []
context_data['request_objects'] = []
context_data['irods_request_uuids'] = ''
irods_backend = get_backend_api('omics_irods')
batch = self.get_irods_request_objects()
Expand All @@ -2698,7 +2698,7 @@ def get_context_data(self, *args, **kwargs):
affected_object_paths += [
o.path for o in affected_objects
]
context_data['irods_request_data'].append(obj)
context_data['request_objects'].append(obj)
context_data['affected_object_paths'] = sorted(
set(affected_object_paths)
)
Expand All @@ -2714,10 +2714,7 @@ def post(self, request, *args, **kwargs):
project = self.get_project()
batch = self.get_irods_request_objects()
if not batch:
messages.error(
self.request,
IRODS_NO_REQ_MSG,
)
messages.error(self.request, IRODS_NO_REQ_MSG)
return redirect(
reverse(
'samplesheets:irods_requests',
Expand Down Expand Up @@ -2954,10 +2951,7 @@ def get_extra_item_data(self, irods_session, item):
def get(self, request, *args, **kwargs):
irods_backend = get_backend_api('omics_irods')
if not irods_backend:
messages.error(
request,
'iRODS backend not enabled',
)
messages.error(request, 'iRODS backend not enabled')
return redirect(
reverse(
'samplesheets:project_sheets',
Expand Down

0 comments on commit 6084a30

Please sign in to comment.