feat: Ability to seed Demo Accounts (#5352)
Introduces the ability to seed sample data into accounts in development and staging. fixes: #3429
This commit is contained in:
@@ -41,4 +41,9 @@ class SuperAdmin::AccountsController < SuperAdmin::ApplicationController
|
||||
|
||||
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
|
||||
# for more information
|
||||
|
||||
def seed
|
||||
Seeders::AccountSeeder.new(account: requested_resource).perform!
|
||||
redirect_back(fallback_location: [namespace, requested_resource], notice: 'Account seeding triggered')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,8 @@ require 'administrate/field/base'
|
||||
|
||||
class AvatarField < Administrate::Field::Base
|
||||
def avatar_url
|
||||
data.presence&.gsub('?d=404', '?d=mp')
|
||||
return data.presence if data.presence
|
||||
|
||||
resource.is_a?(User) ? '/assets/administrate/user/avatar.png' : '/assets/administrate/bot/avatar.png'
|
||||
end
|
||||
end
|
||||
|
||||
14
app/views/super_admin/accounts/_seed_data.html.erb
Normal file
14
app/views/super_admin/accounts/_seed_data.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<% if !Rails.env.production? %>
|
||||
<section class="main-content__body">
|
||||
<hr/>
|
||||
<%= form_for([:seed, namespace, page.resource], method: :post, html: { class: "form" }) do |f| %>
|
||||
|
||||
<div class="form-actions">
|
||||
<div><p> Click the button to generate seed data into this account for demos.</p>
|
||||
<p class="text-color-red">Note: This will clear all the existing data in this account.</p>
|
||||
</div>
|
||||
<%= f.submit 'Generate Seed Data' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</section>
|
||||
<% end %>
|
||||
@@ -85,3 +85,5 @@ as well as a link to its edit page.
|
||||
<% end %>
|
||||
|
||||
</section>
|
||||
|
||||
<%= render partial: "seed_data", locals: {page: page} %>
|
||||
|
||||
Reference in New Issue
Block a user