Commit Graph

249 Commits

Author SHA1 Message Date
Dan Funk cf09d986ea Merge branch 'feature/admin' into feature/refactor_data_loading 2020-06-17 16:48:43 -04:00
Kelly McDonald 1844c93919 STG-26 - basic test case for a looping task
Criteria :
task.multi_instance_type == 'looping'

to terminate, use the standard endpoint for submitting form data with a query variable of terminate_loop=true

Will likely need two buttons:
"Submit and quit"
"Submit and add another"
or something similar
2020-06-17 11:35:06 -04:00
Carlos Lopez 59d66be10f Handling empty task state 2020-06-16 13:13:30 -06:00
Dan Funk c7d8eaff30 Merge branch 'dev' into feature/refactor_data_loading 2020-06-16 13:15:43 -04:00
Dan Funk 0608ffa08a Restricting the admin endpoints to be admin only, and adding a bit of configuration. 2020-06-16 12:26:25 -04:00
Aaron Louie 561e254315 Prevents non-admin users from editing each others' tasks. Fixes bug where test user uid was not being set from token. Moves complete form and get workflow API test utility methods into BaseTest. 2020-06-12 13:46:10 -04:00
Aaron Louie 691258a4fb Fixes bug where approvals counts were off by 1. Tests CSV export and all approvals endpoints with lots of records. 2020-06-11 17:15:44 -04:00
Aaron Louie f51e5e4e6b Adds tests for approval counts and all approvals endpoints 2020-06-11 16:39:00 -04:00
Aaron Louie 768f14b3ac Cleans up console logging 2020-06-11 13:42:44 -04:00
Aaron Louie 312eef4d40 Raises 403 error if no user found 2020-06-11 13:07:27 -04:00
Aaron Louie cccff9b856 Fixes broken unit tests. But still broken. 2020-06-11 11:29:58 -04:00
Aaron Louie 1f5554d0d8 Merge branch 'rrt/dev' into feature/swagger_admin_authentication 2020-06-11 08:55:29 -04:00
Dan Funk 777e429382 Merging production back into dev, because we got out of whack somehow. 2020-06-08 14:19:30 -04:00
Dan Funk 8cf420b781 Default mail user name and password to blank. 2020-06-08 14:15:56 -04:00
Aaron Louie 87e2379871 Merge branch 'rrt/dev' into feature/swagger_admin_authentication 2020-06-08 10:30:16 -04:00
Aaron Louie 1c8c085afe Merge branch 'rrt/dev' into rrt/testing 2020-06-07 22:39:34 -04:00
Aaron Louie 049424d01b Adds back an endpoint that returns all approvals across all statuses or users 2020-06-07 22:38:21 -04:00
Aaron Louie af1c848f65 Merge branch 'rrt/dev' into rrt/testing 2020-06-07 19:57:09 -04:00
Aaron Louie 1d3f98b381 Adds endpoint to quickly get counts of approvals in each status group for a user 2020-06-05 22:19:37 -04:00
Dan Funk 6861991d8f Allow setting the type of approvals you want back, by status.
Some very minor performance enhancements, that will add up on the Approvers page.
2020-06-05 17:49:55 -04:00
Carlos Lopez 57a7c7fa54 Approve/deny fixes 2020-06-05 13:39:52 -06:00
Dan Funk f0db5b70fc Adding some additional logic to the approval endpoint so that we take related approvals into account when setting the status. In addtion to prevous status options, there is a new status of "AWAITING" which means there are pending approvals before this approval that still need to be approved or canceled. 2020-06-05 14:33:00 -04:00
Dan Funk fed6e86f92 Trying to fix LDAP issues on production. Changing LDAP to static only methods, caching the connection and calling bind before all connection requests.
Also assuring we don't load the documents.xls file over and over again.
2020-06-04 14:59:36 -04:00
Dan Funk 50d2acac9c Made a very stupid mistake with LDAP connections, pushing up quickly to production. 2020-06-04 11:57:00 -04:00
Dan Funk 68aeaf1273 BE VERY CAREFUL where you create a new LdapService() - construction is expensive.
Adding a few more details to the "csv" endpoint for RRT.
2020-06-04 10:33:17 -04:00
Dan Funk 1324533865 Some additional cleanup - when a file is "archived" it is no longer returned for any endpoints about files, but it
is directly accessible via id, in the event some request is made for it at a later date.
2020-06-04 09:49:42 -04:00
Dan Funk 217ecfc911 When you can't delete a file, mark it as archived. Don't include archived files in new approval requests. 2020-06-03 17:34:27 -04:00
Dan Funk c179c7781b Do not process or return cancelled approvals via the API. 2020-06-03 16:50:47 -04:00
Dan Funk e102214809 minor cleanup of error codes. 2020-06-03 15:03:22 -04:00
Dan Funk 299ad4fc8b Adding more details to the csv output, and assuring we don't miss people with outstanding approvals that were cancelled. 2020-06-03 07:58:48 -04:00
Dan Funk 4bf13b0718 Doing everything I can imagine to get a CSV dump out tomorrow. 2020-06-02 22:01:49 -04:00
Dan Funk 2424b9d78c Don't overwrite the approval, just allow minor changes. 2020-06-02 19:36:06 -04:00
Dan Funk c7484267e1 For the main approval endpoints - we now group the approvals by study. So you get one record back for each study, but it may have other approvals along with it as "related_approvals".
We now cache the LDAP records - so we look in our own database for the record before calling out to ldap for the details when given a straight up computing id like dhf8r.

