Reimplement personal profile index

This commit is contained in:
Petko Bordjukov 2016-10-09 03:56:41 +03:00
parent 0911ce5a71
commit 72a2057673
4 changed files with 75 additions and 38 deletions

View File

@ -2,9 +2,7 @@ module Management
class PersonalProfilesController < ManagementController
def index
@conference = find_conference
# TODO @conference.participants
@users = User.all
@users = current_conference.participants
end
def toggle_admin

View File

@ -0,0 +1,18 @@
<%- csv_headers = %w{id private_email public_email first_name last_name organisation picture mobile_phone biography github twitter language} -%>
<%= CSV.generate_line(csv_headers).html_safe -%>
<%- @users.each do |user| -%>
<%- profile = user.personal_profile(@conference) -%>
<%= CSV.generate_line([user.id,
user.email,
profile.try(:public_email),
profile.try(:first_name),
profile.try(:last_name),
profile.try(:organisation),
profile.try(:picture).try(:thumb).try(:url),
profile.try(:mobile_phone),
profile.try(:biography),
profile.try(:github),
profile.try(:twitter),
user.language
]).html_safe -%>
<%- end -%>

View File

@ -1,41 +1,57 @@
- content_for :title
= Conference.human_attribute_name(:participants).mb_chars.capitalize
.row
.col-lg-12
h1.page-header
= Conference.human_attribute_name(:participants).mb_chars.capitalize
small<
| (
= t '.total', current: @users.count, total: current_conference.participants.count
=< User.model_name.human(count: current_conference.participants.count).mb_chars.downcase
| )
.row
.col-lg-12
.panel.panel-default
.panel-heading
h2.panel-title= User.model_name.human(count: 2).mb_chars.capitalize
.panel-body
table.table.table-striped.table-hover.record-table#conferences
thead
table.table.table-striped.table-hover.record-table#profiles
thead
tr
th = PersonalProfile.model_name.human
th.actions
tbody
- @users.each do |user|
- profile = user.personal_profile(@conference)
tr
th = User.human_attribute_name :picture
th = User.human_attribute_name :title
th = User.human_attribute_name :admin
th.actions
tbody
- @users.each do |user|
- profile = user.personal_profile(@conference)
td
.media
.media-left
- if profile.present?
= image_tag(profile.picture.thumb.url)
- else
= image_tag(PictureUploader.new.thumb.url)
- if profile.present?
tr
td= image_tag(profile.picture.thumb.url)
td= profile.name
td.boolean-col
= link_to [:toggle_admin, :management, @conference, profile], method: :put do
- if user.admin?
.btn.btn-primary= icon('circle-o')
.media-body
h4.media-heading
- if profile.try(:name).present?
= profile.name
- else
.btn.btn-success= icon('dot-circle-o')
td.actions
div.btn-group.btn-group-sm
= action_buttons(@conference, profile, [:show, :edit, :destroy])
- else
tr
td= image_tag(PictureUploader.new.thumb.url)
td= user.email
td
td.actions
div.btn-group.btn-group-sm
= link_to [:new, :management, @conference, :personal_profile, {user_id: user.id}] do
=> t('actions.create.title', model: User.model_name.human)
= user.email
p
- if profile.present?
- if profile.public_email.present?
= icon :envelope, "#{profile.public_email} (#{PersonalProfile.human_attribute_name(:public_email).mb_chars.downcase})"
br
= icon :envelope, "#{user.email} (#{User.human_attribute_name(:email).mb_chars.downcase})"
- else
= t '.no_profile'
td.actions
div.btn-group.btn-group-sm
- if profile.present?
= action_buttons(@conference, profile, [:show, :edit, :destroy])
- else
= link_to [:new, :management, @conference, :personal_profile, {user_id: user.id}], class: ['btn', 'btn-primary'], title: t('actions.create.title', model: PersonalProfile.model_name.human) do
=> icon('user-plus')
.panel-footer.text-right
= link_to management_conference_personal_profiles_path(current_conference, format: 'csv'), class: 'btn btn-info'
= icon :download, t('.export')

View File

@ -1,5 +1,9 @@
bg:
management:
personal_profiles:
index:
no_profile: 'Този потребител няма въведени профили в системата.'
total: "%{current} от общо %{total}"
conferences:
show:
summary: 'Обобщение'
@ -64,6 +68,7 @@ bg:
rejected: Отхвърлено
backup: Резерва
conference:
participants: "Участници"
description: "Описание"
email: E-mail
end_date: "Крайна дата"