Skip to content

Commit

Permalink
Merge branch 'master' into dev/2.6/prepare-2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scott committed Aug 20, 2019
2 parents ee2983c + d33f171 commit 1395a09
Show file tree
Hide file tree
Showing 46 changed files with 956 additions and 97 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: helpyio
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
51 changes: 25 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/helpyio/helpy_imap
revision: 7b958c12535ce4a462206a8dccc59fc321ed983e
revision: f92b0287c55f6828896b13c9970199a727ddab0b
branch: master
specs:
helpy_imap (1.0.1)
Expand Down Expand Up @@ -70,7 +70,7 @@ GEM
attachinary (1.3.1)
cloudinary (~> 1.1.0)
rails (>= 3.2)
autoprefixer-rails (9.6.0)
autoprefixer-rails (9.6.1)
execjs
awesome_print (1.8.0)
aws_cf_signer (0.1.3)
Expand All @@ -94,12 +94,12 @@ GEM
bootstrap-select-rails (1.12.4)
bootstrap-switch-rails (3.3.3)
bootstrap_form (2.7.0)
brakeman (4.5.0)
brakeman (4.6.1)
builder (3.2.3)
bulk_insert (1.7.0)
activerecord (>= 3.2.0)
bundler-audit (0.6.0)
bundler (~> 1.2)
bundler-audit (0.6.1)
bundler (>= 1.2.0, < 3)
thor (~> 0.18)
byebug (10.0.2)
capybara (2.18.0)
Expand Down Expand Up @@ -156,24 +156,24 @@ GEM
crass (1.0.4)
css_parser (1.7.0)
addressable
daemons (1.2.6)
daemons (1.3.1)
debug_inspector (0.0.3)
deep_merge (1.0.1)
deface (1.5.0)
deface (1.5.1)
nokogiri (>= 1.6)
polyglot
rails (>= 4.1)
rainbow (>= 2.1.0)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (4.6.2)
devise (4.7.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise-bootstrap-views (1.1.0)
devise-i18n (1.8.0)
devise-i18n (1.8.1)
devise (>= 4.6)
devise_invitable (1.7.5)
actionmailer (>= 4.1.0)
Expand All @@ -185,15 +185,15 @@ GEM
equalizer (0.0.11)
erubi (1.8.0)
erubis (2.7.0)
excon (0.64.0)
excon (0.66.0)
execjs (2.7.0)
factory_bot (5.0.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.2)
factory_bot (~> 5.0.2)
railties (>= 4.2.0)
faker (1.9.6)
i18n (>= 0.7)
faker (2.1.2)
i18n (>= 0.8)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
ffi (1.11.1)
Expand Down Expand Up @@ -243,7 +243,7 @@ GEM
grape-kaminari (0.1.9)
grape
kaminari
grape-swagger (0.32.0)
grape-swagger (0.33.0)
grape (>= 0.16.2)
grape-swagger-entity (0.3.3)
grape-entity (>= 0.5.0)
Expand All @@ -254,7 +254,7 @@ GEM
griddler (1.5.2)
htmlentities
rails (>= 3.2.0)
griddler-mailgun (1.0.3)
griddler-mailgun (1.1.1)
griddler
griddler-mandrill (1.1.4)
griddler (>= 1.2.1)
Expand Down Expand Up @@ -364,7 +364,7 @@ GEM
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
minitest-reporters (1.3.5)
minitest-reporters (1.3.8)
ansi
builder
minitest (>= 5.0)
Expand All @@ -376,7 +376,7 @@ GEM
mustermann-grape (1.0.0)
mustermann (~> 1.0.0)
netrc (0.11.0)
nokogiri (1.10.3)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
oauth (0.5.4)
oauth2 (1.4.1)
Expand Down Expand Up @@ -459,14 +459,14 @@ GEM
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.4)
rails-html-sanitizer (1.2.0)
loofah (~> 2.2, >= 2.2.2)
rails-i18n (4.0.9)
i18n (~> 0.7)
railties (~> 4.0)
rails-settings-cached (0.5.6)
rails (>= 4.2.0)
rails-timeago (2.16.0)
rails-timeago (2.17.1)
actionpack (>= 3.1)
activesupport (>= 3.1)
railties (4.2.11.1)
Expand All @@ -485,7 +485,7 @@ GEM
ffi (~> 1.0)
rb-readline (0.5.5)
rdiscount (2.2.0.1)
rdoc (6.0.4)
rdoc (6.1.1)
recaptcha (2.3.0)
json
regexp_parser (0.5.0)
Expand All @@ -504,7 +504,7 @@ GEM
route_translator (4.4.1)
actionpack (>= 3.2, < 5.0)
activesupport (>= 3.2, < 5.0)
rubocop (0.73.0)
rubocop (0.74.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.6)
Expand All @@ -520,10 +520,9 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sassc (2.0.1)
sassc (2.1.0)
ffi (~> 1.9)
rake
scout_apm (2.5.1)
scout_apm (2.5.2)
scss-lint (0.38.0)
rainbow (~> 2.0)
sass (~> 3.4.1)
Expand Down Expand Up @@ -556,7 +555,7 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
staccato (0.5.1)
staccato (0.5.3)
sucker_punch (2.1.2)
concurrent-ruby (~> 1.0)
summernote-rails (0.8.12.0)
Expand All @@ -578,7 +577,7 @@ GEM
execjs (>= 2.2.2, >= 2.2)
less-rails (>= 2.5.0)
railties (>= 3.1)
twitter-bootstrap-rails-confirm (2.0.0)
twitter-bootstrap-rails-confirm (2.0.1)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (4.1.20)
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ def destroy

