Browse Source

新增:gitlink菜单权限

pull/347/head
yystopf 2 years ago
parent
commit
c9d8ce073f
34 changed files with 61 additions and 3 deletions
  1. +13
    -0
      app/controllers/admins/base_controller.rb
  2. +1
    -0
      app/controllers/admins/edu_settings_controller.rb
  3. +1
    -0
      app/controllers/admins/faqs_controller.rb
  4. +1
    -0
      app/controllers/admins/feedbacks_controller.rb
  5. +2
    -0
      app/controllers/admins/glcc_pr_check_controller.rb
  6. +1
    -0
      app/controllers/admins/identity_verifications_controller.rb
  7. +1
    -0
      app/controllers/admins/issues_rank_controller.rb
  8. +1
    -0
      app/controllers/admins/laboratories_controller.rb
  9. +1
    -0
      app/controllers/admins/message_templates_controller.rb
  10. +1
    -0
      app/controllers/admins/nps_controller.rb
  11. +2
    -1
      app/controllers/admins/organizations_controller.rb
  12. +1
    -0
      app/controllers/admins/page_themes_controller.rb
  13. +1
    -0
      app/controllers/admins/project_categories_controller.rb
  14. +1
    -0
      app/controllers/admins/project_ignores_controller.rb
  15. +1
    -0
      app/controllers/admins/project_languages_controller.rb
  16. +1
    -0
      app/controllers/admins/project_licenses_controller.rb
  17. +1
    -0
      app/controllers/admins/projects_controller.rb
  18. +2
    -0
      app/controllers/admins/projects_rank_controller.rb
  19. +1
    -0
      app/controllers/admins/reversed_keywords_controller.rb
  20. +1
    -0
      app/controllers/admins/site_pages_controller.rb
  21. +1
    -0
      app/controllers/admins/sites_controller.rb
  22. +1
    -0
      app/controllers/admins/system_notifications_controller.rb
  23. +1
    -0
      app/controllers/admins/topic/activity_forums_controller.rb
  24. +1
    -0
      app/controllers/admins/topic/banners_controller.rb
  25. +1
    -0
      app/controllers/admins/topic/cards_controller.rb
  26. +1
    -0
      app/controllers/admins/topic/cooperators_controller.rb
  27. +1
    -0
      app/controllers/admins/topic/excellent_projects_controller.rb
  28. +1
    -0
      app/controllers/admins/topic/experience_forums_controller.rb
  29. +1
    -0
      app/controllers/admins/topic/glcc_news_controller.rb
  30. +1
    -0
      app/controllers/admins/topic/pinned_forums_controller.rb
  31. +1
    -0
      app/controllers/admins/users_controller.rb
  32. +1
    -0
      app/controllers/admins/users_rank_controller.rb
  33. +9
    -1
      app/controllers/application_controller.rb
  34. +5
    -1
      app/models/user.rb

+ 13
- 0
app/controllers/admins/base_controller.rb View File

@@ -23,10 +23,23 @@ class Admins::BaseController < ApplicationController
def require_admin! def require_admin!
return if current_user.blank? || !current_user.logged? return if current_user.blank? || !current_user.logged?
return if current_user.admin_or_business? return if current_user.admin_or_business?
return if current_user.admin_or_glcc_admin?


render_forbidden render_forbidden
end end


def require_admin
render_forbidden unless User.current.admin?
end

def require_business
render_forbidden unless admin_or_business?
end

def require_glcc_admin
render_forbidden unless admin_or_glcc_admin?
end

# 触发after ajax render partial hooks,执行一些因为局部刷新后失效的绑定事件 # 触发after ajax render partial hooks,执行一些因为局部刷新后失效的绑定事件
def rebind_event_if_ajax_render_partial def rebind_event_if_ajax_render_partial
return if request.format.symbol != :js return if request.format.symbol != :js


