Class: Stay::Admin::PropertiesController
Instance Method Summary
collapse
#load_stores, #set_currency, #set_current_store, #stores_scope
#current_store, #ensure_current_store, #store_locale
#currency_param, #current_currency, #supported_currencies, #supported_currencies_for_all_stores, #supported_currency?
#after_sign_in_path_for, #current_store
#all_locales_options, #available_locales, #available_locales_options, #config_locale?, #current_locale, #find_with_fallback_default_locale, #locale_full_name, #locale_param, #locale_presentation, #params_locale?, #should_render_locale_dropdown?, #supported_locale?, #supported_locales, #supported_locales_for_all_stores, #supported_locales_options, #user_locale?
#currency_options, #currency_presentation, #currency_symbol, #should_render_currency_dropdown?, #supported_currency_options
Instance Method Details
#approve ⇒ Object
59
60
61
62
63
|
# File 'app/controllers/stay/admin/properties_controller.rb', line 59
def approve
@property.approved
flash[:success] = "Your property has been approved!"
redirect_to edit_admin_property_path(@property)
end
|
#create ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'app/controllers/stay/admin/properties_controller.rb', line 21
def create
@property = current_store.properties.build(property_params)
if @property.save
redirect_to edit_admin_property_path(@property, step: determine_next_step(@step)), notice: "Property was successfully created."
else
render :new
end
end
|
#destroy ⇒ Object
54
55
56
57
|
# File 'app/controllers/stay/admin/properties_controller.rb', line 54
def destroy
@property.destroy
redirect_to admin_properties_url, notice: "Property was successfully destroyed."
end
|
#edit ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/stay/admin/properties_controller.rb', line 30
def edit
@step = params[:step] || "description"
if valid_step?(@step)
render :edit, locals: { step: @step, property: @property }
else
redirect_to admin_properties_path, alert: "Invalid step."
end
end
|
#index ⇒ Object
7
8
9
10
11
|
# File 'app/controllers/stay/admin/properties_controller.rb', line 7
def index
@q = current_store.properties.ransack(params[:q] || {})
per_page = (params[:per_page].presence || 30).to_i.clamp(1, 100)
@properties = @q.result.order(updated_at: :desc).page(params[:page]).per(per_page)
end
|
#new ⇒ Object
16
17
18
19
|
# File 'app/controllers/stay/admin/properties_controller.rb', line 16
def new
@property = current_store.properties.build
@step = "description"
end
|
#reject ⇒ Object
65
66
67
68
69
|
# File 'app/controllers/stay/admin/properties_controller.rb', line 65
def reject
@property.rejected
flash[:success] = "Your property has been rejected!"
redirect_to edit_admin_property_path(@property)
end
|
#show ⇒ Object
13
14
|
# File 'app/controllers/stay/admin/properties_controller.rb', line 13
def show
end
|
#update ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/controllers/stay/admin/properties_controller.rb', line 40
def update
@step = params[:step] || "description"
if @property.update(property_params)
next_step = determine_next_step(@step)
if @step == "calendar"
redirect_to admin_properties_path, notice: "Property was successfully updated and all steps are completed."
else
redirect_to edit_admin_property_path(@property, step: next_step), notice: "Property step '#{@step}' was successfully updated. Continue to the next step."
end
else
render :edit, locals: { step: @step, property: @property }
end
end
|