respond_to do |format|
format.html { redirect_to admin_users_path,
:flash => { :success => "User #{@user.name} was scheduled for permanent deletion." }}
flash: { success: I18n.t(:notify_user_delete, user_name: @user.name)}
}
format.js { }
end
end
Expand Down
12 changes: 9 additions & 3 deletions app/controllers/api/v1/categories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ class Categories < Grape::API
params do
optional :docs, type: Boolean, desc: "Whether to include the documents in the response"
optional :docs_limit, type: Integer, desc: "How many docs to return with the category"
optional :visibility, type: String, desc: "Lets you filter categories by visibility.", values: ['all', 'public', 'internal']
end
get "", root: :categories do
categories = Category.includes(:translations).active.publicly.ordered.all
visibility = params[:visibility] || %w[all public]
categories = Category.where(visibility: visibility).includes(:translations).active.ordered.all
present categories, with: Entity::Category, docs: permitted_params[:docs], docs_limit: permitted_params[:docs_limit]
end

Expand Down Expand Up @@ -53,6 +55,7 @@ class Categories < Grape::API
optional :rank, type: Integer, desc: "The rank can be used to determine the ordering of categories"
optional :front_page, type: Boolean, desc: "Whether or not the category should appear on the front page"
optional :active, type: Boolean, desc: "Whether or not the category is live on the site"
optional :visibility, type: String, desc: "Lets you filter categories by visibility.", values: ['all', 'public', 'internal']
end
post "", root: :categories do
category = Category.create!(
Expand All @@ -63,7 +66,8 @@ class Categories < Grape::API
meta_description: permitted_params[:meta_description],
rank: permitted_params[:rank],
front_page: permitted_params[:front_page],
active: permitted_params[:active]
active: permitted_params[:active],
visibility: permitted_params[:visibility] || 'all'
)
present category, with: Entity::Category
end
Expand All @@ -83,6 +87,7 @@ class Categories < Grape::API
optional :rank, type: Integer, desc: "The rank can be used to determine the ordering of categories"
optional :front_page, type: Boolean, desc: "Whether or not the category should appear on the front page"
optional :active, type: Boolean, desc: "Whether or not the category is live on the site"
optional :visibility, type: String, desc: "Lets you filter categories by visibility.", values: ['all', 'public', 'internal']
end
patch ":id", root: :categories do
category = Category.find(permitted_params[:id])
Expand All @@ -94,7 +99,8 @@ class Categories < Grape::API
meta_description: permitted_params[:meta_description],
rank: permitted_params[:rank],
front_page: permitted_params[:front_page],
active: permitted_params[:active]
active: permitted_params[:active],
visibility: permitted_params[:visibility]
)
present category, with: Entity::Category
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/forums.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Forums < Grape::API
end
get ":id", root: "forum" do
forum = Forum.where(id: permitted_params[:id]).first!
present forum, with: Entity::Forum, topics: true
present forum, with: Entity::Forum, topics: true, topics_limit: permitted_params[:topics_limit]
end

