2014-01-25 17:15:44 +00:00
|
|
|
class Projects::AvatarsController < Projects::ApplicationController
|
2016-02-24 10:53:30 +00:00
|
|
|
include BlobHelper
|
|
|
|
|
2016-03-20 20:03:53 +00:00
|
|
|
before_action :authorize_admin_project!, only: [:destroy]
|
2014-01-25 17:15:44 +00:00
|
|
|
|
|
|
|
def show
|
2016-08-12 14:29:13 +00:00
|
|
|
@blob = @repository.blob_at_branch(@repository.root_ref, @project.avatar_in_git)
|
2014-01-25 17:15:44 +00:00
|
|
|
if @blob
|
|
|
|
headers['X-Content-Type-Options'] = 'nosniff'
|
2016-03-07 13:27:53 +00:00
|
|
|
|
|
|
|
return if cached_blob?
|
|
|
|
|
2016-06-06 11:16:30 +00:00
|
|
|
send_git_blob @repository, @blob
|
2014-01-25 17:15:44 +00:00
|
|
|
else
|
2015-10-09 17:07:29 +00:00
|
|
|
render_404
|
2014-01-25 17:15:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@project.remove_avatar!
|
|
|
|
|
|
|
|
@project.save
|
|
|
|
|
2017-06-06 22:45:16 +00:00
|
|
|
redirect_to edit_project_path(@project), status: 302
|
2014-01-25 17:15:44 +00:00
|
|
|
end
|
|
|
|
end
|