Skip to content

Commit

Permalink
Merge branch 'release/0.12.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kalashnikovisme committed Jan 19, 2017
2 parents f529357 + cfb7447 commit a6a3913
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 17 deletions.
6 changes: 5 additions & 1 deletion app/controllers/concerns/auth_managment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def authenticate_permitted_user!
unless signed_as_admin?
if self.class.name.include?('Unviewed') && Concerns::NotificatableItems.items(current_user.id).any?
return
elsif self.class.name.include?('Welcome') || !permitted_to?(action_name, to_param(model_class.name))
elsif self.class.name.include?('Welcome')
unless permitted_to? :see, :welcome
redirect_to not_found_page_path
end
elsif !permitted_to?(action_name, to_param(model_class.name))
redirect_to not_found_page_path
end
end
Expand Down
24 changes: 13 additions & 11 deletions app/controllers/web/admin/welcome_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ class Web::Admin::WelcomeController < Web::Admin::ApplicationController
before_filter :redirect_to_unviewed

def index
@report = {
users_count: User.count,
event_registrations_count: Event::Registration.count,
uniq_users_event_registrations_count: Event::Registration.all.map(&:user).uniq.count,
uniq_logged_users_for_month_count: LoggedAction.where(action_type: :sign_in).
where('created_at > ?', DateTime.now - 1.month).map(&:user).uniq.count,
new_users_count: User.where('created_at > ?', DateTime.now - 1.month).count,
news_views: News.all.map(&:views).sum,
email_sended: Delivery::Campaign.done.map(&:contacts).flatten.count,
email_sended_this_month: Delivery::Campaign.done.where('created_at > ?', DateTime.now - 1.month).map(&:contacts).flatten.count
}
@report = if signed_as_admin?
{
users_count: User.count,
event_registrations_count: Event::Registration.count,
uniq_users_event_registrations_count: Event::Registration.all.map(&:user).uniq.count,
uniq_logged_users_for_month_count: LoggedAction.where(action_type: :sign_in).
where('created_at > ?', DateTime.now - 1.month).map(&:user).uniq.count,
new_users_count: User.where('created_at > ?', DateTime.now - 1.month).count,
news_views: News.all.map(&:views).sum,
email_sended: Delivery::Campaign.done.map(&:contacts).flatten.count,
email_sended_this_month: Delivery::Campaign.done.where('created_at > ?', DateTime.now - 1.month).map(&:contacts).flatten.count
}
end
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/web/admin/menu_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def permitted_to_anything_in_admin_menu?
menu_item_collection.map do |item|
if item.is_a? Hash
item.values.first.map do |type|
permitted_to? :review, type
permitted_to?(:review, type) || permitted_to?(:index, type)
end
end
end.flatten.include? true
Expand Down
13 changes: 13 additions & 0 deletions app/models/activity_lines/lider/ya_lider/participation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,17 @@ class ActivityLines::Lider::YaLider::Participation < ActiveRecord::Base
belongs_to :stage, class_name: 'ActivityLines::Lider::YaLider::Stage'

validates :participant_id, uniqueness: { scope: :stage }

state_machine :state, initial: :active do
state :active
state :removed

event :restore do
transition all => :active
end

event :remove do
transition all => :removed
end
end
end
2 changes: 1 addition & 1 deletion app/models/activity_lines/lider/ya_lider/stage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def next_stage
end

def current_participants
participants.map do |participant|
participants.active.map do |participant|
participant unless participant.participations.where(stage_id: next_stage.id).any?
end.compact.map &:decorate
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'scopes_rails/state_machine/scopes'

module ActivityLines::Lider::YaLider::ParticipationScopes
extend ActiveSupport::Concern
include StateMachine::Scopes
end
2 changes: 1 addition & 1 deletion app/views/layouts/web/shared/_navbar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
Админка
- if current_user.role.user? && permitted_to_anything_in_admin_menu?
%li
= link_to admin_unviewed_index_path do
= link_to admin_path do
.inner
Админка
- if current_user.is_user? && current_user.unviewed? && !current_user.email.present?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%thead
%tr
%th= model_class.human_attribute_name(:id)
%th= model_class.human_attribute_name(:contest_number)
%th= model_class.human_attribute_name(:full_title)
%th= model_class.human_attribute_name(:contest_year)
- if searching?
%th= model_class.human_attribute_name(:state)
Expand All @@ -14,7 +14,8 @@
%tr{ class: state_color(ya_lider) }
%td{ width: '67px' }
= link_to ya_lider.id, admin_activity_lines_lider_ya_lider_path(ya_lider)
%td= ya_lider.contest_number
%td
= link_to ya_lider.full_title, admin_activity_lines_lider_ya_lider_path(ya_lider)
%td= ya_lider.contest_year
- if searching?
%td= ya_lider.human_state_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
= link_to fa_icon(:pencil), edit_admin_activity_lines_lider_ya_lider_stage_path(stage), class: 'btn btn-sm btn-warning'
= link_to fa_icon(:remove), admin_activity_lines_lider_ya_lider_stage_path(stage), method: :delete, class: 'btn btn-sm btn-danger'
= link_to t('helpers.links.new'), new_admin_activity_lines_lider_ya_lider_stage_path(activity_lines_lider_ya_lider_stage: { ya_lider_id: @ya_lider.id }), class: 'btn btn-success'
%hr
.row
.col-md-6
%b
Expand Down
4 changes: 4 additions & 0 deletions lib/organization/permissions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def letter
update: departaments_headers
}
end

def welcome
{ see: departaments_headers }
end
end
end
end

0 comments on commit a6a3913

Please sign in to comment.