+ 1
- 0
app/controllers/admins/edu_settings_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::EduSettingsController < Admins::BaseController class Admins::EduSettingsController < Admins::BaseController
before_action :require_admin
before_action :find_setting, only: [:edit,:update, :destroy] before_action :find_setting, only: [:edit,:update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/faqs_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::FaqsController < Admins::BaseController class Admins::FaqsController < Admins::BaseController
before_action :require_business
before_action :find_faq, only: [:edit,:update, :destroy] before_action :find_faq, only: [:edit,:update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/feedbacks_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::FeedbacksController < Admins::BaseController class Admins::FeedbacksController < Admins::BaseController
before_action :require_business
before_action :get_feedback, only: [:new_history, :create_history, :destroy] before_action :get_feedback, only: [:new_history, :create_history, :destroy]


def index def index


+ 2
- 0
app/controllers/admins/glcc_pr_check_controller.rb View File

@@ -1,4 +1,6 @@
class Admins::GlccPrCheckController < Admins::BaseController class Admins::GlccPrCheckController < Admins::BaseController
before_action :require_glcc_admin

def index def index
params[:sort_by] = params[:sort_by].presence || 'created_on' params[:sort_by] = params[:sort_by].presence || 'created_on'
params[:sort_direction] = params[:sort_direction].presence || 'desc' params[:sort_direction] = params[:sort_direction].presence || 'desc'


+ 1
- 0
app/controllers/admins/identity_verifications_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::IdentityVerificationsController < Admins::BaseController class Admins::IdentityVerificationsController < Admins::BaseController
before_action :require_business
before_action :finder_identity_verification, except: [:index] before_action :finder_identity_verification, except: [:index]
def index def index
params[:sort_by] = params[:sort_by].presence || 'created_at' params[:sort_by] = params[:sort_by].presence || 'created_at'


+ 1
- 0
app/controllers/admins/issues_rank_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::IssuesRankController < Admins::BaseController class Admins::IssuesRankController < Admins::BaseController
before_action :require_admin


def index def index
@statistics = DailyProjectStatistic.where('date >= ? AND date <= ?', begin_date, end_date) @statistics = DailyProjectStatistic.where('date >= ? AND date <= ?', begin_date, end_date)


+ 1
- 0
app/controllers/admins/laboratories_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::LaboratoriesController < Admins::BaseController class Admins::LaboratoriesController < Admins::BaseController
before_action :require_admin
def index def index
default_sort('id', 'desc') default_sort('id', 'desc')




+ 1
- 0
app/controllers/admins/message_templates_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::MessageTemplatesController < Admins::BaseController class Admins::MessageTemplatesController < Admins::BaseController
before_action :require_admin
before_action :get_template, only: [:edit, :update, :destroy] before_action :get_template, only: [:edit, :update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/nps_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::NpsController < Admins::BaseController class Admins::NpsController < Admins::BaseController
before_action :require_business
def index def index
@on_off_switch = EduSetting.get("nps-on-off-switch").to_s == 'true' @on_off_switch = EduSetting.get("nps-on-off-switch").to_s == 'true'
@user_nps = UserNp.joins(:user).order(created_at: :desc) @user_nps = UserNp.joins(:user).order(created_at: :desc)


+ 2
- 1
app/controllers/admins/organizations_controller.rb View File

@@ -1,5 +1,6 @@
class Admins::OrganizationsController < Admins::BaseController class Admins::OrganizationsController < Admins::BaseController
before_action :finder_org, except: [:index]
before_action :require_admin
before_action :finder_org, except: [:index]


def index def index
params[:sort_by] = params[:sort_by].presence || 'created_on' params[:sort_by] = params[:sort_by].presence || 'created_on'


+ 1
- 0
app/controllers/admins/page_themes_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::PageThemesController < Admins::BaseController class Admins::PageThemesController < Admins::BaseController
before_action :require_admin
before_action :finder_page_theme, only: [:edit, :update, :destroy] before_action :finder_page_theme, only: [:edit, :update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/project_categories_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::ProjectCategoriesController < Admins::BaseController class Admins::ProjectCategoriesController < Admins::BaseController
before_action :require_admin
before_action :get_category, only: [:edit,:update, :destroy] before_action :get_category, only: [:edit,:update, :destroy]
before_action :validate_names, only: [:create, :update] before_action :validate_names, only: [:create, :update]




+ 1
- 0
app/controllers/admins/project_ignores_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::ProjectIgnoresController < Admins::BaseController class Admins::ProjectIgnoresController < Admins::BaseController
before_action :require_admin
before_action :set_ignore, only: [:edit,:update, :destroy,:show] before_action :set_ignore, only: [:edit,:update, :destroy,:show]
# before_action :validate_params, only: [:create, :update] # before_action :validate_params, only: [:create, :update]




+ 1
- 0
app/controllers/admins/project_languages_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::ProjectLanguagesController < Admins::BaseController class Admins::ProjectLanguagesController < Admins::BaseController
before_action :require_admin
before_action :get_language, only: [:edit,:update, :destroy] before_action :get_language, only: [:edit,:update, :destroy]
before_action :validate_names, only: [:create, :update] before_action :validate_names, only: [:create, :update]




+ 1
- 0
app/controllers/admins/project_licenses_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::ProjectLicensesController < Admins::BaseController class Admins::ProjectLicensesController < Admins::BaseController
before_action :require_admin
before_action :set_license, only: [:edit,:update, :destroy,:show] before_action :set_license, only: [:edit,:update, :destroy,:show]
# before_action :validate_params, only: [:create, :update] # before_action :validate_params, only: [:create, :update]




+ 1
- 0
app/controllers/admins/projects_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::ProjectsController < Admins::BaseController class Admins::ProjectsController < Admins::BaseController
before_action :require_admin
before_action :find_project, only: [:edit, :update] before_action :find_project, only: [:edit, :update]


def index def index


+ 2
- 0
app/controllers/admins/projects_rank_controller.rb View File

@@ -1,4 +1,6 @@
class Admins::ProjectsRankController < Admins::BaseController class Admins::ProjectsRankController < Admins::BaseController
before_action :require_admin

def index def index
@statistics = DailyProjectStatistic.where("date >= ? AND date <= ?", begin_date, end_date) @statistics = DailyProjectStatistic.where("date >= ? AND date <= ?", begin_date, end_date)
@statistics = @statistics.group(:project_id).select("project_id, @statistics = @statistics.group(:project_id).select("project_id,


+ 1
- 0
app/controllers/admins/reversed_keywords_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::ReversedKeywordsController < Admins::BaseController class Admins::ReversedKeywordsController < Admins::BaseController
before_action :require_admin
before_action :get_keyword, only: [:edit,:update, :destroy] before_action :get_keyword, only: [:edit,:update, :destroy]
# before_action :validate_identifer, only: [:create, :update] # before_action :validate_identifer, only: [:create, :update]




+ 1
- 0
app/controllers/admins/site_pages_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::SitePagesController < Admins::BaseController class Admins::SitePagesController < Admins::BaseController
before_action :require_admin
before_action :finder_site_page, except: [:index] before_action :finder_site_page, except: [:index]


def index def index


+ 1
- 0
app/controllers/admins/sites_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::SitesController < Admins::BaseController class Admins::SitesController < Admins::BaseController
before_action :require_admin
before_action :find_site, only: [:edit,:update, :destroy] before_action :find_site, only: [:edit,:update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/system_notifications_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::SystemNotificationsController < Admins::BaseController class Admins::SystemNotificationsController < Admins::BaseController
before_action :require_business
before_action :get_notification, only: [:history, :edit,:update, :destroy] before_action :get_notification, only: [:history, :edit,:update, :destroy]
# before_action :validate_identifer, only: [:create, :update] # before_action :validate_identifer, only: [:create, :update]




+ 1
- 0
app/controllers/admins/topic/activity_forums_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::Topic::ActivityForumsController < Admins::Topic::BaseController class Admins::Topic::ActivityForumsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_activity_forum, only: [:edit, :update, :destroy] before_action :find_activity_forum, only: [:edit, :update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/topic/banners_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::Topic::BannersController < Admins::Topic::BaseController class Admins::Topic::BannersController < Admins::Topic::BaseController
before_action :require_business
before_action :find_banner, only: [:edit, :update, :destroy] before_action :find_banner, only: [:edit, :update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/topic/cards_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::Topic::CardsController < Admins::Topic::BaseController class Admins::Topic::CardsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_card, only: [:edit, :update, :destroy] before_action :find_card, only: [:edit, :update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/topic/cooperators_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::Topic::CooperatorsController < Admins::Topic::BaseController class Admins::Topic::CooperatorsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_cooperator, only: [:edit, :update, :destroy] before_action :find_cooperator, only: [:edit, :update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/topic/excellent_projects_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::Topic::ExcellentProjectsController < Admins::Topic::BaseController class Admins::Topic::ExcellentProjectsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_excellent_project, only: [:edit, :update, :destroy] before_action :find_excellent_project, only: [:edit, :update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/topic/experience_forums_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::Topic::ExperienceForumsController < Admins::Topic::BaseController class Admins::Topic::ExperienceForumsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_experience_forum, only: [:edit, :update, :destroy] before_action :find_experience_forum, only: [:edit, :update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/topic/glcc_news_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::Topic::GlccNewsController < Admins::Topic::BaseController class Admins::Topic::GlccNewsController < Admins::Topic::BaseController
before_action :require_glcc_admin
before_action :find_glcc, only: [:edit, :update, :destroy] before_action :find_glcc, only: [:edit, :update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/topic/pinned_forums_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::Topic::PinnedForumsController < Admins::Topic::BaseController class Admins::Topic::PinnedForumsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_pinned_forum, only: [:edit, :update, :destroy] before_action :find_pinned_forum, only: [:edit, :update, :destroy]


def index def index


+ 1
- 0
app/controllers/admins/users_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::UsersController < Admins::BaseController class Admins::UsersController < Admins::BaseController
before_action :require_admin
before_action :finder_user, except: [:index] before_action :finder_user, except: [:index]


def index def index


+ 1
- 0
app/controllers/admins/users_rank_controller.rb View File

@@ -1,4 +1,5 @@
class Admins::UsersRankController < Admins::BaseController class Admins::UsersRankController < Admins::BaseController
before_action :require_admin


def index def index
@rank_date = rank_date @rank_date = rank_date


+ 9
- 1
app/controllers/application_controller.rb View File

@@ -75,7 +75,11 @@ class ApplicationController < ActionController::Base




def admin_or_business? def admin_or_business?
User.current.admin? || User.current.business? || User.current.glcc_admin?
User.current.admin? || User.current.business?
end

def admin_or_glcc_admin?
User.current.admin? || User.current.glcc_admin?
end end


# 判断用户的邮箱或者手机是否可用 # 判断用户的邮箱或者手机是否可用
@@ -195,6 +199,10 @@ class ApplicationController < ActionController::Base
normal_status(403, "") unless admin_or_business? normal_status(403, "") unless admin_or_business?
end end


def require_glcc_admin
normal_status(403, "") unless admin_or_glcc_admin?
end

# 前端会捕捉401,弹登录弹框 # 前端会捕捉401,弹登录弹框
# 未授权的捕捉407,弹试用申请弹框 # 未授权的捕捉407,弹试用申请弹框
def require_login def require_login


+ 5
- 1
app/models/user.rb View File

@@ -833,7 +833,11 @@ class User < Owner
end end


def admin_or_business? def admin_or_business?
admin? || business? || glcc_admin?
admin? || business?
end

def admin_or_glcc_admin?
admin? || glcc_admin?
end end


def self.generate_login(prefix) def self.generate_login(prefix)


Loading…
Cancel
Save