From aa43ab12dd7a93795039de4ba9f31b866827a2d1 Mon Sep 17 00:00:00 2001 From: Andrew Radev Date: Mon, 25 May 2015 11:41:11 +0300 Subject: [PATCH] Profile pictures in user list --- .../fallback/profile_picture/medium_default.png | Bin 0 -> 3003 bytes .../profile_picture/schedule_default.png | Bin 0 -> 1814 bytes .../fallback/profile_picture/thumb_default.png | Bin 0 -> 987 bytes app/controllers/management/users_controller.rb | 2 +- app/models/user.rb | 8 ++++++++ app/uploaders/picture_uploader.rb | 9 +++------ app/views/management/users/index.html.slim | 2 ++ 7 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 app/assets/images/fallback/profile_picture/medium_default.png create mode 100644 app/assets/images/fallback/profile_picture/schedule_default.png create mode 100644 app/assets/images/fallback/profile_picture/thumb_default.png diff --git a/app/assets/images/fallback/profile_picture/medium_default.png b/app/assets/images/fallback/profile_picture/medium_default.png new file mode 100644 index 0000000000000000000000000000000000000000..619f4fe2f46c1d83fc06ee36ae936a767458ffe3 GIT binary patch literal 3003 zcmcImc{r478-HKJ7;BT%jNL?{EHjp3$d;vX?3F`>VNAA=VeIi@NSY%g$(C|x!6-yX z#?q*xBr;Pb(UC1#Pm?T}Z~DH!zVH9C$3^5MFxYcGUU>i@-bt{r zIuSRzP{xg^d@N&0MOi~2caG1mH&DUW?CLWn(z}9`i$?Yj56=-=L=MO;aB6p>g4$2C zd3L94E$xu?#Pw1EuumAqcE%DH{*O>Q0Fdao>EHR^m{<;|oo0nlvqs#a88{#?ID6y0^WB-i~kpLzB?0q6etcR0~`kQikrbie98A&$ct> zb-g*%7H$}278CCXLtw14jC0g>i(wG!=K?R{${S!Pvm6r1aeQs8%Cu$Xx5U=5aK_D- z=2y-FBuA}le_kqB{YQ$w6HUUcf6KV-frJYels39}n?IbA zjG!nV*$n3~tK{`{{hp>$>@tRns_={hG9Q77JGmL49wvs-%R3p-VAJ&zB~A zrClAuVozge^OoCSRdnZg6szX`YH0234G{l^yHJSB^4n#d-B3}WEG>FPefb{B)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5LtJxJ?p-k0>`h&i86 z%HG(q<=W%?2U=nbOCqIi@m9Yoxz-c1DttqZ%90t9RgWhHacM5n&OF)6$}vf0=FQ+9 zZiY!Jj8EbY^&XYjo%|(M`1zk(hR==(1?fBqoqkAy`{lkrg$axe4;aH;i&b_M?CN6f z7BJep{=0bU6an|Re;ui7d3Wi|(Cjf>`lWd8iw$B+OD;<65n-?hR{3RfF7xVB7mlAf ztnFI`{$28yKKHbaxn}Y!H}RedVBTO*Epd$~Nl7e8wMs5Z1yT$~28O1(2Bx}3rXhxg zR>me)#+KR!##ROf6}r`+oQTkno1c=IR*9~`*viBLqQPD6RuoVJgQu&X%Q~loCIGtg Bs!0F< literal 0 HcmV?d00001 diff --git a/app/controllers/management/users_controller.rb b/app/controllers/management/users_controller.rb index b70a7cf..5bffbbe 100644 --- a/app/controllers/management/users_controller.rb +++ b/app/controllers/management/users_controller.rb @@ -1,7 +1,7 @@ module Management class UsersController < ManagementController def index - @users = User.all + @users = User.includes(:speaker_profile) end def toggle_admin diff --git a/app/models/user.rb b/app/models/user.rb index e7cbc1f..3412dda 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -20,4 +20,12 @@ class User < ActiveRecord::Base def toggle_admin! update admin: !admin end + + def profile_picture + if speaker_profile.present? + speaker_profile.picture + else + PictureUploader.new + end + end end diff --git a/app/uploaders/picture_uploader.rb b/app/uploaders/picture_uploader.rb index 0f60f9b..3dc3914 100644 --- a/app/uploaders/picture_uploader.rb +++ b/app/uploaders/picture_uploader.rb @@ -15,12 +15,9 @@ class PictureUploader < CarrierWave::Uploader::Base end # Provide a default URL as a default if there hasn't been a file uploaded: - # def default_url - # # For Rails 3.1+ asset pipeline compatibility: - # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) - # - # "/images/fallback/" + [version_name, "default.png"].compact.join('_') - # end + def default_url + ActionController::Base.helpers.asset_path("fallback/profile_picture/" + [version_name, "default.png"].compact.join('_')) + end # Process files as they are uploaded: # process :scale => [200, 300] diff --git a/app/views/management/users/index.html.slim b/app/views/management/users/index.html.slim index d608b95..d807e5f 100644 --- a/app/views/management/users/index.html.slim +++ b/app/views/management/users/index.html.slim @@ -7,12 +7,14 @@ table.table.table-striped.table-hover.record-table#conferences thead 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| tr + td= image_tag(user.profile_picture.thumb.url) td= user.name td.boolean-col - if user.admin?