administration-zero 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +15 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +3 -5
  5. data/lib/administration_zero/version.rb +1 -1
  6. data/lib/generators/admin/install/install_generator.rb +1 -2
  7. data/lib/generators/admin/install/templates/controllers/admin/application_controller.rb +1 -1
  8. data/lib/generators/admin/install/templates/controllers/admin/password_resets_controller.rb +2 -2
  9. data/lib/generators/admin/install/templates/controllers/admin/sessions_controller.rb +2 -2
  10. data/lib/generators/admin/install/templates/controllers/admin/users_controller.rb +4 -4
  11. data/lib/generators/admin/install/templates/erb/admin/application/_flash_messages.html.erb +6 -8
  12. data/lib/generators/admin/install/templates/erb/admin/application/_secondary_navbar.html.erb +1 -1
  13. data/lib/generators/admin/install/templates/erb/admin/users/edit.html.erb +2 -2
  14. data/lib/generators/admin/install/templates/erb/admin/users/index.html.erb +3 -3
  15. data/lib/generators/admin/install/templates/erb/admin/users/new.html.erb +2 -2
  16. data/lib/generators/admin/install/templates/erb/admin/users/show.html.erb +4 -4
  17. data/lib/generators/admin/install/templates/helpers/admin/application_helper.rb +1 -1
  18. data/lib/generators/admin/install/templates/mailers/admin/application_mailer.rb +4 -0
  19. data/lib/generators/admin/install/templates/mailers/admin/user_mailer.rb +1 -1
  20. data/lib/generators/admin/install/templates/models/admin/application_record.rb +6 -0
  21. data/lib/generators/admin/install/templates/models/{admin_user.rb → admin/user.rb} +1 -3
  22. data/lib/generators/admin/install/templates/seeds.rb +1 -1
  23. data/lib/generators/admin/install/templates/test_unit/application_system_test_case.rb +1 -1
  24. data/lib/generators/admin/install/templates/test_unit/controllers/admin/users_controller_test.rb +4 -4
  25. data/lib/generators/admin/install/templates/test_unit/system/admin/users_test.rb +8 -8
  26. data/lib/generators/admin/scaffold/templates/erb/index.html.erb.tt +1 -1
  27. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1262058b2e76e6b4e80b03390f07439cdf2c5734de1eb3ae2e3dcd79d30ded52
4
- data.tar.gz: 0c5a2ea1b24df7f367d6b37144370f9df0df0e071de0ae2acf08a6fe6d21270c
3
+ metadata.gz: 663bd62eb687f4ebb0a1cd879bc3dae595bc726c7cc29a91431f5e82f133033a
4
+ data.tar.gz: 0ca18a859d138db6b2f50383a1c561df8131466ece26093cfd797184e359f86b
5
5
  SHA512:
