Merge branch 'master' into 369-move_old_bootstrap
This commit is contained in:
commit
93c82fd873
1
Gemfile
1
Gemfile
|
@ -2,6 +2,7 @@ source 'https://rubygems.org'
|
|||
|
||||
gem 'rails', '4.0.4'
|
||||
|
||||
gem 'activeadmin', github: 'gregbell/active_admin'
|
||||
gem 'pg', '~> 0.17.1'
|
||||
gem 'schema_plus', '~> 1.4.0'
|
||||
########
|
||||
|
|
47
Gemfile.lock
47
Gemfile.lock
|
@ -8,6 +8,24 @@ GIT
|
|||
resque (> 1.25)
|
||||
resque-scheduler
|
||||
|
||||
GIT
|
||||
remote: git://github.com/gregbell/active_admin.git
|
||||
revision: 5ac883c59978799829a8c085fab47f858574c42f
|
||||
specs:
|
||||
activeadmin (1.0.0.pre)
|
||||
arbre (~> 1.0)
|
||||
bourbon
|
||||
coffee-rails
|
||||
devise (~> 3.2)
|
||||
formtastic (~> 2.3.0.rc2)
|
||||
inherited_resources (~> 1.3)
|
||||
jquery-rails
|
||||
jquery-ui-rails
|
||||
kaminari (~> 0.15)
|
||||
rails (>= 3.2, <= 4.1)
|
||||
ransack (~> 1.0)
|
||||
sass-rails
|
||||
|
||||
GIT
|
||||
remote: git://github.com/rosa-abf/cancan.git
|
||||
revision: fe1089b70c08d3ed11bac4f8e69ecb3d1d9adc29
|
||||
|
@ -65,6 +83,8 @@ GEM
|
|||
activerecord (>= 3.0.0)
|
||||
angular-i18n (0.1.2)
|
||||
angularjs-rails (1.2.14)
|
||||
arbre (1.0.1)
|
||||
activesupport (>= 3.0.0)
|
||||
arel (4.0.2)
|
||||
atomic (1.1.16)
|
||||
attr_encrypted (1.3.2)
|
||||
|
@ -82,6 +102,9 @@ GEM
|
|||
daemons (~> 1.1.4)
|
||||
i18n (>= 0.5.0)
|
||||
state_machine (~> 1.1)
|
||||
bourbon (3.1.8)
|
||||
sass (>= 3.2.0)
|
||||
thor
|
||||
builder (3.1.4)
|
||||
callsite (0.0.11)
|
||||
cape (1.8.0)
|
||||
|
@ -138,6 +161,8 @@ GEM
|
|||
faraday (0.9.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.9.3)
|
||||
formtastic (2.3.0.rc2)
|
||||
actionpack (>= 3.0)
|
||||
friendly_id (5.0.3)
|
||||
activerecord (>= 4.0.0)
|
||||
fssm (0.2.10)
|
||||
|
@ -168,11 +193,17 @@ GEM
|
|||
activesupport (>= 4.0.1)
|
||||
haml (>= 3.1, < 5.0)
|
||||
railties (>= 4.0.1)
|
||||
has_scope (0.6.0.rc)
|
||||
actionpack (>= 3.2, < 5)
|
||||
activesupport (>= 3.2, < 5)
|
||||
hashie (2.0.5)
|
||||
highline (1.6.21)
|
||||
hike (1.2.3)
|
||||
hirb (0.7.1)
|
||||
i18n (0.6.9)
|
||||
inherited_resources (1.4.1)
|
||||
has_scope (~> 0.6.0.rc)
|
||||
responders (~> 1.0.0.rc)
|
||||
jbuilder (2.0.4)
|
||||
activesupport (>= 3.0.0)
|
||||
multi_json (>= 1.2.0)
|
||||
|
@ -180,12 +211,17 @@ GEM
|
|||
jquery-rails (2.3.0)
|
||||
railties (>= 3.0, < 5.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
jquery-ui-rails (4.2.0)
|
||||
railties (>= 3.2.16)
|
||||
js-routes (0.9.7)
|
||||
railties (>= 3.2)
|
||||
sprockets-rails
|
||||
json (1.8.1)
|
||||
jwt (0.1.11)
|
||||
multi_json (>= 1.5)
|
||||
kaminari (0.15.1)
|
||||
actionpack (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
libv8 (3.16.14.3)
|
||||
localeapp (0.7.1)
|
||||
gli
|
||||
|
@ -272,6 +308,8 @@ GEM
|
|||
cocaine (~> 0.5.3)
|
||||
mime-types
|
||||
pg (0.17.1)
|
||||
polyamorous (0.6.4)
|
||||
activerecord (>= 3.0)
|
||||
polyglot (0.3.4)
|
||||
posix-spawn (0.3.8)
|
||||
protected_attributes (1.0.7)
|
||||
|
@ -308,6 +346,12 @@ GEM
|
|||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.1.1)
|
||||
ransack (1.2.1)
|
||||
actionpack (>= 3.0)
|
||||
activerecord (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
i18n
|
||||
polyamorous (~> 0.6.0)
|
||||
rdiscount (2.1.7)
|
||||
redcarpet (3.1.1)
|
||||
redis (3.0.7)
|
||||
|
@ -330,6 +374,8 @@ GEM
|
|||
redis-store (1.1.4)
|
||||
redis (>= 2.2)
|
||||
ref (1.0.5)
|
||||
responders (1.0.0)
|
||||
railties (>= 3.2, < 5)
|
||||
resque (1.25.2)
|
||||
mono_logger (~> 1.0)
|
||||
multi_json (~> 1.0)
|
||||
|
@ -463,6 +509,7 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
RedCloth
|
||||
activeadmin!
|
||||
airbrake (~> 3.1.2)
|
||||
ancestry (~> 2.0.0)
|
||||
angular-i18n (= 0.1.2)
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
ActiveAdmin.register_page 'Dashboard' do
|
||||
|
||||
menu priority: 1
|
||||
|
||||
content do
|
||||
|
||||
columns do
|
||||
column do
|
||||
panel "Deploy Information" do
|
||||
require 'deploy_info'
|
||||
|
||||
abf = "https://abf.io/abf/rosa-build/"
|
||||
#jenkins = "https://ci.shuttlerock.com/"
|
||||
|
||||
attributes_table_for DeployInfo do
|
||||
row('Branch') { link_to DeployInfo::BRANCH, "#{abf}tree/#{DeployInfo::BRANCH}" }
|
||||
row('Commit') { link_to DeployInfo::GIT_COMMIT, "#{abf}commit/#{DeployInfo::GIT_COMMIT}" }
|
||||
row('Build Number') { DeployInfo::BUILD_NUMBER }
|
||||
row('Build ID') { DeployInfo::BUILD_ID }
|
||||
row('Deployer') { DeployInfo::DEPLOYER }
|
||||
row(:message) { pre DeployInfo.message }
|
||||
end
|
||||
end # panel
|
||||
end # column
|
||||
end # columns
|
||||
|
||||
|
||||
end # content
|
||||
|
||||
end
|
|
@ -0,0 +1,37 @@
|
|||
ActiveAdmin.register EventLog do
|
||||
|
||||
menu parent: 'Misc'
|
||||
|
||||
actions :all, except: %i(create update new edit destroy)
|
||||
|
||||
controller do
|
||||
def scoped_collection
|
||||
EventLog.includes(:user)
|
||||
end
|
||||
end
|
||||
|
||||
index do
|
||||
column :id
|
||||
column :kind
|
||||
column :created_at
|
||||
column :user
|
||||
column :ip
|
||||
column :protocol
|
||||
column('Description') do |el|
|
||||
msg = %w([)
|
||||
msg << I18n.t("event_log.controllers.#{el.controller.underscore}", default: el.controller) << "]"
|
||||
msg << I18n.t("event_log.actions.#{el.controller.underscore}.#{el.action}", default: :"event_log.actions.#{el.action}")
|
||||
if el.eventable_id.present? and el.eventable_type.present?
|
||||
msg << '' << I18n.t("activerecord.models.#{el.eventable_type.underscore}")
|
||||
msg << el.eventable_name
|
||||
msg << "(id##{el.eventable_id})" # link_to "id##{el.eventable_id}", el.eventable
|
||||
end
|
||||
msg << el.message.to_s
|
||||
msg.join(' ')
|
||||
end
|
||||
|
||||
|
||||
default_actions
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
ActiveAdmin.register FlashNotify do
|
||||
|
||||
menu parent: 'Misc'
|
||||
|
||||
index do
|
||||
column :id
|
||||
column(:body_en) do |fn|
|
||||
fn.body_en.truncate(18)
|
||||
end
|
||||
column(:body_ru) do |fn|
|
||||
fn.body_ru.truncate(18)
|
||||
end
|
||||
column :published
|
||||
|
||||
default_actions
|
||||
end
|
||||
|
||||
form do |f|
|
||||
f.inputs do
|
||||
f.input :body_en
|
||||
f.input :body_ru
|
||||
f.input :status, as: :select, collection: FlashNotify::STATUSES, include_blank: false
|
||||
f.input :published
|
||||
end
|
||||
f.actions
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
ActiveAdmin.register RegisterRequest do
|
||||
|
||||
menu parent: 'Misc'
|
||||
|
||||
index do
|
||||
column :id
|
||||
column :name
|
||||
|
||||
column('User') do |request|
|
||||
user = User.find_by(email: request.email) if request.approved
|
||||
link_to(user.uname, admin_user_path(user)) if user
|
||||
end
|
||||
column :interest
|
||||
column :more
|
||||
column :created_at
|
||||
|
||||
default_actions
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
ActiveAdmin.register_page 'Resque' do
|
||||
menu priority: 100, label: 'Resque', url: '/admin/resque/overview'
|
||||
end
|
|
@ -0,0 +1,56 @@
|
|||
ActiveAdmin.register User do
|
||||
|
||||
menu priority: 2
|
||||
|
||||
filter :uname
|
||||
filter :email
|
||||
filter :role, as: :select, collection: User::EXTENDED_ROLES
|
||||
filter :created_at
|
||||
|
||||
controller do
|
||||
def update(options={}, &block)
|
||||
user_params = params[:user]
|
||||
resource.role = user_params.delete(:role)
|
||||
user_params.delete(:password) if user_params[:password].blank?
|
||||
user_params.delete(:password_confirmation) if user_params[:password_confirmation].blank?
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
index do
|
||||
column :id
|
||||
column(:uname) do |user|
|
||||
link_to(user.uname, user_path(user))
|
||||
end
|
||||
column :email
|
||||
column :created_at
|
||||
column :role
|
||||
|
||||
default_actions
|
||||
end
|
||||
|
||||
form do |f|
|
||||
f.inputs do
|
||||
f.input :name
|
||||
f.input :email
|
||||
f.input :uname
|
||||
f.input :role, as: :select, collection: User::EXTENDED_ROLES, include_blank: false
|
||||
f.input :password
|
||||
f.input :password_confirmation
|
||||
end
|
||||
f.actions
|
||||
end
|
||||
|
||||
action_item only: %i(show edit) do
|
||||
link_to 'Reset token', reset_token_admin_user_path(resource),
|
||||
'data-method' => :put,
|
||||
data: { confirm: 'Are you sure you want to reset token?' }
|
||||
end
|
||||
|
||||
member_action :reset_token, :method => :put do
|
||||
resource.reset_authentication_token!
|
||||
flash[:info] = 'User token reseted successfully'
|
||||
redirect_to admin_user_path(resource)
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
#= require active_admin/base
|
|
@ -0,0 +1,17 @@
|
|||
// SASS variable overrides must be declared before loading up Active Admin's styles.
|
||||
//
|
||||
// To view the variables that Active Admin provides, take a look at
|
||||
// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the
|
||||
// Active Admin source.
|
||||
//
|
||||
// For example, to change the sidebar width:
|
||||
// $sidebar-width: 242px;
|
||||
|
||||
// Active Admin's got SASS!
|
||||
@import "active_admin/mixins";
|
||||
@import "active_admin/base";
|
||||
|
||||
// Overriding any non-variable SASS must be done after the fact.
|
||||
// For example, to change the default status-tag color:
|
||||
//
|
||||
// .status_tag { background: #6090DB; }
|
|
@ -1,4 +0,0 @@
|
|||
class Admin::BaseController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
load_and_authorize_resource
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
class Admin::EventLogsController < Admin::BaseController
|
||||
def index
|
||||
@event_logs = EventLog.default_order.eager_loading.paginate page: params[:page]
|
||||
end
|
||||
end
|
|
@ -1,41 +0,0 @@
|
|||
class Admin::FlashNotifiesController < Admin::BaseController
|
||||
def index
|
||||
@flash_notifies = FlashNotify.paginate(page: params[:page], per_page: 20)
|
||||
end
|
||||
|
||||
def new
|
||||
@flash_notify = FlashNotify.new(published: true)
|
||||
end
|
||||
|
||||
def create
|
||||
@flash_notify = FlashNotify.new(params[:flash_notify])
|
||||
if @flash_notify.save
|
||||
flash[:notice] = t("flash.flash_notify.saved")
|
||||
redirect_to admin_flash_notifies_path
|
||||
else
|
||||
flash[:error] = t("flash.flash_notify.save_error")
|
||||
flash[:warning] = @flash_notify.errors.full_messages.join('. ')
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @flash_notify.update_attributes(params[:flash_notify])
|
||||
flash[:notice] = t("flash.flash_notify.saved")
|
||||
redirect_to admin_flash_notifies_path
|
||||
else
|
||||
flash[:error] = t("flash.flash_notify.save_error")
|
||||
flash[:warning] = @flash_notify.errors.full_messages.join('. ')
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @flash_notify.destroy
|
||||
flash[:notice] = t("flash.flash_notify.destroyed")
|
||||
else
|
||||
flash[:error] = t("flash.flash_notify.destroy_error")
|
||||
end
|
||||
redirect_to admin_flash_notifies_path
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
class Admin::RegisterRequestsController < Admin::BaseController
|
||||
def index
|
||||
@register_requests = @register_requests.send((params[:scope] || 'unprocessed').to_sym).paginate(page: params[:page])
|
||||
end
|
||||
|
||||
def update
|
||||
RegisterRequest.where(id: params[:request_ids]).each(¶ms[:update_type].to_sym) if params[:update_type].present? && params[:request_ids].present?
|
||||
redirect_to action: :index
|
||||
end
|
||||
|
||||
def approve
|
||||
@register_request.approve
|
||||
redirect_to action: :index
|
||||
end
|
||||
|
||||
def reject
|
||||
@register_request.reject
|
||||
redirect_to action: :index
|
||||
end
|
||||
end
|
|
@ -1,92 +0,0 @@
|
|||
class Admin::UsersController < Admin::BaseController
|
||||
include AvatarHelper
|
||||
prepend_before_filter :find_user
|
||||
load_and_authorize_resource collection: [:system, :list]
|
||||
|
||||
def index
|
||||
@filter = params[:filter] || 'all'
|
||||
end
|
||||
|
||||
def system
|
||||
@users, @filter = @users.system, 'system'
|
||||
render :index
|
||||
end
|
||||
|
||||
def new
|
||||
@user.role = 'system' if params[:system] == 'true'
|
||||
end
|
||||
|
||||
def create
|
||||
@user.role = params[:role]
|
||||
@user.email, @user.password = "#{@user.uname}@rosalinux.ru", SecureRandom.base64 if @user.system?
|
||||
@user.confirmed_at = Time.now.utc
|
||||
if (@user.save rescue false)
|
||||
flash[:notice] = t('flash.user.saved')
|
||||
flash[:warning] = @user.authentication_token
|
||||
redirect_to(@user.system? ? system_admin_users_path : admin_users_path)
|
||||
else
|
||||
flash[:error] = t('flash.user.save_error')
|
||||
flash[:warning] = @user.errors.full_messages.join('. ')
|
||||
@system = @user.system?
|
||||
|
||||
render action: :new
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
@user.role = params[:role]
|
||||
if @user.update_without_password(params[:user])
|
||||
update_avatar(@user, params)
|
||||
flash[:notice] = t('flash.user.saved')
|
||||
redirect_to admin_users_path
|
||||
else
|
||||
flash[:error] = t('flash.user.save_error')
|
||||
flash[:warning] = @user.errors.full_messages.join('. ')
|
||||
render action: :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@user.destroy
|
||||
flash[:notice] = t("flash.user.destroyed")
|
||||
redirect_to(@user.system? ? system_admin_users_path : admin_users_path)
|
||||
end
|
||||
|
||||
def list
|
||||
if params[:system] != 'true'
|
||||
colName, @users = %w(name uname email created_at), @users.opened
|
||||
else
|
||||
colName, @users, @system_list = ['uname'], @users.system, true
|
||||
end
|
||||
sort_col = params[:iSortCol_0] || 0
|
||||
sort_dir = params[:sSortDir_0]=="asc" ? 'asc' : 'desc'
|
||||
order = "users.#{colName[sort_col.to_i]} #{sort_dir}"
|
||||
|
||||
@users = @users.paginate(page: (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, per_page: params[:iDisplayLength])
|
||||
@total_users = @users.count
|
||||
if !params[:sSearch].blank? && search = "%#{params[:sSearch]}%"
|
||||
@users = @users.where('users.name ILIKE ? or users.uname ILIKE ? or users.email ILIKE ?', search, search, search)
|
||||
end
|
||||
@filter = params[:filter] || 'all'
|
||||
@users = @users.send(@filter) if ['real', 'admin', 'banned', 'tester'].include? @filter
|
||||
@users = @users.order(order)
|
||||
|
||||
render partial: 'users_ajax', layout: false
|
||||
end
|
||||
|
||||
def reset_auth_token
|
||||
@user.reset_authentication_token!
|
||||
flash[:notice] = t("flash.user.reset_auth_token")
|
||||
flash[:warning] = @user.authentication_token
|
||||
redirect_to system_admin_users_path
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def find_user
|
||||
@user = User.find_by!(uname: params[:id]) if params[:id].present?
|
||||
end
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
module ActiveAdmin::AdminHelper
|
||||
|
||||
include ActiveAdmin::Views
|
||||
|
||||
def admin_polymorphic_path(resource)
|
||||
self.send("admin_#{resource.class.to_s.underscore}_path", resource)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
class User < Avatar
|
||||
extend FriendlyId
|
||||
friendly_id :uname, use: [:finders]
|
||||
|
||||
include PersonalRepository
|
||||
include ActsLikeMember
|
||||
include Feed::User
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
= surround '[', ']' do
|
||||
= I18n.t "event_log.controllers.#{el.controller.underscore}", default: el.controller
|
||||
= I18n.t "event_log.actions.#{el.controller.underscore}.#{el.action}", default: :"event_log.actions.#{el.action}"
|
||||
- if el.eventable_id.present? and el.eventable_type.present?
|
||||
= I18n.t "activerecord.models.#{el.eventable_type.underscore}"
|
||||
= el.eventable_name
|
||||
= "(id##{el.eventable_id})" # link_to "id##{el.eventable_id}", el.eventable
|
||||
= el.message
|
|
@ -1,7 +0,0 @@
|
|||
%tr{class: cycle("odd", "even")}
|
||||
%td= event_log.kind
|
||||
%td= event_log.created_at
|
||||
%td= link_to_if event_log.user_id, event_log.user_name, event_log.user #{controller: "users", action: "show", id: event_log.user_id}
|
||||
%td= event_log.ip
|
||||
%td= event_log.protocol
|
||||
%td= render 'description', el: event_log
|
|
@ -1,14 +0,0 @@
|
|||
%h3.fix= title t("layout.event_logs.list_header")
|
||||
|
||||
%table#datatable.tablesorter.list-users
|
||||
%tr
|
||||
%th.first= t("activerecord.attributes.event_log.kind")
|
||||
%th= t("activerecord.attributes.event_log.created_at")
|
||||
%th= t("activerecord.attributes.event_log.user")
|
||||
%th= t("activerecord.attributes.event_log.ip")
|
||||
%th= t("activerecord.attributes.event_log.protocol")
|
||||
%th.last= t("activerecord.attributes.event_log.description")
|
||||
= render @event_logs
|
||||
= will_paginate
|
||||
|
||||
= render 'submenu'
|
|
@ -1,21 +0,0 @@
|
|||
.leftlist= f.label :body_ru, t("activerecord.attributes.flash_notify.body_ru"), class: :label
|
||||
.rightlist= f.text_area :body_ru, class: 'text_field'
|
||||
.both
|
||||
|
||||
.leftlist= f.label :body_en, t("activerecord.attributes.flash_notify.body_en"), class: :label
|
||||
.rightlist= f.text_area :body_en, class: 'text_field'
|
||||
.both
|
||||
|
||||
.leftlist= f.label :status, t("activerecord.attributes.flash_notify.status"), class: :label
|
||||
.rightlist= f.select :status, FlashNotify::STATUSES
|
||||
.both
|
||||
|
||||
.leftlist= f.label :published, t("activerecord.attributes.flash_notify.published"), class: :label
|
||||
.rightlist= f.check_box :published
|
||||
.both
|
||||
|
||||
.button_block
|
||||
= submit_tag t('layout.save'), data: {'disable-with' => t('layout.saving')}
|
||||
%span.text_button_padding= t("layout.or")
|
||||
= link_to t("layout.cancel"), admin_flash_notifies_path, class: "button"
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
%h3= t("layout.flash_notifies.edit_header")
|
||||
|
||||
= form_for @flash_notify, url: admin_flash_notify_path(@flash_notify), html: { class: :form } do |f|
|
||||
= render "form", f: f
|
||||
|
||||
= render 'submenu'
|
|
@ -1,22 +0,0 @@
|
|||
= link_to t("layout.flash_notifies.new"), new_admin_flash_notify_path, class: 'button' if can? :create, FlashNotify
|
||||
|
||||
%table#myTable.tablesorter.flash_notifys{cellspacing: "0", cellpadding: "0"}
|
||||
%thead
|
||||
%tr
|
||||
%th.th1= t("activerecord.attributes.flash_notify.body_en")
|
||||
%th.th2= t("activerecord.attributes.flash_notify.body_ru")
|
||||
%th.th3= t("activerecord.attributes.flash_notify.published")
|
||||
%th.th3= t("layout.flash_notifies.actions")
|
||||
%tbody
|
||||
- @flash_notifies.each do |flash_notify|
|
||||
%tr{class: cycle("odd", "even")}
|
||||
%td= flash_notify.body_en.truncate 18
|
||||
%td= flash_notify.body_ru.truncate 18
|
||||
%td= flash_notify.published
|
||||
%td
|
||||
= link_to t("layout.flash_notifies.edit"), edit_admin_flash_notify_path(flash_notify)
|
||||
= link_to t("layout.flash_notifies.delete"), admin_flash_notify_path(flash_notify), method: :delete, data: { confirm: t("layout.mass_builds.cancel_confirm") } if can?(:delete, flash_notify)
|
||||
|
||||
= will_paginate @flash_notifies
|
||||
|
||||
= render 'submenu'
|
|
@ -1,6 +0,0 @@
|
|||
%h3= t("layout.flash_notifies.new_header")
|
||||
|
||||
= form_for @flash_notify, url: admin_flash_notifies_path, html: { class: :form } do |f|
|
||||
= render "form", f: f
|
||||
|
||||
= render 'submenu'
|
|
@ -4,4 +4,4 @@
|
|||
- if can? :index, base.to_s.classify.constantize
|
||||
%li= link_to title, send(:"#{namespace}#{base}_path"), class: top_menu_class(base)
|
||||
- if current_user.try(:admin?) and which_menu == 'top_menu'
|
||||
%li= link_to t('admins_menu_header'), admin_users_path, class: top_menu_class('admin')
|
||||
%li= link_to t('admins_menu_header'), admin_root_path, class: top_menu_class('admin')
|
|
@ -50,7 +50,9 @@ module Rosa
|
|||
config.encoding = "utf-8"
|
||||
|
||||
# Enable the asset pipeline
|
||||
config.assets.enabled = true
|
||||
config.assets.enabled = true
|
||||
config.assets.initialize_on_precompile = false # http://bit.ly/u7pQKz
|
||||
config.assets.precompile += %w(active_admin.js active_admin.css)
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets
|
||||
config.assets.version = '1.0'
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
ActiveAdmin.setup do |config|
|
||||
|
||||
# == Site Title
|
||||
#
|
||||
# Set the title that is displayed on the main layout
|
||||
# for each of the active admin pages.
|
||||
#
|
||||
config.site_title = "ABF"
|
||||
config.site_title_link = "/"
|
||||
|
||||
# == Default Namespace
|
||||
#
|
||||
# Set the default namespace each administration resource
|
||||
# will be added to.
|
||||
#
|
||||
# eg:
|
||||
# config.default_namespace = :hello_world
|
||||
#
|
||||
# This will create resources in the HelloWorld module and
|
||||
# will namespace routes to /hello_world/*
|
||||
#
|
||||
# To set no namespace by default, use:
|
||||
# config.default_namespace = false
|
||||
config.default_namespace = :admin
|
||||
|
||||
|
||||
# == User Authentication
|
||||
#
|
||||
# Active Admin will automatically call an authentication
|
||||
# method in a before filter of all controller actions to
|
||||
# ensure that there is a currently logged in admin user.
|
||||
#
|
||||
# This setting changes the method which Active Admin calls
|
||||
# within the controller.
|
||||
config.authentication_method = :authenticate_user!
|
||||
|
||||
|
||||
# == Current User
|
||||
#
|
||||
# Active Admin will associate actions with the current
|
||||
# user performing them.
|
||||
#
|
||||
# This setting changes the method which Active Admin calls
|
||||
# to return the currently logged in user.
|
||||
config.current_user_method = :current_user
|
||||
|
||||
|
||||
# == Admin Comments
|
||||
#
|
||||
# Admin comments allow you to add comments to any model for admin use
|
||||
#
|
||||
# Admin comments are enabled by default in the default
|
||||
# namespace only. You can turn them on in a namesapce
|
||||
# by adding them to the comments array.
|
||||
#
|
||||
# config.allow_comments_in = [:admin]
|
||||
config.allow_comments = false
|
||||
|
||||
|
||||
# == Controller Filters
|
||||
#
|
||||
# You can add before, after and around filters to all of your
|
||||
# Active Admin resources from here.
|
||||
#
|
||||
# config.before_filter :do_something_awesome
|
||||
config.before_filter :check_admin_role
|
||||
|
||||
|
||||
# == Register Stylesheets & Javascripts
|
||||
#
|
||||
# We recommend using the built in Active Admin layout and loading
|
||||
# up your own stylesheets / javascripts to customize the look
|
||||
# and feel.
|
||||
#
|
||||
# To load a stylesheet:
|
||||
# config.register_stylesheet 'my_stylesheet.css'
|
||||
#
|
||||
# To load a javascript file:
|
||||
# config.register_javascript 'my_javascript.js'
|
||||
|
||||
config.logout_link_path = :destroy_user_session_path
|
||||
config.logout_link_method = :delete
|
||||
end
|
||||
|
||||
# Block admin access to non-admin-users.
|
||||
ActiveAdmin::BaseController.class_eval do
|
||||
# include ActionController::Caching::Sweeping
|
||||
protected
|
||||
def check_admin_role
|
||||
raise ActiveRecord::RecordNotFound unless current_user.admin?
|
||||
end
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
Kaminari.configure do |config|
|
||||
config.page_method_name = :per_page_kaminari
|
||||
end
|
|
@ -1,5 +1,14 @@
|
|||
Rosa::Application.routes.draw do
|
||||
|
||||
# ActiveAdmin routes.
|
||||
ActiveAdmin.routes(self)
|
||||
|
||||
namespace :admin do
|
||||
constraints Rosa::Constraints::AdminAccess do
|
||||
mount Resque::Server => 'resque'
|
||||
end
|
||||
end
|
||||
|
||||
# Redirect sitemap1.xml.gz file on AWS S3
|
||||
match '/sitemap.xml.gz' => 'sitemap#show', via: [:get, :post, :head], as: :sitemap
|
||||
match '/robots.txt' => 'sitemap#robots', via: [:get, :post, :head], as: :robots
|
||||
|
@ -147,28 +156,6 @@ Rosa::Application.routes.draw do
|
|||
root to: 'home#activity'
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
resources :users do
|
||||
collection do
|
||||
get :list
|
||||
get :system
|
||||
end
|
||||
put :reset_auth_token, on: :member
|
||||
end
|
||||
resources :register_requests, only: [:index] do
|
||||
put :update, on: :collection
|
||||
member do
|
||||
get :approve
|
||||
get :reject
|
||||
end
|
||||
end
|
||||
resources :flash_notifies
|
||||
resources :event_logs, only: :index
|
||||
constraints Rosa::Constraints::AdminAccess do
|
||||
mount Resque::Server => 'resque'
|
||||
end
|
||||
end
|
||||
|
||||
resources :advisories, only: [:index, :show, :search] do
|
||||
get :search, on: :collection
|
||||
end
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# This file gets overwritten during deploy process
|
||||
module DeployInfo
|
||||
BRANCH=`git rev-parse --abbrev-ref HEAD`.strip
|
||||
GIT_COMMIT=`git rev-parse HEAD`.strip
|
||||
BUILD_NUMBER='dev'
|
||||
BUILD_ID='dev'
|
||||
DEPLOYER=`git config user.name`.strip
|
||||
|
||||
def message
|
||||
`git log -1 --pretty=medium`.strip
|
||||
end
|
||||
|
||||
module_function :message
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::DashboardController do
|
||||
it_should_behave_like 'an admin controller'
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::EventLogsController do
|
||||
it_should_behave_like 'an admin controller'
|
||||
end
|
|
@ -1,124 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::FlashNotifiesController do
|
||||
before(:each) do
|
||||
stub_symlink_methods
|
||||
|
||||
@user = FactoryGirl.create(:user)
|
||||
@create_params = {
|
||||
flash_notify: {
|
||||
body_ru: "Hello! I`m ru body",
|
||||
body_en: "Hello! I`m en body",
|
||||
status: "error",
|
||||
published: true
|
||||
}
|
||||
}
|
||||
|
||||
@flash_notify = FactoryGirl.create(:flash_notify)
|
||||
@flash_notify2 = FactoryGirl.create(:flash_notify)
|
||||
|
||||
@update_params = {
|
||||
id: @flash_notify,
|
||||
flash_notify: {
|
||||
body_ru: "updated!"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
context 'for guest' do
|
||||
[:index, :create, :update, :edit, :new, :destroy].each do |action|
|
||||
it "should not be able to perform #{ action } action" do
|
||||
get action, id: @flash_notify
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not change objects count on create' do
|
||||
lambda { post :create, @create_params }.should change{ FlashNotify.count }.by(0)
|
||||
end
|
||||
|
||||
it 'should not change objects count on destroy' do
|
||||
lambda { delete :destroy, id: @flash_notify }.should change{ FlashNotify.count }.by(0)
|
||||
end
|
||||
|
||||
it 'should not change flash notify body on update' do
|
||||
put :update, @update_params
|
||||
@flash_notify.reload.body_ru.should_not == "updated!"
|
||||
end
|
||||
end
|
||||
|
||||
context 'for global admin' do
|
||||
before(:each) do
|
||||
@admin = FactoryGirl.create(:admin)
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@admin)
|
||||
end
|
||||
|
||||
it 'should load 2 flash notifies objects on index' do
|
||||
get :index
|
||||
assigns[:flash_notifies].count.should == 2
|
||||
end
|
||||
|
||||
[:index, :new, :edit].each do |action|
|
||||
it "should be able to perform #{action} action" do
|
||||
get action, id: @flash_notify
|
||||
response.should render_template(action)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should be able to perform create action' do
|
||||
post :create, @create_params
|
||||
response.should redirect_to(admin_flash_notifies_path)
|
||||
end
|
||||
|
||||
it 'should change objects count on create' do
|
||||
lambda { post :create, @create_params }.should change{ FlashNotify.count }.by(1)
|
||||
end
|
||||
|
||||
it 'should be able to perform destroy action' do
|
||||
delete :destroy, id: @flash_notify
|
||||
response.should redirect_to(admin_flash_notifies_path)
|
||||
end
|
||||
|
||||
it 'should change objects count on destroy' do
|
||||
lambda { delete :destroy, id: @flash_notify }.should change{ FlashNotify.count }.by(-1)
|
||||
end
|
||||
|
||||
it 'should be able to perform update action' do
|
||||
put :update, @update_params
|
||||
response.should redirect_to(admin_flash_notifies_path)
|
||||
end
|
||||
|
||||
it 'should change flash notify body on update' do
|
||||
put :update, @update_params
|
||||
@flash_notify.reload.body_ru.should == "updated!"
|
||||
end
|
||||
end
|
||||
|
||||
context 'for simple user' do
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
end
|
||||
|
||||
[:index, :create, :update, :edit, :new, :destroy].each do |action|
|
||||
it "should not be able to perform #{ action } action" do
|
||||
get action, id: @flash_notify
|
||||
response.should redirect_to(forbidden_path)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not change objects count on create' do
|
||||
lambda { post :create, @create_params }.should change{ FlashNotify.count }.by(0)
|
||||
end
|
||||
|
||||
it 'should not change objects count on destroy' do
|
||||
lambda { delete :destroy, id: @flash_notify }.should change{ FlashNotify.count }.by(0)
|
||||
end
|
||||
|
||||
it 'should not change flash notify body on update' do
|
||||
put :update, @update_params
|
||||
@flash_notify.reload.body_ru.should_not == "updated!"
|
||||
end
|
||||
end
|
||||
it_should_behave_like 'an admin controller'
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::RegisterRequestsController do
|
||||
it_should_behave_like 'an admin controller'
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::ResqueController do
|
||||
it_should_behave_like 'an admin controller'
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::UsersController do
|
||||
it_should_behave_like 'an admin controller'
|
||||
end
|
|
@ -0,0 +1,22 @@
|
|||
shared_examples_for 'an admin controller' do
|
||||
|
||||
it 'redirects to login when accessed unauthorised' do
|
||||
get :index
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
|
||||
it 'raises a 404 for non-admin users' do
|
||||
user = User.first || FactoryGirl.create(:user)
|
||||
sign_in user
|
||||
get :index
|
||||
response.should redirect_to('/404.html')
|
||||
end
|
||||
|
||||
it 'is successful for admin users' do
|
||||
user = User.first || FactoryGirl.create(:admin)
|
||||
sign_in user
|
||||
get :index
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue