2013-02-06 03:16:51 +08:00
|
|
|
class DraftController < ApplicationController
|
2017-08-31 12:06:56 +08:00
|
|
|
before_action :ensure_logged_in
|
2015-05-20 15:12:16 +08:00
|
|
|
# TODO really do we need to skip this?
|
2017-08-31 12:06:56 +08:00
|
|
|
skip_before_action :check_xhr, :preload_json
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
def show
|
|
|
|
seq = params[:sequence] || DraftSequence.current(current_user, params[:draft_key])
|
2017-07-28 09:20:09 +08:00
|
|
|
render json: { draft: Draft.get(current_user, params[:draft_key], seq), draft_sequence: seq }
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2013-02-07 23:45:24 +08:00
|
|
|
Draft.set(current_user, params[:draft_key], params[:sequence].to_i, params[:data])
|
2013-09-11 14:18:46 +08:00
|
|
|
render json: success_json
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
Draft.clear(current_user, params[:draft_key], params[:sequence].to_i)
|
2013-09-11 14:18:46 +08:00
|
|
|
render json: success_json
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|