diff --git a/app/controllers/internal/sponsorships_controller.rb b/app/controllers/internal/sponsorships_controller.rb new file mode 100644 index 000000000..11193f262 --- /dev/null +++ b/app/controllers/internal/sponsorships_controller.rb @@ -0,0 +1,38 @@ +class Internal::SponsorshipsController < Internal::ApplicationController + layout "internal" + + 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 internal_sponsorships_path + else + flash[:danger] = @sponsorship.errors.full_messages.join(", ") + 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 internal_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 diff --git a/app/views/internal/shared/_navbar.html.erb b/app/views/internal/shared/_navbar.html.erb index 6f9070228..07275e291 100644 --- a/app/views/internal/shared/_navbar.html.erb +++ b/app/views/internal/shared/_navbar.html.erb @@ -1,6 +1,5 @@ -<% menu_items = %w[comments articles users tags welcome broadcasts reports pages tools chat_channels permissions growth mods config events badges organizations].each_with_object({}) { |v, h| h[v] = v } %> +<% menu_items = %w[comments articles users tags welcome broadcasts reports pages tools chat_channels permissions growth mods config events badges organizations sponsorships podcasts].each_with_object({}) { |v, h| h[v] = v } %> <% menu_items[:listings] = "classified_listings" %> -<% menu_items[:podcasts] = "podcasts" %> <% menu_items[:webhooks] = "webhook_endpoints" %>