From 72a20576737b9b4c44fa7cccacba89362b95d66e Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sun, 9 Oct 2016 03:56:41 +0300 Subject: [PATCH] Reimplement personal profile index --- .../personal_profiles_controller.rb | 4 +- .../personal_profiles/index.csv.erb | 18 ++++ .../personal_profiles/index.html.slim | 86 +++++++++++-------- config/locales/bg.yml | 5 ++ 4 files changed, 75 insertions(+), 38 deletions(-) create mode 100644 app/views/management/personal_profiles/index.csv.erb diff --git a/app/controllers/management/personal_profiles_controller.rb b/app/controllers/management/personal_profiles_controller.rb index fb86c90..7997b7b 100644 --- a/app/controllers/management/personal_profiles_controller.rb +++ b/app/controllers/management/personal_profiles_controller.rb @@ -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 diff --git a/app/views/management/personal_profiles/index.csv.erb b/app/views/management/personal_profiles/index.csv.erb new file mode 100644 index 0000000..f41b159 --- /dev/null +++ b/app/views/management/personal_profiles/index.csv.erb @@ -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 -%> diff --git a/app/views/management/personal_profiles/index.html.slim b/app/views/management/personal_profiles/index.html.slim index cdc779c..1608da2 100644 --- a/app/views/management/personal_profiles/index.html.slim +++ b/app/views/management/personal_profiles/index.html.slim @@ -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') diff --git a/config/locales/bg.yml b/config/locales/bg.yml index f80047f..57503d9 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -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: "Крайна дата"