Fix personal profile creation

This commit is contained in:
Petko Bordjukov 2016-10-08 22:40:56 +03:00
parent f79ca34cda
commit e9995cbc0b
5 changed files with 23 additions and 12 deletions

View File

@ -1,9 +1,15 @@
module EventsHelper
def participant_names_or_emails(event)
def links_to_event_participants_for(event)
event.participants.map do |participant|
participant.try(:personal_profile, current_conference).try(:name) ||
participant.personal_profiles.last.try(:name) ||
participant.email
if participant.personal_profile(event.conference).present?
profile = participant.personal_profile(event.conference)
link_to icon(:user, profile.name), management_conference_personal_profile_path(profile, conference_id: event.conference.id)
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

View File

@ -18,6 +18,7 @@ class Conference < ActiveRecord::Base
has_many :volunteers
has_one :call_for_participation, dependent: :destroy
has_many :participants, class_name: 'User', through: :events
has_many :participant_profiles, class_name: 'PersonalProfile'
has_many :slots, through: :halls
accepts_nested_attributes_for :tracks, :halls, :event_types, :volunteer_teams,
@ -25,10 +26,6 @@ class Conference < ActiveRecord::Base
after_create :create_call_for_participation
def participants
events.where(conference_id: id).map(&:user)
end
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.group_by { |s| s.created_at.to_date }

View File

@ -26,6 +26,12 @@ class Event < ActiveRecord::Base
delegate :status, to: :proposition
def all_participants_have_profiles?
participants.all? do |participant|
participant.personal_profile(conference).present?
end
end
def proposer_profile
proposer.personal_profile(conference)
end

View File

@ -1,4 +1,4 @@
tr
= content_tag :tr, class: event.all_participants_have_profiles? ? nil : 'warning'
td
dl.dl-horizontal
dt = Event.human_attribute_name :title
@ -7,7 +7,7 @@ tr
dt = Event.human_attribute_name :subtitle
dd = event.subtitle
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
dd = event.event_type.name
dt = Event.human_attribute_name :track
@ -16,7 +16,7 @@ tr
dd = t("locales.#{event.language}")
td.visible-md.visible-lg.visible-xl
= participant_names_or_emails(event).join(', ')
= links_to_event_participants_for(event)
td.action
.dropdown
button class="btn btn-sm dropdown-toggle btn-#{proposition_status_class(event.status)}" type="button" data-toggle="dropdown" title="#{t "status.#{event.status}"}"

View File

@ -6,6 +6,8 @@ bg:
events:
index:
all: "Всички"
event:
create_profile: "Създай профил"
no_records:
no_records_found: 'Не бяха открити записи, които да отговарят на изискванията'
abstract: "Резюме"