Class: Pattana::CountriesController
- Inherits:
-
ResourceController
- Object
- Kuppayam::BaseController
- ApplicationController
- ResourceController
- Pattana::CountriesController
- Defined in:
- app/controllers/pattana/countries_controller.rb
Instance Method Summary collapse
- #cities ⇒ Object
- #hide_in_api ⇒ Object
- #mark_as_operational ⇒ Object
- #regions ⇒ Object
- #remove_operational ⇒ Object
- #show_in_api ⇒ Object
Instance Method Details
#cities ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/pattana/countries_controller.rb', line 19 def cities @country = Country.find_by_id(params[:id]) @relation = @country.cities.limit(50) parse_filters apply_filters @filter_ui_settings[:operational][:drop_down_options] = {remote: true} @filter_ui_settings[:operational][:url_method_name] = "cities_country_url" @filter_ui_settings[:show_in_api][:drop_down_options] = {remote: true} @filter_ui_settings[:show_in_api][:url_method_name] = "cities_country_url" @cities = @relation.page(@current_page).per(@per_page) end |
#hide_in_api ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/pattana/countries_controller.rb', line 50 def hide_in_api @country = @r_object = Country.find(params[:id]) if @country @country.show_in_api = false if @country.valid? @country.save set_notification(true, I18n.t('countries.hide_in_api.heading'), I18n.t('countries.hide_in_api.message')) else set_notification(false, I18n.t('status.error'), I18n.translate("error"), @country.errors..join("<br>")) end else set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize)) end render_row end |
#mark_as_operational ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/pattana/countries_controller.rb', line 66 def mark_as_operational @country = @r_object = Country.find(params[:id]) if @country @country.operational = true if @country.valid? @country.save set_notification(true, I18n.t('countries.marked_as_operational.heading'), I18n.t('countries.marked_as_operational.message')) else set_notification(false, I18n.t('status.error'), I18n.translate("error"), @country.errors..join("<br>")) end else set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize)) end render_row end |
#regions ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/pattana/countries_controller.rb', line 4 def regions @country = Country.find_by_id(params[:id]) @relation = @country.regions.limit(50) parse_filters apply_filters @filter_ui_settings[:operational][:drop_down_options] = {remote: true} @filter_ui_settings[:operational][:url_method_name] = "regions_country_url" @filter_ui_settings[:show_in_api][:drop_down_options] = {remote: true} @filter_ui_settings[:show_in_api][:url_method_name] = "regions_country_url" @regions = @relation.page(@current_page).per(@per_page) end |
#remove_operational ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/controllers/pattana/countries_controller.rb', line 82 def remove_operational @country = @r_object = Country.find(params[:id]) if @country @country.operational = false if @country.valid? @country.save set_notification(true, I18n.t('countries.removed_operational.heading'), I18n.t('countries.removed_operational.message')) else set_notification(false, I18n.t('status.error'), I18n.translate("error"), @country.errors..join("<br>")) end else set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize)) end render_row end |
#show_in_api ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/pattana/countries_controller.rb', line 34 def show_in_api @country = @r_object = Country.find(params[:id]) if @country @country.show_in_api = true if @country.valid? @country.save set_notification(true, I18n.t('countries.show_in_api.heading'), I18n.t('countries.show_in_api.message')) else set_notification(false, I18n.t('status.error'), I18n.translate("error"), @country.errors..join("<br>")) end else set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize)) end render_row end |