Skip to content

Commit 1395a09

Browse files
committed
Merge branch 'master' into dev/2.6/prepare-2.6.0
2 parents ee2983c + d33f171 commit 1395a09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+956
-97
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: helpyio
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

Gemfile.lock

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GIT
22
remote: https://github.com/helpyio/helpy_imap
3-
revision: 7b958c12535ce4a462206a8dccc59fc321ed983e
3+
revision: f92b0287c55f6828896b13c9970199a727ddab0b
44
branch: master
55
specs:
66
helpy_imap (1.0.1)
@@ -70,7 +70,7 @@ GEM
7070
attachinary (1.3.1)
7171
cloudinary (~> 1.1.0)
7272
rails (>= 3.2)
73-
autoprefixer-rails (9.6.0)
73+
autoprefixer-rails (9.6.1)
7474
execjs
7575
awesome_print (1.8.0)
7676
aws_cf_signer (0.1.3)
@@ -94,12 +94,12 @@ GEM
9494
bootstrap-select-rails (1.12.4)
9595
bootstrap-switch-rails (3.3.3)
9696
bootstrap_form (2.7.0)
97-
brakeman (4.5.0)
97+
brakeman (4.6.1)
9898
builder (3.2.3)
9999
bulk_insert (1.7.0)
100100
activerecord (>= 3.2.0)
101-
bundler-audit (0.6.0)
102-
bundler (~> 1.2)
101+
bundler-audit (0.6.1)
102+
bundler (>= 1.2.0, < 3)
103103
thor (~> 0.18)
104104
byebug (10.0.2)
105105
capybara (2.18.0)
@@ -156,24 +156,24 @@ GEM
156156
crass (1.0.4)
157157
css_parser (1.7.0)
158158
addressable
159-
daemons (1.2.6)
159+
daemons (1.3.1)
160160
debug_inspector (0.0.3)
161161
deep_merge (1.0.1)
162-
deface (1.5.0)
162+
deface (1.5.1)
163163
nokogiri (>= 1.6)
164164
polyglot
165165
rails (>= 4.1)
166166
rainbow (>= 2.1.0)
167167
descendants_tracker (0.0.4)
168168
thread_safe (~> 0.3, >= 0.3.1)
169-
devise (4.6.2)
169+
devise (4.7.0)
170170
bcrypt (~> 3.0)
171171
orm_adapter (~> 0.1)
172-
railties (>= 4.1.0, < 6.0)
172+
railties (>= 4.1.0)
173173
responders
174174
warden (~> 1.2.3)
175175
devise-bootstrap-views (1.1.0)
176-
devise-i18n (1.8.0)
176+
devise-i18n (1.8.1)
177177
devise (>= 4.6)
178178
devise_invitable (1.7.5)
179179
actionmailer (>= 4.1.0)
@@ -185,15 +185,15 @@ GEM
185185
equalizer (0.0.11)
186186
erubi (1.8.0)
187187
erubis (2.7.0)
188-
excon (0.64.0)
188+
excon (0.66.0)
189189
execjs (2.7.0)
190190
factory_bot (5.0.2)
191191
activesupport (>= 4.2.0)
192192
factory_bot_rails (5.0.2)
193193
factory_bot (~> 5.0.2)
194194
railties (>= 4.2.0)
195-
faker (1.9.6)
196-
i18n (>= 0.7)
195+
faker (2.1.2)
196+
i18n (>= 0.8)
197197
faraday (0.15.4)
198198
multipart-post (>= 1.2, < 3)
199199
ffi (1.11.1)
@@ -243,7 +243,7 @@ GEM
243243
grape-kaminari (0.1.9)
244244
grape
245245
kaminari
246-
grape-swagger (0.32.0)
246+
grape-swagger (0.33.0)
247247
grape (>= 0.16.2)
248248
grape-swagger-entity (0.3.3)
249249
grape-entity (>= 0.5.0)
@@ -254,7 +254,7 @@ GEM
254254
griddler (1.5.2)
255255
htmlentities
256256
rails (>= 3.2.0)
257-
griddler-mailgun (1.0.3)
257+
griddler-mailgun (1.1.1)
258258
griddler
259259
griddler-mandrill (1.1.4)
260260
griddler (>= 1.2.1)
@@ -364,7 +364,7 @@ GEM
364364
mini_mime (1.0.2)
365365
mini_portile2 (2.4.0)
366366
minitest (5.11.3)
367-
minitest-reporters (1.3.5)
367+
minitest-reporters (1.3.8)
368368
ansi
369369
builder
370370
minitest (>= 5.0)
@@ -376,7 +376,7 @@ GEM
376376
mustermann-grape (1.0.0)
377377
mustermann (~> 1.0.0)
378378
netrc (0.11.0)
379-
nokogiri (1.10.3)
379+
nokogiri (1.10.4)
380380
mini_portile2 (~> 2.4.0)
381381
oauth (0.5.4)
382382
oauth2 (1.4.1)
@@ -459,14 +459,14 @@ GEM
459459
activesupport (>= 4.2.0, < 5.0)
460460
nokogiri (~> 1.6)
461461
rails-deprecated_sanitizer (>= 1.0.1)
462-
rails-html-sanitizer (1.0.4)
462+
rails-html-sanitizer (1.2.0)
463463
loofah (~> 2.2, >= 2.2.2)
464464
rails-i18n (4.0.9)
465465
i18n (~> 0.7)
466466
railties (~> 4.0)
467467
rails-settings-cached (0.5.6)
468468
rails (>= 4.2.0)
469-
rails-timeago (2.16.0)
469+
rails-timeago (2.17.1)
470470
actionpack (>= 3.1)
471471
activesupport (>= 3.1)
472472
railties (4.2.11.1)
@@ -485,7 +485,7 @@ GEM
485485
ffi (~> 1.0)
486486
rb-readline (0.5.5)
487487
rdiscount (2.2.0.1)
488-
rdoc (6.0.4)
488+
rdoc (6.1.1)
489489
recaptcha (2.3.0)
490490
json
491491
regexp_parser (0.5.0)
@@ -504,7 +504,7 @@ GEM
504504
route_translator (4.4.1)
505505
actionpack (>= 3.2, < 5.0)
506506
activesupport (>= 3.2, < 5.0)
507-
rubocop (0.73.0)
507+
rubocop (0.74.0)
508508
jaro_winkler (~> 1.5.1)
509509
parallel (~> 1.10)
510510
parser (>= 2.6)
@@ -520,10 +520,9 @@ GEM
520520
sprockets (>= 2.8, < 4.0)
521521
sprockets-rails (>= 2.0, < 4.0)
522522
tilt (>= 1.1, < 3)
523-
sassc (2.0.1)
523+
sassc (2.1.0)
524524
ffi (~> 1.9)
525-
rake
526-
scout_apm (2.5.1)
525+
scout_apm (2.5.2)
527526
scss-lint (0.38.0)
528527
rainbow (~> 2.0)
529528
sass (~> 3.4.1)
@@ -556,7 +555,7 @@ GEM
556555
actionpack (>= 4.0)
557556
activesupport (>= 4.0)
558557
sprockets (>= 3.0.0)
559-
staccato (0.5.1)
558+
staccato (0.5.3)
560559
sucker_punch (2.1.2)
561560
concurrent-ruby (~> 1.0)
562561
summernote-rails (0.8.12.0)
@@ -578,7 +577,7 @@ GEM
578577
execjs (>= 2.2.2, >= 2.2)
579578
less-rails (>= 2.5.0)
580579
railties (>= 3.1)
581-
twitter-bootstrap-rails-confirm (2.0.0)
580+
twitter-bootstrap-rails-confirm (2.0.1)
582581
tzinfo (1.2.5)
583582
thread_safe (~> 0.1)
584583
uglifier (4.1.20)