Added "date_approved" to the approval model.

And moved the approver and primary investigator into real associated models to make it easier to dump.

Fixed a problem with the validation that was causing it to throw incorrect errors on valid workflows. Getting it to behave a little more like the front end behaves, and respecting the read-only fields.  But it was mainly to do with always returning all the data with each form submission.
2020-06-02 18:17:00 -04:00
Dan Funk d8329e9eff I completely missed pushing up my changes last night before handing back over to Carlos. Sorry about that.
Added checks to assure the approver matches g.uid of the current user - otherwise don't modify the approval record.
2020-06-02 07:43:19 -04:00
Dan Funk c2a1b0175a Tweaks to approvals 2020-06-01 21:49:30 -04:00
Dan Funk 1db9401166 Don't put all the data into Spiff Tasks on a reload or backtrack, just store the data that gets submitted each time in the task log, and use that.
This should correct issues with parallel tasks and other complex areas - so we don't have tasks seeing data that isn't along their path.
2020-06-01 17:42:39 -04:00
Aaron Louie cd16b984e0 Adds workflow spec title to workflow api schema 2020-05-31 22:46:56 -04:00
Aaron Louie f0bd8d4f9e Adds approvals to study schema. Adds approvals endpoint 2020-05-31 22:46:32 -04:00
Dan Funk 9c7de39b09 This adds additional file data details to the study model as well. 2020-05-31 21:15:40 -04:00
Carlos Lopez 2e54f07095 Adding more info to files and renaming approval waiting status 2020-05-31 17:24:23 -06:00
Aaron Louie c4a84ac509 Work in progress: Trying to get Swagger to use verify_token_admin to protect admin endpoints. Not working for some reason, though. 2020-05-31 18:01:08 -04:00
Aaron Louie be9b613bbb Refactors user authentication endpoints so we can use the Swagger UI in production mode 2020-05-31 16:49:39 -04:00
Dan Funk 98fb305868 Run the validation process twice, each time it is requested, first populating everything, and then a second time
using on the required form fields.
2020-05-30 18:43:20 -04:00
Dan Funk 1f0e8741ba Run the validation twice, once completing all of the data, and a second time, completing only the required fields.
Also, add a helper method to reduce boiler plate code around Workflow Exceptions.
2020-05-30 17:26:27 -04:00
Dan Funk 860c475b29 Fill out repeating sections during validation process.
Also, when returning error messages, attempt to include the task data for the task that caused the error.
Also, when attempting to delete any file, respond with an API error explaining the issue, and log the details.
2020-05-30 15:37:04 -04:00
Dan Funk 0ba2819867 Merge branch 'dev' into feature/approval_request_script 2020-05-29 04:51:50 -04:00
Dan Funk afb6be7c60 re-working the way the redirects function, so we pass arguments as a get parameter. Just trying to get rid of the weird lag on production.
I noticed the validation sometimes looks ahead for files, so looking at all the tasks now, not just the ready tasks for the lookup field.
Ran into an issue with validation where a workflow model was required, so I create one and delete it.  Another refactor for another day.
2020-05-29 04:42:48 -04:00
Dan Funk 11413838a7 Faster lookup fields. We were parsing the spec each time to get details about how to search. We're just grabbing the workflow id and task id now and building that straight into the full text search index for faster lookups. Should be peppy.
Another speed improvement - data in the FileDataModel is deferred, and not queried until it is specifically used, as the new data structures need to use this model frequently.
2020-05-29 01:39:39 -04:00
Dan Funk dba41f4759 Ludicrously stupid launch in a refactor of the way all files work in the system at a time where I crave sleep and peace above all other things.
Added a File class, that we wrap around the FileModel so the api endpoints don't change, but File no longer holds refences to versions or dates of the file_data model, we
figure this out based on a clean database structure.

