Show profile pictures to admins and allow them to upload pics

This commit is contained in:
Michael Ball 2020-07-15 23:37:40 -07:00
parent 10d58ef050
commit d5a9b79f6e
4 changed files with 17 additions and 2 deletions

View file

@ -43,7 +43,8 @@ module Admin
# 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
# 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
current_sign_in_ip last_sign_in_ip)
end

View file

@ -160,7 +160,6 @@ class User < ApplicationRecord
# Partials should *not* directly call `gravatar_url`
def profile_picture(opts = {})
return gravatar_url(opts) unless picture.present?
puts "ASKED FOR PROFILE PIC!! #{opts[:size]}"
size = (opts[:size] || 0).to_i
if size < 50
picture.tiny.url

View file

@ -19,6 +19,18 @@
= f.input :username, :as => :string if @user.new_record?
= f.input :email
= 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 :biography, input_html: { rows: 10, data: { provide: 'markdown' } },
hint: markdown_hint

View file

@ -26,6 +26,9 @@
- elsif attr == 'biography'
%td
= markdown(@user.biography)
- elsif attr == 'profile_picture'
%td
= image_tag @user.profile_picture(size: '100'), alt: ''
- elsif attr == 'email'
%td
= @user.send(attr)