Remove resource_admin dashboards (Administrate) (#11792)

* First cleanup commit

* Email messages preview

* Tweak tests

* spec typo fix

* Remove lingering Administrate Fields & Abuse report link fix

* Add missing gemfile lock update

* Extract email_messages into its own controller & add test
This commit is contained in:
Fernando Valverde 2020-12-08 12:38:13 -06:00 committed by GitHub
parent 686b174012
commit 0ac3e83b0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 110 additions and 2313 deletions

View file

@ -3,7 +3,6 @@ unless ENV["COVERAGE"] == "false"
add_filter "/spec/"
add_filter "/dashboards/"
add_filter "/app/controllers/admin/"
add_filter "/app/controllers/resource_admin/"
add_filter "/app/black_box/"
add_filter "/app/fields/"
add_filter "/app/views/admin/"

View file

@ -14,7 +14,6 @@ gem "active_record_union", "~> 1.3" # Adds proper union and union_all methods to
gem "acts-as-taggable-on", "~> 6.5" # A tagging plugin for Rails applications that allows for custom tagging along dynamic contexts
gem "acts_as_follower", github: "thepracticaldev/acts_as_follower", branch: "master" # Allow any model to follow any other model
gem "addressable", "~> 2.7" # A replacement for the URI implementation that is part of Ruby's standard library
gem "administrate", "~> 0.14" # A Rails engine that helps you put together a super-flexible admin dashboard
gem "ahoy_email", "~> 1.1" # Email analytics for Rails
gem "ahoy_matey", "~> 3.1" # Tracking analytics for Rails
gem "ancestry", "~> 3.2" # Ancestry allows the records of a ActiveRecord model to be organized in a tree structure

View file

@ -70,17 +70,6 @@ GEM
activerecord (>= 5.0, < 6.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
administrate (0.14.0)
actionpack (>= 4.2)
actionview (>= 4.2)
activerecord (>= 4.2)
autoprefixer-rails (>= 6.0)
datetime_picker_rails (~> 0.0.7)
jquery-rails (>= 4.0)
kaminari (>= 1.0)
momentjs-rails (~> 2.8)
sassc-rails (~> 2.1)
selectize-rails (~> 0.6)
ahoy_email (1.1.0)
actionmailer (>= 5)
addressable (>= 2.3.2)
@ -98,8 +87,6 @@ GEM
nokogiri (~> 1.6)
thor (~> 0.18)
ast (2.4.1)
autoprefixer-rails (9.8.6.2)
execjs
aws-eventstream (1.1.0)
aws-sigv4 (1.2.2)
aws-eventstream (~> 1, >= 1.0.2)
@ -202,8 +189,6 @@ GEM
database_cleaner-active_record (1.8.0)
activerecord
database_cleaner (~> 1.8.0)
datetime_picker_rails (0.0.7)
momentjs-rails (>= 2.8.1)
ddtrace (0.43.0)
msgpack
debug_inspector (0.0.3)
@ -462,8 +447,6 @@ GEM
mini_racer (0.3.1)
libv8 (~> 8.4.255)
minitest (5.14.2)
momentjs-rails (2.20.1)
railties (>= 3.1)
msgpack (1.3.3)
multi_json (1.15.0)
multi_xml (0.6.0)
@ -701,7 +684,6 @@ GEM
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
sax-machine (1.3.2)
selectize-rails (0.12.6)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
@ -838,7 +820,6 @@ DEPENDENCIES
acts-as-taggable-on (~> 6.5)
acts_as_follower!
addressable (~> 2.7)
administrate (~> 0.14)
ahoy_email (~> 1.1)
ahoy_matey (~> 3.1)
amazing_print (~> 1.2)

View file

@ -3,6 +3,4 @@
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
//= link s3_direct_upload.js
//= link administrate/application.css
//= link administrate/application.js
//= link katex.css

View file

@ -0,0 +1,10 @@
module Admin
class EmailMessagesController < Admin::ApplicationController
layout "admin"
def show
@user = User.find(params[:user_id])
@email = EmailMessage.find(params[:id])
end
end
end

View file

@ -1,30 +0,0 @@
# All Administrate controllers inherit from this `Admin::ApplicationController`,
# making it the ideal place to put authentication logic or other
# before_filters.
#
# If you want to add pagination or other controller-level concerns,
# you're free to overwrite the RESTful controller actions.
module ResourceAdmin
class ApplicationController < Administrate::ApplicationController
include Pundit
before_action :authorize_admin
def order
@order ||= Administrate::Order.new(params[:order] || "id", params[:direction] || "desc")
end
def valid_request_origin?
# Temp monkey patch. Since we use https at the edge via fastly I think our protocol expectations
# are out of wack.
raise InvalidAuthenticityToken, NULL_ORIGIN_MESSAGE if request.origin == "null"
request.origin.nil? || request.origin.gsub("https", "http") == request.base_url.gsub("https", "http")
end
private
def authorize_admin
authorize :admin, :show?
end
end
end

View file

@ -1,44 +0,0 @@
module ResourceAdmin
class ArticlesController < ResourceAdmin::ApplicationController
def create
resource = resource_class.new(resource_params)
authorize_resource(resource)
user = User.find(resource_params[:user_id])
resource = Articles::Creator.call(user, resource_params)
if resource.persisted?
redirect_to(
[namespace, resource],
notice: translate_with_resource("create.success"),
)
else
render :new, locals: {
page: Administrate::Page::Form.new(dashboard, resource)
}
end
end
def update
if requested_resource.update(resource_params)
Webhook::DispatchEvent.call("article_updated", requested_resource)
redirect_to(
[namespace, requested_resource],
notice: translate_with_resource("update.success"),
)
else
render :edit, locals: {
page: Administrate::Page::Form.new(dashboard, requested_resource)
}
end
end
def destroy
Articles::Destroyer.call(requested_resource)
if requested_resource.destroyed?
flash[:notice] = translate_with_resource("destroy.success")
else
flash[:error] = requested_resource.errors.full_messages.join("<br/>")
end
redirect_to action: :index
end
end
end

View file

@ -1,21 +0,0 @@
module ResourceAdmin
class BadgeAchievementsController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# you can overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = BadgeAchievement.
# page(params[:page]).
# per(10)
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# BadgeAchievement.find_by!(slug: param)
# end
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,21 +0,0 @@
module ResourceAdmin
class BadgesController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# you can overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = Badge.
# page(params[:page]).
# per(10)
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# Badge.find_by!(slug: param)
# end
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,19 +0,0 @@
module ResourceAdmin
class CollectionsController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# simply overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = Collection.all.paginate(10, params[:page])
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# Collection.find_by!(slug: param)
# end
# See https://administrate-docs.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,21 +0,0 @@
module ResourceAdmin
class CommentsController < ResourceAdmin::ApplicationController
def update
comment = Comment.find(params[:id])
if comment.update(comment_params)
flash[:notice] = "Comment successfully updated"
redirect_to "/resource_admin/comments/#{comment.id}"
else
flash.now[:error] = comment.errors.full_messages
render :new, locals: { page: Administrate::Page::Form.new(dashboard, comment) }
end
end
private
def comment_params
accessible = %i[user_id body_markdown deleted score]
params.require(:comment).permit(accessible)
end
end
end

View file

@ -1,21 +0,0 @@
module ResourceAdmin
class DisplayAdsController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# you can overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = DisplayAd.
# page(params[:page]).
# per(10)
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# DisplayAd.find_by!(slug: param)
# end
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,21 +0,0 @@
module ResourceAdmin
class EmailMessagesController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# simply overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = Ahoy::Message.
# page(params[:page]).
# per(8)
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# Ahoy::Message.find_by!(slug: param)
# end
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,21 +0,0 @@
module ResourceAdmin
class FeedbackMessagesController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# you can overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = FeedbackMessage.
# page(params[:page]).
# per(10)
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# FeedbackMessage.find_by!(slug: param)
# end
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,19 +0,0 @@
module ResourceAdmin
class FollowsController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# simply overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = Follow.all.paginate(10, params[:page])
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# Follow.find_by!(slug: param)
# end
# See https://administrate-docs.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,34 +0,0 @@
module ResourceAdmin
class HtmlVariantSuccessesController < ResourceAdmin::ApplicationController
# Overwrite any of the RESTful controller actions to implement custom behavior
# For example, you may want to send an email after a foo is updated.
#
# def update
# foo = Foo.find(params[:id])
# foo.update(params[:foo])
# send_foo_updated_email
# end
# Override this method to specify custom lookup behavior.
# This will be used to set the resource for the `show`, `edit`, and `update`
# actions.
#
# def find_resource(param)
# Foo.find_by!(slug: param)
# end
# Override this if you have certain roles that require a subset
# this will be used to set the records shown on the `index` action.
#
# def scoped_resource
# if current_user.super_admin?
# resource_class
# else
# resource_class.with_less_stuff
# end
# end
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,34 +0,0 @@
module ResourceAdmin
class HtmlVariantTrialsController < ResourceAdmin::ApplicationController
# Overwrite any of the RESTful controller actions to implement custom behavior
# For example, you may want to send an email after a foo is updated.
#
# def update
# foo = Foo.find(params[:id])
# foo.update(params[:foo])
# send_foo_updated_email
# end
# Override this method to specify custom lookup behavior.
# This will be used to set the resource for the `show`, `edit`, and `update`
# actions.
#
# def find_resource(param)
# Foo.find_by!(slug: param)
# end
# Override this if you have certain roles that require a subset
# this will be used to set the records shown on the `index` action.
#
# def scoped_resource
# if current_user.super_admin?
# resource_class
# else
# resource_class.with_less_stuff
# end
# end
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,21 +0,0 @@
module ResourceAdmin
class HtmlVariantsController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# you can overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = HtmlVariant.
# page(params[:page]).
# per(10)
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# HtmlVariant.find_by!(slug: param)
# end
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,46 +0,0 @@
module ResourceAdmin
class ListingCategoriesController < ResourceAdmin::ApplicationController
# Overwrite any of the RESTful controller actions to implement custom behavior
# For example, you may want to send an email after a foo is updated.
#
# def update
# super
# send_foo_updated_email(requested_resource)
# end
# Override this method to specify custom lookup behavior.
# This will be used to set the resource for the `show`, `edit`, and `update`
# actions.
#
# def find_resource(param)
# Foo.find_by!(slug: param)
# end
# The result of this lookup will be available as `requested_resource`
# Override this if you have certain roles that require a subset
# this will be used to set the records shown on the `index` action.
#
# def scoped_resource
# if current_user.super_admin?
# resource_class
# else
# resource_class.with_less_stuff
# end
# end
# Override `resource_params` if you want to transform the submitted
# data before it's persisted. For example, the following would turn all
# empty values into nil values. It uses other APIs such as `resource_class`
# and `dashboard`:
#
# def resource_params
# params.require(resource_class.model_name.param_key).
# permit(dashboard.permitted_attributes).
# transform_values { |value| value == "" ? nil : value }
# end
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,24 +0,0 @@
module ResourceAdmin
class OrganizationsController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# simply overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = Organization.all.paginate(10, params[:page])
# end
def update
super
@requested_resource.touch(:profile_updated_at)
end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# Organization.find_by!(slug: param)
# end
# See https://administrate-docs.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,19 +0,0 @@
module ResourceAdmin
class PodcastEpisodesController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# simply overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = PodcastEpisode.all.paginate(10, params[:page])
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# PodcastEpisode.find_by!(slug: param)
# end
# See https://administrate-docs.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,20 +0,0 @@
module ResourceAdmin
class PodcastsController < ResourceAdmin::ApplicationController
def create
resource = resource_class.new(resource_params)
authorize_resource(resource)
if resource.save
Podcasts::GetEpisodesWorker.perform_async(podcast_id: resource.id) if resource.published
redirect_to(
[namespace, resource],
notice: translate_with_resource("create.success"),
)
else
render :new, locals: {
page: Administrate::Page::Form.new(dashboard, resource)
}
end
end
end
end

View file

@ -1,19 +0,0 @@
module ResourceAdmin
class ReactionsController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# simply overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = Reaction.all.paginate(10, params[:page])
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# Reaction.find_by!(slug: param)
# end
# See https://administrate-docs.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,21 +0,0 @@
module ResourceAdmin
class SponsorshipsController < ResourceAdmin::ApplicationController
# To customize the behavior of this controller,
# you can overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = Sponsorship.
# page(params[:page]).
# per(10)
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# Sponsorship.find_by!(slug: param)
# end
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
# for more information
end
end

View file

@ -1,43 +0,0 @@
module ResourceAdmin
class TagsController < ResourceAdmin::ApplicationController
def update
@tag = Tag.find(params[:id])
if @tag.update(tag_params) && @tag.errors.messages.blank?
flash[:notice] = "Tag successfully updated"
redirect_to "/resource_admin/tags/#{@tag.id}"
else
render :new, locals: { page: Administrate::Page::Form.new(dashboard, @tag) }
end
end
private
def convert_empty_string_to_nil
# nil plays nicely with our hex colors, whereas empty string doesn't
params[:tag][:text_color_hex] = nil if params[:tag][:text_color_hex] == ""
params[:tag][:bg_color_hex] = nil if params[:tag][:bg_color_hex] == ""
end
def tag_params
accessible = %i[
name
category
badge_id
supported
alias_for
wiki_body_markdown
rules_markdown
short_summary
requires_approval
submission_template
pretty_name
bg_color_hex
text_color_hex
keywords_for_search
buffer_profile_id_code
]
convert_empty_string_to_nil
params.require(:tag).permit(accessible)
end
end
end

View file

@ -1,87 +0,0 @@
module ResourceAdmin
class UsersController < ResourceAdmin::ApplicationController
def update
user = User.find(params[:id])
# Email normally needs confirmation. We skip it here when acting as admin
user.update_column(:email, user_params[:email]) if user_params[:email].present?
if user.errors.messages.blank? && user.update(user_params)
flash[:notice] = "User successfully updated"
redirect_to "/resource_admin/users/#{params[:id]}"
else
render :new, locals: { page: Administrate::Page::Form.new(dashboard, user) }
end
end
private
def user_params
verify_usernames params.require(:user).permit(allowed_params)
end
# make sure usernames are not empty, to be able to use the database unique index
def verify_usernames(user_params)
user_params[:twitter_username] = nil if user_params[:twitter_username] == ""
user_params[:github_username] = nil if user_params[:github_username] == ""
user_params
end
def allowed_params
core_params | url_params | other_params
end
def core_params
%i[
name
email
username
twitter_username
github_username
profile_image
employment_title
currently_learning
available_for
mostly_work_with
currently_hacking_on
location
email_public
education
]
end
def url_params
%i[
facebook_url
youtube_url
behance_url
dribbble_url
medium_url
gitlab_url
linkedin_url
twitch_url
instagram_url
website_url
employer_url
feed_url
]
end
def other_params
%i[
email_newsletter
email_comment_notifications
email_follower_notifications
summary
organization_id
org_admin
bg_color_hex
text_color_hex
employer_name
reputation_modifier
saw_onboarding
scholar_email
registered
registered_at
]
end
end
end

View file

@ -253,7 +253,7 @@ class StoriesController < ApplicationController
def redirect_if_view_param
redirect_to "/admin/users/#{@user.id}" if params[:view] == "moderate"
redirect_to "/resource_admin/users/#{@user.id}/edit" if params[:view] == "admin"
redirect_to "/admin/users/#{@user.id}/edit" if params[:view] == "admin"
end
def redirect_if_show_view_param

View file

@ -31,7 +31,7 @@ class TagsController < ApplicationController
def admin
tag = Tag.find_by!(name: params[:tag])
authorize tag
redirect_to "/resource_admin/tags/#{tag.id}/edit"
redirect_to "/admin/tags/#{tag.id}/edit"
end
def onboarding

View file

@ -1,96 +0,0 @@
require "administrate/base_dashboard"
class ArticleDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
user: Field::BelongsTo,
user_id: UserIdField,
co_author_ids: Field::Select.with_options(collection: []),
organization: Field::BelongsTo,
id: Field::Number,
title: Field::String,
search_optimized_title_preamble: Field::String,
search_optimized_description_replacement: Field::String,
body_html: Field::Text,
body_markdown: Field::Text,
slug: Field::String,
canonical_url: Field::String,
created_at: Field::DateTime,
updated_at: Field::DateTime,
main_image: Field::String,
description: Field::String,
published: Field::Boolean,
featured: Field::Boolean,
approved: Field::Boolean,
featured_number: Field::Number,
password: Field::String,
published_at: Field::DateTime,
social_image: Field::String,
collection: Field::BelongsTo,
show_comments: Field::Boolean,
main_image_background_hex_color: Field::String,
comments: Field::HasMany,
video: Field::String,
video_code: Field::String,
video_source_url: Field::String,
video_thumbnail_url: Field::String,
video_closed_caption_track_url: Field::String
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
user
title
published
featured
comments
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
user_id
organization
title
search_optimized_title_preamble
search_optimized_description_replacement
body_markdown
slug
social_image
featured
approved
featured_number
canonical_url
password
published_at
collection
show_comments
main_image_background_hex_color
video
video_code
video_source_url
video_thumbnail_url
video_closed_caption_track_url
].freeze
# Overwrite this method to customize how articles are displayed
# across all pages of the admin dashboard.
#
def display_resource(article)
"Article ##{article.id} - #{article.title}"
end
end

View file

@ -1,63 +0,0 @@
require "administrate/base_dashboard"
class BadgeAchievementDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
user: Field::BelongsTo,
user_id: UserIdField,
badge: Field::BelongsTo,
rewarder: Field::BelongsTo.with_options(class_name: "User"),
rewarding_context_message_markdown: Field::String,
rewarding_context_message: Field::String,
id: Field::Number,
rewarder_id: UserIdField,
created_at: Field::DateTime,
updated_at: Field::DateTime
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
user
badge
rewarder
id
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
id
user
badge
rewarding_context_message
rewarder
created_at
updated_at
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
user_id
rewarding_context_message_markdown
badge
rewarder_id
].freeze
# Overwrite this method to customize how badge achievements are displayed
# across all pages of the admin dashboard.
#
# def display_resource(badge_achievement)
# "BadgeAchievement ##{badge_achievement.id}"
# end
end

