Skip to content

Commit 72329ed

Browse files
committed
standardize document name selection
1 parent 9f469f8 commit 72329ed

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

app/models/document.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,43 @@ class Document < ApplicationRecord
1616

1717
validate :custom_uniqueness_check
1818

19+
VALID_NAMES = [
20+
"Terms of Service",
21+
"Privacy Policy",
22+
"Imprint",
23+
"Trackers Policy",
24+
"Developer Terms",
25+
"Community Guidelines",
26+
"Deceased Users",
27+
"Acceptable Use Policy",
28+
"Restricted Use Policy",
29+
"Commercial Terms",
30+
"Copyright Claims Policy",
31+
"Law Enforcement Guidelines",
32+
"Human Rights Policy",
33+
"In-App Purchases Policy",
34+
"Review Guidelines",
35+
"Brand Guidelines",
36+
"Quality Guidelines",
37+
"Data Controller Agreement",
38+
"Data Processor Agreement",
39+
"User Consent Policy",
40+
"Closed Captioning Policy",
41+
"Seller Warranty",
42+
"Single Sign-On Policy",
43+
"Vulnerability Disclosure Policy",
44+
"Live Policy",
45+
"Complaints Policy",
46+
"General Conditions of Sale",
47+
"Marketplace Buyers Conditions",
48+
"Marketplace Sellers Conditions",
49+
"Ranking Parameters Description",
50+
"Premium Partner Conditions",
51+
"Platform to Business Notice",
52+
"Business Mediation Policy",
53+
"Business Privacy Policy"
54+
]
55+
1956
def self.search_by_document_name(query)
2057
Document.joins(:service).where('services.name ILIKE ? or documents.name ILIKE ? or documents.url ILIKE?', "%#{query}%", "%#{query}%", "%#{query}%")
2158
end

app/views/documents/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<%= simple_form_for [@document] do |f| %>
22
<%= f.association :service, collection: Service.order('name ASC'), hint: "If your service isn't on the list, please contact the team" %>
3-
<%= f.input :name, hint: "Name of this document", placeholder: "e.g. \"Privacy Policy\"" %>
3+
<%= f.input :name, collection: Document::VALID_NAMES, hint: 'Name of the document', selected: 'Privacy Policy'%>
44
<%= f.input :url, hint: "Where we should fetch this document", placeholder: "e.g. \"https://www.facebook.com/about/privacy\"" %>
55
<%= f.input :xpath, input_html: { value: (f.object.xpath.present?) ? f.object.xpath : '//body' }, placeholder: "e.g. \"//*[@id='content']//div[@class='_5tkp _3m9']\"", hint: "The location of the terms on the page (Using <a href=\"https://en.wikipedia.org/wiki/XPath\" title=\"Wikipedia explanation of XPath\" target=\"_blank\">XPath</a>.)".html_safe %>
66
<%= f.input :crawler_server, collection: (Rails.env.development?) ? DocumentsController::DEV_CRAWLERS : DocumentsController::PROD_CRAWLERS, label_method: :second, value_method: :first, hint: "<a href=\"https://to.tosdr.org/U98u1\">Select from which country the crawler should be used, or a specific crawler. Useful if blocked by EU. (Optional)</a>".html_safe, selected: @document.crawler_server || "eu.crawler.api.tosdr.org" %>

0 commit comments

Comments
 (0)