Fix personal profile creation
This commit is contained in:
parent
f79ca34cda
commit
e9995cbc0b
|
@ -1,9 +1,15 @@
|
||||||
module EventsHelper
|
module EventsHelper
|
||||||
def participant_names_or_emails(event)
|
def links_to_event_participants_for(event)
|
||||||
event.participants.map do |participant|
|
event.participants.map do |participant|
|
||||||
participant.try(:personal_profile, current_conference).try(:name) ||
|
if participant.personal_profile(event.conference).present?
|
||||||
participant.personal_profiles.last.try(:name) ||
|
profile = participant.personal_profile(event.conference)
|
||||||
participant.email
|
link_to icon(:user, profile.name), management_conference_personal_profile_path(profile, conference_id: event.conference.id)
|
||||||
end
|
else
|
||||||
|
link_to icon('user-plus', participant.email),
|
||||||
|
new_management_conference_personal_profile_path(conference_id: event.conference.id,
|
||||||
|
user_id: participant.id),
|
||||||
|
title: t('.create_profile'), class: 'bg-danger'
|
||||||
|
end
|
||||||
|
end.join(', ').html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Conference < ActiveRecord::Base
|
||||||
has_many :volunteers
|
has_many :volunteers
|
||||||
has_one :call_for_participation, dependent: :destroy
|
has_one :call_for_participation, dependent: :destroy
|
||||||
has_many :participants, class_name: 'User', through: :events
|
has_many :participants, class_name: 'User', through: :events
|
||||||
|
has_many :participant_profiles, class_name: 'PersonalProfile'
|
||||||
has_many :slots, through: :halls
|
has_many :slots, through: :halls
|
||||||
|
|
||||||
accepts_nested_attributes_for :tracks, :halls, :event_types, :volunteer_teams,
|
accepts_nested_attributes_for :tracks, :halls, :event_types, :volunteer_teams,
|
||||||
|
@ -25,10 +26,6 @@ class Conference < ActiveRecord::Base
|
||||||
|
|
||||||
after_create :create_call_for_participation
|
after_create :create_call_for_participation
|
||||||
|
|
||||||
def participants
|
|
||||||
events.where(conference_id: id).map(&:user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def submissions_grouped_by_day
|
def submissions_grouped_by_day
|
||||||
submissions = events.group('date(events.created_at)').select('date(events.created_at) as created_at, count(events.id) as number')
|
submissions = events.group('date(events.created_at)').select('date(events.created_at) as created_at, count(events.id) as number')
|
||||||
submissions.group_by { |s| s.created_at.to_date }
|
submissions.group_by { |s| s.created_at.to_date }
|
||||||
|
|
|
@ -26,6 +26,12 @@ class Event < ActiveRecord::Base
|
||||||
|
|
||||||
delegate :status, to: :proposition
|
delegate :status, to: :proposition
|
||||||
|
|
||||||
|
def all_participants_have_profiles?
|
||||||
|
participants.all? do |participant|
|
||||||
|
participant.personal_profile(conference).present?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def proposer_profile
|
def proposer_profile
|
||||||
proposer.personal_profile(conference)
|
proposer.personal_profile(conference)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
tr
|
= content_tag :tr, class: event.all_participants_have_profiles? ? nil : 'warning'
|
||||||
td
|
td
|
||||||
dl.dl-horizontal
|
dl.dl-horizontal
|
||||||
dt = Event.human_attribute_name :title
|
dt = Event.human_attribute_name :title
|
||||||
|
@ -7,7 +7,7 @@ tr
|
||||||
dt = Event.human_attribute_name :subtitle
|
dt = Event.human_attribute_name :subtitle
|
||||||
dd = event.subtitle
|
dd = event.subtitle
|
||||||
dt.visible-sm.visible-xs = Event.human_attribute_name :participants
|
dt.visible-sm.visible-xs = Event.human_attribute_name :participants
|
||||||
dd.visible-sm.visible-xs = participant_names_or_emails(event).join(', ')
|
dd.visible-sm.visible-xs = links_to_event_participants_for(event)
|
||||||
dt = EventType.model_name.human.mb_chars.titleize
|
dt = EventType.model_name.human.mb_chars.titleize
|
||||||
dd = event.event_type.name
|
dd = event.event_type.name
|
||||||
dt = Event.human_attribute_name :track
|
dt = Event.human_attribute_name :track
|
||||||
|
@ -16,7 +16,7 @@ tr
|
||||||
dd = t("locales.#{event.language}")
|
dd = t("locales.#{event.language}")
|
||||||
|
|
||||||
td.visible-md.visible-lg.visible-xl
|
td.visible-md.visible-lg.visible-xl
|
||||||
= participant_names_or_emails(event).join(', ')
|
= links_to_event_participants_for(event)
|
||||||
td.action
|
td.action
|
||||||
.dropdown
|
.dropdown
|
||||||
button class="btn btn-sm dropdown-toggle btn-#{proposition_status_class(event.status)}" type="button" data-toggle="dropdown" title="#{t "status.#{event.status}"}"
|
button class="btn btn-sm dropdown-toggle btn-#{proposition_status_class(event.status)}" type="button" data-toggle="dropdown" title="#{t "status.#{event.status}"}"
|
||||||
|
|
|
@ -6,6 +6,8 @@ bg:
|
||||||
events:
|
events:
|
||||||
index:
|
index:
|
||||||
all: "Всички"
|
all: "Всички"
|
||||||
|
event:
|
||||||
|
create_profile: "Създай профил"
|
||||||
no_records:
|
no_records:
|
||||||
no_records_found: 'Не бяха открити записи, които да отговарят на изискванията'
|
no_records_found: 'Не бяха открити записи, които да отговарят на изискванията'
|
||||||
abstract: "Резюме"
|
abstract: "Резюме"
|
||||||
|
|
Loading…
Reference in New Issue