View file

@ -1,63 +0,0 @@
require "administrate/base_dashboard"
class BadgeDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
users: Field::HasMany,
id: Field::Number,
title: Field::String,
slug: Field::String,
description: Field::String,
badge_image: CarrierwaveField,
created_at: Field::DateTime,
updated_at: Field::DateTime
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
badge_image
id
title
slug
description
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
users
id
title
slug
description
badge_image
created_at
updated_at
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
title
slug
description
badge_image
].freeze
# Overwrite this method to customize how badges are displayed
# across all pages of the admin dashboard.
#
def display_resource(badge)
"Badge - #{badge.title}"
end
end

View file

@ -1,75 +0,0 @@
require "administrate/base_dashboard"
class CollectionDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
articles: Field::HasMany,
user: Field::BelongsTo,
organization: Field::BelongsTo,
id: Field::Number,
title: Field::String,
slug: Field::String,
description: Field::String,
main_image: Field::String,
social_image: Field::String,
published: Field::Boolean,
created_at: Field::DateTime,
updated_at: Field::DateTime
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
articles
user
organization
id
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
articles
user
organization
id
title
slug
description
main_image
social_image
published
created_at
updated_at
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
articles
user
organization
title
slug
description
main_image
social_image
published
].freeze
# Overwrite this method to customize how collections are displayed
# across all pages of the admin dashboard.
#
# def display_resource(collection)
# "Collection ##{collection.id}"
# end
end

