rosa-build/app/controllers/commit_subscribes_controlle...

33 lines
941 B
Ruby
Raw Normal View History

# -*- encoding : utf-8 -*-
2012-01-23 19:42:54 +00:00
class CommitSubscribesController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource :project
before_filter :find_commit
def create
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
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
@commit = @project.git_repository.commit(params[:commit_id])
2012-01-29 20:18:14 +00:00
@options = {:project_id => @project.id, :subscribeable_id => @commit.id, :subscribeable_type => @commit.class.name, :user_id => current_user.id}
2012-01-23 19:42:54 +00:00
end
end