The ApprovalFile is directly related to the file_data_model - so no chance that a reviewer would review the incorrect version of a file.py

Noticed that our FileType enum called "bpmn" "bpmm", hope this doesn't screw someone up.

Workflows are directly related to the data_models that create the workflow spec it needs.  So the files should always be there.  There are no more hashes, and thus no more hash errors where it can't find the files to rebuild the workflow.py

Not much to report here, other than I broke every single test in the system at one point.  So I'm super concerned about this, and will be testing it a lot before creating the pull request.
2020-05-28 20:03:50 -04:00
Carlos Lopez 41b26e28bd Merge branch 'dev' into feature/approval_request_script 2020-05-28 08:11:31 -06:00
Dan Funk cd7f67ab48 A major refactor of how we search and store files, as there was a lot of confusing bits in here.
From an API point of view you can do the following (and only the following)

/files?workflow_spec_id=x
* You can find all files associated with a workflow_spec_id, and add a file with a workflow_spec_id
/files?workflow_id=x
* You can find all files associated with a workflow_id, and add a file that is directly associated with the workflow
/files?workflow_id=x&form_field_key=y
* You can find all files associated with a form element on a running workflow, and add a new file.
   Note: you can add multiple files to the same form_field_key, IF they have different file names. If the same name, the original file is archived,
   and the new file takes its place.

The study endpoints always return a list of the file metadata associated with the study.  Removed /studies-files, but there is an
endpoint called

/studies/all  - that returns all the studies in the system, and does include their files.

On a deeper level:
 The File model no longer contains:
  - study_id,
  - task_id,
  - form_field_key

