forked from saurabh/orbit4-5
Updated Authorization with modal working
Conflicts: app/controllers/admin/sites_controller.rb
This commit is contained in:
parent
4621ba8e9d
commit
51b287fb4e
|
@ -1,4 +1,5 @@
|
||||||
class Admin::AuthorizationsController < OrbitAdminController
|
class Admin::AuthorizationsController < OrbitAdminController
|
||||||
|
prepend_before_filter :admin_or_manager
|
||||||
layout "back_end"
|
layout "back_end"
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -17,12 +18,12 @@ class Admin::AuthorizationsController < OrbitAdminController
|
||||||
end
|
end
|
||||||
unless @objects.blank?
|
unless @objects.blank?
|
||||||
@object ||= @objects.first
|
@object ||= @objects.first
|
||||||
@authorizations = Authorization.category_authorized_users(@object.id)
|
@authorizations = Authorization.category_sub_managers(@object)
|
||||||
else
|
else
|
||||||
@error = t(:no_data)
|
@error = t(:no_data)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@authorizations = Authorization.module_authorized_users(@module_app.id)
|
@authorizations = @module_app.module_managers rescue nil
|
||||||
end
|
end
|
||||||
elsif @module_apps
|
elsif @module_apps
|
||||||
@module_app = @module_apps.first
|
@module_app = @module_apps.first
|
||||||
|
@ -31,15 +32,23 @@ class Admin::AuthorizationsController < OrbitAdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_users
|
def add_users
|
||||||
users = User.find(params[:user_ids]) rescue nil
|
users = User.find(params[:user_ids]) rescue nil
|
||||||
unless users.nil?
|
unless users.nil?
|
||||||
authorization = get_or_create_authorization
|
authorization = users.map {|u| get_or_create_authorization(u.id)}.first
|
||||||
add_users_to_auth(authorization, users)
|
|
||||||
end
|
|
||||||
@users = authorization.authorized_users
|
|
||||||
render 'admin/authorizations/reload_users'
|
|
||||||
end
|
end
|
||||||
|
@users = @module_app.module_managers
|
||||||
|
render 'admin/authorizations/reload_users'
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_roles
|
||||||
|
roles = Role.find(params[:role_ids]) rescue nil
|
||||||
|
unless roles.nil?
|
||||||
|
authorization = roles.map { |r| get_or_create_authorization_with_role(r.id)}.first
|
||||||
|
end
|
||||||
|
@users = @module_app.module_managers
|
||||||
|
render 'admin/authorizations/reload_users'
|
||||||
|
end
|
||||||
|
|
||||||
def modal_select
|
def modal_select
|
||||||
existing_users = User.find(params[:ids]) rescue []
|
existing_users = User.find(params[:ids]) rescue []
|
||||||
|
@ -47,24 +56,103 @@ class Admin::AuthorizationsController < OrbitAdminController
|
||||||
if @type
|
if @type
|
||||||
@object_id = @object.id if @object
|
@object_id = @object.id if @object
|
||||||
@sorted_users = roles.inject({}) do |users, role|
|
@sorted_users = roles.inject({}) do |users, role|
|
||||||
users[role] = role.users.where(admin: false) - existing_users - @module_app.managers
|
users_for_role = role.member_profiles.select {|m| !m.user.is_admin?}.map {|u| u.user}
|
||||||
|
users[role] = users_for_role - existing_users - @module_app.module_managers
|
||||||
users
|
users
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@sorted_users = roles.inject({}) do |users, role|
|
@sorted_users = roles.inject({}) do |users, role|
|
||||||
users[role] = role.users.where(admin: false) - existing_users
|
users_for_role = role.member_profiles.select {|m| !m.user.is_admin?}.map {|u| u.user}
|
||||||
|
users[role] = users_for_role - existing_users
|
||||||
users
|
users
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_roles
|
||||||
|
roles = Role.find(params[:role_ids]) rescue []
|
||||||
|
unless roles.blank?
|
||||||
|
authorization = get_or_create_authorization
|
||||||
|
remove_roles_form_auth(authorization, roles)
|
||||||
|
end
|
||||||
|
@users = authorization.authorized_users
|
||||||
|
render 'admin/authorizations/reload_users'
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_users
|
||||||
|
@users = User.find(params[:ids]) rescue []
|
||||||
|
unless @users.blank?
|
||||||
|
authorization = @users.map {|u| remove_authorizations(u.id)}.first
|
||||||
|
end
|
||||||
|
@users = @module_app.module_managers
|
||||||
|
render 'admin/authorizations/reload_users'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def get_or_create_authorization(user_id)
|
||||||
|
case @type
|
||||||
|
when 'category_authorization'
|
||||||
|
if @object
|
||||||
|
Authorization.create_category_authorization(@module_app.id, @object.id, user_id)
|
||||||
|
else
|
||||||
|
@error = t(:no_data)
|
||||||
|
end
|
||||||
|
when nil
|
||||||
|
Authorization.create_module_authorization(@module_app.id, user_id)
|
||||||
|
else
|
||||||
|
auth = @object.get_authorization_by_title("#{@type}_#{@module_app.key}")
|
||||||
|
unless auth
|
||||||
|
auth = Authorization.create_category_authorization(@module_app.id, @object.id, user_id) if @type.include?('authorization')
|
||||||
|
end
|
||||||
|
auth
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_or_create_authorization_with_role(role_id)
|
||||||
|
case @type
|
||||||
|
when 'category_authorization'
|
||||||
|
if @object
|
||||||
|
Authorization.create_category_authorization_with_role(@module_app.id, @object.id, role_id)
|
||||||
|
else
|
||||||
|
@error = t(:no_data)
|
||||||
|
end
|
||||||
|
when nil
|
||||||
|
Authorization.create_module_authorization_with_role(@module_app.id,role_id)
|
||||||
|
else
|
||||||
|
auth = @object.get_authorization_by_title("#{@type}_#{@module_app.key}")
|
||||||
|
unless auth
|
||||||
|
auth = Authorization.create_category_authorization_with_role(@module_app.id, @object.id, role_id)
|
||||||
|
end
|
||||||
|
auth
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_authorizations(user_id)
|
||||||
|
case @type
|
||||||
|
when 'category_authorization'
|
||||||
|
if @object
|
||||||
|
Authorization.remove_category_authorization(@object.id, user_id)
|
||||||
|
@error = t(:no_data)
|
||||||
|
end
|
||||||
|
when nil
|
||||||
|
Authorization.remove_module_authorization(@module_app.id, user_id)
|
||||||
|
else
|
||||||
|
auth = @object.get_authorization_by_title("#{@type}_#{@module_app.key}")
|
||||||
|
unless auth
|
||||||
|
auth = Authorization.remove_category_authorization(@object.id, user_id)
|
||||||
|
end
|
||||||
|
auth
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def admin_or_manager
|
def admin_or_manager
|
||||||
@override_can_use = true
|
@override_can_use = true
|
||||||
setup_vars
|
setup_vars
|
||||||
authenticate_user!
|
authenticate_user
|
||||||
current_user.is_manager?(@module_app) unless current_user.is_admin?
|
current_user.is_manager?(@module_app) unless current_user.is_admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
class Admin::DashboardsController < OrbitAdminController
|
class Admin::DashboardsController < ApplicationController
|
||||||
|
before_action :authenticate_user
|
||||||
|
layout "back_end"
|
||||||
|
|
||||||
def index
|
def index
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
class Admin::SitesController < OrbitAdminController
|
class Admin::SitesController < OrbitAdminController
|
||||||
before_filter :get_site
|
before_filter :get_site
|
||||||
layout "structure"
|
layout "structure"
|
||||||
|
|
||||||
def mail_setting
|
def mail_setting
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,14 @@ module Authorize
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def open_for_user
|
||||||
|
if current_user.present?
|
||||||
|
"Authorized"
|
||||||
|
else
|
||||||
|
render "public/404" , layout: "back_end"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_variables(module_app)
|
def set_variables(module_app)
|
||||||
|
|
|
@ -10,20 +10,79 @@ class Authorization
|
||||||
scope :module_authorized_users, ->(module_app){ where(module_app_id: module_app) }
|
scope :module_authorized_users, ->(module_app){ where(module_app_id: module_app) }
|
||||||
scope :category_authorized_users, ->(category){ where(category_id: category) }
|
scope :category_authorized_users, ->(category){ where(category_id: category) }
|
||||||
|
|
||||||
def self.create_authorization(module_app_id=nil,category_id=nil,user_id,type)
|
|
||||||
user = User.find(user_id)
|
def self.category_sub_managers(category)
|
||||||
if user.is_admin?
|
workgroup = Workgroup.find_by(key: 'sub_managers')
|
||||||
elsif user.workgroup.nil?
|
category_authorizations = self.category_authorized_users(category).where(:user_id.ne => nil, :workgroup_id => workgroup.id).map {|a| a.user} rescue nil
|
||||||
if type == "module_authorization"
|
category_authorzied_roles = self.category_authorized_users(category).where(:role_id.ne => nil).map {|a| a.role}.first rescue nil
|
||||||
workgroup = Workgroup.find_by(key: "managers")
|
users_authorized_by_roles = category_authorzied_roles.member_profiles.map {|u| u.user} rescue []
|
||||||
user.update_attributes(workgroup_id: workgroup.id)
|
if users_authorized_by_roles.present?
|
||||||
a = self.new(module_app_id: module_app_id, user_id: user_id, workgroup_id: workgroup.id)
|
category_authorizations.inject(users_authorized_by_roles, :<<) rescue []
|
||||||
a.save
|
else
|
||||||
elsif type == "category_authorization"
|
category_authorizations
|
||||||
self.create(category_id: category_id, user_id: user_id )
|
end
|
||||||
workgroup = Workgroup.find_by(key: "sub_managers")
|
end
|
||||||
user.update_attributes(workgroup_id: workgroup.id)
|
|
||||||
end
|
def self.category_role_sub_managers(category)
|
||||||
end
|
authorizations = self.category_authorized_users(category)
|
||||||
|
users = authorizations.map { |a| a.role if role.present? }
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.create_module_authorization(module_app_id,user_id)
|
||||||
|
user = User.find(user_id)
|
||||||
|
workgroup = Workgroup.find_by(key: "managers")
|
||||||
|
module_app = ModuleApp.find(module_app_id)
|
||||||
|
if (user.is_admin? || user.is_manager?(module_app) || user.is_sub_manager?(module_app)|| user.is_manager_with_role?(module_app))
|
||||||
|
puts "User Already Authorized"
|
||||||
|
else
|
||||||
|
a = self.create(module_app_id: module_app_id, user_id: user_id, workgroup_id: workgroup.id)
|
||||||
|
a.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.create_category_authorization(module_app_id, category_id, user_id)
|
||||||
|
user = User.find(user_id)
|
||||||
|
workgroup = Workgroup.find_by(key: "sub_managers")
|
||||||
|
module_app = ModuleApp.find_by(module_app_id)
|
||||||
|
if (user.is_admin? || user.is_manager?(module_app) || user.is_sub_manager?(module_app) || user.is_manager_with_role?(module_app))
|
||||||
|
puts "User Already Authorized"
|
||||||
|
else
|
||||||
|
a = self.create(category_id: category_id, user_id: user_id, workgroup_id: workgroup.id)
|
||||||
|
a.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.create_module_authorization_with_role(module_app_id,role_id)
|
||||||
|
current_auth = self.where(role_id: role_id, module_app_id: module_app_id)
|
||||||
|
workgroup = Workgroup.find_by(key: "managers")
|
||||||
|
module_app = ModuleApp.find(module_app_id)
|
||||||
|
if current_auth.present?
|
||||||
|
puts "User Already Authorized"
|
||||||
|
else
|
||||||
|
a = self.create(module_app_id: module_app_id, role_id: role_id, workgroup_id: workgroup.id)
|
||||||
|
a.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.create_category_authorization_with_role(module_app_id,category_id,role_id)
|
||||||
|
current_auth = self.where(role_id: role_id, category_id: category_id)
|
||||||
|
workgroup = Workgroup.find_by(key: "sub_managers")
|
||||||
|
module_app = ModuleApp.find(module_app_id)
|
||||||
|
if current_auth.present?
|
||||||
|
puts "User Already Authorized"
|
||||||
|
else
|
||||||
|
a = self.create(category_id: category_id, role_id: role_id, workgroup_id: workgroup.id)
|
||||||
|
a.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.remove_module_authorization(module_app_id,user_id)
|
||||||
|
auth = self.find_by(module_app_id: module_app_id, user_id: user_id)
|
||||||
|
auth.delete
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.remove_category_authorization(category_id,user_id)
|
||||||
|
auth = self.find_by(category_id: category_id, user_id: user_id)
|
||||||
|
auth
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -66,9 +66,15 @@ class ModuleApp
|
||||||
Authorization.module_authorized_users(self).pluck(:user_id)
|
Authorization.module_authorized_users(self).pluck(:user_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def role_module_managers
|
def role_managers
|
||||||
users = Authorization.module_authorized_users(self).pluck(:user_id)
|
Authorization.module_authorized_users(self).pluck(:role_id)
|
||||||
roles = Authorization.module_authorized_users(self).pluck(:role_id)
|
end
|
||||||
users + roles
|
|
||||||
|
def module_managers
|
||||||
|
workgroup = Workgroup.find_by(key: 'sub_managers')
|
||||||
|
authorized_users = Authorization.module_authorized_users(self).where(:user_id.ne => nil, :workgroup_id.ne => workgroup.id).map {|u| u.user} rescue nil
|
||||||
|
authorized_members = Authorization.module_authorized_users(self).where(:role_id.ne => nil).map {|m| m.role.member_profiles}.first rescue nil
|
||||||
|
users_authorized_by_role = authorized_members.map {|u| u.user} rescue []
|
||||||
|
authorized_users.inject(users_authorized_by_role, :<<) rescue []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Site
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
field :title, localize: true
|
field :title, type: String, localize: true
|
||||||
field :school, type: String
|
field :school, type: String
|
||||||
field :department, type: String
|
field :department, type: String
|
||||||
field :address, type: String
|
field :address, type: String
|
||||||
|
|
|
@ -48,7 +48,26 @@ class User
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_authorized_with_role?(module_app)
|
def is_manager_with_role?(module_app)
|
||||||
|
user_roles = self.member_profile.role_ids.map {|r| r}
|
||||||
|
authorized_roles = module_app.role_managers rescue []
|
||||||
|
intersection = (user_roles & authorized_roles)
|
||||||
|
|
||||||
|
if ((intersection.count > 0 if intersection.present?) && !self.is_admin? && !self.is_manager?(module_app) && !self.is_sub_manager?(module_app))
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_workgroup(module_app)
|
||||||
|
if self.is_admin?
|
||||||
|
"Admin"
|
||||||
|
elsif (self.is_manager?(module_app) || is_manager_with_role?(module_app))
|
||||||
|
"Manager"
|
||||||
|
elsif self.is_sub_manager?(module_app)
|
||||||
|
"Sub Manager"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.not_admins
|
def self.not_admins
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
<% if user.user.present?%>
|
<li class="filter-item selected_user <%= 'check-item' unless user == current_user || user.is_admin? %>" id="<%= user.id %>">
|
||||||
<li class="filter-item selected_user <%= 'check-item' unless user == current_user || user.user.is_admin? %>" id="<%= user.user.id %>">
|
|
||||||
<label>
|
<label>
|
||||||
<%= image_tag (user.user.member_profile.avatar? ? user.user.member_profile.avatar.thumb : 'menber-pic.png'), :class => "user-pic" %>
|
<%= image_tag (user.member_profile.avatar? ? user.member_profile.avatar.thumb : 'menber-pic.png'), :class => "user-pic" %>
|
||||||
<span class="user-name"><%= user.user.member_profile.name %></span>
|
<span class="user-name"><%= user.member_profile.name %></span>
|
||||||
<% if user.user.is_admin?%>
|
<span><%= user.user_workgroup(@module_app) %></span>
|
||||||
<span>Admin</span>
|
|
||||||
<% else %>
|
|
||||||
<span><%= user.workgroup.title.singularize if user.workgroup %></span>
|
|
||||||
<% end %>
|
|
||||||
</label>
|
</label>
|
||||||
<% unless user == current_user || user.user.is_admin? %>
|
<% unless user == current_user || user.is_admin? %>
|
||||||
<input type="checkbox">
|
<input type="checkbox">
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
<%= javascript_include_tag 'member-selection'%>
|
||||||
|
|
||||||
<div class="mini-layout row-fluid">
|
<div class="mini-layout row-fluid">
|
||||||
<div class="mini-layout-sidebar span2">
|
<div class="mini-layout-sidebar span2">
|
||||||
<div class="nano">
|
<div class="nano">
|
||||||
|
@ -32,7 +34,7 @@
|
||||||
<!-- footer -->
|
<!-- footer -->
|
||||||
<div class="bottomnav clearfix">
|
<div class="bottomnav clearfix">
|
||||||
<div class="action pull-right">
|
<div class="action pull-right">
|
||||||
<%= link_to content_tag(:i, nil, class: "icons-plus") + ' ' + t(:add), '#', class: 'btn btn-primary select_user_modal', rel: admin_modal_select_authorizations_path(@module_app.key, @type, @object) %>
|
<%= link_to content_tag(:i, nil, class: "icons-plus") + ' ' + t(:add), '#', class: 'btn btn-primary select_user_modal', rel: modal_select_authorizations_path(@module_app.key, @type, @object) %>
|
||||||
<%= link_to content_tag(:i, nil, class: "icon-trash") + ' ' + t(:delete_), '#', id: 'remove_users', class: 'btn btn-danger' %>
|
<%= link_to content_tag(:i, nil, class: "icon-trash") + ' ' + t(:delete_), '#', id: 'remove_users', class: 'btn btn-danger', rel: remove_users_authorizations_path(@module_app.key, @type, @object) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
$("#select_user").html("<%= j render partial: 'admin/member_selects/modal_select', locals: {role_form_url: admin_add_roles_authorizations_path(@module_app.key, @type, @object_id), user_form_url: admin_add_users_authorizations_path(@module_app.key, @type, @object_id)} %>");
|
$("#select_user").html("<%= j render partial: 'admin/member_selects/modal_select', locals: {role_form_url: add_roles_authorizations_path(@module_app.key, @type, @object_id), user_form_url: add_users_authorizations_path(@module_app.key, @type, @object_id)} %>");
|
||||||
$("#member-filter").modal();
|
$("#member-filter").modal();
|
|
@ -0,0 +1,2 @@
|
||||||
|
$("#card-list").html("<%= j render partial: 'user', collection: @users %>");
|
||||||
|
$("#member-filter").modal('hide');
|
|
@ -0,0 +1,3 @@
|
||||||
|
<% @users.each do |user| %>
|
||||||
|
$("#<%= user.id.to_s %>").remove()
|
||||||
|
<% end %>
|
|
@ -28,7 +28,6 @@
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="button" class="btn" data-dismiss="modal"><%= t(:cancel) %></button>
|
<button type="button" class="btn" data-dismiss="modal"><%= t(:cancel) %></button>
|
||||||
<%= submit_tag t(:submit), class: "btn btn-primary" %>
|
<%= submit_tag t(:submit), class: "btn btn-primary" %>
|
||||||
<%= hidden_field_tag field, @field %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -42,8 +41,8 @@
|
||||||
<% users.each do |user| %>
|
<% users.each do |user| %>
|
||||||
<li class="check-item">
|
<li class="check-item">
|
||||||
<label>
|
<label>
|
||||||
<%= image_tag (user.avatar.file ? user.avatar : "menber-pic.png"), class: "user-pic" %>
|
<%= image_tag (user.member_profile.avatar.file ? user.member_profile.avatar : "menber-pic.png"), class: "user-pic" %>
|
||||||
<span class="user-name"><%= user.name %></span>
|
<span class="user-name"><%= user.member_profile.name %></span>
|
||||||
</label>
|
</label>
|
||||||
<%= check_box_tag 'user_ids[]', user.id , false %>
|
<%= check_box_tag 'user_ids[]', user.id , false %>
|
||||||
</li>
|
</li>
|
||||||
|
@ -54,7 +53,6 @@
|
||||||
<div class="form-actions condition">
|
<div class="form-actions condition">
|
||||||
<button type="button" class="btn" data-dismiss="modal"><%= t(:cancel) %></button>
|
<button type="button" class="btn" data-dismiss="modal"><%= t(:cancel) %></button>
|
||||||
<%= submit_tag t(:submit), class: "btn btn-primary" %>
|
<%= submit_tag t(:submit), class: "btn btn-primary" %>
|
||||||
<%= hidden_field_tag field, @field %>
|
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
gem 'announcement', git: 'git@gitlab.tp.rulingcom.com:saurabh/announcement-test.git'
|
gem 'announcement', path: '/Users/saurabhbhatia/announcement-test'
|
||||||
gem 'ad_banner', git: 'git@gitlab.tp.rulingcom.com:saurabh/adbanner-test.git'
|
gem 'ad_banner', path: '/Users/saurabhbhatia/ad_banner'
|
||||||
gem 'gallery', git: 'git@gitlab.tp.rulingcom.com:saurabh/gallery.git'
|
gem 'gallery', path: '/Users/saurabhbhatia/gallery'
|
|
@ -26,6 +26,10 @@ Orbit::Application.routes.draw do
|
||||||
|
|
||||||
# You can have the root of your site routed with "root"
|
# You can have the root of your site routed with "root"
|
||||||
root 'pages#home'
|
root 'pages#home'
|
||||||
|
get 'admin/authorizations/modal_select/:module(/:type(/:id))' => 'admin/authorizations#modal_select', :as => :modal_select_authorizations
|
||||||
|
match 'admin/authorizations/add_users/:module(/:type(/:id))' => 'admin/authorizations#add_users', :as => :add_users_authorizations, via: [:get, :post]
|
||||||
|
match 'admin/authorizations/add_roles/:module(/:type(/:id))' => 'admin/authorizations#add_roles', :as => :add_roles_authorizations, via: [:get, :post]
|
||||||
|
match 'admin/authorizations/remove_users/:module(/:type(/:id))' => 'admin/authorizations#remove_users', :as => :remove_users_authorizations, via: [:delete]
|
||||||
|
|
||||||
locales = Site.first.in_use_locales rescue I18n.available_locales
|
locales = Site.first.in_use_locales rescue I18n.available_locales
|
||||||
|
|
||||||
|
@ -38,9 +42,6 @@ Orbit::Application.routes.draw do
|
||||||
resources :module_apps
|
resources :module_apps
|
||||||
|
|
||||||
get 'authorizations(/:module(/:type(/:id)))' => 'authorizations#index', :as => :authorizations
|
get 'authorizations(/:module(/:type(/:id)))' => 'authorizations#index', :as => :authorizations
|
||||||
get 'authorizations/add_users/:module(/:type(/:id))' => 'authorizations#add_users', :as => :add_users_authorizations
|
|
||||||
get 'authorizations/modal_select/:module(/:type(/:id))' => 'authorizations#modal_select', :as => :modal_select_authorizations
|
|
||||||
|
|
||||||
|
|
||||||
resources :authorizations
|
resources :authorizations
|
||||||
resources :items
|
resources :items
|
||||||
|
@ -55,23 +56,23 @@ Orbit::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :sites do
|
resources :sites do
|
||||||
get 'mail_setting'
|
get 'mail_setting'
|
||||||
get 'site_info'
|
get 'site_info'
|
||||||
get 'responsive_setting'
|
get 'responsive_setting'
|
||||||
get 'search_engine'
|
get 'search_engine'
|
||||||
get 'sitemap'
|
get 'sitemap'
|
||||||
get 'sitemap_frontend'
|
get 'sitemap_frontend'
|
||||||
get 'sitemap_toggle', :on => :member
|
get 'sitemap_toggle', :on => :member
|
||||||
get 'system_info'
|
get 'system_info'
|
||||||
get 'ui_theme'
|
get 'ui_theme'
|
||||||
get 'change_design'
|
get 'change_design'
|
||||||
get 'reset_default_locale'
|
get 'reset_default_locale'
|
||||||
get 'preference'
|
get 'preference'
|
||||||
get 'update_manager'
|
get 'update_manager'
|
||||||
get 'get_update_history'
|
get 'get_update_history'
|
||||||
get 'check_updates'
|
get 'check_updates'
|
||||||
get 'update_orbit'
|
get 'update_orbit'
|
||||||
get 'restart_server'
|
get 'restart_server'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -173,9 +173,10 @@ module OrbitCoreLib
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_user_can_use
|
def check_user_can_use
|
||||||
if ((current_user.is_admin? if current_user.present?) || (current_user.is_manager?(@module_app) if current_user.present?) || (current_user.is_sub_manager?(@module_app) if current_user.present?))
|
condition_check = ((current_user.is_admin? if current_user.present?) || (current_user.is_manager?(@module_app) if current_user.present?) || (current_user.is_sub_manager?(@module_app) if current_user.present?) || (current_user.is_manager_with_role?(@module_app) if current_user.present?))
|
||||||
|
if condition_check.eql?(true)
|
||||||
# redirect_to admin_dashboards_url
|
# redirect_to admin_dashboards_url
|
||||||
elsif ((current_user.is_admin? if current_user.present?) || (current_user.is_manager?(@module_app) if current_user.present?) || (current_user.is_sub_manager?(@module_app) if current_user.present?)).eql?(false)
|
elsif condition_check.eql?(false)
|
||||||
render "public/404" , layout: "back_end"
|
render "public/404" , layout: "back_end"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue