Show profile pictures to admins and allow them to upload pics
This commit is contained in:
parent
10d58ef050
commit
d5a9b79f6e
4 changed files with 17 additions and 2 deletions
|
|
@ -43,7 +43,8 @@ module Admin
|
||||||
# Variable @show_attributes holds the attributes that are visible for the 'show' action
|
# Variable @show_attributes holds the attributes that are visible for the 'show' action
|
||||||
# If you want to change the attributes that are shown in the 'show' action of users
|
# If you want to change the attributes that are shown in the 'show' action of users
|
||||||
# add/remove the attributes in the following string array
|
# add/remove the attributes in the following string array
|
||||||
@show_attributes = %w(name email username nickname affiliation biography registered attended roles created_at
|
@show_attributes = %w(name email username nickname affiliation biography
|
||||||
|
profile_picture registered attended roles created_at
|
||||||
updated_at sign_in_count current_sign_in_at last_sign_in_at
|
updated_at sign_in_count current_sign_in_at last_sign_in_at
|
||||||
current_sign_in_ip last_sign_in_ip)
|
current_sign_in_ip last_sign_in_ip)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,6 @@ class User < ApplicationRecord
|
||||||
# Partials should *not* directly call `gravatar_url`
|
# Partials should *not* directly call `gravatar_url`
|
||||||
def profile_picture(opts = {})
|
def profile_picture(opts = {})
|
||||||
return gravatar_url(opts) unless picture.present?
|
return gravatar_url(opts) unless picture.present?
|
||||||
puts "ASKED FOR PROFILE PIC!! #{opts[:size]}"
|
|
||||||
size = (opts[:size] || 0).to_i
|
size = (opts[:size] || 0).to_i
|
||||||
if size < 50
|
if size < 50
|
||||||
picture.tiny.url
|
picture.tiny.url
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,18 @@
|
||||||
= f.input :username, :as => :string if @user.new_record?
|
= f.input :username, :as => :string if @user.new_record?
|
||||||
= f.input :email
|
= f.input :email
|
||||||
= f.input :password if @user.new_record?
|
= f.input :password if @user.new_record?
|
||||||
|
.control-label
|
||||||
|
Gravatar
|
||||||
|
= image_tag(@user.profile_picture(size: '48'), alt: '')
|
||||||
|
%p
|
||||||
|
Or upload a picture.
|
||||||
|
= f.input :picture, hint: 'If you upload a picture, it will be used in place of Gravatar.'
|
||||||
|
- if @user.picture?
|
||||||
|
%p
|
||||||
|
Current Picture
|
||||||
|
%br
|
||||||
|
= image_tag(@user.picture.url, width: '20%')
|
||||||
|
|
||||||
= f.input :affiliation, as: :string
|
= f.input :affiliation, as: :string
|
||||||
= f.input :biography, input_html: { rows: 10, data: { provide: 'markdown' } },
|
= f.input :biography, input_html: { rows: 10, data: { provide: 'markdown' } },
|
||||||
hint: markdown_hint
|
hint: markdown_hint
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@
|
||||||
- elsif attr == 'biography'
|
- elsif attr == 'biography'
|
||||||
%td
|
%td
|
||||||
= markdown(@user.biography)
|
= markdown(@user.biography)
|
||||||
|
- elsif attr == 'profile_picture'
|
||||||
|
%td
|
||||||
|
= image_tag @user.profile_picture(size: '100'), alt: ''
|
||||||
- elsif attr == 'email'
|
- elsif attr == 'email'
|
||||||
%td
|
%td
|
||||||
= @user.send(attr)
|
= @user.send(attr)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue