Skip to content

Commit

Permalink
Merge branch 'release/0.11.9.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
kalashnikovisme committed Dec 25, 2016
2 parents 76bd425 + 276c353 commit 8e508e7
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def index
end

def show
@online_conference = ::ActivityLines::Corporative::OnlineConference.find params[:id]
@online_conference = ::ActivityLines::Corporative::OnlineConference.find(params[:id]).decorate
end

def new
Expand All @@ -35,7 +35,7 @@ def update
@online_conference_form = ::ActivityLines::Corporative::OnlineConferenceForm.find_with_model params[:id]
@online_conference_form.submit params[:activity_lines_corporative_online_conference]
if @online_conference_form.save
redirect_to admin_activity_lines_corporative_online_conferences_path
redirect_to admin_activity_lines_corporative_online_conference_path @online_conference_form.model
else
render action: :edit
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,24 @@ def self.collections
def event_title
"#{I18n.t('activerecord.attributes.activity_lines/corporative/online_conference.event_title')} «#{object.title}»"
end

def show_attributes
[ :title, :formatted_date, :video_link_to, :event_link ]
end

def formatted_date
I18n.l(object.date, format: '%d %B %Y')
end

def video_link_to
h.content_tag(:a, href: object.video_link) do
object.video_link
end
end

def event_link
h.content_tag(:a, href: event_path(object.event)) do
object.event.title
end
end
end
1 change: 1 addition & 0 deletions app/models/activity_lines/corporative/online_conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class ActivityLines::Corporative::OnlineConference < ActiveRecord::Base
belongs_to :event

validates :title, uniqueness: true, presence: true
validates :video_link, youtu_dot_be_video_link: true

state_machine :state, initial: :active do
state :active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
.row
.col-lg-12
%table.table.attributes-table
- @online_conference.attributes.each do |key, value|
- @online_conference.show_attributes.each do |attribute|
%tr
%td= model_class.human_attribute_name key
%td= value
%td= model_class.human_attribute_name attribute
%td= @online_conference.send attribute
%hr
- if @online_conference.questions.any?
%h4
Expand All @@ -34,8 +34,12 @@
- else
= fa_icon 'user-secret 2x'
%td= question.text
%td= link_to question.answer_link, question.answer_link
%td
- if question.answer_link.present?
= link_to question.answer_link, question.answer_link
%td{ width: '96px' }
- unless question.is_answered?
- if question.is_answered?
= link_to fa_icon(:pencil), edit_admin_activity_lines_corporative_online_conference_question_path(question, reason: :answer_timestamp), class: 'btn btn-warning'
- else
= link_to fa_icon('plus-square'), edit_admin_activity_lines_corporative_online_conference_question_path(question, reason: :answer_timestamp), class: 'btn btn-warning'
= link_to fa_icon(:remove), admin_activity_lines_corporative_online_conference_question_path(question), method: :delete, class: 'btn tbtn-xs btn-danger pull-right'
7 changes: 7 additions & 0 deletions config/locales/ru/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ ru:
activity_lines/corporative/online_conference:
title: Название
date: Дата
formatted_date: Дата
video_link: Ссылка на видео
video_link_to: Ссылка на видео
event_title: 'Онлайн-конференция'
event_link: Ссылка на мероприятие
activity_lines/corporative/online_conference/question:
text: Текст вопроса
answer_link: Ссылка на ответ
Expand Down Expand Up @@ -274,6 +277,10 @@ ru:
attributes:
mobile_phone:
phone: имеет неверный формат
activity_lines/corporative/online_conference:
attributes:
video_link:
video_link: cледует добавить ссылку вида youtu.be. Её можно получить под видео на Youtube в разделе Поделиться.
scopes:
event:
future: Грядущие
Expand Down
9 changes: 9 additions & 0 deletions lib/validators/youtu_dot_be_video_link_validator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class YoutuDotBeVideoLinkValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if value.present?
unless value =~ /youtu.be/
record.errors.add(attribute, :video_link, options.merge(value: value))
end
end
end
end

0 comments on commit 8e508e7

Please sign in to comment.