Skip to content

Commit 08dd1cc

Browse files
committed
removes references to models from views
1 parent ca15bf2 commit 08dd1cc

24 files changed

+61
-36
lines changed

β€Žapp/controllers/cases_controller.rbβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class CasesController < ApplicationController
77
before_action :authenticate_user!, except: %i[index show list_all]
88
before_action :set_curator, only: [:destroy]
99
before_action :set_case, only: %i[show edit update destroy]
10+
before_action :set_topics, only: %i[new edit]
1011

1112
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
1213

@@ -83,6 +84,10 @@ def set_case
8384
@case = Case.find(params[:id])
8485
end
8586

87+
def set_topics
88+
@topics = Topic.order('title ASC')
89+
end
90+
8691
def case_params
8792
params.require(:case).permit(:classification, :score, :title, :description, :topic_id, :privacy_related, :docbot_regex)
8893
end

β€Žapp/controllers/documents_controller.rbβ€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class DocumentsController < ApplicationController
2727

2828
before_action :authenticate_user!, except: %i[index show]
2929
before_action :set_document, only: %i[show edit update crawl restore_points]
30+
before_action :set_services, only: %i[new edit]
31+
before_action :set_document_names, only: %i[new edit]
32+
before_action :set_crawlers, only: %i[new edit]
3033

3134
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
3235

@@ -149,6 +152,18 @@ def set_document
149152
@document = Document.find(params[:id].to_i)
150153
end
151154

155+
def set_services
156+
@services = Service.order('name ASC')
157+
end
158+
159+
def set_document_names
160+
@document_names = Document::VALID_NAMES
161+
end
162+
163+
def set_crawlers
164+
@crawlers = Rails.env.development? ? DEV_CRAWLERS : PROD_CRAWLERS
165+
end
166+
152167
def document_params
153168
params.require(:document).permit(:service, :service_id, :user_id, :name, :url, :xpath, :crawler_server)
154169
end

β€Žapp/controllers/points_controller.rbβ€Ž

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ class PointsController < ApplicationController
88

99
before_action :authenticate_user!, except: [:show]
1010
before_action :set_point, only: %i[show edit update review post_review approve decline]
11-
before_action :set_topics, only: %i[new create edit update approve]
11+
before_action :set_topics, only: %i[new edit]
12+
before_action :set_services, only: %i[new edit]
1213
before_action :check_status, only: %i[create update]
1314

1415
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
@@ -183,6 +184,10 @@ def set_topics
183184
@topics = Topic.all.includes(:cases).all
184185
end
185186

187+
def set_services
188+
@services = Service.order('name ASC')
189+
end
190+
186191
def point_params
187192
params.require(:point).permit(:title, :source, :status, :analysis, :service_id, :query, :point_change, :case_id, :document, :source)
188193
end

β€Žapp/views/cases/_form.html.erbβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<div class="form-login">
22
<div class="row row-form">
3-
<%= simple_form_for([@case]) do |f| %>
3+
<%= simple_form_for([case_obj]) do |f| %>
44
<div class="form-inputs col-xs-12">
55
<%= f.input :title, placeholder: "Case title", label: 'Title' %>
66
<%= f.input :classification, as: :radio_buttons, collection: [['blocker', 'blocker'], ['bad', 'bad'], ['neutral', 'neutral'], ['good', 'good']] %>
7-
<%= f.input :score, placeholder: 50, input_html: { min: 0, max: 100, value: @case.score || 50 }, label: 'Weight', hint: "Range: 0..100. Higher weights make good points extra good, and bad/blocker points extra bad. Higher weight points have more impact on a service's rating, and are also displayed more prominently in the review summaries on <a href=\"https://tosdr.org\">ToS;DR</a>.".html_safe %>
8-
<%= f.association :topic, collection: Topic.order('title ASC'), hint: "Pick the topic where the case applies" %>
7+
<%= f.input :score, placeholder: 50, input_html: { min: 0, max: 100, value: case_obj.score || 50 }, label: 'Weight', hint: "Range: 0..100. Higher weights make good points extra good, and bad/blocker points extra bad. Higher weight points have more impact on a service's rating, and are also displayed more prominently in the review summaries on <a href=\"https://tosdr.org\">ToS;DR</a>.".html_safe %>
8+
<%= f.association :topic, collection: topics, hint: "Pick the topic where the case applies" %>
99
<%= f.input :description, as: :text , input_html: { rows: 3, class: "text-area" } %>
1010
<%= f.input :docbot_regex, label: 'DocBot Regex', hint: "(Optional) Regex for use in the DocBot Server. Insert nothing if you do not know what this is." %>
1111
<%= f.input :privacy_related, label: "This case is related to privacy, meaning it will affect <a href=\"https://spreadprivacy.com/privacy-simplified/\">DuckDuckGo's Privacy Grade</a>.".html_safe, checked_value: true, unchecked_value: false %>

β€Žapp/views/cases/create.html.erbβ€Ž

Lines changed: 0 additions & 2 deletions
This file was deleted.

β€Žapp/views/cases/destroy.html.erbβ€Ž

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% content_for :title do %>
22
<title>Edit Case <%= @case.id %> (ToS;DR Phoenix)</title>
33
<% end %>
4-
<%= render 'form' %>
4+
<%= render 'form', case_obj: @case, topics: @topics %>
55

β€Žapp/views/cases/index.html.erbβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</div>
2424

2525
<div class="col-lg-6 text-right justify-content-end">
26-
<% if current_user && current_user.curator %>
26+
<% if current_user&.curator %>
2727
<%= link_to 'Add Case', new_case_path, class: 'btn btn-primary smaller-btn-text' %>
2828
<% end %>
2929
</div>

β€Žapp/views/cases/new.html.erbβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<% content_for :title do %>
22
<title>New Case (ToS;DR Phoenix)</title>
33
<% end %>
4-
<%= render 'form' %>
4+
<%= render 'form', case_obj: @case, topics: @topics %>

β€Žapp/views/cases/show.html.erbβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@
4646
<br>
4747
<br>
4848

49-
<%= render 'shared/comments', comments: @case.case_comments.includes([:user, :spams]) %>
49+
<%= render 'shared/comments', comments: @case.case_comments.includes([:user, :spams]) %>

0 commit comments

Comments
Β (0)