Skip to content

Commit

Permalink
Merge branch 'release/0.13.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kalashnikovisme committed Jan 23, 2017
2 parents 478753b + bf16518 commit c909ca3
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 84 deletions.
13 changes: 12 additions & 1 deletion app/assets/javascripts/web/admin/teams.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ $ ->
$team_input = $('.team_input')
$team_input.hide()

$project_input = $('.project_input')
$project_input.hide()

show_or_hide_municipality_input = ($element) ->
if $element.val() in ['Team::Departament', 'Team::Primary']
$municipality_input.slideDown()
Expand All @@ -26,7 +29,7 @@ $ ->
return

show_or_hide_title_input = ($element) ->
if $element.val() in ['Team::Administration', 'Team::Subdivision', 'Team::Committee']
if $element.val() in ['Team::Administration', 'Team::Subdivision']
$title_input.slideDown()
else if $element.val() != undefined
$title_input.slideUp()
Expand All @@ -38,18 +41,26 @@ $ ->
else if $element.val() != undefined
$team_input.slideUp()

show_or_hide_project_input = ($element) ->
if $element.val() == 'Team::Committee'
$project_input.slideDown()
else if $element.val() != undefined
$project_input.slideUp()

init_hidden_inputs = ($input) ->
unless $input == undefined
$input.change ->
show_or_hide_municipality_input $input
show_or_hide_school_input $input
show_or_hide_title_input $input
show_or_hide_team_input $input
show_or_hide_project_input $input
return
show_or_hide_municipality_input $input
show_or_hide_school_input $input
show_or_hide_title_input $input
show_or_hide_team_input $input
show_or_hide_project_input $input
return

init_hidden_inputs $('.team_departament_type select')
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/web/admin/teams_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Web::Admin::TeamsController < Web::Admin::ApplicationController
before_filter :choose_members, only: [ :new, :edit ]
before_filter :choose_departaments, only: [ :new, :edit ]
before_filter :choose_teammates, only: [ :new, :edit ]
before_filter :choose_projects, only: [ :new, :edit ]

def index
if params[:search]
Expand All @@ -31,6 +32,7 @@ def create
choose_members
choose_departaments
choose_teammates
choose_projects
@categories = Category.presented.decorate
render action: :new
end
Expand All @@ -50,6 +52,7 @@ def update
choose_members
choose_departaments
choose_teammates
choose_projects
render action: :edit
end
end
Expand All @@ -62,6 +65,10 @@ def destroy

private

def choose_projects
@projects = ActivityLines::Lider::YaLider.active.decorate
end

def choose_departaments
@departaments = TeamDecorator.decorate_collection Team::Departament.active
end
Expand Down
2 changes: 2 additions & 0 deletions app/decorators/activity_lines/lider/ya_lider_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ def full_title
"#{to_text_in_roman(object.contest_number)} областной конкурс актива учащейся молодёжи «Я-лидер!»"
end

alias title full_title

def self.collections
[ :current, :past, :removed ]
end
Expand Down
6 changes: 6 additions & 0 deletions app/decorators/team_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ def full_title(type_case = nil)
"#{type_case ? send(type_case, team_type) : team_type} в #{instrumental(object.municipality)}"
elsif object.is_primary?
"#{type_case ? send(type_case, team_type) : team_type} в #{object.school}"
elsif object.is_committee?
if object.project
"#{type_case ? send(type_case, team_type) : team_type} #{object.project.decorate.title}"
else
'Исправь это!!'
end
else
type_case ? send(type_case, title) : title
end
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions app/decorators/web/event/registration_decorator.rb

This file was deleted.

13 changes: 0 additions & 13 deletions app/decorators/web/event_decorator.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/forms/team_form.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class TeamForm < ApplicationReform
properties :title, :member_id, :description, :state, :user_ids, :school, :municipality, :type, :team_id, :publicity,
:state_event
:state_event, :project_type, :project_id
end
18 changes: 10 additions & 8 deletions app/helpers/web/admin/teams_helper.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
module Web::Admin::TeamsHelper
def team_types
team_types = t('activerecord.attributes.team.types')
types = {}
team_types.each do |key, value|
types[value] = "Team::#{key.to_s.capitalize}"
team_types.reduce({}) do |types, value|
types.merge! value[1] => "Team::#{value[0].to_s.capitalize}"
end
types
end

def team_types_name(type)
t("activerecord.attributes.team.types.#{type.split(':').last.downcase}")
end

def teams_hash(teams)
teams_hash = {}
teams.each do |team|
teams_hash[team.full_title] = team.id
teams.reduce({}) do |teams_hash, team|
teams_hash.merge! team.full_title => team.id
end
end

