Skip to content

Commit

Permalink
Merge branch 'release/0.11.8.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
kalashnikovisme committed Dec 30, 2016
2 parents 3c1f56b + d53d4fc commit d13a7f2
Show file tree
Hide file tree
Showing 29 changed files with 265 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ GIT

GIT
remote: git://github.com/luizpicolo/youtube_rails.git
revision: 934fdb6305a9416ef8fafb8c2dcf82f6355b2503
revision: 18d102bafaf9f837455b8f7c7726f1b4aad80d79
specs:
youtube_rails (1.2.1)
youtube_rails (1.2.2)

GIT
remote: git://github.com/nitinstp23/foursquare2.git
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
class Web::Admin::ActivityLines::Lider::YaLider::ParticipantsController < ApplicationController
class Web::Admin::ActivityLines::Lider::YaLider::ParticipantsController < Web::Admin::ActivityLines::Lider::YaLider::ApplicationController
before_filter :choose_users, only: [ :new, :edit ]

def new
@participant_form = ::ActivityLines::Lider::YaLider::ParticipantForm.new_with_model
end

def create
@participant_form = ::ActivityLines::Lider::YaLider::ParticipantForm.new_with_model
if @participant_form.submit params[:activity_lines_lider_ya_lider_participant]
redirect_to admin_activity_lines_lider_ya_lider_path @participant_form.model.ya_lider
redirect_to admin_activity_lines_lider_ya_liders_path
else
choose_users
render action: :new
end
end
Expand All @@ -19,15 +22,16 @@ def edit
def update
@participant_form = ::ActivityLines::Lider::YaLider::ParticipantForm.find_with_model params[:id]
if @participant_form.submit params[:activity_lines_lider_ya_lider_participant]
redirect_to admin_activity_lines_lider_ya_lider_path @participant_form.model.ya_lider
redirect_to admin_activity_lines_lider_ya_liders_path
else
choose_users
render action: :edit
end
end

def destroy
@participant = ::ActivityLines::Lider::YaLider::Participant.find params[:id]
@participant.remove
redirect_to admin_activity_lines_lider_ya_lider_path @participant.ya_lider
redirect_to admin_activity_lines_lider_ya_liders_path
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
class Web::Admin::ActivityLines::Lider::YaLider::ParticipationsController < Web::Admin::ActivityLines::Lider::YaLider::ApplicationController
before_filter :choose_users, only: [ :new, :edit ]

def new
@participation_form = ::ActivityLines::Lider::YaLider::ParticipationForm.new_with_model
end

def create
@participation_form = ::ActivityLines::Lider::YaLider::ParticipationForm.new_with_model
if @participation_form.submit params[:activity_lines_lider_ya_lider_participation]
redirect_to admin_activity_lines_lider_ya_lider_path @participation_form.model.ya_lider
else
choose_users
render action: :new
end
end

def edit
@participation_form = ::ActivityLines::Lider::YaLider::ParticipationForm.find_with_model params[:id]
end

def update
@participation_form = ::ActivityLines::Lider::YaLider::ParticipationForm.find_with_model params[:id]
if @participation_form.submit params[:activity_lines_lider_ya_lider_participation]
redirect_to admin_activity_lines_lider_ya_lider_path @participation_form.model.ya_lider
else
choose_users
render action: :edit
end
end

def destroy
@participation = ::ActivityLines::Lider::YaLider::Participation.find params[:id]
@participation.remove
redirect_to admin_activity_lines_lider_ya_lider_path @participation.ya_lider
end
end
6 changes: 6 additions & 0 deletions app/forms/activity_lines/lider/ya_lider/participant_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class ActivityLines::Lider::YaLider::ParticipantForm < ApplicationReform
properties :contest_year, :user_id, :state

