diff --git a/app/controllers/api/contents_controller.rb b/app/controllers/api/contents_controller.rb deleted file mode 100644 index fc59c6e1c4..0000000000 --- a/app/controllers/api/contents_controller.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class Api::ContentsController < FrontendController - - activate_menu :serviceadmin - before_action :find_service - - def edit; end - - def update - if @service.update(params[:service]) - redirect_to edit_admin_service_content_path(@service), success: t('.success') - else - render :action => :edit - end - end - - protected - - def find_service - @service = current_user.accessible_services.find params[:service_id] - - authorize! :update, @service - end -end diff --git a/app/controllers/api/supports_controller.rb b/app/controllers/api/supports_controller.rb deleted file mode 100644 index 57cb49b3df..0000000000 --- a/app/controllers/api/supports_controller.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class Api::SupportsController < FrontendController - - activate_menu :serviceadmin - before_action :find_service - - def edit; end - - def update - if @edited_service.update(params[:service]) - redirect_to edit_admin_service_support_path(@service), success: t('.success') - else - render :action => :edit - end - end - - protected - - def find_service - @edited_service = current_user.accessible_services.find params[:service_id] - authorize! :update, @edited_service - authorize! :manage, :connect_portal - end - -end diff --git a/app/controllers/api/terms_controller.rb b/app/controllers/api/terms_controller.rb deleted file mode 100644 index 80c09ed1ff..0000000000 --- a/app/controllers/api/terms_controller.rb +++ /dev/null @@ -1,30 +0,0 @@ -class Api::TermsController < FrontendController - - activate_menu :site - before_action :find_service - - def default - @service = current_user.accessible_services.default - redirect_to :action => :edit, :service_id => @service.id - end - - def edit; end - - def update - if @edited_service.update(params[:edited_service]) - redirect_to edit_admin_service_terms_path(@edited_service), success: t('.success') - else - render :action => :edit - end - end - - protected - - def find_service - @edited_service = current_user.accessible_services.find params[:service_id] - - authorize! :update, @edited_service - authorize! :manage, :connect_portal - end - -end diff --git a/app/controllers/forums/admin/categories_controller.rb b/app/controllers/forums/admin/categories_controller.rb deleted file mode 100644 index 2c0de64d01..0000000000 --- a/app/controllers/forums/admin/categories_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Forums::Admin::CategoriesController < Forums::Admin::HidenForumController - include ForumSupport::Admin - include ForumSupport::Categories - - activate_menu :buyers, :forum, :categories -end diff --git a/app/controllers/forums/admin/forums_controller.rb b/app/controllers/forums/admin/forums_controller.rb deleted file mode 100644 index 06ce1ebb71..0000000000 --- a/app/controllers/forums/admin/forums_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Forums::Admin::ForumsController < Forums::Admin::HidenForumController - include ForumSupport::Admin - include ForumSupport::Forums - - activate_menu :buyers, :forum, :threads -end diff --git a/app/controllers/forums/admin/hiden_forum_controller.rb b/app/controllers/forums/admin/hiden_forum_controller.rb deleted file mode 100644 index a57c69fae1..0000000000 --- a/app/controllers/forums/admin/hiden_forum_controller.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class Forums::Admin::HidenForumController < FrontendController - before_action :hide_forum - - private - - def hide_forum - raise ActionController::RoutingError, '' - end -end diff --git a/app/controllers/forums/admin/posts_controller.rb b/app/controllers/forums/admin/posts_controller.rb deleted file mode 100644 index 836ac6e4ff..0000000000 --- a/app/controllers/forums/admin/posts_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Forums::Admin::PostsController < Forums::Admin::HidenForumController - include ForumSupport::Admin - include ForumSupport::Posts - - activate_menu :buyers, :forum -end diff --git a/app/controllers/forums/admin/subscriptions_controller.rb b/app/controllers/forums/admin/subscriptions_controller.rb deleted file mode 100644 index 1e769a7ceb..0000000000 --- a/app/controllers/forums/admin/subscriptions_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Forums::Admin::SubscriptionsController < Forums::Admin::HidenForumController - include ForumSupport::Admin - include ForumSupport::UserTopics - - activate_menu :buyers, :forum -end diff --git a/app/controllers/forums/admin/topics_controller.rb b/app/controllers/forums/admin/topics_controller.rb deleted file mode 100644 index 34ecc8a74f..0000000000 --- a/app/controllers/forums/admin/topics_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Forums::Admin::TopicsController < Forums::Admin::HidenForumController - include ForumSupport::Admin - include ForumSupport::Topics - - activate_menu :buyers, :forum, :my_threads -end diff --git a/app/controllers/forums/admin/user_topics_controller.rb b/app/controllers/forums/admin/user_topics_controller.rb deleted file mode 100644 index dbbae956fb..0000000000 --- a/app/controllers/forums/admin/user_topics_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Forums::Admin::UserTopicsController < Forums::Admin::HidenForumController - include ForumSupport::Admin - include ForumSupport::UserTopics - - activate_menu :buyers, :forum -end diff --git a/app/controllers/forums/public/categories_controller.rb b/app/controllers/forums/public/categories_controller.rb deleted file mode 100644 index 4e25201c5b..0000000000 --- a/app/controllers/forums/public/categories_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Forums::Public::CategoriesController < FrontendController - include ForumSupport::Public - include ForumSupport::Categories -end diff --git a/app/controllers/forums/public/forums_controller.rb b/app/controllers/forums/public/forums_controller.rb deleted file mode 100644 index 6e76c22733..0000000000 --- a/app/controllers/forums/public/forums_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Forums::Public::ForumsController < FrontendController - self.builtin_template_scope = 'forum/forums' - - include ForumSupport::Public - include ForumSupport::Forums - -end diff --git a/app/controllers/forums/public/posts_controller.rb b/app/controllers/forums/public/posts_controller.rb deleted file mode 100644 index 52d55959fb..0000000000 --- a/app/controllers/forums/public/posts_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Forums::Public::PostsController < FrontendController - include ForumSupport::Public - include ForumSupport::Posts -end diff --git a/app/controllers/forums/public/topics_controller.rb b/app/controllers/forums/public/topics_controller.rb deleted file mode 100644 index b67d9fca22..0000000000 --- a/app/controllers/forums/public/topics_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Forums::Public::TopicsController < FrontendController - include ForumSupport::Public - include ForumSupport::Topics -end diff --git a/app/controllers/forums/public/user_topics_controller.rb b/app/controllers/forums/public/user_topics_controller.rb deleted file mode 100644 index 5ece3f5080..0000000000 --- a/app/controllers/forums/public/user_topics_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Forums::Public::UserTopicsController < FrontendController - include ForumSupport::Public - include ForumSupport::UserTopics -end diff --git a/app/controllers/sites/documentations_controller.rb b/app/controllers/sites/documentations_controller.rb deleted file mode 100644 index 4bbd6c024d..0000000000 --- a/app/controllers/sites/documentations_controller.rb +++ /dev/null @@ -1,34 +0,0 @@ -class Sites::DocumentationsController < Sites::BaseController - # see ForumsController - activate_menu :serviceadmin - - before_action :authorize_connect - before_action :find_settings - - def edit - end - - def update - attrs = params[:settings].slice( :app_gallery_enabled, - :documentation_enabled, - :documentation_public) - - if @settings.update(attrs) - redirect_to edit_admin_site_documentation_url, success: t('.success') - else - flash.now[:danger] = t('.error') - render :action => 'edit' - end - end - - private - - def authorize_connect - authorize! :manage, :connect_portal - end - - def find_settings - @settings = current_account.settings - end - -end diff --git a/app/lib/forum_support/admin.rb b/app/lib/forum_support/admin.rb deleted file mode 100644 index 7351d10af9..0000000000 --- a/app/lib/forum_support/admin.rb +++ /dev/null @@ -1,79 +0,0 @@ -# frozen_string_literal: true - -module ForumSupport - # Mix in this module into admin-side controllers (forum, topic, post, ...) - module Admin - def self.included(base) - base.extend(ClassMethods) - - base.before_action :ensure_provider_domain - base.before_action :find_forum - - base.prefix_routes :admin_, :forum, - :forum_topics, :forum_topic, - :forum_topic_posts, :forum_posts, :forum_post, - :forum_categories, :forum_category, - :forum_subscriptions, :forum_subscription - - base.alias_route :new_forum_topic, :new_admin_forum_topic - base.alias_route :edit_forum_topic, :edit_admin_forum_topic - - base.alias_route :new_forum_topic_post, :new_admin_forum_topic_post - base.alias_route :edit_forum_post, :edit_admin_forum_post - - base.alias_route :new_forum_category, :new_admin_forum_category - base.alias_route :edit_forum_category, :edit_admin_forum_category - - base.alias_route :my_forum_topics, :my_admin_forum_topics - end - - private - - def find_forum - nil - end - - module ClassMethods - # TODO: extract this to module/plugin. - # TODO: document how to use this. - # TODO: test this! - # - def alias_route(new_name, old_name, &block) - raise "new name must be different from the old one" if new_name == old_name - - define_route_alias(:path, new_name, old_name, &block) - define_route_alias(:url, new_name, old_name, &block) - end - - # Convenience method for the common case of aliasing a route by prefixing it. - # - # Note: The non-prefixed routes alias the prefixed ones, not the other way around: - # - # # :blogs_path will be alias for :admin_blogs_path - # prefix_routes :admin_, :blogs, :posts - # - # Warning: Currently does not work with new_ and edit_ routes correctly. - def prefix_routes(prefix, *routes) - routes.each do |route| - alias_route route, "#{prefix}#{route}".to_sym - end - end - - private - - def define_route_alias(type, new_name, old_name, &block) - name = "#{new_name}_#{type}" - - define_method(name) do |*args| - dynamic_args = block ? block.bind(self).call : [] - dynamic_args = [dynamic_args] unless dynamic_args.is_a?(Array) - - send("#{old_name}_#{type}", *(dynamic_args + args)) - end - - helper_method name - private name - end - end -end -end diff --git a/app/lib/forum_support/categories.rb b/app/lib/forum_support/categories.rb deleted file mode 100644 index 9c3a7a54f4..0000000000 --- a/app/lib/forum_support/categories.rb +++ /dev/null @@ -1,60 +0,0 @@ -# frozen_string_literal: true - -module ForumSupport - module Categories - def self.included(base) - base.before_action :find_category, :only => %i[show edit update destroy] - base.authorize_resource :class => TopicCategory, :instance_name => :category - - base.builtin_template_scope = 'forum/categories' - end - - def index - @categories = @forum.categories.includes(:topics) - end - - def show - @topics = @category.topics.paginate(:page => params[:page]) - @topic = @category.topics.build - end - - def new - @category = @forum.categories.build - end - - def create - @category = @forum.categories.build(params[:topic_category]) - - if @category.save - flash[:notice] = "Category was successfully created." - redirect_to forum_categories_url - else - render :new - end - end - - def edit; end - - def update - if @category.update(params[:topic_category]) - flash[:notice] = "Category was successfully updated." - redirect_to forum_categories_url - else - render :edit - end - end - - def destroy - @category.destroy - - flash[:notice] = "Category was successfully deleted." - redirect_to forum_categories_url - end - - private - - def find_category - @category = @forum.categories.find(params[:id]) - end - end -end diff --git a/app/lib/forum_support/deprecated/admin_paths_helper.rb b/app/lib/forum_support/deprecated/admin_paths_helper.rb deleted file mode 100644 index 17a67f4164..0000000000 --- a/app/lib/forum_support/deprecated/admin_paths_helper.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -module Forum::AdminPathsHelper - - def forum_home - admin_forum_path - end - - def forum_topic_posts(topic) - admin_forum_topic_posts_path(topic) - end - - def edit_forum_topic(topic) - edit_admin_forum_topic_path(topic) - end - - def new_forum_topic - new_admin_forum_topic_path - end - - def forum_topic(topic, options = {}) - admin_forum_topic_path(topic, options) - end - alias path_to_forum_topic forum_topic - - def forum_topics - admin_forum_topics_path - end - - def show_forum_topic(topic, options) - admin_forum_topic_path(topic, options) - end - - def edit_forum_topic_post(topic, post) - edit_admin_forum_topic_post_path(topic, post) - end - - def forum_topic_post(post) - admin_forum_topic_post_path(post.topic, post) - end - - def delete_forum_topic_post(post) - admin_forum_topic_post_path(post.topic, post) - end - -end diff --git a/app/lib/forum_support/forums.rb b/app/lib/forum_support/forums.rb deleted file mode 100644 index 5f02dc3d91..0000000000 --- a/app/lib/forum_support/forums.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -module ForumSupport::Forums - def self.included(base) - base.class_eval do - include SearchSupport - end - end - - def show - @topic = @forum.topics.build - @topics = @forum.topics.smart_search(params[:query], pagination_params) - - end - - private - def pagination_params - { page: params[:page] } - end -end diff --git a/app/lib/forum_support/posts.rb b/app/lib/forum_support/posts.rb deleted file mode 100644 index 6a207d06a5..0000000000 --- a/app/lib/forum_support/posts.rb +++ /dev/null @@ -1,76 +0,0 @@ -# frozen_string_literal: true - -module ForumSupport - module Posts - def self.included(base) - base.before_action :find_topic - base.before_action :find_post, :only => %i[edit update destroy] - base.before_action :authorize_resources - - base.builtin_template_scope = 'forum/posts' - end - - def index - # TODO: search - @posts = parent.posts.paginate(:page => params[:page], :per_page => 20) - end - - def create - @post = @topic.posts.build(params[:post]) - @post.user = current_user - - if spam_check_save(@post) - flash[:notice] = 'Post was successfully created.' - # TODO: redirect to the last page - redirect_to forum_topic_url(@topic, :anchor => "new_post") - else - render :new - end - end - - def edit; end - - def update - @post.attributes = params[:post] - if spam_check_save(@post) - flash[:notice] = 'Post was successfully updated.' - redirect_to forum_topic_url(@post.topic) - else - render :edit - end - end - - def destroy - @post.destroy - - flash[:notice] = 'Post was successfully deleted.' - redirect_to forum_topic_url(@post.topic) - end - - private - - def authorize_resources - if @post - authorize! params[:action].to_sym, @post - else - authorize! :reply, @topic - end - end - - def find_topic - @topic = @forum.topics.find_by!(permalink: params[:topic_id]) if params[:topic_id] - end - - def find_post - @post = @forum.posts.find(params[:id]) - end - - def parent - if params[:topic_id] - @topic - else - @forum - end - end - end -end diff --git a/app/lib/forum_support/public.rb b/app/lib/forum_support/public.rb deleted file mode 100644 index 67d31f6520..0000000000 --- a/app/lib/forum_support/public.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -module ForumSupport - # Mix in this module into public-side controllers (forum, topic, post, ...) - module Public - def self.included(base) - base.skip_before_action :login_required - base.before_action :render_not_found_if_forum_disabled - base.before_action :login_required_unless_public - - base.before_action :find_forum - base.liquify - end - - private - - def render_not_found_if_forum_disabled - render_error('Page not found', status: :not_found) - end - - def login_required_unless_public - login_required unless site_account.settings.forum_public? - end - - def find_forum - @forum = site_account.forum - end - end -end diff --git a/app/lib/forum_support/topics.rb b/app/lib/forum_support/topics.rb deleted file mode 100644 index 3072206ed5..0000000000 --- a/app/lib/forum_support/topics.rb +++ /dev/null @@ -1,113 +0,0 @@ -# frozen_string_literal: true - -module ForumSupport::Topics - def self.included(base) - base.before_action :find_topic, :only => %i[show edit update destroy] - base.before_action :authorize_topic - - base.builtin_template_scope = 'forum/topics' - - base.respond_to :html - end - - def my - @topics = @forum.topics.with_post_by(current_user).paginate(:page => params[:page]) - @my = true - - respond_with @topics - end - - def show - @topic.hit! - @posts = @topic.posts.includes(:topic, :user).paginate(:page => params[:page], :per_page => 20) - @post = @topic.posts.build - - respond_with @topic - end - - def new - @topic = @forum.topics.build - @topic.category = category(params[:category]) - - respond_with @topic - end - - def create - @topic = @forum.topics.build(topic_params) - set_protected_attributes - - if spam_check_save(@topic) - flash[:notice] = "Thread was successfully created." - redirect_to forum_topic_url(@topic) - else - render :new - end - end - - def edit - respond_with @topic - end - - def update - @topic.attributes = topic_params - set_protected_attributes - - if spam_check_save(@topic) - flash[:notice] = "Thread was successfully updated." - redirect_to forum_topic_url(@topic) - else - render :edit - end - end - - def destroy - @topic.destroy - - flash[:notice] = "Thread was successfully deleted." - redirect_to forum_url - end - - private - - def authorize_topic - if @topic - # there is no :show permission, but :read - if params[:action].to_sym == :show - authorize! :read, @topic - else # other permissions should be ok - authorize! params[:action].to_sym, @topic - end - else - # creating new forum - authorize! :reply, @forum.topics.build - end - end - - def find_topic - @topic = @forum.topics.find_by!(permalink: params[:id]) - end - - def set_protected_attributes - @topic.user = current_user - @topic.category = category - - @topic.sticky = topic_params.fetch(:sticky, @topic.sticky) if can?(:stick, @topic) - @topic.locked = topic_params.fetch(:locked, @topic.locked) if can?(:lock, @topic) - end - - def topic_params - params.require(:topic) - end - - def category(category_id = topic_params[:category_id]) - @forum.categories.find(category_id) if category_id - end - - # def human_tested - # if @user.anonymous? - # verify_recaptcha(:model => @post, :message => "Oh! It's error with reCAPTCHA!") - # else - # true - # end - # end -end diff --git a/app/lib/forum_support/user_topics.rb b/app/lib/forum_support/user_topics.rb deleted file mode 100644 index da4ce89ec6..0000000000 --- a/app/lib/forum_support/user_topics.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -module ForumSupport - module UserTopics - def self.included(base) - base.class_eval do - before_action :login_required - end - - base.builtin_template_scope = 'forum/user_topics' - end - - def index - @user_topics = current_user.user_topics.paginate(:page => params[:page]) - - respond_to do |format| - format.html - format.xml { render :xml => @user_topics } - end - end - - def create - @user_topic = UserTopic.new :user => current_user - - # ensuring the topic belongs to the site_account forum - @user_topic.topic = @forum.topics.find_by(id: params[:user_topic][:topic_id]) - - respond_to do |format| - flash[:notice] = 'You have successfully subscribed to the thread.' if @user_topic.save - - format.html { redirect_back_or_to(forum_subscriptions_path) } - end - end - - # beware that what's passed as params[:id] is the topic id - def destroy - topic = Topic.find params[:id] - user_topic = current_user.user_topics.find_by!(topic_id: topic.id) - user_topic.destroy - - respond_to do |format| - flash[:notice] = 'You have successfully unsubscribed from the thread.' - - format.html { redirect_back_or_to(root_path) } - end - end - end -end diff --git a/app/services/reports/data_export_service.rb b/app/services/reports/data_export_service.rb index 4e07b1c6f7..a686a05443 100644 --- a/app/services/reports/data_export_service.rb +++ b/app/services/reports/data_export_service.rb @@ -1,3 +1,5 @@ +require 'zip' + class Reports::DataExportService attr_reader :provider, :type, :period diff --git a/app/views/notification_mailer/post_created.html.slim b/app/views/notification_mailer/post_created.html.slim index fc5fa2f75b..5deaf7168c 100644 --- a/app/views/notification_mailer/post_created.html.slim +++ b/app/views/notification_mailer/post_created.html.slim @@ -7,5 +7,3 @@ p - else p | Anonymous user has posted a new message in your forum - -p= link_to 'View new forum post', forum_topic_url(@post.topic, host: @provider_account.external_domain) diff --git a/app/views/notification_mailer/post_created.text.erb b/app/views/notification_mailer/post_created.text.erb index 1d17bb9b49..5e590a9867 100644 --- a/app/views/notification_mailer/post_created.text.erb +++ b/app/views/notification_mailer/post_created.text.erb @@ -4,4 +4,3 @@ Dear <%= @receiver.informal_name %>, <% else %> Anonymous user has posted a new message in your forum <% end %> -To view new forum post, follow this link <%= forum_topic_url(@post.topic, host: @provider_account.external_domain) %> diff --git a/app/views/sites/documentations/edit.html.erb b/app/views/sites/documentations/edit.html.erb deleted file mode 100644 index 14dfb1b527..0000000000 --- a/app/views/sites/documentations/edit.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -