docbrown/app/controllers/admin/sponsorships_controller.rb
Josh Puetz 1c566e0ec4
[deploy] Move /internal to `/admin (#9639)
* First draft - all the big changes

* Changing some more references to 'internal'

* Relocate internal request tests to admin

* Relocate internal system tests to admin

* Fix trailing space

* Test fix

* Move queries from internal to admin

* Docs updates

* Rename internal stimuls controllers to admin (plus docs)

* Rename admin layout

* Fix routing after rebase

* Fixes for latest added admin interfaces

* Serviceworker ignore paths
2020-08-07 10:36:26 -04:00

41 lines
1.2 KiB
Ruby

module Admin
class SponsorshipsController < Admin::ApplicationController
layout "admin"
def index
@sponsorships = Sponsorship.includes(:organization, :user).order(created_at: :desc).page(params[:page]).per(50)
end
def edit
@sponsorship = Sponsorship.find(params[:id])
end
def update
@sponsorship = Sponsorship.find(params[:id])
if @sponsorship.update(sponsorship_params)
flash[:notice] = "Sponsorship was successfully updated"
redirect_to admin_sponsorships_path
else
flash[:danger] = @sponsorship.errors_as_sentence
render action: :edit
end
end
def destroy
@sponsorship = Sponsorship.find(params[:id])
if @sponsorship.destroy
flash[:notice] = "Sponsorship was successfully destroyed"
else
flash[:danger] = "Sponsorship was not destroyed"
end
redirect_to admin_sponsorships_path
end
private
def sponsorship_params
params.require(:sponsorship).permit(%i[status expires_at tagline url blurb_html featured_number instructions
instructions_updated_at])
end
end
end