6
- metadata.gz: 58cb7fe33173e0a58f62684b65ff9477526956e366411a5e2427a4093f3b01cf86ec2ec5908c9529c7e5ef0edd1da522bca552f2ab3bc1f731ad902d7d5ffab7
7
- data.tar.gz: d3bec811c90c09b6b051a50fefdc09aafbed7290d14d06d739839376c19c1c2f037dfe80298801d929e477cfa5288872bbe2cdcf0ae30f3dc6cb916119f0e548
6
+ metadata.gz: f4d3486f4dcb59a2fb0aa41d4968106fc4cf6f8569f85610823cb0d832da093d380366ebb4a8ecdaf9aac5767635e2d9d557343b34b3189dc667f9566cccd7bf
7
+ data.tar.gz: 65eebeed7cbf48951eed8a0feef6242b2b32f37302726f0a4f9b74b20bb456564ad18d1ab8bb4b3e9dfa5f56269ed09eba1b7e881ebb77cc0497ef5264956f9c
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ inherit_from: https://raw.githubusercontent.com/rails/rails/master/.rubocop.yml
2
+
3
+ Performance:
4
+ Exclude:
5
+ - 'test/**/*'
6
+
7
+ Style/FrozenStringLiteralComment:
8
+ Enabled: false
9
+
10
+ Style/StringLiterals:
11
+ Enabled: true
12
+ EnforcedStyle: double_quotes
13
+ Include:
14
+ - 'app/**/*'
15
+ - 'test/**/*'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- administration-zero (0.0.9)
4
+ administration-zero (0.0.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -27,13 +27,13 @@ Then run `bundle install`
27
27
  You'll need to create a model to be administrated, if you don't have one. for this example let's use the following:
28
28
 
29
29
  ```
30
- $ rails generate model posts title:string body:text published:boolean
30
+ rails generate model posts title:string body:text published:boolean
31
31
  ```
32
32
 
33
33
  ## Usage
34
34
 
35
35
  ```
36
- $ rails generate admin:install
36
+ rails generate admin:install
37
37
  ```
38
38
 
39
39
  Then run `bundle install` again
@@ -44,13 +44,11 @@ Then run `rails db:migrate db:seed`, you can access the admin panel in `/admin`,
44
44
  Now you're ready to generate your admin scaffolds.
45
45
 
46
46
  ```
47
- $ rails generate admin:scaffold posts title:string body:text published:boolean
47
+ rails generate admin:scaffold posts title:string body:text published:boolean
48
48
  ```
49
49
 
50
50
  ## Development
51
51
 
52
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
53
-
54
52
  To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
55
53
 
56
54
  ## Contributing
@@ -1,3 +1,3 @@
1
1
  module AdministrationZero
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -21,12 +21,11 @@ module Admin
21
21
 
22
22
  def create_models
23
23
  directory "models/admin", "app/models/admin"
24
- copy_file "models/admin_user.rb", "app/models/admin_user.rb"
25
24
  copy_file "models/application_record.rb", "app/models/application_record.rb", force: true
26
25
  end
27
26
 
28
27
  def create_fixture_file
29
- copy_file "test_unit/admin_users.yml", "test/fixtures/admin_users.yml"
28
+ copy_file "test_unit/admin_users.yml", "test/fixtures/admin/users.yml"
30
29
  end
31
30
 
32
31
  def create_controllers
@@ -4,7 +4,7 @@ class Admin::ApplicationController < ActionController::Base
4
4
  before_action :authenticate
5
5
 
6
6
  def authenticate
7
- if admin_user = AdminUser.find_by_id(session[:admin_user_id])
7
+ if admin_user = Admin::User.find_by_id(session[:admin_user_id])
8
8
  Admin::Current.user = admin_user
9
9
  else
10
10
  redirect_to admin_sign_in_path
@@ -12,7 +12,7 @@ class Admin::PasswordResetsController < Admin::ApplicationController
12
12
  end
13
13
 
14
14
  def create
15
- if @admin_user = AdminUser.find_by(email: params[:email])
15
+ if @admin_user = Admin::User.find_by(email: params[:email])
16
16
  Admin::UserMailer.with(admin_user: @admin_user).password_reset_provision.deliver_later
17
17
  redirect_to admin_sign_in_path, notice: "Check your email for reset instructions"
18
18
  else
@@ -30,7 +30,7 @@ class Admin::PasswordResetsController < Admin::ApplicationController
30
30
 
31
31
  private
32
32
  def set_admin_user
33
- @admin_user = AdminUser.find_signed!(params[:token], purpose: :password_reset)
33
+ @admin_user = Admin::User.find_signed!(params[:token], purpose: :password_reset)
34
34
  rescue
35
35
  redirect_to new_admin_password_reset_path, alert: "That password reset link is invalid"
36
36
  end
@@ -4,11 +4,11 @@ class Admin::SessionsController < Admin::ApplicationController
4
4
  layout "admin/authentication"
5
5
 
6
6
  def new
7
- @admin_user = AdminUser.new
7
+ @admin_user = Admin::User.new
8
8
  end
9
9
 
10
10
  def create
11
- @admin_user = AdminUser.find_by(email: params[:email])
11
+ @admin_user = Admin::User.find_by(email: params[:email])
12
12
 
13
13
  if @admin_user && @admin_user.authenticate(params[:password])
14
14
  session[:admin_user_id] = @admin_user.id
@@ -2,7 +2,7 @@ class Admin::UsersController < Admin::ApplicationController
2
2
  before_action :set_admin_user, only: %i[ show edit update destroy ]
3
3
 
4
4
  def index
5
- @search = AdminUser.all.ransack(params[:q])
5
+ @search = Admin::User.all.ransack(params[:q])
6
6
 
7
7
  respond_to do |format|
8
8
  format.html { @pagy, @admin_users = pagy(@search.result) }
@@ -14,14 +14,14 @@ class Admin::UsersController < Admin::ApplicationController
14
14
  end
15
15
 
16
16
  def new
17
- @admin_user = AdminUser.new
17
+ @admin_user = Admin::User.new
18
18
  end
19
19
 
20
20
  def edit
21
21
  end
22
22
 
23
23
  def create
24
- @admin_user = AdminUser.new(admin_user_params)
24
+ @admin_user = Admin::User.new(admin_user_params)
25
25
 
26
26
  if @admin_user.save
27
27
  redirect_to @admin_user, notice: "User was successfully created."
@@ -45,7 +45,7 @@ class Admin::UsersController < Admin::ApplicationController
45
45
 
46
46
  private
47
47
  def set_admin_user
48
- @admin_user = AdminUser.find(params[:id])
48
+ @admin_user = Admin::User.find(params[:id])
49
49
  end
50
50
 
51
51
  def admin_user_params
@@ -1,11 +1,9 @@
1
- <% flash.each do |type, message| %>
2
- <% if ["notice", "alert"].include?(type) %>
3
- <div class="position-fixed start-50 translate-middle-x" style="z-index: 1030; top: 8rem;">
4
- <div class="toast hide text-center text-white bg-dark border-0" data-controller="flash-message">
5
- <div class="toast-body">
6
- <%= message %>
7
- </div>
1
+ <% flash.each do |name, message| %>
2
+ <div class="position-fixed start-50 translate-middle-x" style="z-index: 1030; top: 8rem;">
3
+ <div class="toast hide text-center text-white bg-dark border-0" data-controller="flash-message">
4
+ <div class="toast-body">
5
+ <%= message %>
8
6
  </div>
9
7
  </div>
10
- <% end %>
8
+ </div>
11
9
  <% end %>
@@ -19,7 +19,7 @@
19
19
  <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><circle cx="9" cy="7" r="4"></circle><path d="M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path><path d="M21 21v-2a4 4 0 0 0 -3 -3.85"></path></svg>
20
20
  </span>
21
21
  <span class="nav-link-title">
22
- Admin users
22
+ Users
23
23
  </span>
24
24
  <% end %>
25
25
  </li>
@@ -1,7 +1,7 @@
1
1
  <%= render "page_header" do %>
2
- <%= render "page_header_breadcrumb", title: "Editing admin user" do %>
2
+ <%= render "page_header_breadcrumb", title: "Editing user" do %>
3
3
  <li class="breadcrumb-item"><%= link_to "Admin", admin_path %></li>
4
- <li class="breadcrumb-item"><%= link_to "Admin users", admin_users_path %></li>
4
+ <li class="breadcrumb-item"><%= link_to "Users", admin_users_path %></li>
5
5
  <li class="breadcrumb-item"><%= link_to @admin_user.email, @admin_user %></li>
6
6
  <% end %>
7
7
  <% end %>
@@ -1,11 +1,11 @@
1
1
  <%= render "page_header" do %>
2
- <%= render "page_header_breadcrumb", title: "Admin users" do %>
2
+ <%= render "page_header_breadcrumb", title: "Users" do %>
3
3
  <li class="breadcrumb-item"><%= link_to "Admin", admin_path %></li>
4
4
  <% end %>
5
5
 
6
6
  <%= render "page_header_actions" do %>
7
7
  <%= link_to "Filters", "#offcanvas_filters", "data-bs-toggle": "offcanvas", class: "btn btn-light" %>
8
- <%= link_to "New admin user", new_admin_user_path, class: "btn btn-primary" %>
8
+ <%= link_to "New user", new_admin_user_path, class: "btn btn-primary" %>
9
9
  <% end %>
10
10
  <% end %>
11
11
 
@@ -41,7 +41,7 @@
41
41
  <div class="card-footer d-flex align-items-center fs-5">
42
42
  <div class="d-none d-md-block">
43
43
  <div>Download: <%= link_to "CSV", admin_users_path(format: :csv, q: request.params[:q]) %></div>
44
- <%== pagy_info @pagy %>
44
+ <%= raw pagy_info(@pagy) %>
45
45
  </div>
46
46
  <div class="ms-auto">
47
47
  <%= render "pagination", pagy: @pagy %>
@@ -1,7 +1,7 @@
1
1
  <%= render "page_header" do %>
2
- <%= render "page_header_breadcrumb", title: "New admin user" do %>
2
+ <%= render "page_header_breadcrumb", title: "New user" do %>
3
3
  <li class="breadcrumb-item"><%= link_to "Admin", admin_path %></li>
4
- <li class="breadcrumb-item"><%= link_to "Admin users", admin_users_path %></li>
4
+ <li class="breadcrumb-item"><%= link_to "Users", admin_users_path %></li>
5
5
  <% end %>
6
6
  <% end %>
7
7
 
@@ -1,12 +1,12 @@
1
1
  <%= render "page_header" do %>
2
2
  <%= render "page_header_breadcrumb", title: @admin_user.email do %>
3
3
  <li class="breadcrumb-item"><%= link_to "Admin", admin_path %></li>
4
- <li class="breadcrumb-item"><%= link_to "Admin users", admin_users_path %></li>
4
+ <li class="breadcrumb-item"><%= link_to "Users", admin_users_path %></li>
5
5
  <% end %>
6
6
 
7
7
  <%= render "page_header_actions" do %>
8
- <%= link_to "Edit admin user", edit_admin_user_path(@admin_user), class: "btn btn-primary" %>
9
- <%= button_to "Delete admin user", @admin_user, method: :delete, "data-confirm": "Are you sure?", form_class: "d-inline", class: "btn btn-light" %>
8
+ <%= link_to "Edit user", edit_admin_user_path(@admin_user), class: "btn btn-primary" %>
9
+ <%= button_to "Delete user", @admin_user, method: :delete, "data-confirm": "Are you sure?", form_class: "d-inline", class: "btn btn-light" %>
10
10
  <% end %>
11
11
  <% end %>
12
12
 
@@ -14,7 +14,7 @@
14
14
  <div class="container-xl">
15
15
  <div class="card">
16
16
  <div class="card-header">
17
- <h3 class="card-title">Admin user details</h3>
17
+ <h3 class="card-title">User details</h3>
18
18
  </div>
19
19
  <div class="card-body">
20
20
  <dl class="row">
@@ -2,7 +2,7 @@ module Admin::ApplicationHelper
2
2
  include Pagy::Frontend
3
3
 
4
4
  def title
5
- content_for(:title) || Rails.application.class.to_s.split('::').first
5
+ content_for(:title) || Rails.application.class.to_s.split("::").first
6
6
  end
7
7
 
8
8
  def active_nav_item(controller, actions = %w( index show new edit create update))
@@ -0,0 +1,4 @@
1
+ class Admin::ApplicationMailer < ActionMailer::Base
2
+ default from: "from@example.com"
3
+ layout "mailer"
4
+ end
@@ -1,4 +1,4 @@
1
- class Admin::UserMailer < ApplicationMailer
1
+ class Admin::UserMailer < Admin::ApplicationMailer
2
2
  def password_reset_provision
3
3
  @admin_user = params[:admin_user]
4
4
  @signed_id = @admin_user.signed_id(purpose: :password_reset, expires_in: 20.minutes)
@@ -0,0 +1,6 @@
1
+ class Admin::ApplicationRecord < ActiveRecord::Base
2
+ include SpreadsheetArchitect
3
+
4
+ self.abstract_class = true
5
+ self.table_name_prefix = "admin_"
6
+ end
@@ -1,6 +1,4 @@
1
- class AdminUser < ApplicationRecord
2
- include SpreadsheetArchitect
3
-
1
+ class Admin::User < Admin::ApplicationRecord
4
2
  has_secure_password
5
3
 
6
4
  validates :email, presence: true, uniqueness: true
@@ -6,4 +6,4 @@
6
6
  # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
7
7
  # Character.create(name: "Luke", movie: movies.first)
8
8
 
9
- AdminUser.create(email: "admin@example.com", password: "Password9957", password_confirmation: "Password9957")
9
+ Admin::User.create(email: "admin@example.com", password: "Password9957", password_confirmation: "Password9957")
@@ -10,6 +10,6 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
10
10
  click_on "Sign in"
11
11
  assert_current_path admin_url
12
12
 
13
- return user
13
+ user
14
14
  end
15
15
  end
@@ -16,11 +16,11 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
16
16
  end
17
17
 
18
18
  test "should create admin_user" do
19
- assert_difference("AdminUser.count") do
20
- post admin_users_url, params: { admin_user: { email: "lazaronixon@hey.com", password: "Secret1*3*5*", password_confirmation: "Secret1*3*5*"} }
19
+ assert_difference("Admin::User.count") do
20
+ post admin_users_url, params: { admin_user: { email: "lazaronixon@hey.com", password: "Secret1*3*5*", password_confirmation: "Secret1*3*5*" } }
21
21
  end
22
22
 
23
- assert_redirected_to admin_user_url(AdminUser.last)
23
+ assert_redirected_to admin_user_url(Admin::User.last)
24
24
  end
25
25
 
26
26
  test "should show admin_user" do
@@ -39,7 +39,7 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
39
39
  end
40
40
 
41
41
  test "should destroy admin_user" do
42
- assert_difference("AdminUser.count", -1) do
42
+ assert_difference("Admin::User.count", -1) do
43
43
  delete admin_user_url(@admin_user)
44
44
  end
45
45
 
@@ -7,36 +7,36 @@ class Admin::UsersTest < ApplicationSystemTestCase
7
7
 
8
8
  test "visiting the index" do
9
9
  visit admin_users_url
10
- assert_selector "h2", text: "Admin users"
10
+ assert_selector "h2", text: "Users"
11
11
  end
12
12
 
13
13
  test "should create user" do
14
14
  visit admin_users_url
15
- click_on "New admin user"
15
+ click_on "New user"
16
16
 
17
17
  fill_in "Email", with: "lazaronixon@hey.com"
18
18
  fill_in "Password", with: "Secret1*3*5*"
19
19
  fill_in "Password confirmation", with: "Secret1*3*5*"
20
- click_on "Create Admin user"
20
+ click_on "Create User"
21
21
 
22
22
  assert_text "User was successfully created"
23
23
  end
24
24
 
25
- test "should update User" do
25
+ test "should update user" do
26
26
  visit admin_user_url(@admin_user)
27
- click_on "Edit admin user"
27
+ click_on "Edit user"
28
28
 
29
29
  fill_in "Email", with: @admin_user.email
30
30
  fill_in "Password", with: "NewSecret1*3*5*"
31
31
  fill_in "Password confirmation", with: "NewSecret1*3*5*"
32
- click_on "Update Admin user"
32
+ click_on "Update User"
33
33
 
34
34
  assert_text "User was successfully updated"
35
35
  end
36
36
 
37
- test "should destroy User" do
37
+ test "should destroy user" do
38
38
  visit admin_user_url(@admin_user)
39
- page.accept_confirm { click_on "Delete admin user" }
39
+ page.accept_confirm { click_on "Delete user" }
40
40
 
41
41
  assert_text "User was successfully destroyed"
42
42
  end
@@ -49,7 +49,7 @@
49
49
  <div class="card-footer d-flex align-items-center fs-5">
50
50
  <div class="d-none d-md-block">
51
51
  <div>Download: <%%= link_to "CSV", <%= index_helper(type: :path) %>(format: :csv, q: request.params[:q]) %></div>
52
- <%%== pagy_info @pagy %>
52
+ <%%= raw pagy_info(@pagy) %>
53
53
  </div>
54
54
  <div class="ms-auto">
55
55
  <%%= render "pagination", pagy: @pagy %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administration-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-14 00:00:00.000000000 Z
11
+ date: 2022-03-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -19,6 +19,7 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - ".documentation/screenshot.png"
21
21
  - ".gitignore"
22
+ - ".rubocop.yml"
22
23
  - CHANGELOG.md
23
24
  - CODE_OF_CONDUCT.md
24
25
  - Gemfile
@@ -63,10 +64,12 @@ files:
63
64
  - lib/generators/admin/install/templates/helpers/admin/application_helper.rb
64
65
  - lib/generators/admin/install/templates/images/admin/000m.jpg
65
66
  - lib/generators/admin/install/templates/images/admin/logo.svg
67
+ - lib/generators/admin/install/templates/mailers/admin/application_mailer.rb
66
68
  - lib/generators/admin/install/templates/mailers/admin/user_mailer.rb
67
69
  - lib/generators/admin/install/templates/migrations/create_admin_users.rb.tt
70
+ - lib/generators/admin/install/templates/models/admin/application_record.rb
68
71
  - lib/generators/admin/install/templates/models/admin/current.rb
69
- - lib/generators/admin/install/templates/models/admin_user.rb
72
+ - lib/generators/admin/install/templates/models/admin/user.rb
70
73
  - lib/generators/admin/install/templates/models/application_record.rb
71
74
  - lib/generators/admin/install/templates/seeds.rb
72
75
  - lib/generators/admin/install/templates/test_unit/admin_users.yml