2012-05-02 10:18:07 +01:00
|
|
|
class Projects::CommitSubscribesController < Projects::BaseController
|
2015-03-04 23:19:19 +00:00
|
|
|
before_action :authenticate_user!
|
|
|
|
before_action :find_commit
|
2012-01-23 19:42:54 +00:00
|
|
|
|
|
|
|
def create
|
2012-01-30 11:59:57 +00:00
|
|
|
if Subscribe.subscribe_to_commit(@options)
|
2012-01-24 19:00:51 +00:00
|
|
|
flash[:notice] = I18n.t("flash.subscribe.commit.saved")
|
2012-01-23 19:42:54 +00:00
|
|
|
# TODO js
|
|
|
|
redirect_to commit_path(@project, @commit)
|
|
|
|
else
|
|
|
|
flash[:error] = I18n.t("flash.subscribe.saved_error")
|
|
|
|
redirect_to commit_path(@project, @commit)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2012-01-30 11:59:57 +00:00
|
|
|
Subscribe.unsubscribe_from_commit(@options)
|
2012-01-24 19:00:51 +00:00
|
|
|
flash[:notice] = t("flash.subscribe.commit.destroyed")
|
2012-01-23 19:42:54 +00:00
|
|
|
redirect_to commit_path(@project, @commit)
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def find_commit
|
2012-07-17 09:02:56 +01:00
|
|
|
@commit = @project.repo.commit(params[:commit_id])
|
2014-01-21 04:51:49 +00:00
|
|
|
@options = {project_id: @project.id, subscribeable_id: @commit.id.hex, subscribeable_type: @commit.class.name, user_id: current_user.id}
|
2012-01-23 19:42:54 +00:00
|
|
|
end
|
|
|
|
end
|