View file

@ -1,72 +0,0 @@
require "administrate/base_dashboard"
class CommentDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
commentable: Field::Polymorphic,
user: Field::BelongsTo,
user_id: UserIdField,
reactions: Field::HasMany,
id: Field::Number,
body_markdown: Field::Text.with_options(searchable: true),
body_html: Field::Text,
edited: Field::Boolean,
created_at: Field::DateTime,
updated_at: Field::DateTime,
ancestry: Field::String,
id_code: Field::String,
score: Field::Number,
deleted: Field::Boolean
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
id
user
body_markdown
reactions
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
commentable
user
reactions
id
body_markdown
edited
created_at
updated_at
ancestry
id_code
score
deleted
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
user_id
body_markdown
score
deleted
].freeze
# Overwrite this method to customize how comments are displayed
# across all pages of the admin dashboard.
#
def display_resource(comment)
"Comment ##{comment.id} - #{comment.title}"
end
end

View file

@ -1,42 +0,0 @@
# DashboardManifest tells Administrate which dashboards to display
class DashboardManifest
# `DASHBOARDS`
# a list of dashboards to display in the side navigation menu
#
# These are all of the rails models that we found in your database
# at the time you installed Administrate.
#
# To show or hide dashboards, add or remove the model name from this list.
# Dashboards returned from this method must be Rails models for Administrate
# to work correctly.
DASHBOARDS = %i[
articles
users
organizations
comments
follows
reactions
podcasts
podcast_episodes
collections
tags
email_messages
feedback_messages
badges
badge_achievements
sponsorships
listing_categories
].freeze
# DASHBOARDS = [
# :users,
# :articles,
# :podcast_episodes,
# ]
# `ROOT_DASHBOARD`
# the name of the dashboard that will be displayed
# at "http://your_site.com/admin"
#
# This dashboard will likely be the first page that admins see
# when they log into the dashboard.
ROOT_DASHBOARD = DASHBOARDS.first
end

