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