validates :contest_year, presence: true
validates :user_id, presence: true
end
17 changes: 17 additions & 0 deletions app/models/activity_lines/lider/ya_lider/participant.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
class ActivityLines::Lider::YaLider::Participant < ActiveRecord::Base
belongs_to :user

state_machine :state, initial: :unviewed do
state :unviewed
state :active
state :won
state :lost
state :removed
state :declined

event :remove do
transition all => :removed
end

event :restore do
transition removed: :active
end
end
end
2 changes: 1 addition & 1 deletion app/models/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Member < User
allow_blank: true
validates :patronymic, human_name: true,
allow_blank: true
validates :ticket, uniqueness: true,
validates :ticket, uniqueness: { scope: :state },
allow_blank: true
validates :mobile_phone, phone: true,
allow_blank: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- model_class = ActivityLines::Lider::YaLider::Participant
- current_title = page_title(action, model_class.model_name.human)
- title current_title, :admin
.page-header
%h1=t current_title
.row
.col-lg-12
= render 'layouts/web/admin/shared/messages', object: @participant_form
.row
.col-lg-12
= simple_form_for [:admin, @participant_form], input_html: { class: 'form-horizontal' } do |f|
= f.button :submit, class: 'btn-success', value: t('helpers.links.save')
-#= link_to t('helpers.links.back'), admin_activity_lines_lider_ya_lider_path(ya_lider_id), class: 'btn btn-default'
= f.input :contest_year, as: :string
= f.input :user_id, as: :select, collection: users_cache_hash(@users), input_html: { class: :select2 }, label: false
= f.input :state_event, as: :state_event
= f.button :submit, class: 'btn-success', value: t('helpers.links.save')
-#= link_to t('helpers.links.back'), admin_activity_lines_lider_ya_lider_path(ya_lider_id), class: 'btn btn-default'
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
= paginate activity_lines_lider_ya_liders, theme: 'twitter-bootstrap-3'
- model_class = ActivityLines::Lider::YaLider
%table.table.table-striped.table-condensed
%thead
%tr
%th= model_class.human_attribute_name(:id)
%th= model_class.human_attribute_name(:contest_number)
%th= model_class.human_attribute_name(:contest_year)
- if searching?
%th= model_class.human_attribute_name(:state)
%th=t 'helpers.links.actions'
%tbody
- activity_lines_lider_ya_liders.each do |ya_lider|
%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= ya_lider.contest_year
- if searching?
%td= ya_lider.human_state_name
%td.actions
= link_to fa_icon(:pencil), edit_admin_activity_lines_lider_ya_lider_path(ya_lider), class: 'btn btn-warning btn-xs'
= link_to fa_icon(:remove), admin_activity_lines_lider_ya_lider_path(ya_lider), method: :delete, class: 'btn btn-xs btn-danger'
= paginate activity_lines_lider_ya_liders, theme: 'twitter-bootstrap-3'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= render partial: 'form', locals: { action: :update }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= render 'web/admin/default/index', items: @ya_liders
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= render partial: 'form', locals: { action: :create }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- title @ya_lider.full_title
.panel-info
.panel-heading
%h4
= @ya_lider.full_title
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- model_class = ActivityLines::Lider::YaLider::Participant
- current_title = page_title(action, model_class.model_name.human)
- title current_title, :admin
.page-header
%h1=t current_title
.row
.col-lg-12
= render 'layouts/web/admin/shared/messages', object: @participant_form
.row
.col-lg-12
= simple_form_for [:admin, @participant_form], input_html: { class: 'form-horizontal' } do |f|
= f.button :submit, class: 'btn-success', value: t('helpers.links.save')
-#= link_to t('helpers.links.back'), admin_activity_lines_lider_ya_lider_path(ya_lider_id), class: 'btn btn-default'
= f.input :user_id, as: :select, collection: users_cache_hash(@users), input_html: { class: :select2 }, label: false
= f.input :state_event, as: :state_event
= f.button :submit, class: 'btn-success', value: t('helpers.links.save')
-#= link_to t('helpers.links.back'), admin_activity_lines_lider_ya_lider_path(ya_lider_id), class: 'btn btn-default'
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
= paginate activity_lines_lider_ya_liders, theme: 'twitter-bootstrap-3'
- model_class = ActivityLines::Lider::YaLider
%table.table.table-striped.table-condensed
%thead
%tr
%th= model_class.human_attribute_name(:id)
%th= model_class.human_attribute_name(:contest_number)
%th= model_class.human_attribute_name(:contest_year)
- if searching?
%th= model_class.human_attribute_name(:state)
%th=t 'helpers.links.actions'
%tbody
- activity_lines_lider_ya_liders.each do |ya_lider|
%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= ya_lider.contest_year
- if searching?
%td= ya_lider.human_state_name
%td.actions
= link_to fa_icon(:pencil), edit_admin_activity_lines_lider_ya_lider_path(ya_lider), class: 'btn btn-warning btn-xs'
= link_to fa_icon(:remove), admin_activity_lines_lider_ya_lider_path(ya_lider), method: :delete, class: 'btn btn-xs btn-danger'
= paginate activity_lines_lider_ya_liders, theme: 'twitter-bootstrap-3'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= render partial: 'form', locals: { action: :update }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= render 'web/admin/default/index', items: @ya_liders
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= render partial: 'form', locals: { action: :create }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- title @ya_lider.full_title
.panel-info
.panel-heading
%h4
= @ya_lider.full_title
2 changes: 1 addition & 1 deletion app/views/web/events/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
.row
.small-9.columns
.youtube_video
!= YouTubeRails.youtube_embed_url(@event.online_conference.video_link, 420, 315, { ssl: true })
!= YouTubeRails.youtube_embed_url(@event.online_conference.video_link, 420, 315, ssl: true)
.event-content.container.ask-question
.row
.small-6.columns
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 @@ -21,6 +21,7 @@ ru:
activity_lines/corporative/online_conference/question: Вопросы на онлайн-конференцию
activity_lines/lider/ya_lider: Конкурс "Я-лидер!"
activity_lines/lider/ya_lider/stage: Этап конкурса "Я-лидер!"
activity_lines/lider/ya_lider/participant: Участник конкурса "Я-лидер!"
logged_action: Лог действия
redirect_rule: Редирект
image: Изображение
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
resources :ya_liders
namespace :ya_lider do
resources :stages, except: [ :index, :show ]
resources :participants, except: [ :index, :show ]
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddStateToActivityLinesLiderYaLiderParticipants < ActiveRecord::Migration
def change
add_column :activity_lines_lider_ya_lider_participations, :state, :text
end
end
1 change: 1 addition & 0 deletions lib/yaml/russian_cases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ cases:
'приложение': приложение
'конкурс "я-лидер!"': конкурс "Я-лидер!"
'этап конкурса "я-лидер!"': этап конкурса "Я-лидер!"
'участник конкурса "я-лидер!"': участника конкурса "Я-лидер!"
dative:
'местное отделение': местном отделении
'первичная организация': первичной организации
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Web::Admin::ActivityLines::Corporative::OnlineConferencesControllerTest <
attributes = attributes_for :activity_lines_corporative_online_conference
patch :update, activity_lines_corporative_online_conference: attributes, id: @online_conference
assert_response :redirect, @response.body
assert_redirected_to admin_activity_lines_corporative_online_conferences_path
assert_redirected_to admin_activity_lines_corporative_online_conference_path @online_conference
@online_conference.reload
@online_conference.attributes.keys.except(*@exceptions_attributes).each do |key|
assert_equal attributes[key.to_sym], @online_conference.send(key), key
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,67 @@
require 'test_helper'