View file

@ -1,74 +0,0 @@
require "administrate/base_dashboard"
class DisplayAdDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
organization: Field::BelongsTo,
id: Field::Number,
placement_area: Field::String,
body_markdown: Field::Text,
processed_html: Field::Text,
impressions_count: Field::Number,
clicks_count: Field::Number,
success_rate: Field::Number,
published: Field::Boolean,
approved: Field::Boolean,
created_at: Field::DateTime,
updated_at: Field::DateTime
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
organization
id
placement_area
body_markdown
published
approved
success_rate
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
organization
id
placement_area
body_markdown
processed_html
impressions_count
clicks_count
success_rate
published
approved
created_at
updated_at
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
organization
placement_area
body_markdown
published
approved
].freeze
# Overwrite this method to customize how display ads are displayed
# across all pages of the admin dashboard.
#
# def display_resource(display_ad)
# "DisplayAd ##{display_ad.id}"
# end
end

View file

@ -1,73 +0,0 @@
require "administrate/base_dashboard"
class EmailMessageDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
user: Field::Polymorphic,
id: Field::Number,
token: Field::String,
to: Field::Text,
mailer: Field::String,
subject: Field::Text,
content: Field::Text,
utm_source: Field::String,
utm_medium: Field::String,
utm_term: Field::String,
utm_content: Field::String,
utm_campaign: Field::String,
sent_at: Field::DateTime,
opened_at: Field::DateTime,
clicked_at: Field::DateTime
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
user
id
subject
opened_at
clicked_at
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
user
id
token
to
mailer
subject
content
utm_source
utm_medium
utm_term
utm_content
utm_campaign
sent_at
opened_at
clicked_at
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [].freeze
# Overwrite this method to customize how messages are displayed
# across all pages of the admin dashboard.
#
# def display_resource(message)
# "Ahoy::Message ##{message.id}"
# end
# Mac is cool.
end

View file