Instead, if the file is associated with workflow - then that is the one way it is connected to the study, and we use this relationship to find files for a study.
A file is never associated with a task_id, as these change when the workflow is reloaded.
The form_field_key must match the irb_doc_code, so when requesting files for a form field, we just look up the irb_doc_code.
2020-05-28 08:27:26 -04:00
Carlos Lopez 54640988a7 Update endpoint fixes 2020-05-27 12:06:32 -06:00
Dan Funk eb15d172c1 I absolutely must fix our cascade deletes, but I sort of like the horror such chunks of code cause, we really need to protect these endpoints, and assure they never get called under normal circumstances, and raise some thoughtful errors. 2020-05-26 21:18:09 -04:00
Dan Funk 987790164e use redirect, not redirect_url. 2020-05-26 15:09:57 -04:00
Carlos Lopez 72b59deeaf Completing tests 2020-05-26 10:21:36 -06:00
Dan Funk a14168362a Merge branch 'feature/support_ui_dashboard' into dev 2020-05-25 21:31:16 -04:00
Carlos Lopez 727274ae33 Using full approval payload to update record 2020-05-25 15:40:24 -06:00
Dan Funk 6cd4ef64d1 Fixing add_study api endpoint, so you can actually add a new "Study" with just some basic information.
Using the LDAP service for checking user details in development mode - even if you are using the back door.
Added a new Flask fucntion load-example-rrt-data that loads the rrt workflow, and not the CRC wrokflows.
Modified the "load-example-data" in the tests to use some test data, rather than loading up all the workflows[
in CRC each time, with a parameter to load crc data if that is required - which is enabled for just a handful of tests.
(Tests run in 1/4 the time now)
2020-05-25 12:29:05 -04:00
Carlos Lopez e9bd19b112 Fixing broken test 2020-05-24 01:22:14 -06:00
Carlos Lopez 49eb4b3f98 Making working endpoints for approvals 2020-05-23 23:53:48 -06:00
Aaron Louie 4eaee57076 Apparently, APPLICATION_ROOT does something. 2020-05-24 00:05:13 -04:00
Aaron Louie 68084a84cf Adds base href environment variable. Sets base path for API and all routes from BASE_HREF environment variable. 2020-05-23 22:07:22 -04:00
Dan Funk d5c91e575f stuff that might be broken. 2020-05-23 15:21:30 -04:00
Aaron Louie 6c14248ef9 Adds 'v1.0/' to login route 2020-05-23 14:49:02 -04:00
Dan Funk 49c322177b
Merge pull request #76 from sartography/feature/rrp-endpoints
Feature/rrp endpoints
2020-05-22 19:38:26 -04:00
Dan Funk 148e86bb42 Building out the boilerplate code to make pushing forward on this a little friendlier.
There is an approval api file, and approval model file and an approval test file.
2020-05-22 18:25:00 -04:00
Dan Funk 571c1d7d24 Merge branch 'feature/rrp-endpoints' into feature/disable_protocol_builder 2020-05-22 16:18:33 -04:00
Dan Funk 1017bb1897 On the tools/render_docx api, allow sending the json data in the body, rather than as a ludicrous long get parameter. Silly Dan. 2020-05-22 15:30:22 -04:00
Dan Funk 503c1c8f18 Allow disabling the Protocol Builder
PB_ENABLED can be set to false in the configuration (either in a file called instance/config.py, or as an environment variable)

Added a check in the base_test, to assure that we are always running tests with the test configuration, and bail out otherwise.  Setting TESTING=true as an environment variable will get this, but so well the correct ordering of imports. Just be dead certain the first file every test file imports is base_test.py.

Aaron was right, and we call the Protocol Builder in all kinds of awful places.  But we don't do this now.  So Carlos, you should have the ability to reuse a lot of the logic in the study_service now.

I dropped the poorly named "study-update" endpoint completely.  We weren't using it. POST and PUT to Study still work just fine for doing exactly that.

All the tests now run and pass with the Protocol builder disabled. Tests that specifically check PB behavior turn it back on for the test, or mock it out.
2020-05-22 14:37:49 -04:00
Carlos Lopez a0c884499e Merge branch 'feature/rrp-endpoints' of github.com:sartography/cr-connect-workflow into feature/rrp-endpoints 2020-05-22 09:46:25 -06:00
Carlos Lopez 1ed7930aab Endpoint for studies with files 2020-05-22 09:46:03 -06:00
Dan Funk b490005af7 dropping the remaining config stuff for flask_sso.
updaing the user 'sso' endpoint to provide additional information for debugging.
Pulling information from ldap to stay super consistent on where we get our information.
2020-05-22 09:50:18 -04:00
Dan Funk 4627318818 Dropping flask_sso library in favor of reading from the headers directly. Updating login to read from ldap once it has the user_id. Adding more information to the sso endpoint. 2020-05-22 07:55:58 -04:00
Dan Funk 0265db7146 adding an /sso endpoint for testing. 2020-05-21 16:02:45 -04:00
Dan Funk 4628834106 just a few more logging details. 2020-05-21 12:11:35 -04:00
Dan Funk 951710d762 ldap lookup.
Refactored calls into a new lookup_service to keep things tidy.

New keys for all enum/auto-complete fields:
    PROP_OPTIONS_FILE = "spreadsheet.name"
    PROP_OPTIONS_VALUE_COLUMN = "spreadsheet.value.column"
    PROP_OPTIONS_LABEL_COL = "spreadsheet.label.column"
    PROP_LDAP_LOOKUP = "ldap.lookup"
    FIELD_TYPE_AUTO_COMPLETE = "autocomplete"
2020-05-19 16:11:43 -04:00
Dan Funk fc080ce7a8 Don't reset the token to something that already has a token. Terrible things happen and we hit a recursion. 2020-05-17 13:29:36 -04:00
Dan Funk 43bf8f5337 Fixing a bug with navigation where elements went missing past exclusive gateways on subsequent forks. 2020-05-16 15:33:06 -04:00
Dan Funk 7d3f139633 Merge branch 'feature/navigation' of github.com:sartography/cr-connect-workflow into feature/navigation 2020-05-15 16:39:25 -04:00
Dan Funk de435bd961 the heck with camel case, what the heck TypeScript? Get a grip. This is a python API. 2020-05-15 16:38:37 -04:00
Aaron Louie 0f1fbd0249 Merge branch 'dev' into feature/navigation 2020-05-15 16:10:40 -04:00
Dan Funk 53255ef35e massive overhaul of the Workflow API endpoint.
No Previous Task, No Last Task, No Task List.  Just the current task, and the Navigation.
Use the token endpoint to set the current task, even if it is a "READY" task in the api.
Previous Task can be set by identifying the prior task in the Navigation (I'm hoping)
Prefering camel case to snake case on all new apis.  Maybe clean the rest up later.
2020-05-15 15:54:53 -04:00
Dan Funk b63ee8159e We now only return the ready user tasks, not all tasks, and even then the ready user tasks don't come back with the forms and details, just the bare minimum. Speeds things up considerably, and most of this information wasn't used anyway. 2020-05-14 17:13:47 -04:00
Dan Funk f2c9fd5fc4 adding a default url. And some debugging information to see if we hit he endpoint in the logs. 2020-05-14 15:07:05 -04:00
Dan Funk 55a1850e7c adding a navigation component to the Workflow Model.
running all extension/properties through the Jinja template processor so you can have custom display names using data, very helpful for building multi-instance displays.
Properties was returned as an array of key/value pairs, which is just mean.  Switched this to a dictionary.
2020-05-14 13:43:23 -04:00
Dan Funk e723992fde Found a number of bugs with the parallel multi-instance - pulling in some recent changes from Spiffworkflow to open things up a bit more to allow functional jumping between tasks. 2020-05-12 12:23:43 -04:00
Aaron Louie 9afcd753c4 No longer requires task_id 2020-05-06 14:27:28 -04:00
Dan Funk 1571986c0e I had to give up and live with the idea that we can only render documentation on the current task, not on the previous or next tasks. I think this is ok. If you want to view a task, you need to make it the active task to assure all the parts and pieces are in place. 2020-05-06 13:01:38 -04:00
Dan Funk 2699f5c65c Refactor the stats models, and assure they are very correct across all tests with the workflow api.
I noticed we were saving the workflow every time we loaded it up, rather than only when we were making changes to it.  Refactored this to be a little more careful.
Centralized the saving of the workflow into one location in the processor, so we can make sure we update all the details about that workflow every time we save.
The workflow service has a method that will log any task action taken in a consistent way.
The stats models were removed from the API completely.  Will wait for a use case for dealing with this later.
2020-05-04 10:57:09 -04:00
Dan Funk 1f5002680a Initial work on a "Previous" task. 2020-05-01 12:11:39 -04:00
Dan Funk bec59a71d7 Deleteing stuff is a damn mess, but this is a little cleaner. 2020-04-29 16:07:39 -04:00
Dan Funk 13333fb306 Adding an API endpoint that allows setting the token on the workflow to a specific task.
Added error checking such that attempting to submit data for a task that is not in the "READY" state throws an error message.
For some reason I'm getting lots of errors in the tests as they try to hit API endpoints they were not hitting before, so adding a number of mocks to some of the study service tests.
2020-04-28 17:25:53 -04:00
Dan Funk 12eb039bc9 Server isn't erroring out, but can't find the lookup table id in the database, so trying to use the in-memory model instead, to give things time to get to the database. Really unsure what is happening here. Hard to see in the database. 2020-04-24 07:01:32 -04:00
Dan Funk 3aeb7ad116 Server isn't erroring out, but can't find the lookup table id in the database, so trying to use the in-memory model instead, to give things time to get to the database. Really unsure what is happening here. Hard to see in the database. 2020-04-23 14:58:17 -04:00
Dan Funk b5b46b7c2c better overall search results for type ahead. Still dealing with stop words failing. 2020-04-23 12:05:08 -04:00
Dan Funk 65b29e1a9d Don't just bomb out as soon as someone types an empty string. 2020-04-23 09:44:11 -04:00
Dan Funk 7b085c9c9d Adding an API Endpoint that will return a list of LookupValues that match a given query - can be used to populate an auto-complete table. 2020-04-22 19:40:40 -04:00
Dan Funk fd0adb1d43 Updated the study status to use a different enumeration. Migration correctly handles modifying the enum.
INCOMPLETE = 'Incomplete in Protocol Builder',
  ACTIVE = 'Active / Ready to roll',
  HOLD = 'On Hold',
  OPEN = 'Open - this study is in progress',
  ABANDONED = 'Abandoned, it got deleted in Protocol Builder'
2020-04-21 17:13:30 -04:00
Dan Funk c8b817e98a Be careful not to clean out all the data when a form is submitted, just merge the data in as it comes. 2020-04-17 13:51:48 -04:00
Dan Funk dc2895cb05 Allow configurators to upload xls files into a workflow for defining enumrations of values for dropdown lists in forms. Fixing lots of tests.
Found a problem where the documentation for elements was being processed BEFORE data was loaded from a script.  There still may be some issues here.

Ran into an issue with circular dependencies - handling it with a new workflow_service, and pulling computational logic out of the api_models - it was the right thing to do.
2020-04-15 11:13:32 -04:00