Skip to content

Commit

Permalink
Scottx611x/deletion from ui (#1445)
Browse files Browse the repository at this point in the history
* Inject uibModal

* Add modal to be triggered by an `x` from individual datasets on dashboard

* Add Styles

* Add tests for DataSet api v1 and add `analyses` field to api response

* Fix typo

* Add `get_file_store_items` method and appropriate tests

* Add FileStoreItem class method `terminate_file_import_task` and add appropriate test

* Adjust DataSet deletion per: https://refinery-platform.slack.com/archives/general/p1474548215000470

* Add delete endpoint for datasets and appropriate tests

* Update dataset-delete-dialog partial

* Update launchpad to have deletionModal triggered from little trashcan

* Add controller for Dataset deletion

* Add method to open dataSetDeletionModal

* Clear cache upon a reload of DataSet list

* Add common service for deletion of objects behind Django

* Update some values here so that the dataSet UIScroll list displays the proper information

* Add styles

* Try out selenium for interactions with datasets (upload & deletion)

* Fix relative import

* 😕

* remove  `__init__.py`

* Explicitly add `DJANGO_SETTINGS_MODULE` for selenium usage

* Remove hyperlink from analyses upon successful deletion

* Try to import isatab directly from shell

* Provide correct path

* Add sample isatab

* Change to relative path

* Add analysis ui deletion and appropriate tests

* Try loading test isatab within travis.yml

* Try loading isatab from full path

* Still trying to import an isatab

* Remove usage of isatab zip in favor of bare-minimum fixture repr. of DataSets

* Fixing `.less` formatting

* Update test expectations and re-add a `cd`

* Update test contraints

* Something is not in favor of the `·` within selenium tests...

* Add some ids that aid selenium testing

* Fix for dataset deletion Selenium test

* Test if explicitly defining the encoding will resolve Travis Error

* Change separator as it seems to be the cause of failing travis builds

* Change trashcan icon from `<a>` to `<i>` to combat weird highlighting issue

* Add `factory_boy` requirement

* Move away from the use of fixtures in favor of `factory_boy`

* Refactor as Investigations aren't actually Django Models

* Fix minimal DataSet creation and rename file to `dataset_factory`

* Set proper ownership so that Datasets show up on the LaunchPad for the logged in user

* Move imports to correct location

* Fix one-off error

* Add reused methods to `selenium/utils/utils.py` and refactor tests accordingly

* It looks like Saucelabs may have a runtime limit, so 50 Datasets being deleted is taking too long

* Add ownership information to list of analyses return from DataSetResource

* Add Analysis ownership information so that its available within analysisDeletionModal

* adjust dashboard.readableDate method to be accepting of differently formatted dates

* Update both Analysis and Dataset deletion modals

* Adjust analysis list's style to be more uniform with datasets look on the launchpad

* Update test to check for Analysis ownership within DataSet API v1 response

* Adjust error message text

* add method to create minimal Datasets with Analyes

* Remove HTTP status codes from ui error messages

* Add ids to aid selenium testing

* Adjust Dataset delete modal layout

* remove title arg as Analyses have no title field

* Remove title field from factory definition as well

* Change `dataset` arg to `data_set` per Analysis model reqs

* Add Factories necessary to create a minimal `Workflow`

* Fix for removing too many thing from Solr upon a deletion of an analysis that was run upon derived data

* Remove unused import

* call set_ownership before analyses get saved

* Adjust deletion success and error messages

* Add `deleteSuccessful` variable

* Add indicator to Datatsets on dashboard about total number of analyses run upon

* Remove datasets form DataCart upon deletion

* Update analysis and Dataset delete dialogues

* add alert-success to analyses list in dataset delete modal

* Increase pytest output verbosity

* Update Tooltip text

* Add `--silent` arg to `nom install` this should get rid of some of the lengthy output, but still output any errors

* Add `--silent` arg here as well

* Suppress lengthy `pip` output as well

* Edit selenium timings

* remove tooltip delays

* Fix selenium test errors

* Add some implicit waiting, I think there may just be a timing issue within Travis

* Disallow modal closing while deletion is in progress

* `-v` flag is too verbose here

* Only need to login once per test suite

* Add proper warning colors

* Need to login before these tests can run

* Try this as it looks like even though login happened the page needs a refresh before datasets show up

* Add missing `login`

* Check to see if we are still logged in for the second test method

* insert some waits to try and figure out the issue with travis

* Fix typo

* It seems that the removal of `Project` objects in the cleanup method was causing a Django "yellow page" and Travis was complaining about the content of said page.

* Handle default case

* Adjust factories for usage in create method

* Disable controls while deletion is in progress

* Remove superfluous alert styling

* Re-add `&middot;` throughout launchpad in hopes that travis can handle their encoding now

* Change factory method to create a single Dataset with many analyses "run" on it

* See if pytest is cool with moving these test fixtures into `utils`

* Adjust old tests and add new acceptance test for cascading deletion of analyses

* Add ids to aid testing and adjust tests

* Create a single Dataset instance and utilize Factory_boy's `django _get_or_create`

* Fix undefined var

* Creating all of the objects necessary for a Dataset in the loop may have been an issue

* Utilize `django _get_or_create`

* Override Workflow Factory and provide new `uuid`

* Add test to make sure 404s are properly handled on the FrontEnd

* See if advice from http://flake8.pycqa.org/en/latest/user/ignoring-errors.html helps

* PEP8-ification

* Instantiate web driver and pass to login function

* Remove pytest fixtures from utils

* These flags don't help the output length all that much

* Add decorator to pass function calls that pollute Travis log output

* Add optional logic to suppress this output in local testing

* Reduce pytest verbosity

* Add functionality to reduce Travis log output

* Remove exclamation marks

* Remove unused method

* Simplify logic for getting isa/pre-isa archives

* Try to append to `PYTHON_PATH` within Travis

* Reorder import

* Remove redefinition

* Rename `import as` to be more easily readable

* Cleanup code

* Remove unnecessary test

* add logger statement

* Adjust logic and update test accordingly

* Fix formatting

* Rename `object` to `dataObj`

* Refactor Controllers

* Update travis syntax

* Refactor `PYTHONPATH` env var and update model factories & selenium test

* adjust test

* Fx `runserver` output redirection syntax

* Add test for common service

* Suppress some output on travis

* `-v 0` has no helpful effect

* Remove more Exclamation marks

* Add one more test for potential analysis 404s

* Fix one-off error
  • Loading branch information
scottx611x authored and jkmarx committed Oct 6, 2016
1 parent 24ce2d8 commit 0a17a82
Show file tree
Hide file tree
Showing 32 changed files with 2,165 additions and 214 deletions.
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ services:
- postgresql
- neo4j
install:
- pip install -r requirements.txt
- pip install -r requirements.txt --quiet
env:
- DJANGO_SETTINGS_MODULE=config.settings.dev
- DJANGO_SETTINGS_MODULE=config.settings.dev REDUCE_TEST_OUTPUT=true PYTHONPATH=$PYTHONPATH:../refinery:../refinery/config
before_script:
- createuser --createdb --no-superuser --no-createrole vagrant
- createdb -O vagrant refinery
Expand All @@ -24,10 +24,10 @@ before_script:
- python manage.py create_public_group
- python manage.py syncdb --migrate --noinput
- python manage.py create_user 'guest' 'guest' 'guest@example.com' 'GuestFirst' 'GuestLast' 'GuestAffiliation' 'active'
- npm install -g grunt-cli@0.1.13 bower@1.7.7 --progress false
- npm install -g grunt-cli@0.1.13 bower@1.7.7 --progress false --quiet
- cd ui
- npm install --progress false
- bower install --config.interactive=false
- npm install --progress false --quiet
- bower install --config.interactive=false --quiet
- cd ../
script:
- set -e # Any error will cause travis to exit early and report a failure.
Expand All @@ -41,7 +41,8 @@ script:
- echo 'travis_fold:end:grunt'

- echo 'travis_fold:start:selenium'
- python manage.py runserver &
# NOTE: Redirect runserver output since it's polluting logs
- python manage.py runserver > /dev/null 2>&1 &
- pushd ../selenium
# NOTE: Sauce Connect needs SAUCE_USERNAME and SAUCE_ACCESS_KEY
# (https://docs.travis-ci.com/user/sauce-connect/),
Expand All @@ -52,7 +53,7 @@ script:
- export SAUCELABS_USERNAME=$SAUCE_USERNAME SAUCELABS_API_KEY=$SAUCE_ACCESS_KEY
- printenv | sort | grep SAUCE | perl -pne 's/=(...).+/=$1.../' # Debug helper
- export BASE_URL=http://localhost:8000 CREDS_YML=guest_creds.yml UPLOAD=gff3.csv
- pytest --driver SauceLabs --capability browserName Firefox --capability tunnelIdentifier $TRAVIS_JOB_NUMBER
- pytest --driver SauceLabs --capability browserName Firefox --capability tunnelIdentifier $TRAVIS_JOB_NUMBER -r fE
- popd
- echo 'travis_fold:end:selenium'

Expand Down
4 changes: 2 additions & 2 deletions refinery/analysis_manager/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ def import_analysis_in_galaxy(ret_list, library_id, connection):
curr_file_uuid = Node.objects.get(
uuid=cur_item['node_uuid']).file_uuid
except Node.DoesNotExist:
logger.error("Couldn't fetch Node!")
logger.error("Couldn't fetch Node")
return None

try:
current_filestore_item = FileStoreItem.objects.get_item(
uuid=curr_file_uuid)
except FileStoreItem.DoesNotExist:
logger.error("Couldn't fetch FileStoreItem!")
logger.error("Couldn't fetch FileStoreItem")
return None

# Create url based on filestore_item's location (local file or
Expand Down
4 changes: 2 additions & 2 deletions refinery/analysis_manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ def run(request):
workflow=curr_workflow,
time_start=timezone.now()
)
analysis.save()
analysis.set_owner(request.user)
analysis.save()