@ -1,56 +0,0 @@
require "administrate/base_dashboard"
class FeedbackMessageDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
user: Field::BelongsTo,
id: Field::Number,
message: Field::Text,
feedback_type: Field::String,
category: Field::String
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
user
id
message
feedback_type
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
user
id
message
feedback_type
category
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
user
message
feedback_type
category
].freeze
# Overwrite this method to customize how feedback messages are displayed
# across all pages of the admin dashboard.
#
# def display_resource(feedback_message)
# "FeedbackMessage ##{feedback_message.id}"
# end
end

View file

@ -1,60 +0,0 @@
require "administrate/base_dashboard"
class FollowDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
followable: Field::Polymorphic,
follower: Field::Polymorphic,
followable_type: Field::String,
followable_id: Field::Number,
id: Field::Number,
blocked: Field::Boolean,
created_at: Field::DateTime,
updated_at: Field::DateTime
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
created_at
followable_type
follower
blocked
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
followable_type
followable_id
follower
id
blocked
created_at
updated_at
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
followable_id
follower
blocked
].freeze
# Overwrite this method to customize how follows are displayed
# across all pages of the admin dashboard.
#
# def display_resource(follow)
# "Follow ##{follow.id}"
# end
end

View file

@ -1,81 +0,0 @@
require "administrate/base_dashboard"
class ListingCategoryDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
listings: Field::HasMany,
id: Field::Number,
cost: Field::Number,
created_at: Field::DateTime,
name: Field::String,
rules: Field::String,
slug: Field::String,
social_preview_description: Field::String,
social_preview_color: Field::String,
updated_at: Field::DateTime
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
name
slug
rules
cost
social_preview_description
social_preview_color
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
id
name
slug
rules
cost
social_preview_description
social_preview_color
created_at
updated_at
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
name
slug
rules
cost
social_preview_description
social_preview_color
].freeze
# COLLECTION_FILTERS
# a hash that defines filters that can be used while searching via the search
# field of the dashboard.
#
# For example to add an option to search for open resources by typing "open:"
# in the search field:
#
# COLLECTION_FILTERS = {
# open: ->(resources) { resources.where(open: true) }
# }.freeze
COLLECTION_FILTERS = {}.freeze
# Overwrite this method to customize how listing categories are displayed
# across all pages of the admin dashboard.
#
# def display_resource(listing_category)
# "ListingCategory ##{listing_category.id}"
# end
end

View file

@ -1,72 +0,0 @@
require "administrate/base_dashboard"
class OrganizationDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
id: Field::Number,
name: Field::String,
slug: Field::String,
summary: Field::Text,
tag_line: Field::String,
profile_image: CarrierwaveField,
nav_image: CarrierwaveField,
dark_nav_image: CarrierwaveField,
url: Field::String,
twitter_username: Field::String,
github_username: Field::String,
bg_color_hex: Field::String,
text_color_hex: Field::String,
created_at: Field::DateTime,
updated_at: Field::DateTime,
users: Field::HasMany,
cta_button_text: Field::String,
cta_button_url: Field::String,
cta_body_markdown: Field::Text
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
profile_image
name
url
twitter_username
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
name
slug
summary
tag_line
profile_image
nav_image
dark_nav_image
url
bg_color_hex
text_color_hex
twitter_username
github_username
cta_button_text
cta_button_url
cta_body_markdown
].freeze
def display_resource(organization)
organization.name
end
end

View file

@ -1,102 +0,0 @@
require "administrate/base_dashboard"
class PodcastDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
podcast_episodes: Field::HasMany,
id: Field::Number,
title: Field::String,
description: Field::Text,
feed_url: Field::String,
itunes_url: Field::String,
overcast_url: Field::String,
android_url: Field::String,
soundcloud_url: Field::String,
website_url: Field::String,
main_color_hex: Field::String,
twitter_username: Field::String,
image: CarrierwaveField,
pattern_image: CarrierwaveField,
slug: Field::String,
reachable: Field::Boolean,
published: Field::Boolean,
status_notice: Field::Text,
created_at: Field::DateTime,
updated_at: Field::DateTime
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
podcast_episodes
id
reachable
published
status_notice
title
description
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
podcast_episodes
id
title
description
feed_url
itunes_url
overcast_url
android_url
soundcloud_url
website_url
status_notice
twitter_username
main_color_hex
image
pattern_image
slug
reachable
published
created_at
updated_at
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
podcast_episodes
title
description
status_notice
feed_url
itunes_url
overcast_url
android_url
soundcloud_url
website_url
twitter_username
pattern_image
main_color_hex
image
slug
reachable
published
].freeze
# Overwrite this method to customize how podcasts are displayed
# across all pages of the admin dashboard.
#
# def display_resource(podcast)
# "Podcast ##{podcast.id}"
# end
end

View file

@ -1,87 +0,0 @@
require "administrate/base_dashboard"
class PodcastEpisodeDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
id: Field::Number,
title: Field::String,
subtitle: Field::String,
summary: Field::Text,
body: Field::Text,
quote: Field::Text,
processed_html: Field::Text,
comments_count: Field::Number,
reactions_count: Field::Number,
media_url: Field::String,
website_url: Field::String,
itunes_url: Field::String,
image: CarrierwaveField,
podcast: Field::BelongsTo,
published_at: Field::DateTime,
slug: Field::String,
guid: Field::String,
reachable: Field::Boolean,
https: Field::Boolean,
created_at: Field::DateTime,
updated_at: Field::DateTime,
social_image: CarrierwaveField
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
id
title
media_url
reachable
https
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
id
podcast
title
image
social_image
body
media_url
website_url
itunes_url
published_at
slug
reachable
https
created_at
updated_at
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
title
body
website_url
media_url
itunes_url
social_image
published_at
].freeze
# Overwrite this method to customize how podcast episodes are displayed
# across all pages of the admin dashboard.
#
# def display_resource(podcast_episode)
# "PodcastEpisode ##{podcast_episode.id}"
# end
end

View file

