Skip to content

Commit

Permalink
Added question label constaints
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoynter committed Oct 27, 2016
1 parent 76c1b9e commit 1477e70
Show file tree
Hide file tree
Showing 21 changed files with 108,641 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/assets/javascripts/lib/data_manager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ data_manager.factory(
console.log obj
for key, value of row
obj[key] = row[key]
if ['CcLoop','CcCondition','CcQuestion','CcStatement','CcSequence'].indexOf(obj.type) != -1
obj.type = Map.translate(obj.type)
console.log obj
arr.push obj

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/instruments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def reorder_ccs
unless params[:updates].nil?
params[:updates].each do |u|
unless u[:type].nil? || u[:id].nil? || u[:parent].nil?
cc = @object.send(u[:type] + 's').find(u[:id])
parent = @object.send(u[:parent][:type] + 's').find(u[:parent][:id])
cc = @object.send(u[:type].tableize).find(u[:id])
parent = @object.send(u[:parent][:type].tableize).find(u[:parent][:id])
unless cc.nil? or parent.nil?
cc.position = u[:position]
cc.parent = parent
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Archivist
class Application
VERSION = '6.1.2'
VERSION = '6.1.3'
BETA = false
end
end
9 changes: 9 additions & 0 deletions db/migrate/20161027133806_add_question_label_constraints.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddQuestionLabelConstraints < ActiveRecord::Migration[5.0]
def change
change_column_null :question_items, :label, false
change_column_null :question_grids, :label, false

add_index :question_grids, [:label, :instrument_id], unique: true
add_index :question_items, [:label, :instrument_id], unique: true
end
end
2 changes: 2 additions & 0 deletions lib/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Question::Model

include Realtime::RtUpdate

validates :label, uniqueness: { scope: :instrument_id }

alias constructs cc_questions

def response_domains
Expand Down

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 1477e70

Please sign in to comment.