# getting distinct workflow inputs
try:
Expand Down Expand Up @@ -408,8 +408,8 @@ def run(request):
workflow=curr_workflow,
time_start=timezone.now()
)
analysis.save()
analysis.set_owner(request.user)
analysis.save()

# getting distinct workflow inputs
workflow_data_inputs = curr_workflow.data_inputs.all()
Expand Down
13 changes: 12 additions & 1 deletion refinery/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
FastQCResource, UserProfileResource)
from core.models import DataSet, AuthenticationFormUsernameOrEmail
from core.views import (WorkflowViewSet, NodeViewSet,
CustomRegistrationView, NodeGroups)
CustomRegistrationView, NodeGroups, DataSetsViewSet,
AnalysesViewSet)
from file_store.views import FileStoreItems
from data_set_manager.views import Assays, AssaysFiles, AssaysAttributes
from data_set_manager.api import (AttributeOrderResource, StudyResource,
Expand Down Expand Up @@ -172,6 +173,16 @@
r'[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{'
r''r'12})/$', FileStoreItems.as_view()),

url(r'^api/v2/data_sets/(?P<uuid>'
r'[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{'
r''r'12})/$',
DataSetsViewSet.as_view()),

url(r'^api/v2/analyses/(?P<uuid>'
r'[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{'
r''r'12})/$',
AnalysesViewSet.as_view()),

# (r'^favicon\.ico$',
# 'django.views.generic.simple.redirect_to',
# {'url': STATIC_URL+'images/favicon.ico'}),
Expand Down
23 changes: 23 additions & 0 deletions refinery/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,29 @@ def dehydrate(self, bundle):
if pre_isa_archive:
bundle.data["pre_isa_archive"] = pre_isa_archive.uuid

analyses = []
for analysis in bundle.obj.get_analyses():
analysis_dict = analysis.__dict__
analysis_dict['is_owner'] = False
owner = analysis.get_owner()
if owner:
try:
analysis_dict['owner'] = owner.userprofile.uuid
user = bundle.request.user
if (hasattr(user, 'userprofile') and
user.userprofile.uuid == analysis_dict['owner']):
analysis_dict['is_owner'] = True
except:
analysis_dict['owner'] = None

else:
analysis_dict['owner'] = None

analyses.append(analysis_dict)

if analyses:
bundle.data["analyses"] = analyses

bundle.data["version"] = bundle.obj.get_version_details().version
bundle.data["date"] = bundle.obj.get_version_details().date
bundle.data["creation_date"] = bundle.obj.creation_date
Expand Down

0 comments on commit 0a17a82

Please sign in to comment.