@ -1,62 +0,0 @@
require "administrate/base_dashboard"
class ReactionDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
reactable: Field::Polymorphic,
user: Field::BelongsTo,
user_id: UserIdField,
id: Field::Number,
category: Field::String,
points: Field::Number.with_options(decimals: 2),
created_at: Field::DateTime,
updated_at: Field::DateTime
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
reactable
user
id
category
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
reactable
user
user_id
id
category
points
created_at
updated_at
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
reactable
user_id
category
points
].freeze
# Overwrite this method to customize how reactions are displayed
# across all pages of the admin dashboard.
#
def display_resource(reaction)
"#{reaction.category} on #{reaction.reactable_type} ##{reaction.reactable_id}"
end
end

View file

@ -1,89 +0,0 @@
require "administrate/base_dashboard"
class SponsorshipDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
user: Field::BelongsTo,
user_id: UserIdField,
organization: Field::BelongsTo,
organization_id: Field::Number,
id: Field::Number,
level: Field::String,
status: Field::String,
expires_at: Field::DateTime,
blurb_html: Field::Text,
featured_number: Field::Number,
instructions: Field::Text,
instructions_updated_at: Field::DateTime,
tagline: Field::String,
url: Field::String,
sponsorable_id: Field::Number,
sponsorable_type: Field::String,
created_at: Field::DateTime,
updated_at: Field::DateTime
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
user
organization
id
level
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
user
organization
id
level
status
expires_at
blurb_html
featured_number
instructions
instructions_updated_at
tagline
url
sponsorable_id
sponsorable_type
created_at
updated_at
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
user_id
organization_id
level
status
expires_at
blurb_html
featured_number
instructions
instructions_updated_at
tagline
url
sponsorable_id
sponsorable_type
].freeze
# Overwrite this method to customize how sponsorships are displayed
# across all pages of the admin dashboard.
#
# def display_resource(sponsorship)
# "Sponsorship ##{sponsorship.id}"
# end
end

View file

@ -1,91 +0,0 @@
require "administrate/base_dashboard"
class TagDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
id: Field::Number,
name: Field::String,
supported: Field::Boolean,
wiki_body_markdown: Field::Text,
wiki_body_html: Field::Text,
rules_markdown: Field::Text,
rules_html: Field::Text,
short_summary: Field::String,
requires_approval: Field::Boolean,
submission_template: Field::Text,
pretty_name: Field::String,
profile_image: CarrierwaveField,
social_image: CarrierwaveField,
bg_color_hex: Field::String,
text_color_hex: Field::String,
keywords_for_search: Field::String,
taggings_count: Field::Number,
buffer_profile_id_code: Field::String
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to five items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
id
name
supported
taggings_count
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
id
name
supported
wiki_body_markdown
wiki_body_html
rules_markdown
rules_html
short_summary
requires_approval
submission_template
pretty_name
profile_image
social_image
bg_color_hex
text_color_hex
keywords_for_search
buffer_profile_id_code
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
name
supported
wiki_body_markdown
rules_markdown
short_summary
requires_approval
submission_template
pretty_name
profile_image
social_image
bg_color_hex
text_color_hex
keywords_for_search
buffer_profile_id_code
].freeze
# Overwrite this method to customize how tags are displayed
# across all pages of the admin dashboard.
#
# def display_resource(tag)
# "Tag ##{tag.id}"
# end
end

View file

@ -1,104 +0,0 @@
require "administrate/base_dashboard"
class UserDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
id: Field::Number,
name: Field::String,
profile_image: CarrierwaveField,
username: Field::String,
twitter_username: Field::String,
github_username: Field::String,
summary: Field::String,
email: Field::String,
website_url: Field::String,
created_at: Field::DateTime,
updated_at: Field::DateTime,
registered: Field::Boolean,
registered_at: Field::DateTime,
articles: Field::HasMany,
comments: Field::HasMany,
reputation_modifier: Field::Number,
signup_cta_variant: Field::String,
onboarding_package_requested: Field::Boolean,
twitter_followers_count: Field::Number,
bg_color_hex: Field::String,
text_color_hex: Field::String,
feed_url: Field::String,
facebook_url: Field::String,
youtube_url: Field::String,
behance_url: Field::String,
dribbble_url: Field::String,
medium_url: Field::String,
gitlab_url: Field::String,
instagram_url: Field::String,
linkedin_url: Field::String,
twitch_url: Field::String,
feed_admin_publish_permission: Field::Boolean,
feed_mark_canonical: Field::Boolean,
saw_onboarding: Field::Boolean,
following_tags_count: Field::Number,
monthly_dues: Field::Number,
stripe_id_code: Field::String
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
profile_image
id
username
twitter_username
github_username
name
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
name
username
email
registered
registered_at
twitter_username
github_username
profile_image
summary
website_url
facebook_url
youtube_url
behance_url
dribbble_url
medium_url
gitlab_url
instagram_url
linkedin_url
twitch_url
bg_color_hex
text_color_hex
reputation_modifier
feed_url
saw_onboarding
].freeze
# Overwrite this method to customize how users are displayed
# across all pages of the admin dashboard.
#
def display_resource(user)
"ID: ##{user.id} - #{user.username}"
end
end

View file

@ -1,9 +0,0 @@
require "administrate/field/base"
class CarrierwaveField < Administrate::Field::Base
delegate :url, to: :data
def to_s
data
end
end

View file

@ -1,15 +0,0 @@
require "administrate/field/base"
class UserIdField < Administrate::Field::Base
def find_user_id
data
end
def render_label
if attribute == :rewarder_id
"Rewarder ID"
else
"User ID"
end
end
end

View file

@ -0,0 +1,50 @@
<div class="grid gap-6">
<div class="crayons-card p-6">
<h2>Email message</h2>
<table class="crayons-table mt-5" width="100%">
<tbody>
<tr>
<td>Subject</td>
<td><%= @email.subject %></td>
</tr>
<tr>
<td>To</td>
<td><%= @email.to %></td>
</tr>
<tr>
<td>Abuse Report (Feedback Message)</td>
<% if @email.feedback_message_id.present? %>
<td><%= link_to "See report", admin_report_path(id: @email.feedback_message_id) %></td>
<% else %>
<td>N/A</td>
<% end %>
</tr>
<tr>
<td>Sent at</td>
<td><%= @email.sent_at&.strftime("%b %e '%y") %></td>
</tr>
<tr>
<td>Opened At</td>
<td><%= @email.opened_at&.strftime("%b %e '%y") %></td>
</tr>
<tr>
<td>UTM Campaign</td>
<td><%= @email.utm_campaign %></td>
</tr>
<tr>
<td>Mailer</td>
<td><%= @email.mailer %></td>
</tr>
</tbody>
</table>
</div>
<div class="crayons-card p-6">
<h2>Email content</h2>
<p><em>The content is previewed below without formatting</em></p>
<div class="crayons-card my-5 p-5">
<%= @email.body_html_content.html_safe %>
</div>
</div>
</div>