class Web::Admin::ActivityLines::Lider::YaLider::ParticipantsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
setup do
admin = create :admin
sign_in admin
create :ya_lider
@participant = create :ya_lider_participant
@exceptions_attributes = ['id', 'created_at', 'updated_at', 'begin_date', 'end_date']
end

test 'should get new' do
get :new, activity_lines_lider_ya_lider_participant: { ya_lider_id: ActivityLines::Lider::YaLider.last.id }
assert_response :success, @response.body
end

test 'should create participant' do
attributes = attributes_for :ya_lider_participant
attributes[:arguments_attributes] = {}
attributes[:arguments_attributes]['0'] = attributes_for :argument
post :create, activity_lines_lider_ya_lider_participant: attributes
participant = ActivityLines::Lider::YaLider::Participant.last
assert_response :redirect, @response.body
assert_redirected_to admin_activity_lines_lider_ya_liders_path
participant.attributes.keys.except(*@exceptions_attributes).each do |key|
assert_equal attributes[key.to_sym], participant.send(key), key
end
end

test 'should not create participant' do
attributes = { user_id: @participant.user_id }
post :create, activity_lines_lider_ya_lider_participant: attributes
assert_response :success
end

test 'should get edit by admin' do
4.times { create :argument }
get :edit, id: @participant
assert_response :success
end