def projects_hash(projects)
projects.reduce({}) do |hash, project|
hash.merge! project.title => project.id
end
teams_hash
end
end
1 change: 1 addition & 0 deletions app/models/activity_lines/lider/ya_lider.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class ActivityLines::Lider::YaLider < ActiveRecord::Base
has_many :stages, foreign_key: :contest_id, class_name: 'ActivityLines::Lider::YaLider::Stage'
has_many :tokens, as: :record, dependent: :destroy
has_one :committee, as: :project, class_name: 'Team::Committee'

validates :contest_number, presence: true, uniqueness: { scope: :state }
validates :contest_year, presence: true, uniqueness: { scope: :state }
Expand Down
4 changes: 4 additions & 0 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def is_primary?
model_name == 'Team::Primary'
end

def is_committee?
model_name == 'Team::Committee'
end

def is_presidium?
title == 'Президиум'
end
Expand Down
5 changes: 4 additions & 1 deletion app/models/team/committee.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
class Team::Committee < Team
validates :title, presence: true
belongs_to :project, polymorphic: true

extend Enumerize
enumerize :project_type, in: [ 'ActivityLines::Lider::YaLider' ]
end
17 changes: 13 additions & 4 deletions app/views/web/admin/activity_lines/lider/ya_liders/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
- title @ya_lider.full_title
.panel-info
.panel-heading
%h4
= @ya_lider.full_title
.page-header
%h2
= @ya_lider.full_title
.row
.col-md-6
%h5
Expand All @@ -16,6 +15,16 @@
= 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'
.col-md-6
%h5
= @ya_lider.committee.decorate.full_title
%table.table.table-condensed.table-hover
- @ya_lider.committee.members.decorate.each do |member|
%tr
%td
= image_tag member.small_avatar_url
%td
= link_to member.short_name
%hr
.row
.col-md-6
Expand Down
3 changes: 3 additions & 0 deletions app/views/web/admin/teams/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
= f.input :title, as: :string
.team_input
= f.input :team_id, as: :select, collection: teams_hash(@departaments), input_html: { class: :select2 }
.project_input
= f.input :project_type, as: :hidden, input_html: { value: 'ActivityLines::Lider::YaLider' }
= f.input :project_id, as: :select, collection: projects_hash(@projects)
= f.input :description, as: :text
= f.input :state_event, as: :state_event
= f.input :publicity
Expand Down
1 change: 1 addition & 0 deletions config/locales/ru/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ ru:
publicity: Публичность
state: Статус
users: Члены команды
project_id: Проект
types:
departament: Местное отделение
subdivision: Структурное подразделение
Expand Down
6 changes: 6 additions & 0 deletions db/migrate/20170123020021_add_project_id_to_teams.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddProjectIdToTeams < ActiveRecord::Migration
def change
add_column :teams, :project_id, :integer
add_column :teams, :project_type, :text
end
end
9 changes: 5 additions & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170121022820) do
ActiveRecord::Schema.define(version: 20170123020021) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -90,6 +90,7 @@
t.integer "stage_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "state"
end

create_table "activity_lines_lider_ya_lider_stages", force: :cascade do |t|
Expand All @@ -109,6 +110,7 @@
t.text "state"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "org_team_id"
end

create_table "articles", force: :cascade do |t|
Expand Down Expand Up @@ -489,16 +491,15 @@
t.text "school"
t.integer "team_id"
t.text "publicity"
t.integer "project_id"
t.text "project_type"
end

create_table "teams_users", id: false, force: :cascade do |t|
t.integer "team_id"
t.integer "user_id"
end

add_index "teams_users", ["team_id"], name: "index_teams_users_on_team_id", using: :btree
add_index "teams_users", ["user_id"], name: "index_teams_users_on_user_id", using: :btree

create_table "test_paper_questions", force: :cascade do |t|
t.text "text"
t.integer "test_paper_id"
Expand Down
14 changes: 14 additions & 0 deletions lib/organization/permissions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ def place
review: User.tech_admins
}
end

def activity_lines_lider_ya_lider
{
index: (lider_lead + User.tech_admins),
show: (lider_lead + User.tech_admins),
new: (lider_lead + User.tech_admins),
create: (lider_lead + User.tech_admins),
edit: (lider_lead + User.tech_admins),
update: (lider_lead + User.tech_admins)
}
end

def activity_lines_lider_ya_lider_stage
end
end
end
end

0 comments on commit c909ca3

Please sign in to comment.