]> git.openstreetmap.org Git - rails.git/blob - app/controllers/changeset_subscriptions_controller.rb
Create changeset subscription resource
[rails.git] / app / controllers / changeset_subscriptions_controller.rb
1 class ChangesetSubscriptionsController < ApplicationController
2   layout "site"
3
4   before_action :authorize_web
5   before_action :set_locale
6   before_action :check_database_writable
7
8   authorize_resource :class => :changeset_subscription
9
10   around_action :web_timeout
11
12   def show
13     @changeset = Changeset.find(params[:changeset_id])
14     @subscribed = @changeset.subscribed?(current_user)
15   rescue ActiveRecord::RecordNotFound
16     render :action => "no_such_entry", :status => :not_found
17   end
18
19   def create
20     @changeset = Changeset.find(params[:changeset_id])
21
22     @changeset.subscribe(current_user) unless @changeset.subscribed?(current_user)
23
24     redirect_to changeset_path(@changeset)
25   rescue ActiveRecord::RecordNotFound
26     render :action => "no_such_entry", :status => :not_found
27   end
28
29   def destroy
30     @changeset = Changeset.find(params[:changeset_id])
31
32     @changeset.unsubscribe(current_user)
33
34     redirect_to changeset_path(@changeset)
35   rescue ActiveRecord::RecordNotFound
36     render :action => "no_such_entry", :status => :not_found
37   end
38 end