2016-08-18 14:31:44 +00:00
|
|
|
class AvatarUploader < GitlabUploader
|
2017-02-15 18:11:44 +00:00
|
|
|
include RecordsUploads
|
2015-11-14 18:29:58 +00:00
|
|
|
include UploaderHelper
|
|
|
|
|
2015-02-20 14:19:50 +00:00
|
|
|
storage :file
|
|
|
|
|
|
|
|
def store_dir
|
2017-02-23 21:54:25 +00:00
|
|
|
"#{base_dir}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
2015-02-20 14:19:50 +00:00
|
|
|
end
|
|
|
|
|
2016-07-15 14:03:31 +00:00
|
|
|
def exists?
|
2017-09-19 14:34:10 +00:00
|
|
|
model.avatar.file && model.avatar.file.present?
|
2016-07-15 14:03:31 +00:00
|
|
|
end
|
2017-01-02 11:35:15 +00:00
|
|
|
|
|
|
|
# We set move_to_store and move_to_cache to 'false' to prevent stealing
|
|
|
|
# the avatar file from a project when forking it.
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab-ce/issues/26158
|
|
|
|
def move_to_store
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def move_to_cache
|
|
|
|
false
|
|
|
|
end
|
2015-02-20 14:19:50 +00:00
|
|
|
end
|