Skip to content

Commit c491985

Browse files
author
Christopher Talib
authored
Merge pull request #291 from tosdr/201804-reason-on-point-update
added 'reason' form input to point edit page
2 parents 0a96c8c + 440f6df commit c491985

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

app/controllers/points_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def set_service
9191
end
9292

9393
def point_params
94-
params.require(:point).permit(:title, :source, :status, :rating, :analysis, :topic_id, :service_id, :is_featured, :query)
94+
params.require(:point).permit(:title, :source, :status, :rating, :analysis, :topic_id, :service_id, :is_featured, :query, :reason)
9595
end
9696

9797
def points_get

app/views/points/_form.html.erb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,21 @@
3232
<%= f.input :status, collection: ["pending", "draft"], hint: "Choose pending for the curators to review your point" %>
3333
<% end %>
3434
</div>
35+
<% if params[:action] == "edit" %>
36+
<div class="col-xs-12">
37+
<%= f.input :reason, as: :text , input_html: { rows: 4, class: "text-area" }, hint: "Provide a reason for your changes to this analysis point." %>
38+
</div>
39+
<% end %>
3540
<div class="form-actions col-xs-4 col-sm-2 col-md-2">
3641
<%= link_to "Back", :back, class: "btn btn-default" %>
3742
</div>
3843
<div class="form-actions col-xs-8 col-sm-4 col-sm-offset-6 col-md-3 col-md-offset-7">
39-
<%= f.submit "Submit Point", name: "only_create", class: 'btn btn-primary' %>
40-
<%= f.submit "Submit Point + Add Another", name: "create_add_another", class: 'btn btn-primary' %>
44+
<% if params[:action] == "new" %>
45+
<%= f.submit "Submit", name: "only_create", class: 'btn btn-primary' %>
46+
<%= f.submit "Submit + Add Another", name: "create_add_another", class: 'btn btn-primary' %>
47+
<% else %>
48+
<%= f.submit "Update", class: 'btn btn-primary' %>
49+
<% end %>
4150
</div>
4251
</div>
4352
<% end %>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class RemoveChangeReasonFromPoints < ActiveRecord::Migration[5.1]
2+
def change
3+
remove_column :points, :change_reason, :text
4+
end
5+
end

db/schema.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 20180414123052) do
13+
ActiveRecord::Schema.define(version: 20180424095751) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -34,9 +34,9 @@
3434
t.integer "score"
3535
t.string "title"
3636
t.text "description"
37-
t.bigint "topic_id"
3837
t.datetime "created_at", null: false
3938
t.datetime "updated_at", null: false
39+
t.integer "topic_id"
4040
t.index ["topic_id"], name: "index_cases_on_topic_id"
4141
end
4242

@@ -65,7 +65,6 @@
6565
t.bigint "case_id"
6666
t.string "oldId"
6767
t.text "reason"
68-
t.text "change_reason"
6968
t.index ["case_id"], name: "index_points_on_case_id"
7069
t.index ["service_id"], name: "index_points_on_service_id"
7170
t.index ["topic_id"], name: "index_points_on_topic_id"
@@ -89,10 +88,13 @@
8988
t.datetime "created_at", null: false
9089
t.datetime "updated_at", null: false
9190
t.string "grade"
91+
t.bigint "user_id"
92+
t.string "status"
9293
t.string "wikipedia"
9394
t.string "keywords"
9495
t.string "related"
9596
t.string "slug"
97+
t.index ["user_id"], name: "index_services_on_user_id"
9698
end
9799

98100
create_table "topics", force: :cascade do |t|
@@ -137,12 +139,12 @@
137139
t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
138140
end
139141

140-
add_foreign_key "cases", "topics"
141142
add_foreign_key "comments", "points"
142143
add_foreign_key "points", "cases"
143144
add_foreign_key "points", "services"
144145
add_foreign_key "points", "topics"
145146
add_foreign_key "points", "users"
146147
add_foreign_key "reasons", "points"
147148
add_foreign_key "reasons", "users"
149+
add_foreign_key "services", "users"
148150
end

0 commit comments

Comments
 (0)