Create changeset subscription resource
This commit is contained in:
parent
7b19ba580c
commit
84a3a41531
17 changed files with 232 additions and 210 deletions
|
@ -7,9 +7,8 @@ class ChangesetsController < ApplicationController
|
|||
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action -> { check_database_readable(:need_api => true) }, :only => [:index, :feed, :show]
|
||||
before_action -> { check_database_readable(:need_api => true) }
|
||||
before_action :require_oauth, :only => :show
|
||||
before_action :check_database_writable, :only => [:subscribe, :unsubscribe]
|
||||
|
||||
authorize_resource
|
||||
|
||||
|
@ -107,34 +106,6 @@ class ChangesetsController < ApplicationController
|
|||
render :template => "browse/not_found", :status => :not_found, :layout => map_layout
|
||||
end
|
||||
|
||||
##
|
||||
# subscribe to a changeset
|
||||
def subscribe
|
||||
@changeset = Changeset.find(params[:id])
|
||||
|
||||
if request.post?
|
||||
@changeset.subscribe(current_user) unless @changeset.subscribed?(current_user)
|
||||
|
||||
redirect_to changeset_path(@changeset)
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "no_such_entry", :status => :not_found
|
||||
end
|
||||
|
||||
##
|
||||
# unsubscribe from a changeset
|
||||
def unsubscribe
|
||||
@changeset = Changeset.find(params[:id])
|
||||
|
||||
if request.post?
|
||||
@changeset.unsubscribe(current_user)
|
||||
|
||||
redirect_to changeset_path(@changeset)
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "no_such_entry", :status => :not_found
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
#------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue