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

KG - Editable Status Bug #1082

Merged
merged 2 commits into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/editable_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

class EditableStatus < ApplicationRecord
TYPES = (AVAILABLE_STATUSES.keys << 'first_draft')
TYPES = AVAILABLE_STATUSES.keys

audited

Expand Down
4 changes: 2 additions & 2 deletions app/models/sub_service_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ def ctrc?

#A request is locked if the organization it's in isn't editable
def is_locked?
!self.organization.process_ssrs_parent.has_editable_status?(status)
self.status != 'first_draft' && !self.organization.process_ssrs_parent.has_editable_status?(status)
end

# Can't edit a request if it's placed in an uneditable status
def can_be_edited?
self.organization.process_ssrs_parent.has_editable_status?(status) && !is_complete?
self.status == 'first_draft' || (self.organization.process_ssrs_parent.has_editable_status?(self.status) && !self.is_complete?)
end

def is_complete?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
%br
%legend= t(:organization_form)[:editable_statuses]
%table
= f.fields_for :editable_statuses, @organization.editable_statuses.select{ |es| es.status != 'first_draft'}.sort{|x, y| AVAILABLE_STATUSES[x.status] <=> AVAILABLE_STATUSES[y.status]} do |es|
= f.fields_for :editable_statuses, @organization.editable_statuses.sort{|x, y| AVAILABLE_STATUSES[x.status] <=> AVAILABLE_STATUSES[y.status]} do |es|
%tr{ class: "#{es.object.status}-dependent", style: @organization.available_statuses.select{ |as| !as.new_record? }.map(&:status).include?(es.object.status) ? "display:table-row;" : "display:none;" }
%th= es.label :status, "#{AVAILABLE_STATUSES[es.object.status].gsub('CTRC', 'Nexus')}:"
%td= es.check_box "_destroy", {:checked => !es.object.new_record?}, false, true
Expand All @@ -56,7 +56,7 @@
%legend= t(:organization_form)[:selected_statuses]
%table
%tr
- @organization.editable_statuses.select{ |es| es.status != 'first_draft' }.sort{|x, y| AVAILABLE_STATUSES[x.status] <=> AVAILABLE_STATUSES[y.status]}.each do |es|
- @organization.editable_statuses.sort{|x, y| AVAILABLE_STATUSES[x.status] <=> AVAILABLE_STATUSES[y.status]}.each do |es|
- unless es.id.nil?
%tr{ class: "#{es.status}-dependent", style: @organization.available_statuses.select{ |as| !as.new_record? }.map(&:status).include?(es.status) ? "display:table-row;" : "display:none;" }
%th= AVAILABLE_STATUSES[es.status]
6 changes: 3 additions & 3 deletions db/migrate/20170622132807_create_editable_statuses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ def up
if defined?(EDITABLE_STATUSES)
EDITABLE_STATUSES.each do |org_id, statuses|
if organization = Organization.find_by_id(org_id)
(statuses << 'first_draft').each do |status|
statuses.each do |status|
organization.editable_statuses.create(status: status)
end
end
end

Organization.where.not(id: EDITABLE_STATUSES.keys).each do |org|
(AVAILABLE_STATUSES.keys << 'first_draft').each do |status|
AVAILABLE_STATUSES.keys.each do |status|
org.editable_statuses.create(status: status)
end
end
else
Organization.all.each do |org|
(AVAILABLE_STATUSES.keys << 'first_draft').each do |status|
AVAILABLE_STATUSES.keys.each do |status|
org.editable_statuses.create(status: status)
end
end
Expand Down