app/controllers/admin/users_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ def destroy
136136

137137
respond_to do |format|
138138
format.html { redirect_to admin_users_path,
139-
:flash => { :success => "User #{@user.name} was scheduled for permanent deletion." }}
139+
flash: { success: I18n.t(:notify_user_delete, user_name: @user.name)}
140+
}
140141
format.js { }
141142
end
142143
end

app/controllers/api/v1/categories.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ class Categories < Grape::API
2020
params do
2121
optional :docs, type: Boolean, desc: "Whether to include the documents in the response"
2222
optional :docs_limit, type: Integer, desc: "How many docs to return with the category"
23+
optional :visibility, type: String, desc: "Lets you filter categories by visibility.", values: ['all', 'public', 'internal']
2324
end
2425
get "", root: :categories do
25-
categories = Category.includes(:translations).active.publicly.ordered.all
26+
visibility = params[:visibility] || %w[all public]
27+
categories = Category.where(visibility: visibility).includes(:translations).active.ordered.all
2628
present categories, with: Entity::Category, docs: permitted_params[:docs], docs_limit: permitted_params[:docs_limit]
2729
end
2830

@@ -53,6 +55,7 @@ class Categories < Grape::API
5355
optional :rank, type: Integer, desc: "The rank can be used to determine the ordering of categories"
5456
optional :front_page, type: Boolean, desc: "Whether or not the category should appear on the front page"
5557
optional :active, type: Boolean, desc: "Whether or not the category is live on the site"
58+
optional :visibility, type: String, desc: "Lets you filter categories by visibility.", values: ['all', 'public', 'internal']
5659
end
5760
post "", root: :categories do
5861
category = Category.create!(
@@ -63,7 +66,8 @@ class Categories < Grape::API
6366
meta_description: permitted_params[:meta_description],
6467
rank: permitted_params[:rank],
6568
front_page: permitted_params[:front_page],
66-
active: permitted_params[:active]
69+
active: permitted_params[:active],
70+
visibility: permitted_params[:visibility] || 'all'
6771
)
6872
present category, with: Entity::Category
6973
end
@@ -83,6 +87,7 @@ class Categories < Grape::API
8387
optional :rank, type: Integer, desc: "The rank can be used to determine the ordering of categories"
8488
optional :front_page, type: Boolean, desc: "Whether or not the category should appear on the front page"
8589
optional :active, type: Boolean, desc: "Whether or not the category is live on the site"
90+
optional :visibility, type: String, desc: "Lets you filter categories by visibility.", values: ['all', 'public', 'internal']
8691
end
8792
patch ":id", root: :categories do
8893
category = Category.find(permitted_params[:id])
@@ -94,7 +99,8 @@ class Categories < Grape::API
9499
meta_description: permitted_params[:meta_description],
95100
rank: permitted_params[:rank],
96101
front_page: permitted_params[:front_page],
97-
active: permitted_params[:active]
102+
active: permitted_params[:active],
103+
visibility: permitted_params[:visibility]
98104
)
99105
present category, with: Entity::Category
100106
end

