Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ability to set data checked status multiple times #111 #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .idea/disburser.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 141 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ gem 'will_paginate-foundation'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
gem 'pry'
end

group :development do
Expand Down
7 changes: 5 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ GEM
bcrypt (3.1.20)
bindex (0.8.1)
builder (3.2.4)
byebug (11.1.3)
capistrano (3.6.0)
airbrussh (>= 1.0.0)
capistrano-harrow
Expand Down Expand Up @@ -85,6 +84,7 @@ GEM
ckeditor (5.1.1)
orm_adapter (~> 0.5.0)
cocoon (1.2.15)
coderay (1.1.3)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
Expand Down Expand Up @@ -216,6 +216,9 @@ GEM
activerecord (>= 4.2)
request_store (~> 1.1)
pg (1.5.6)
pry (0.15.0)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.5)
puma (3.12.6)
pundit (2.3.1)
Expand Down Expand Up @@ -384,7 +387,6 @@ PLATFORMS

DEPENDENCIES
american_date
byebug
capistrano (= 3.6.0)
capistrano-rails
capistrano-rvm
Expand Down Expand Up @@ -412,6 +414,7 @@ DEPENDENCIES
net-ldap
paper_trail
pg
pry
puma (~> 3.0)
pundit
rails (~> 5.0.0, >= 5.0.0.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Disburser.DisburserRequestEditAdminStatus
constructor: () ->
render: () ->
$("input[name='disburser_request[data_status]']").on 'change', (e) ->
if $(this).val() == $('#data_status_original').val()
if ($(this).val() != 'data checked' && $(this).val() == $('#data_status_original').val())
$('#disburser_request_data_status_comments').val('');
$('#disburser_request_data_status_comments').attr('disabled', true)
$('#disburser_request_data_status_status_at').attr('disabled', true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Disburser.DisburserRequestEditDataStatus
constructor: () ->
render: () ->
$("input[name='disburser_request[data_status]']").on 'change', (e) ->
if $(this).val() == $('#data_status_original').val()
if ($(this).val() != 'data checked' && $(this).val() == $('#data_status_original').val())
$('#disburser_request_data_status_comments').val('');
$('#disburser_request_data_status_comments').attr('disabled', true)
$('#disburser_request_data_status_status_at').attr('disabled', true)
Expand Down
2 changes: 1 addition & 1 deletion app/models/disburser_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def build_disburser_request_status
disburser_request_statuses.build(status_type: DisburserRequestStatus::DISBURSER_REQUEST_STATUS_TYPE_STATUS, status: self.status, user_id: self.status_user.id, comments: self.status_comments, status_at: self.status_at)
end

if !self.data_status_not_started? && self.data_status_changed?
if !self.data_status_not_started? && (self.data_status_changed? || self.data_status == DISBURSER_REQUEST_DATA_STATUS_DATA_CHECKED)
if self.data_status_status_at.blank?
self.data_status_status_at = DateTime.now
end
Expand Down
5 changes: 3 additions & 2 deletions app/views/disburser_requests/edit_admin_status.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- data_disabled = @disburser_request.data_status == DisburserRequest::DISBURSER_REQUEST_DATA_STATUS_DATA_CHECKED ? false : true
- content_for(:title) do
Request
#disburser_request
Expand Down Expand Up @@ -36,14 +37,14 @@
.disburser_request_data_status_status_at
%label{for: 'disburser_request_data_status_status_at' }
Date
= f.text_field :data_status_status_at, disabled: true, class: 'datepicker'
= f.text_field :data_status_status_at, disabled: data_disabled, class: 'datepicker'
- if validation_errors?(@disburser_request, :data_status_status_at)
%p.error=format_validation_errors(@disburser_request, :data_status_status_at)
%br
.disburser_request_data_status_comments
%label{for: 'disburser_request_data_status_comments' }
Data Status Comments
= f.text_area :data_status_comments, rows: 3, disabled: true
= f.text_area :data_status_comments, rows: 3, disabled: data_disabled
.specimen_status{ class: 'large-8 columns' }
.disburser_request_specimen_status
%label{for: 'disburser_request_specimen_status' }
Expand Down
5 changes: 3 additions & 2 deletions app/views/disburser_requests/edit_data_status.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- disabled = @disburser_request.data_status == 'data checked' ? false : true
- content_for(:title) do
Request
#disburser_request_show
Expand All @@ -23,14 +24,14 @@
.data_status_status_at
%label{for: 'disburser_request_data_status_status_at' }
Date
= f.text_field :data_status_status_at, disabled: true, class: 'datepicker'
= f.text_field :data_status_status_at, disabled: disabled, class: 'datepicker'
- if validation_errors?(@disburser_request, :data_status_status_at)
%p.error=format_validation_errors(@disburser_request, :data_status_status_at)
%br
.data_status_comments
%label{for: 'disburser_request_data_status_comments' }
Data Status Comments
= f.text_area :data_status_comments, rows: 3, disabled: true
= f.text_area :data_status_comments, rows: 3, disabled: disabled
.row
.navigation{ class: 'large-offset-8 large-16 columns' }
= f.submit 'Save', class: 'button'
Expand Down
12 changes: 11 additions & 1 deletion spec/models/disburser_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
expect(disburser_request_1.disburser_request_statuses.first.comments).to eq(data_status_comments)
end

it "saves a disburser request status once the data status reaches anything but 'not started' (but only once)", focus: false do
it "saves a disburser request status once the data status reaches anything but 'not started' (but only once if not data checked)", focus: false do
disburser_request_1 = FactoryGirl.create(:disburser_request, repository: @moomin_repository, submitter: @moomintroll_user)
expect(disburser_request_1.disburser_request_statuses.size).to eq(0)
expect(disburser_request_1.data_status).to eq(DisburserRequest::DISBURSER_REQUEST_DATA_STATUS_NOT_STARTED)
Expand All @@ -273,6 +273,16 @@
disburser_request_1.data_status_comments = data_status_comments
disburser_request_1.save!
expect(disburser_request_1.disburser_request_statuses.size).to eq(1)
disburser_request_1.data_status = DisburserRequest::DISBURSER_REQUEST_DATA_STATUS_DATA_CHECKED
data_status_comments = 'data check 1'
disburser_request_1.data_status_comments = data_status_comments
disburser_request_1.save!
expect(disburser_request_1.disburser_request_statuses.size).to eq(2)
disburser_request_1.data_status = DisburserRequest::DISBURSER_REQUEST_DATA_STATUS_DATA_CHECKED
data_status_comments = 'data check 2'
disburser_request_1.data_status_comments = data_status_comments
disburser_request_1.save!
expect(disburser_request_1.disburser_request_statuses.size).to eq(3)
end

it "can return disburser requests that do not have a status of 'draft'", focus: false do
Expand Down
Loading