Skip to content

Commit

Permalink
Хотфикс
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrwizard committed Dec 25, 2014
1 parent 68372f7 commit c706478
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 55 deletions.
31 changes: 26 additions & 5 deletions Capfile
@@ -1,6 +1,27 @@
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks
# Load DSL and set up stages
require 'capistrano/setup'

default_run_options[:pty] = true
# Include default deployment tasks
require 'capistrano/deploy'

# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails
# https://github.com/capistrano/passenger
#
require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/passenger'

# Load custom tasks from `lib/capistrano/tasks' if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
10 changes: 6 additions & 4 deletions Gemfile
Expand Up @@ -58,9 +58,12 @@ group :development do
gem 'spring'
end

gem 'capistrano'
gem 'rvm-capistrano'
gem 'capistrano-ec2group'
gem 'capistrano', '~> 3.3.0'
gem 'capistrano-rails'
gem 'capistrano-bundler'
gem 'capistrano-passenger'
# gem 'rvm-capistrano'
# gem 'capistrano-ec2group'

group :development, :test do
gem 'rspec-rails'
Expand All @@ -79,7 +82,6 @@ gem "figaro"
gem 'redis-rails'

gem 'meta-tags', :require => 'meta_tags'
#gem 'sitemap_generator'

# Use ActiveModel has_secure_password
gem 'bcrypt-ruby', :require => 'bcrypt'
Expand Down
49 changes: 25 additions & 24 deletions Gemfile.lock
Expand Up @@ -41,15 +41,20 @@ GEM
bullet (4.7.1)
activesupport
uniform_notifier (>= 1.4.0)
capistrano (2.15.5)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
capistrano-ec2group (1.0.9)
capistrano (>= 2.1.0)
right_aws (>= 3.0.0)
capistrano (3.3.5)
capistrano-stats (~> 1.1.0)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
capistrano-bundler (1.1.3)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-passenger (0.0.1)
capistrano (~> 3.0)
capistrano-rails (1.1.2)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-stats (1.1.1)
capybara (2.2.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
Expand All @@ -67,6 +72,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.7.0)
colorize (0.7.5)
compass (0.12.3)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
Expand All @@ -92,7 +98,6 @@ GEM
json
haml (4.0.5)
tilt
highline (1.6.20)
hike (1.2.3)
i18n (0.6.11)
jbuilder (1.5.3)
Expand Down Expand Up @@ -124,13 +129,9 @@ GEM
mocha (1.0.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.7.0)
net-ssh-gateway (1.2.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
pg (0.17.1)
Expand Down Expand Up @@ -173,9 +174,6 @@ GEM
redis-store (1.1.4)
redis (>= 2.2)
ref (1.0.5)
right_aws (3.1.0)
right_http_connection (>= 1.2.5)
right_http_connection (1.4.0)
rspec-core (2.14.7)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
Expand All @@ -191,8 +189,6 @@ GEM
rubyzip (1.1.0)
russian (0.6.0)
i18n (>= 0.5.0)
rvm-capistrano (1.5.1)
capistrano (~> 2.15.4)
sass (3.2.14)
sass-rails (4.0.5)
railties (>= 4.0.0, < 5.0)
Expand Down Expand Up @@ -224,6 +220,10 @@ GEM
sqlite3 (1.3.8)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
sshkit (1.6.1)
colorize (>= 0.7.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
therubyracer (0.12.0)
libv8 (~> 3.16.14.0)
ref
Expand Down Expand Up @@ -256,8 +256,10 @@ DEPENDENCIES
binding_of_caller
bootstrap-sass
bullet
capistrano
capistrano-ec2group
capistrano (~> 3.3.0)
capistrano-bundler
capistrano-passenger
capistrano-rails
capybara
coffee-rails (~> 4.0.0)
compass-rails
Expand All @@ -275,7 +277,6 @@ DEPENDENCIES
redis-rails
rspec-rails
russian (~> 0.6.0)
rvm-capistrano
sass-rails
selenium-webdriver
spring
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin_controller.rb
@@ -1,8 +1,8 @@
# Админка
class AdminController < ApplicationController
require 'bcrypt'
include Admin
layout 'admin'
include Admin

# Главная админки. Если админ, то отображает админку, иначе - рендерит форму логина
# @note GET /admin
Expand Down
25 changes: 12 additions & 13 deletions app/controllers/concerns/admin.rb
Expand Up @@ -2,27 +2,26 @@
module Admin
extend ActiveSupport::Concern

# Проверяет содержимое сессии админа на право быть админом
# @return [Boolean] админ текущий юзер или нет
# @example
# unless is_admin?
#
# @see Admin#allow_access?
def is_admin?
session[:admin].try(:[], :value)
end

# Если юзер не админ, то делает редирект на главную
# @note На вьюхах моделей и админки
# @example
# before_action :allow_access?
#
# @see AdminController
def _allow_access?
unless _is_admin?
def allow_access?
unless is_admin?
notice = {class: "alert-danger", value: 'Сюда нельзя' }
redirect_to root_path, notice: notice
end
end


# Проверяет содержимое сессии админа на право быть админом
# @return [Boolean] админ текущий юзер или нет
# @example
# unless is_admin?
#
# @see Admin#allow_access?
def _is_admin?
session[:admin].try(:[], :value)
end
end
2 changes: 1 addition & 1 deletion app/controllers/news_controller.rb
Expand Up @@ -2,7 +2,7 @@
class NewsController < ApplicationController
include Admin

before_action :_allow_access?, only: [:index, :show, :edit, :new, :create, :update, :destroy]
before_action :allow_access?, only: [:index, :show, :edit, :new, :create, :update, :destroy]

layout 'admin'

Expand Down
5 changes: 0 additions & 5 deletions app/controllers/pages_controller.rb
@@ -1,10 +1,5 @@
# Методы страниц для пользователей
class PagesController < ApplicationController
include AuthorHelper
include ModalHelper
include SocialHelper
include PlacesCache

# Главная страница. Готовит новости, причины и места к отображению.
# @note GET /
# @note Также вызывается в случае пагинации. Тогда выдает либо пагинацию новостей, либо пагинацию причин.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/reasons_controller.rb
Expand Up @@ -2,7 +2,7 @@
class ReasonsController < ApplicationController
include Admin

before_action :_allow_access?, only: [:index, :show, :edit, :new, :create, :update, :destroy]
before_action :allow_access?, only: [:index, :show, :edit, :new, :create, :update, :destroy]

layout 'admin', except: [:get_one_random, :get_three_random]

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/stats_controller.rb
Expand Up @@ -4,7 +4,7 @@ class StatsController < ApplicationController

before_action :_get_stat
before_action :_update_reason, only: [:vk_post, :tw_post, :fb_post, :bl_post]
before_action :_allow_access?, only: [:index]
before_action :allow_access?, only: [:index]

layout 'admin', only: [:index]

Expand Down

0 comments on commit c706478

Please sign in to comment.