app/controllers/api/v1/forums.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Forums < Grape::API
3333
end
3434
get ":id", root: "forum" do
3535
forum = Forum.where(id: permitted_params[:id]).first!
36-
present forum, with: Entity::Forum, topics: true
36+
present forum, with: Entity::Forum, topics: true, topics_limit: permitted_params[:topics_limit]
3737
end
3838

3939
# CREATE NEW FORUM

app/controllers/api/v1/topics.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Topics < Grape::API
7070
topic = Topic.includes(:posts).find(permitted_params[:id])
7171
end
7272
if topic.present?
73-
present topic, with: Entity::Topic, posts: true
73+
present topic, with: Entity::Topic, posts: true, user: true
7474
else
7575
error!('Unauthorized. Insufficient access priviledges.', 401)
7676
end
@@ -124,7 +124,7 @@ class Topics < Grape::API
124124
user_id: user_id,
125125
kind: 'first',
126126
)
127-
present ticket, with: Entity::Topic, posts: true
127+
present ticket, with: Entity::Topic, posts: true, user: true
128128
end
129129

130130
# ASSIGN TICKET
@@ -144,7 +144,7 @@ class Topics < Grape::API
144144
previous_assigned_id = ticket.assigned_user_id? ? ticket.assigned_user_id : params[:assigned_user_id]
145145
assigned_user = User.find(params[:assigned_user_id])
146146
ticket.assign(previous_assigned_id, assigned_user.id)
147-
present ticket, with: Entity::Topic, posts: true
147+
present ticket, with: Entity::Topic, posts: true, user: true
148148
else
149149
error!('Unauthorized. Insufficient access priviledges.', 401)
150150
end
@@ -175,7 +175,7 @@ class Topics < Grape::API
175175
ticket.current_status = params[:status]
176176
ticket.save
177177
end
178-
present ticket, with: Entity::Topic, posts: true
178+
present ticket, with: Entity::Topic, posts: true, user: true
179179
else
180180
error!('Unauthorized. Insufficient access priviledges.', 401)
181181
end
@@ -197,7 +197,7 @@ class Topics < Grape::API
197197
if ticket.present?
198198
ticket.tag_list = params[:tag_list]
199199
ticket.save
200-
present ticket, with: Entity::Topic, posts: true
200+
present ticket, with: Entity::Topic, posts: true, user: true
201201
else
202202
error!('Unauthorized. Insufficient access priviledges.', 401)
203203
end
@@ -221,7 +221,7 @@ class Topics < Grape::API
221221
ticket.private = is_private
222222
ticket.forum_id = params[:forum_id]
223223
ticket.save
224-
present ticket, with: Entity::Topic, posts: true
224+
present ticket, with: Entity::Topic, posts: true, user: true
225225
else
226226
error!('Unauthorized. Insufficient access priviledges.', 401)
227227
end
@@ -280,7 +280,7 @@ class Topics < Grape::API
280280
post "merge", root: :topics do
281281
@ticket = Topic.merge_topics(params[:topic_ids], params[:user_id])
282282
if @ticket.present?
283-
present @ticket, with: Entity::Topic, posts: true
283+
present @ticket, with: Entity::Topic, posts: true, user: true
284284
end
285285
end
286286
end
@@ -298,7 +298,7 @@ class Topics < Grape::API
298298
end
299299
get ":id", root: :topics do
300300
topic = Topic.includes(:posts).find(permitted_params[:id])#
301-
present topic, with: Entity::Topic, posts: true
301+
present topic, with: Entity::Topic, posts: true, user: true
302302
end
303303