# CREATE NEW FORUM
Expand Down
20 changes: 10 additions & 10 deletions app/controllers/api/v1/topics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Topics < Grape::API
topic = Topic.includes(:posts).find(permitted_params[:id])
end
if topic.present?
present topic, with: Entity::Topic, posts: true
present topic, with: Entity::Topic, posts: true, user: true
else
error!('Unauthorized. Insufficient access priviledges.', 401)
end
Expand Down Expand Up @@ -124,7 +124,7 @@ class Topics < Grape::API
user_id: user_id,
kind: 'first',
)
present ticket, with: Entity::Topic, posts: true
present ticket, with: Entity::Topic, posts: true, user: true
end

# ASSIGN TICKET
Expand All @@ -144,7 +144,7 @@ class Topics < Grape::API
previous_assigned_id = ticket.assigned_user_id? ? ticket.assigned_user_id : params[:assigned_user_id]
assigned_user = User.find(params[:assigned_user_id])
ticket.assign(previous_assigned_id, assigned_user.id)
present ticket, with: Entity::Topic, posts: true
present ticket, with: Entity::Topic, posts: true, user: true
else
error!('Unauthorized. Insufficient access priviledges.', 401)
end
Expand Down Expand Up @@ -175,7 +175,7 @@ class Topics < Grape::API
ticket.current_status = params[:status]
ticket.save
end
present ticket, with: Entity::Topic, posts: true
present ticket, with: Entity::Topic, posts: true, user: true
else
error!('Unauthorized. Insufficient access priviledges.', 401)
end
Expand All @@ -197,7 +197,7 @@ class Topics < Grape::API
if ticket.present?
ticket.tag_list = params[:tag_list]
ticket.save
present ticket, with: Entity::Topic, posts: true
present ticket, with: Entity::Topic, posts: true, user: true
else
error!('Unauthorized. Insufficient access priviledges.', 401)
end
Expand All @@ -221,7 +221,7 @@ class Topics < Grape::API
ticket.private = is_private
ticket.forum_id = params[:forum_id]
ticket.save
present ticket, with: Entity::Topic, posts: true
present ticket, with: Entity::Topic, posts: true, user: true
else
error!('Unauthorized. Insufficient access priviledges.', 401)
end
Expand Down Expand Up @@ -280,7 +280,7 @@ class Topics < Grape::API
post "merge", root: :topics do
@ticket = Topic.merge_topics(params[:topic_ids], params[:user_id])
if @ticket.present?
present @ticket, with: Entity::Topic, posts: true
present @ticket, with: Entity::Topic, posts: true, user: true
end
end
end
Expand All @@ -298,7 +298,7 @@ class Topics < Grape::API
end
get ":id", root: :topics do
topic = Topic.includes(:posts).find(permitted_params[:id])#
present topic, with: Entity::Topic, posts: true
present topic, with: Entity::Topic, posts: true, user: true
end


Expand Down Expand Up @@ -329,7 +329,7 @@ class Topics < Grape::API
user_id: permitted_params[:user_id],
kind: 'first'
)
present topic, with: Entity::Topic, posts: true
present topic, with: Entity::Topic, posts: true, user: true
end

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

# VOTE FOR A TOPIC
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/api/v1/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ class Users < Grape::API
present users, with: Entity::User
end

# LOAD YOUR OWN USER
desc "Load your own user", {
entity: Entity::User,
notes: "Returns the currently logged in user"
}
get "self", root: :users do
present current_user, with: Entity::User
end

# SEARCH USERS
desc "Search users by name, email, account number, phone, etc.", {
entity: Entity::User,
Expand Down
17 changes: 16 additions & 1 deletion app/models/doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Doc < ActiveRecord::Base
validates :category_id, presence: true

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

pg_search_scope :agent_assist,
Expand Down Expand Up @@ -95,4 +95,19 @@ def tag_list
@tag_list ||= ActsAsTaggableOn::TagList.new tags.collect(&:name)
end

# These methods aggregate translations into the search table so articles
# are searchable by any of their available translations

def title_with_translations
self.doc_translations.collect { |doc| doc.title }.join(" ")
end

def body_with_translations
self.doc_translations.collect { |doc| doc.body }.join(" ")
end

def keywords_with_translations
self.doc_translations.collect { |doc| doc.keywords }.join(" ")
end

end
Loading

0 comments on commit 1395a09

Please sign in to comment.