View file

@ -1,4 +1,4 @@
<div class="crayons-card p-6 grid gap-6">
<div class="crayons-card p-6 grid gap-6" id="user-email-tools">
<h2>Email Tools</h2>
<div>
@ -25,7 +25,7 @@
<h3>Recent Emails</h3>
<div class="list-group-flush">
<% @user.email_messages.order(sent_at: :desc).limit(50).each do |email| %>
<a href="<%= resource_admin_email_message_path(email.id) %>"
<a href="<%= admin_user_email_message_path(@user, email) %>"
class="list-group-item list-group-item-action"
rel="noopener noreferer"
target="_blank">

View file

@ -8,7 +8,6 @@ Disallow: /search/?q=*
Disallow: /listings*?q=*
Disallow: /mod/*
Disallow: /mod?*
Disallow: /resource_admin/*
Disallow: /admin/*
Sitemap: https://<%= ApplicationConfig["AWS_BUCKET_NAME"] %>.s3.amazonaws.com/sitemaps/sitemap.xml.gz

View file

@ -1,103 +0,0 @@
<%#
# Collection
This partial is used on the `index` and `show` pages
to display a collection of resources in an HTML table.
## Local variables:
- `collection_presenter`:
An instance of [Administrate::Page::Collection][1].
The table presenter uses `ResourceDashboard::COLLECTION_ATTRIBUTES` to determine
the columns displayed in the table
- `resources`:
An ActiveModel::Relation collection of resources to be displayed in the table.
By default, the number of resources is limited by pagination
or by a hard limit to prevent excessive page load times
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
%>
<table aria-labelledby="<%= table_title %>">
<thead>
<tr>
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
<th class="cell-label
cell-label--<%= attr_type.html_class %>
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>"
scope="col"
role="columnheader"
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
<%= link_to(sanitized_order_params(
page, collection_field_name
).merge(
collection_presenter.order_params_for(attr_name, key: collection_field_name),
)) do %>
<%= t(
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
default: attr_name.to_s,
).titleize %>
<% if collection_presenter.ordered_by?(attr_name) %>
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
<svg aria-hidden="true">
<use xlink:href="#icon-up-caret" />
</svg>
</span>
<% end %>
<% end %>
</th>
<% end %>
<% [valid_action?(:edit, collection_presenter.resource_name),
valid_action?(:destroy, collection_presenter.resource_name)].count(true).times do %>
<th scope="col"></th>
<% end %>
</tr>
</thead>
<tbody>
<% resources.each do |resource| %>
<tr class="js-table-row"
tabindex="0"
<% if valid_action? :show, collection_presenter.resource_name %>
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) %>
<% end %>>
<% collection_presenter.attributes_for(resource).each do |attribute| %>
<td class="cell-data cell-data--<%= attribute.html_class %>">
<% if show_action? :show, resource -%>
<a href="<%= polymorphic_path([namespace, resource]) -%>"
class="action-show">
<%= render_field attribute %>
</a>
<% end -%>
</td>
<% end %>
<% if valid_action? :edit, collection_presenter.resource_name %>
<td>
<% if show_action? :edit, resource %>
<%= link_to(
t("administrate.actions.edit"),
[:edit, namespace, resource],
class: "action-edit",
) %>
<% end %>
</td>
<% end %>
<% if valid_action? :destroy, collection_presenter.resource_name %>
<td>
<% if show_action? :destroy, resource %>
<%= link_to(
t("administrate.actions.destroy"),
[namespace, resource],
class: "text-color-red",
method: :delete,
data: { confirm: t("administrate.actions.confirm") },
) %>
<% end %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>

View file

@ -1,68 +0,0 @@
<%#
# Index
This view is the template for the index page.
It is responsible for rendering the search bar, header and pagination.
It renders the `_table` partial to display details about the resources.
## Local variables:
- `page`:
An instance of [Administrate::Page::Collection][1].
Contains helper methods to help display a table,
and knows which attributes should be displayed in the resource's table.
- `resources`:
An instance of `ActiveRecord::Relation` containing the resources
that match the user's search criteria.
By default, these resources are passed to the table partial to be displayed.
- `search_term`:
A string containing the term the user has searched for, if any.
- `show_search_bar`:
A boolean that determines if the search bar should be shown.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
%>
<% content_for(:title) do %>
<%= display_resource_name(page.resource_name) %>
<% end %>
<header class="main-content__header" role="banner">
<h1 class="main-content__page-title" id="page-title">
<%= content_for(:title) %>
</h1>
<% if show_search_bar %>
<%= render(
"search",
search_term: search_term,
resource_name: display_resource_name(page.resource_name),
) %>
<% end %>
<div>
<% if valid_action?(:new) && show_action?(:new, new_resource) %>
<%= link_to(
t(
"administrate.actions.new_resource",
name: page.resource_name.titleize.downcase,
),
[:new, namespace, page.resource_path],
class: "button",
) %>
<% end %>
</div>
</header>
<section class="main-content__body main-content__body--flush">
<%= render(
"collection",
collection_presenter: page,
collection_field_name: resource_name,
page: page,
resources: resources,
table_title: "page-title",
) %>
<%= paginate resources %>
</section>

View file

@ -108,7 +108,6 @@
'/onboarding', // Don't run on onboarding.
'/podcasts', // redirects
'/rails/mailers', // Skip for mailers previews in development mode
'/resource_admin', // Don't fetch for administrate dashboard.
'/robots.txt', // Skip robots for web crawlers
'/rss', // Skip the RSS feed alternative path
'/search/chat_channels', // Don't run on search endpoints

View file

@ -43,15 +43,6 @@ Rails.application.routes.draw do
mount FieldTest::Engine, at: "abtests"
end
namespace :resource_admin do
# Check administrate gem docs
DashboardManifest::DASHBOARDS.each do |dashboard_resource|
resources dashboard_resource
end
root controller: DashboardManifest::ROOT_DASHBOARD, action: :index
end
namespace :admin do
get "/" => "admin_portals#index"
@ -113,6 +104,8 @@ Rails.application.routes.draw do
resource :moderator, only: %i[create destroy], module: "tags"
end
resources :users, only: %i[index show edit update] do
resources :email_messages, only: :show
member do
post "banish"
post "export_data"

View file

@ -1,39 +0,0 @@
---
title: Resource Admin Panel
---
# What is the resource admin panel?
The resource admin panel is a CRUD interface generated via the
[Administrate gem](https://github.com/thoughtbot/administrate). In production,
this is generally not used often and will be deprecated in favor of the admin
panel (`http://localhost:3000/admin/*`). For more details, see
[the admin guide](/admin).
# Accessing the resource admin panel
There is an resource admin panel located at
<http://localhost:3000/resource_admin>.
To access the panel, you must be logged with a user with the `admin` role
activated.
To activate such a role, you can follow these instructions:
- open the Rails console
```shell
rails console
```
1. load the user object of for _bob_ (or whatever the username is)
```ruby
Loading development environment (Rails 6.0.3)
[1] pry(main)> user = User.find_by(username: "bob")
[2] pry(main)> user.add_role(:super_admin)
[3] pry(main)> user.save!
```
Now you'll be able to access the
[resource administration panel](http://localhost:3000/resource_admin).

View file

@ -46,11 +46,12 @@ RSpec.describe "admin/users", type: :request do
end
context "when a user has been sent an email" do
it "renders a link to the user email on the Resource Admin" do
it "renders a link to the user email preview" do
email = create(:email_message, user: user, to: user.email)
get admin_user_path(user.id)
expect(response.body).to include(resource_admin_email_message_path(email.id))
preview_path = admin_user_email_message_path(user, email)
expect(response.body).to include(preview_path)
end
end
end

View file

@ -1,43 +0,0 @@
require "rails_helper"
RSpec.describe "ResourceAdmin::Podcasts", type: :request do
let(:super_admin) { create(:user, :super_admin) }
let(:image_file) { Rails.root.join("spec/support/fixtures/images/image1.jpeg") }
before do
sign_in super_admin
end
describe "POST #create" do
let(:valid_attributes) do
{
title: "Developer Tea",
description: "Super Podcast",
feed_url: "http://feeds.feedburner.com/developertea",
slug: "devtea",
published: true,
main_color_hex: "333333",
image: Rack::Test::UploadedFile.new(image_file, "image/jpeg")
}
end
it "creates a podcast" do
expect do
post "/resource_admin/podcasts", params: { podcast: valid_attributes }
end.to change(Podcast, :count).by(1)
end
it "enqueues a job after creating a podcast" do
sidekiq_assert_enqueued_jobs(1, only: Podcasts::GetEpisodesWorker) do
post "/resource_admin/podcasts", params: { podcast: valid_attributes }
end
end
it "doesn't enqueue a job when creating an unpublished podcast" do
valid_attributes[:published] = false
sidekiq_assert_no_enqueued_jobs(only: Podcasts::GetEpisodesWorker) do
post "/resource_admin/podcasts", params: { podcast: valid_attributes }
end
end
end
end

View file

@ -192,7 +192,7 @@ RSpec.describe "UserProfiles", type: :request do
it "redirects to admin" do
user = create(:user)
get "/#{user.username}/admin"
expect(response.body).to redirect_to "/resource_admin/users/#{user.id}/edit"
expect(response.body).to redirect_to "/admin/users/#{user.id}/edit"
end
it "redirects to moderate" do

View file

@ -0,0 +1,40 @@
require "rails_helper"
RSpec.describe "Admin Email Tools within User management", type: :system do
let(:admin) { create(:user, :super_admin) }
let(:user) { create(:user) }
let(:email_subject) { "Email subject" }
let(:email_body) { "Email body" }
context "when looking at a user with recorded emails in the admin panel" do
before do
sign_in admin
visit admin_user_path(user)
# Send the test user an email using the built in form
within(:css, "#user-email-tools") do
fill_in("email_subject", with: email_subject)
fill_in("email_body", with: email_body)
click_on("Send Email")
end
visit admin_user_path(user)
end
it "shows the email sent to the user" do
email_tools_section = find("#user-email-tools")
expect(email_tools_section).to have_text(email_subject)
end
it "redirects and displays the email details" do
within(:css, "#user-email-tools") do
all("a.list-group-item-action").first.click
end
expect(page).to have_content(email_subject)
expect(page).to have_content(email_body)
expect(page).to have_content("NotifyMailer#user_contact_email")
expect(page).to have_content(user.email)
end
end
end

View file

@ -1,27 +0,0 @@
require "rails_helper"
RSpec.describe "Admin dashboard is presented", type: :system do
let(:admin) { build(:user, :super_admin) }
let(:user) { build_stubbed(:user) }
before { Bullet.raise = false }
after { Bullet.raise = true }
it "loads the admin dashboard articles view", js: true do
sign_in admin
visit "/resource_admin"
expect(page).to have_content("Articles")
end
it "loads the admin dashboard podcasts view", js: true do
sign_in admin
visit "/resource_admin/podcasts"
expect(page).to have_content("Podcast Episodes")
end
it "fails to load admin view for unauthorized users" do
expect { visit "/resource_admin" }.to raise_error(Pundit::NotAuthorizedError)
expect { visit "/resource_admin/podcasts" }.to raise_error(Pundit::NotAuthorizedError)
end
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.