304304

@@ -329,7 +329,7 @@ class Topics < Grape::API
329329
user_id: permitted_params[:user_id],
330330
kind: 'first'
331331
)
332-
present topic, with: Entity::Topic, posts: true
332+
present topic, with: Entity::Topic, posts: true, user: true
333333
end
334334

335335
# UPDATE SINGLE TOPIC (PRIVACY, STATUS, ASSIGNED, ETC)
@@ -352,7 +352,7 @@ class Topics < Grape::API
352352
assigned_user_id: permitted_params[:assigned_user_id],
353353
priority: permitted_params[:priority] || 'normal'
354354
)
355-
present topic, with: Entity::Topic, posts: true
355+
present topic, with: Entity::Topic, posts: true, user: true
356356
end
357357

358358
# VOTE FOR A TOPIC

app/controllers/api/v1/users.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ class Users < Grape::API
2525
present users, with: Entity::User
2626
end
2727

28+
# LOAD YOUR OWN USER
29+
desc "Load your own user", {
30+
entity: Entity::User,
31+
notes: "Returns the currently logged in user"
32+
}
33+
get "self", root: :users do
34+
present current_user, with: Entity::User
35+
end
36+
2837
# SEARCH USERS
2938
desc "Search users by name, email, account number, phone, etc.", {
3039
entity: Entity::User,

app/models/doc.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Doc < ActiveRecord::Base
4040
validates :category_id, presence: true
4141

4242
include PgSearch::Model
43-
multisearchable against: [:title, :body, :keywords],
43+
multisearchable against: [:title_with_translations, :body_with_translations, :keywords_with_translations],
4444
:if => lambda { |record| record.category.present? && record.category.publicly_viewable? && record.active && record.category.active? }
4545

4646
pg_search_scope :agent_assist,
@@ -95,4 +95,19 @@ def tag_list
9595
@tag_list ||= ActsAsTaggableOn::TagList.new tags.collect(&:name)
9696
end
9797

98+
# These methods aggregate translations into the search table so articles
99+
# are searchable by any of their available translations
100+
101+
def title_with_translations
102+
self.doc_translations.collect { |doc| doc.title }.join(" ")
103+
end
104+
105+
def body_with_translations
106+
self.doc_translations.collect { |doc| doc.body }.join(" ")
107+
end
108+
109+
def keywords_with_translations
110+
self.doc_translations.collect { |doc| doc.keywords }.join(" ")
111+
end
112+
98113
end

0 commit comments

Comments
 (0)