test 'should update participant by admin' do
attributes = attributes_for :ya_lider_participant
put :update, id: @participant, activity_lines_lider_ya_lider_participant: attributes
assert_response :redirect
assert_redirected_to admin_activity_lines_lider_ya_liders_path
@participant.reload
@participant.attributes.keys.except(*@exceptions_attributes).each do |key|
assert_equal attributes[key.to_sym], @participant.send(key), key
end
end

test 'should not update participant by admin' do
attributes = attributes_for :ya_lider_participant
attributes[:user_id] = nil
count_before_save = ActivityLines::Lider::YaLider::Participant.count
put :update, id: @participant, activity_lines_lider_ya_lider_participant: attributes
assert_equal ActivityLines::Lider::YaLider::Participant.count, count_before_save
assert_response :success
end

test 'should destroy participant' do
delete :destroy, id: @participant
@participant.reload
assert @participant.removed?
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Web::Admin::ActivityLines::Lider::YaLider::StagesControllerTest < ActionCo
admin = create :admin
sign_in admin
@stage = create :ya_lider_stage
@exceptions_attributes = ['id', 'created_at', 'updated_at', 'begin_date', 'end_date']
@exceptions_attributes = ['id', 'created_at', 'updated_at']
end

test 'should get new' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
factory :activity_lines_corporative_online_conference, class: 'ActivityLines::Corporative::OnlineConference' do
title { generate :string }
date { generate :datetime }
video_link { generate :url }
video_link 'https://youtu.be/someURL'
state { ::ActivityLines::Corporative::OnlineConference.state_machines[:state].states.map(&:name).first.to_s }
end
end
7 changes: 7 additions & 0 deletions test/factories/activity_lines/lider/ya_lider/participants.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FactoryGirl.define do
factory :ya_lider_participant, class: 'ActivityLines::Lider::YaLider::Participant' do
contest_year { generate :integer }
user_id { User.last ? User.last.id : create(:user).id }
state { ActivityLines::Lider::YaLider::Participant.state_machines[:state].states.map(&:name).first.to_s }
end
end
13 changes: 13 additions & 0 deletions test/factories/activity_lines/lider/ya_lider/participations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FactoryGirl.define do
factory :ya_lider_participation, class: 'ActivityLines::Lider::YaLider::Participation' do
stage_id do
if ActivityLines::Lider::YaLider::Stage.last
ActivityLines::Lider::YaLider::Stage.last.id
else
create(:ya_lider_stage).id
end
end
user_id { User.last.present? ? User.last.id : create(:user).id }
state { ActivityLines::Lider::YaLider::Participation.state_machines[:state].states.map(&:name).first.to_s }
end
end

0 comments on commit d13a7f2

Please sign in to comment.