From 215c989806cb57966bad4477e729e2e7cd6229ec Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Fri, 9 Oct 2015 08:17:29 -0400 Subject: [PATCH] Create admin namespace for data admin --- .../{ => admin}/awaken_types.coffee | 0 .../javascripts/{ => admin}/cards.coffee | 0 .../javascripts/{ => admin}/characters.coffee | 0 .../dashboard.coffee} | 0 .../leader_skills.coffee} | 0 .../links.coffee} | 0 .../passive_skills.coffee} | 0 .../rarities.coffee} | 0 .../super_attacks.coffee} | 0 .../{users.coffee => admin/types.coffee} | 0 app/assets/javascripts/admin/users.coffee | 3 ++ .../stylesheets/{ => admin}/awaken_types.scss | 0 app/assets/stylesheets/{ => admin}/cards.scss | 0 .../stylesheets/{ => admin}/characters.scss | 0 app/assets/stylesheets/admin/dashboard.scss | 3 ++ .../{ => admin}/leader_skills.scss | 0 app/assets/stylesheets/{ => admin}/links.scss | 0 .../{ => admin}/passive_skills.scss | 0 .../stylesheets/{ => admin}/rarities.scss | 0 .../{ => admin}/super_attacks.scss | 0 app/assets/stylesheets/{ => admin}/types.scss | 0 app/assets/stylesheets/{ => admin}/users.scss | 0 app/assets/stylesheets/custom.scss | 4 ++ .../{ => admin}/awaken_types_controller.rb | 8 +-- app/controllers/admin/base_controller.rb | 3 ++ .../{ => admin}/cards_controller.rb | 8 +-- .../{ => admin}/characters_controller.rb | 8 +-- app/controllers/admin/dashboard_controller.rb | 4 ++ .../{ => admin}/leader_skills_controller.rb | 8 +-- .../{ => admin}/links_controller.rb | 8 +-- .../{ => admin}/passive_skills_controller.rb | 8 +-- .../{ => admin}/rarities_controller.rb | 2 +- .../{ => admin}/super_attacks_controller.rb | 8 +-- .../{ => admin}/types_controller.rb | 8 +-- .../{ => admin}/users_controller.rb | 6 +-- app/helpers/admin/dashboard_helper.rb | 2 + app/policies/admin_dashboard_policy.rb | 5 ++ app/views/admin/_navbar.html.slim | 49 +++++++++++++++++++ .../awaken_types}/_form.html.slim | 2 +- .../{ => admin}/awaken_types/edit.html.slim | 0 .../{ => admin}/awaken_types/index.html.slim | 8 +-- .../{ => admin}/awaken_types/new.html.slim | 0 app/views/{ => admin}/cards/_form.html.slim | 2 +- app/views/{ => admin}/cards/edit.html.slim | 0 app/views/{ => admin}/cards/index.html.slim | 8 +-- app/views/{ => admin}/cards/new.html.slim | 0 .../characters}/_form.html.slim | 2 +- .../{ => admin}/characters/edit.html.slim | 0 .../{ => admin}/characters/index.html.slim | 8 +-- .../{ => admin}/characters/new.html.slim | 0 app/views/admin/dashboard/index.html.slim | 1 + .../{ => admin}/leader_skills/_form.html.slim | 2 +- .../{ => admin}/leader_skills/edit.html.slim | 0 .../{ => admin}/leader_skills/index.html.slim | 8 +-- .../{ => admin}/leader_skills/new.html.slim | 0 .../links}/_form.html.slim | 2 +- app/views/{ => admin}/links/edit.html.slim | 0 app/views/{ => admin}/links/index.html.slim | 8 +-- app/views/{ => admin}/links/new.html.slim | 0 .../admin/passive_skills/_form.html.slim | 6 +++ .../{ => admin}/passive_skills/edit.html.slim | 0 .../passive_skills/index.html.slim | 8 +-- .../{ => admin}/passive_skills/new.html.slim | 0 .../{links => admin/rarities}/_form.html.slim | 2 +- app/views/{ => admin}/rarities/edit.html.slim | 0 .../{ => admin}/rarities/index.html.slim | 8 +-- app/views/{ => admin}/rarities/new.html.slim | 0 .../{ => admin}/super_attacks/_form.html.slim | 2 +- .../{ => admin}/super_attacks/edit.html.slim | 0 .../{ => admin}/super_attacks/index.html.slim | 8 +-- .../{ => admin}/super_attacks/new.html.slim | 0 .../{rarities => admin/types}/_form.html.slim | 2 +- app/views/{ => admin}/types/edit.html.slim | 0 app/views/{ => admin}/types/index.html.slim | 8 +-- app/views/{ => admin}/types/new.html.slim | 0 app/views/{ => admin}/users/_form.html.slim | 2 +- app/views/{ => admin}/users/edit.html.slim | 0 app/views/{ => admin}/users/index.html.slim | 4 +- app/views/application/_navbar.html.slim | 40 +-------------- app/views/layouts/admin.html.slim | 18 +++++++ app/views/types/_form.html.slim | 6 --- config/routes.rb | 29 ++++++----- 82 files changed, 201 insertions(+), 138 deletions(-) rename app/assets/javascripts/{ => admin}/awaken_types.coffee (100%) rename app/assets/javascripts/{ => admin}/cards.coffee (100%) rename app/assets/javascripts/{ => admin}/characters.coffee (100%) rename app/assets/javascripts/{leader_skills.coffee => admin/dashboard.coffee} (100%) rename app/assets/javascripts/{links.coffee => admin/leader_skills.coffee} (100%) rename app/assets/javascripts/{passive_skills.coffee => admin/links.coffee} (100%) rename app/assets/javascripts/{rarities.coffee => admin/passive_skills.coffee} (100%) rename app/assets/javascripts/{super_attacks.coffee => admin/rarities.coffee} (100%) rename app/assets/javascripts/{types.coffee => admin/super_attacks.coffee} (100%) rename app/assets/javascripts/{users.coffee => admin/types.coffee} (100%) create mode 100644 app/assets/javascripts/admin/users.coffee rename app/assets/stylesheets/{ => admin}/awaken_types.scss (100%) rename app/assets/stylesheets/{ => admin}/cards.scss (100%) rename app/assets/stylesheets/{ => admin}/characters.scss (100%) create mode 100644 app/assets/stylesheets/admin/dashboard.scss rename app/assets/stylesheets/{ => admin}/leader_skills.scss (100%) rename app/assets/stylesheets/{ => admin}/links.scss (100%) rename app/assets/stylesheets/{ => admin}/passive_skills.scss (100%) rename app/assets/stylesheets/{ => admin}/rarities.scss (100%) rename app/assets/stylesheets/{ => admin}/super_attacks.scss (100%) rename app/assets/stylesheets/{ => admin}/types.scss (100%) rename app/assets/stylesheets/{ => admin}/users.scss (100%) rename app/controllers/{ => admin}/awaken_types_controller.rb (75%) create mode 100644 app/controllers/admin/base_controller.rb rename app/controllers/{ => admin}/cards_controller.rb (80%) rename app/controllers/{ => admin}/characters_controller.rb (75%) create mode 100644 app/controllers/admin/dashboard_controller.rb rename app/controllers/{ => admin}/leader_skills_controller.rb (75%) rename app/controllers/{ => admin}/links_controller.rb (75%) rename app/controllers/{ => admin}/passive_skills_controller.rb (76%) rename app/controllers/{ => admin}/rarities_controller.rb (94%) rename app/controllers/{ => admin}/super_attacks_controller.rb (76%) rename app/controllers/{ => admin}/types_controller.rb (75%) rename app/controllers/{ => admin}/users_controller.rb (75%) create mode 100644 app/helpers/admin/dashboard_helper.rb create mode 100644 app/policies/admin_dashboard_policy.rb create mode 100644 app/views/admin/_navbar.html.slim rename app/views/{characters => admin/awaken_types}/_form.html.slim (60%) rename app/views/{ => admin}/awaken_types/edit.html.slim (100%) rename app/views/{ => admin}/awaken_types/index.html.slim (68%) rename app/views/{ => admin}/awaken_types/new.html.slim (100%) rename app/views/{ => admin}/cards/_form.html.slim (95%) rename app/views/{ => admin}/cards/edit.html.slim (100%) rename app/views/{ => admin}/cards/index.html.slim (72%) rename app/views/{ => admin}/cards/new.html.slim (100%) rename app/views/{awaken_types => admin/characters}/_form.html.slim (61%) rename app/views/{ => admin}/characters/edit.html.slim (100%) rename app/views/{ => admin}/characters/index.html.slim (68%) rename app/views/{ => admin}/characters/new.html.slim (100%) create mode 100644 app/views/admin/dashboard/index.html.slim rename app/views/{ => admin}/leader_skills/_form.html.slim (62%) rename app/views/{ => admin}/leader_skills/edit.html.slim (100%) rename app/views/{ => admin}/leader_skills/index.html.slim (68%) rename app/views/{ => admin}/leader_skills/new.html.slim (100%) rename app/views/{passive_skills => admin/links}/_form.html.slim (71%) rename app/views/{ => admin}/links/edit.html.slim (100%) rename app/views/{ => admin}/links/index.html.slim (73%) rename app/views/{ => admin}/links/new.html.slim (100%) create mode 100644 app/views/admin/passive_skills/_form.html.slim rename app/views/{ => admin}/passive_skills/edit.html.slim (100%) rename app/views/{ => admin}/passive_skills/index.html.slim (69%) rename app/views/{ => admin}/passive_skills/new.html.slim (100%) rename app/views/{links => admin/rarities}/_form.html.slim (70%) rename app/views/{ => admin}/rarities/edit.html.slim (100%) rename app/views/{ => admin}/rarities/index.html.slim (72%) rename app/views/{ => admin}/rarities/new.html.slim (100%) rename app/views/{ => admin}/super_attacks/_form.html.slim (67%) rename app/views/{ => admin}/super_attacks/edit.html.slim (100%) rename app/views/{ => admin}/super_attacks/index.html.slim (69%) rename app/views/{ => admin}/super_attacks/new.html.slim (100%) rename app/views/{rarities => admin/types}/_form.html.slim (71%) rename app/views/{ => admin}/types/edit.html.slim (100%) rename app/views/{ => admin}/types/index.html.slim (73%) rename app/views/{ => admin}/types/new.html.slim (100%) rename app/views/{ => admin}/users/_form.html.slim (70%) rename app/views/{ => admin}/users/edit.html.slim (100%) rename app/views/{ => admin}/users/index.html.slim (86%) create mode 100644 app/views/layouts/admin.html.slim delete mode 100644 app/views/types/_form.html.slim diff --git a/app/assets/javascripts/awaken_types.coffee b/app/assets/javascripts/admin/awaken_types.coffee similarity index 100% rename from app/assets/javascripts/awaken_types.coffee rename to app/assets/javascripts/admin/awaken_types.coffee diff --git a/app/assets/javascripts/cards.coffee b/app/assets/javascripts/admin/cards.coffee similarity index 100% rename from app/assets/javascripts/cards.coffee rename to app/assets/javascripts/admin/cards.coffee diff --git a/app/assets/javascripts/characters.coffee b/app/assets/javascripts/admin/characters.coffee similarity index 100% rename from app/assets/javascripts/characters.coffee rename to app/assets/javascripts/admin/characters.coffee diff --git a/app/assets/javascripts/leader_skills.coffee b/app/assets/javascripts/admin/dashboard.coffee similarity index 100% rename from app/assets/javascripts/leader_skills.coffee rename to app/assets/javascripts/admin/dashboard.coffee diff --git a/app/assets/javascripts/links.coffee b/app/assets/javascripts/admin/leader_skills.coffee similarity index 100% rename from app/assets/javascripts/links.coffee rename to app/assets/javascripts/admin/leader_skills.coffee diff --git a/app/assets/javascripts/passive_skills.coffee b/app/assets/javascripts/admin/links.coffee similarity index 100% rename from app/assets/javascripts/passive_skills.coffee rename to app/assets/javascripts/admin/links.coffee diff --git a/app/assets/javascripts/rarities.coffee b/app/assets/javascripts/admin/passive_skills.coffee similarity index 100% rename from app/assets/javascripts/rarities.coffee rename to app/assets/javascripts/admin/passive_skills.coffee diff --git a/app/assets/javascripts/super_attacks.coffee b/app/assets/javascripts/admin/rarities.coffee similarity index 100% rename from app/assets/javascripts/super_attacks.coffee rename to app/assets/javascripts/admin/rarities.coffee diff --git a/app/assets/javascripts/types.coffee b/app/assets/javascripts/admin/super_attacks.coffee similarity index 100% rename from app/assets/javascripts/types.coffee rename to app/assets/javascripts/admin/super_attacks.coffee diff --git a/app/assets/javascripts/users.coffee b/app/assets/javascripts/admin/types.coffee similarity index 100% rename from app/assets/javascripts/users.coffee rename to app/assets/javascripts/admin/types.coffee diff --git a/app/assets/javascripts/admin/users.coffee b/app/assets/javascripts/admin/users.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/admin/users.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/awaken_types.scss b/app/assets/stylesheets/admin/awaken_types.scss similarity index 100% rename from app/assets/stylesheets/awaken_types.scss rename to app/assets/stylesheets/admin/awaken_types.scss diff --git a/app/assets/stylesheets/cards.scss b/app/assets/stylesheets/admin/cards.scss similarity index 100% rename from app/assets/stylesheets/cards.scss rename to app/assets/stylesheets/admin/cards.scss diff --git a/app/assets/stylesheets/characters.scss b/app/assets/stylesheets/admin/characters.scss similarity index 100% rename from app/assets/stylesheets/characters.scss rename to app/assets/stylesheets/admin/characters.scss diff --git a/app/assets/stylesheets/admin/dashboard.scss b/app/assets/stylesheets/admin/dashboard.scss new file mode 100644 index 0000000..c75b95a --- /dev/null +++ b/app/assets/stylesheets/admin/dashboard.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Admin::Dashboard controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/leader_skills.scss b/app/assets/stylesheets/admin/leader_skills.scss similarity index 100% rename from app/assets/stylesheets/leader_skills.scss rename to app/assets/stylesheets/admin/leader_skills.scss diff --git a/app/assets/stylesheets/links.scss b/app/assets/stylesheets/admin/links.scss similarity index 100% rename from app/assets/stylesheets/links.scss rename to app/assets/stylesheets/admin/links.scss diff --git a/app/assets/stylesheets/passive_skills.scss b/app/assets/stylesheets/admin/passive_skills.scss similarity index 100% rename from app/assets/stylesheets/passive_skills.scss rename to app/assets/stylesheets/admin/passive_skills.scss diff --git a/app/assets/stylesheets/rarities.scss b/app/assets/stylesheets/admin/rarities.scss similarity index 100% rename from app/assets/stylesheets/rarities.scss rename to app/assets/stylesheets/admin/rarities.scss diff --git a/app/assets/stylesheets/super_attacks.scss b/app/assets/stylesheets/admin/super_attacks.scss similarity index 100% rename from app/assets/stylesheets/super_attacks.scss rename to app/assets/stylesheets/admin/super_attacks.scss diff --git a/app/assets/stylesheets/types.scss b/app/assets/stylesheets/admin/types.scss similarity index 100% rename from app/assets/stylesheets/types.scss rename to app/assets/stylesheets/admin/types.scss diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/admin/users.scss similarity index 100% rename from app/assets/stylesheets/users.scss rename to app/assets/stylesheets/admin/users.scss diff --git a/app/assets/stylesheets/custom.scss b/app/assets/stylesheets/custom.scss index 48713c3..abd35ef 100644 --- a/app/assets/stylesheets/custom.scss +++ b/app/assets/stylesheets/custom.scss @@ -5,3 +5,7 @@ .control-icon { padding: 0 3px 0 3px; } + +.no-margin { + margin-bottom: 0px !important; +} diff --git a/app/controllers/awaken_types_controller.rb b/app/controllers/admin/awaken_types_controller.rb similarity index 75% rename from app/controllers/awaken_types_controller.rb rename to app/controllers/admin/awaken_types_controller.rb index b4fe600..017dee9 100644 --- a/app/controllers/awaken_types_controller.rb +++ b/app/controllers/admin/awaken_types_controller.rb @@ -1,4 +1,4 @@ -class AwakenTypesController < ApplicationController +class Admin::AwakenTypesController < Admin::BaseController before_action :set_awaken_type, only: [:show, :edit, :update, :destroy] after_action :verify_authorized @@ -24,7 +24,7 @@ class AwakenTypesController < ApplicationController authorize @awaken_type if @awaken_type.save - redirect_to awaken_types_path, notice: 'Awaken Type was created' + redirect_to admin_awaken_types_path, notice: 'Awaken Type was created' else render :new end @@ -38,7 +38,7 @@ class AwakenTypesController < ApplicationController authorize @awaken_type if @awaken_type.update(awaken_type_params) - redirect_to awaken_types_path, notice: 'Awaken Type was updated' + redirect_to admin_awaken_types_path, notice: 'Awaken Type was updated' else render :edit end @@ -47,7 +47,7 @@ class AwakenTypesController < ApplicationController def destroy @awaken_type.destroy - redirect_to awaken_types_path, notice: 'Awaken Type was deleted' + redirect_to admin_awaken_types_path, notice: 'Awaken Type was deleted' end private diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb new file mode 100644 index 0000000..807fd9a --- /dev/null +++ b/app/controllers/admin/base_controller.rb @@ -0,0 +1,3 @@ +class Admin::BaseController < ApplicationController + layout 'admin' +end diff --git a/app/controllers/cards_controller.rb b/app/controllers/admin/cards_controller.rb similarity index 80% rename from app/controllers/cards_controller.rb rename to app/controllers/admin/cards_controller.rb index a22cb10..ce1de73 100644 --- a/app/controllers/cards_controller.rb +++ b/app/controllers/admin/cards_controller.rb @@ -1,4 +1,4 @@ -class CardsController < ApplicationController +class Admin::CardsController < Admin::BaseController before_action :set_card, only: [:show, :edit, :update, :destroy] after_action :verify_authorized @@ -24,7 +24,7 @@ class CardsController < ApplicationController authorize @card if @card.save - redirect_to cards_path, notice: 'Card was created' + redirect_to admin_cards_path, notice: 'Card was created' else render :new end @@ -38,7 +38,7 @@ class CardsController < ApplicationController authorize @card if @card.update(card_params) - redirect_to cards_path, notice: 'Card was updated' + redirect_to admin_cards_path, notice: 'Card was updated' else render :edit end @@ -49,7 +49,7 @@ class CardsController < ApplicationController @card.destroy - redirect_to cards_path, notice: 'Card was deleted' + redirect_to admin_cards_path, notice: 'Card was deleted' end private diff --git a/app/controllers/characters_controller.rb b/app/controllers/admin/characters_controller.rb similarity index 75% rename from app/controllers/characters_controller.rb rename to app/controllers/admin/characters_controller.rb index 72d3cd0..1cdcc1d 100644 --- a/app/controllers/characters_controller.rb +++ b/app/controllers/admin/characters_controller.rb @@ -1,4 +1,4 @@ -class CharactersController < ApplicationController +class Admin::CharactersController < Admin::BaseController before_action :set_character, only: [:show, :edit, :update, :destroy] after_action :verify_authorized @@ -24,7 +24,7 @@ class CharactersController < ApplicationController authorize @character if @character.save - redirect_to characters_path, notice: 'Character was created' + redirect_to admin_characters_path, notice: 'Character was created' else render :new end @@ -38,7 +38,7 @@ class CharactersController < ApplicationController authorize @character if @character.update(character_params) - redirect_to characters_path, notice: 'Character was updated' + redirect_to admin_characters_path, notice: 'Character was updated' else render :edit end @@ -49,7 +49,7 @@ class CharactersController < ApplicationController @character.destroy - redirect_to characters_path, notice: 'Character was deleted' + redirect_to admin_characters_path, notice: 'Character was deleted' end private diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb new file mode 100644 index 0000000..311d077 --- /dev/null +++ b/app/controllers/admin/dashboard_controller.rb @@ -0,0 +1,4 @@ +class Admin::DashboardController < Admin::BaseController + def index + end +end diff --git a/app/controllers/leader_skills_controller.rb b/app/controllers/admin/leader_skills_controller.rb similarity index 75% rename from app/controllers/leader_skills_controller.rb rename to app/controllers/admin/leader_skills_controller.rb index bdcc036..f520ff5 100644 --- a/app/controllers/leader_skills_controller.rb +++ b/app/controllers/admin/leader_skills_controller.rb @@ -1,4 +1,4 @@ -class LeaderSkillsController < ApplicationController +class Admin::LeaderSkillsController < Admin::BaseController before_action :set_leader_skill, only: [:show, :edit, :update, :destroy] after_action :verify_authorized @@ -24,7 +24,7 @@ class LeaderSkillsController < ApplicationController authorize @leader_skill if @leader_skill.save - redirect_to leader_skills_path, notice: 'Leader Skill was created' + redirect_to admin_leader_skills_path, notice: 'Leader Skill was created' else render :new end @@ -38,7 +38,7 @@ class LeaderSkillsController < ApplicationController authorize @leader_skill if @leader_skill.update(leader_skill_params) - redirect_to leader_skills_path, notice: 'Leader Skill was updated' + redirect_to admin_leader_skills_path, notice: 'Leader Skill was updated' else render :edit end @@ -49,7 +49,7 @@ class LeaderSkillsController < ApplicationController @leader_skill.destroy - redirect_to leader_skills_path, notice: 'Leader Skills was deleted' + redirect_to admin_leader_skills_path, notice: 'Leader Skills was deleted' end private diff --git a/app/controllers/links_controller.rb b/app/controllers/admin/links_controller.rb similarity index 75% rename from app/controllers/links_controller.rb rename to app/controllers/admin/links_controller.rb index e8c9639..07da04d 100644 --- a/app/controllers/links_controller.rb +++ b/app/controllers/admin/links_controller.rb @@ -1,4 +1,4 @@ -class LinksController < ApplicationController +class Admin::LinksController < Admin::BaseController before_action :set_link, only: [:show, :edit, :update, :destroy] after_action :verify_authorized @@ -24,7 +24,7 @@ class LinksController < ApplicationController authorize @link if @link.save - redirect_to links_path, notice: 'Link was created' + redirect_to admin_links_path, notice: 'Link was created' else render :new end @@ -38,7 +38,7 @@ class LinksController < ApplicationController authorize @link if @link.update(link_params) - redirect_to links_path, notice: 'Link was updated' + redirect_to admin_links_path, notice: 'Link was updated' else render :edit end @@ -49,7 +49,7 @@ class LinksController < ApplicationController @link.destroy - redirect_to links_path, notice: 'Link was deleted' + redirect_to admin_links_path, notice: 'Link was deleted' end private diff --git a/app/controllers/passive_skills_controller.rb b/app/controllers/admin/passive_skills_controller.rb similarity index 76% rename from app/controllers/passive_skills_controller.rb rename to app/controllers/admin/passive_skills_controller.rb index 4246406..97ed963 100644 --- a/app/controllers/passive_skills_controller.rb +++ b/app/controllers/admin/passive_skills_controller.rb @@ -1,4 +1,4 @@ -class PassiveSkillsController < ApplicationController +class Admin::PassiveSkillsController < Admin::BaseController before_action :set_passive_skill, only: [:show, :edit, :update, :destroy] after_action :verify_authorized @@ -24,7 +24,7 @@ class PassiveSkillsController < ApplicationController authorize @passive_skill if @passive_skill.save - redirect_to passive_skills_path, notice: 'Passive Skill was created' + redirect_to admin_passive_skills_path, notice: 'Passive Skill was created' else render :new end @@ -38,7 +38,7 @@ class PassiveSkillsController < ApplicationController authorize @passive_skill if @passive_skill.update(passive_skill_params) - redirect_to passive_skills_path, notice: 'Passive Skill was updated' + redirect_to admin_passive_skills_path, notice: 'Passive Skill was updated' else render :edit end @@ -49,7 +49,7 @@ class PassiveSkillsController < ApplicationController @passive_skill.destroy - redirect_to passive_skills_path, notice: 'Passive Skill was deleted' + redirect_to admin_passive_skills_path, notice: 'Passive Skill was deleted' end private diff --git a/app/controllers/rarities_controller.rb b/app/controllers/admin/rarities_controller.rb similarity index 94% rename from app/controllers/rarities_controller.rb rename to app/controllers/admin/rarities_controller.rb index 1304c7b..835bd32 100644 --- a/app/controllers/rarities_controller.rb +++ b/app/controllers/admin/rarities_controller.rb @@ -1,4 +1,4 @@ -class RaritiesController < ApplicationController +class Admin::RaritiesController < Admin::BaseController before_action :set_rarity, only: [:show, :edit, :update, :destroy] after_action :verify_authorized diff --git a/app/controllers/super_attacks_controller.rb b/app/controllers/admin/super_attacks_controller.rb similarity index 76% rename from app/controllers/super_attacks_controller.rb rename to app/controllers/admin/super_attacks_controller.rb index f948bb0..caa408e 100644 --- a/app/controllers/super_attacks_controller.rb +++ b/app/controllers/admin/super_attacks_controller.rb @@ -1,4 +1,4 @@ -class SuperAttacksController < ApplicationController +class Admin::SuperAttacksController < Admin::BaseController before_action :set_super_attack, only: [:show, :edit, :update, :destroy] after_action :verify_authorized @@ -24,7 +24,7 @@ class SuperAttacksController < ApplicationController authorize @super_attack if @super_attack.save - redirect_to super_attacks_path, notice: 'Super Attack was created' + redirect_to admin_super_attacks_path, notice: 'Super Attack was created' else render :new end @@ -38,7 +38,7 @@ class SuperAttacksController < ApplicationController authorize @super_attack if @super_attack.update(super_attack_params) - redirect_to super_attacks_path, notice: 'Super Attack was updated' + redirect_to admin_super_attacks_path, notice: 'Super Attack was updated' else render :edit end @@ -49,7 +49,7 @@ class SuperAttacksController < ApplicationController @super_attack.destroy - redirect_to super_attacks_path, notice: 'Super Attack was deleted' + redirect_to admin_super_attacks_path, notice: 'Super Attack was deleted' end private diff --git a/app/controllers/types_controller.rb b/app/controllers/admin/types_controller.rb similarity index 75% rename from app/controllers/types_controller.rb rename to app/controllers/admin/types_controller.rb index 3577c73..95e6817 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/admin/types_controller.rb @@ -1,4 +1,4 @@ -class TypesController < ApplicationController +class Admin::TypesController < Admin::BaseController before_action :set_type, only: [:show, :edit, :update, :destroy] after_action :verify_authorized @@ -23,7 +23,7 @@ class TypesController < ApplicationController authorize @type if @type.save - redirect_to types_path, notice: 'Type was created' + redirect_to admin_types_path, notice: 'Type was created' else render :new end @@ -37,7 +37,7 @@ class TypesController < ApplicationController authorize @type if @type.update(type_params) - redirect_to types_path, notice: 'Type was updated' + redirect_to admin_types_path, notice: 'Type was updated' else render :edit end @@ -48,7 +48,7 @@ class TypesController < ApplicationController @type.destroy - redirect_to types_path, notice: 'Type was deleted' + redirect_to admin_types_path, notice: 'Type was deleted' end private diff --git a/app/controllers/users_controller.rb b/app/controllers/admin/users_controller.rb similarity index 75% rename from app/controllers/users_controller.rb rename to app/controllers/admin/users_controller.rb index 91d0455..368481c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,4 +1,4 @@ -class UsersController < ApplicationController +class Admin::UsersController < Admin::BaseController before_action :set_user, only: [:show, :edit, :update, :destroy] after_action :verify_authorized @@ -20,7 +20,7 @@ class UsersController < ApplicationController authorize @user if @user.update(user_params) - redirect_to users_path, notice: 'User was updated' + redirect_to admin_users_path, notice: 'User was updated' else render :edit end @@ -31,7 +31,7 @@ class UsersController < ApplicationController @user.destroy - redirect_to users_path, notice: 'User was deleted' + redirect_to admin_users_path, notice: 'User was deleted' end private diff --git a/app/helpers/admin/dashboard_helper.rb b/app/helpers/admin/dashboard_helper.rb new file mode 100644 index 0000000..4052b7c --- /dev/null +++ b/app/helpers/admin/dashboard_helper.rb @@ -0,0 +1,2 @@ +module Admin::DashboardHelper +end diff --git a/app/policies/admin_dashboard_policy.rb b/app/policies/admin_dashboard_policy.rb new file mode 100644 index 0000000..cf6ef58 --- /dev/null +++ b/app/policies/admin_dashboard_policy.rb @@ -0,0 +1,5 @@ +class AdminDashboardPolicy < Struct.new(:user, :admin_dashbard) + def index? + user.admin? || user.moderator? + end +end diff --git a/app/views/admin/_navbar.html.slim b/app/views/admin/_navbar.html.slim new file mode 100644 index 0000000..318e75f --- /dev/null +++ b/app/views/admin/_navbar.html.slim @@ -0,0 +1,49 @@ +.navbar.navbar-default.navbar-static-top.navbar-custom + .container + .navbar-header + button.navbar-toggle.collapsed type='button' data-toggle='collapse' data-target='.navbar-collapse' + span.sr-only Toggle navigation + span.icon-bar + span.icon-bar + span.icon-bar + = link_to 'DBZDokkan', root_path, class: 'navbar-brand' + .collapse.navbar-collapse + ul.nav.navbar-nav + li= link_to 'Administration', admin_root_path + ul.nav.navbar-nav.navbar-right + - if policy(:link).index? || policy(:leader_skill).index? || policy(:passive_skill).index? || policy(:super_attack).index? + li.dropdown + a href='#' class='dropdown-toggle' data-toggle='dropdown' + = 'Abilities ' + span class='caret' + ul.dropdown-menu + - if policy(:link).index? + li= link_to 'Links', admin_links_path + - if policy(:leader_skill).index? + li= link_to 'Leader Skills', admin_leader_skills_path + - if policy(:passive_skill).index? + li= link_to 'Passive Skills', admin_passive_skills_path + - if policy(:super_attack).index? + li= link_to 'Super Attacks', admin_super_attacks_path + - if policy(:card).index? + li= nav_link_to 'Cards', admin_cards_path + - if policy(:character).index? + li= nav_link_to 'Characters', admin_characters_path + - if policy(:awaken_type).index? || policy(:rarity).index? || policy(:type).index? + li.dropdown + a href='#' class='dropdown-toggle' data-toggle='dropdown' + = 'Others ' + span class='caret' + ul.dropdown-menu + - if policy(:awaken_type).index? + li= link_to 'Awaken Types', admin_awaken_types_path + - if policy(:rarity).index? + li= link_to 'Rarities', admin_rarities_path + - if policy(:type).index? + li= link_to 'Types', admin_types_path + - if policy(:user).index? + li= nav_link_to 'Users', admin_users_path + - if logged_in? + li= link_to 'Log Out', logout_path, method: :delete + - else + li= link_to 'Log In', login_path(:reddit) diff --git a/app/views/characters/_form.html.slim b/app/views/admin/awaken_types/_form.html.slim similarity index 60% rename from app/views/characters/_form.html.slim rename to app/views/admin/awaken_types/_form.html.slim index 36b96cf..673bcdd 100644 --- a/app/views/characters/_form.html.slim +++ b/app/views/admin/awaken_types/_form.html.slim @@ -1,4 +1,4 @@ -= simple_form_for @character do |f| += simple_form_for [:admin, @awaken_type] do |f| .form-inputs = f.input :name .form-actions diff --git a/app/views/awaken_types/edit.html.slim b/app/views/admin/awaken_types/edit.html.slim similarity index 100% rename from app/views/awaken_types/edit.html.slim rename to app/views/admin/awaken_types/edit.html.slim diff --git a/app/views/awaken_types/index.html.slim b/app/views/admin/awaken_types/index.html.slim similarity index 68% rename from app/views/awaken_types/index.html.slim rename to app/views/admin/awaken_types/index.html.slim index 51226b7..b1235ca 100644 --- a/app/views/awaken_types/index.html.slim +++ b/app/views/admin/awaken_types/index.html.slim @@ -2,7 +2,7 @@ .row .col-md-12 .pull-right - = link_to 'New Awaken Type', new_awaken_type_path, class: 'btn btn-primary' + = link_to 'New Awaken Type', new_admin_awaken_type_path, class: 'btn btn-primary' .row .col-md-12 @@ -17,11 +17,11 @@ td= awaken_type.name td - if policy(:awaken_type).edit? - = link_to glyph('edit', classes: 'control-icon'), edit_awaken_type_path(awaken_type) + = link_to glyph('edit', classes: 'control-icon'), edit_admin_awaken_type_path(awaken_type) - if policy(:awaken_type).destroy? - = link_to glyph('trash', classes: 'control-icon'), awaken_type_path(awaken_type), method: :delete + = link_to glyph('trash', classes: 'control-icon'), admin_awaken_type_path(awaken_type), method: :delete - if policy(:awaken_type).new? .row .col-md-12 - = link_to 'New Awaken Type', new_awaken_type_path, class: 'btn btn-primary' + = link_to 'New Awaken Type', new_admin_awaken_type_path, class: 'btn btn-primary' diff --git a/app/views/awaken_types/new.html.slim b/app/views/admin/awaken_types/new.html.slim similarity index 100% rename from app/views/awaken_types/new.html.slim rename to app/views/admin/awaken_types/new.html.slim diff --git a/app/views/cards/_form.html.slim b/app/views/admin/cards/_form.html.slim similarity index 95% rename from app/views/cards/_form.html.slim rename to app/views/admin/cards/_form.html.slim index a327bc8..6ffc0a4 100644 --- a/app/views/cards/_form.html.slim +++ b/app/views/admin/cards/_form.html.slim @@ -1,4 +1,4 @@ -= simple_form_for @card do |f| += simple_form_for [:admin, @card] do |f| .form-inputs .row .col-md-4 diff --git a/app/views/cards/edit.html.slim b/app/views/admin/cards/edit.html.slim similarity index 100% rename from app/views/cards/edit.html.slim rename to app/views/admin/cards/edit.html.slim diff --git a/app/views/cards/index.html.slim b/app/views/admin/cards/index.html.slim similarity index 72% rename from app/views/cards/index.html.slim rename to app/views/admin/cards/index.html.slim index 80d33d2..762086f 100644 --- a/app/views/cards/index.html.slim +++ b/app/views/admin/cards/index.html.slim @@ -2,7 +2,7 @@ .row .col-md-12 .pull-right - = link_to 'New Card', new_card_path, class: 'btn btn-primary' + = link_to 'New Card', new_admin_card_path, class: 'btn btn-primary' .row .col-md-12 @@ -19,11 +19,11 @@ td= card.title td - if policy(:card).edit? - = link_to glyph('edit', classes: 'control-icon'), edit_card_path(card) + = link_to glyph('edit', classes: 'control-icon'), edit_admin_card_path(card) - if policy(:card).destroy? - = link_to glyph('trash', classes: 'control-icon'), card_path(card), method: :delete + = link_to glyph('trash', classes: 'control-icon'), admin_card_path(card), method: :delete - if policy(:card).new? .row .col-md-12 - = link_to 'New Card', new_card_path, class: 'btn btn-primary' + = link_to 'New Card', new_admin_card_path, class: 'btn btn-primary' diff --git a/app/views/cards/new.html.slim b/app/views/admin/cards/new.html.slim similarity index 100% rename from app/views/cards/new.html.slim rename to app/views/admin/cards/new.html.slim diff --git a/app/views/awaken_types/_form.html.slim b/app/views/admin/characters/_form.html.slim similarity index 61% rename from app/views/awaken_types/_form.html.slim rename to app/views/admin/characters/_form.html.slim index f9451c1..00d446a 100644 --- a/app/views/awaken_types/_form.html.slim +++ b/app/views/admin/characters/_form.html.slim @@ -1,4 +1,4 @@ -= simple_form_for @awaken_type do |f| += simple_form_for [:admin, @character] do |f| .form-inputs = f.input :name .form-actions diff --git a/app/views/characters/edit.html.slim b/app/views/admin/characters/edit.html.slim similarity index 100% rename from app/views/characters/edit.html.slim rename to app/views/admin/characters/edit.html.slim diff --git a/app/views/characters/index.html.slim b/app/views/admin/characters/index.html.slim similarity index 68% rename from app/views/characters/index.html.slim rename to app/views/admin/characters/index.html.slim index 6eaf687..394ab22 100644 --- a/app/views/characters/index.html.slim +++ b/app/views/admin/characters/index.html.slim @@ -2,7 +2,7 @@ .row .col-md-12 .pull-right - = link_to 'New Character', new_character_path, class: 'btn btn-primary' + = link_to 'New Character', new_admin_character_path, class: 'btn btn-primary' .row .col-md-12 @@ -17,11 +17,11 @@ td= character.name td - if policy(:character).edit? - = link_to glyph('edit', classes: 'control-icon'), edit_character_path(character) + = link_to glyph('edit', classes: 'control-icon'), edit_admin_character_path(character) - if policy(:character).destroy? - = link_to glyph('trash', classes: 'control-icon'), character_path(character), method: :delete + = link_to glyph('trash', classes: 'control-icon'), admin_character_path(character), method: :delete - if policy(:character).new? .row .col-md-12 - = link_to 'New Character', new_character_path, class: 'btn btn-primary' + = link_to 'New Character', new_admin_character_path, class: 'btn btn-primary' diff --git a/app/views/characters/new.html.slim b/app/views/admin/characters/new.html.slim similarity index 100% rename from app/views/characters/new.html.slim rename to app/views/admin/characters/new.html.slim diff --git a/app/views/admin/dashboard/index.html.slim b/app/views/admin/dashboard/index.html.slim new file mode 100644 index 0000000..382c996 --- /dev/null +++ b/app/views/admin/dashboard/index.html.slim @@ -0,0 +1 @@ +Admin dashboard diff --git a/app/views/leader_skills/_form.html.slim b/app/views/admin/leader_skills/_form.html.slim similarity index 62% rename from app/views/leader_skills/_form.html.slim rename to app/views/admin/leader_skills/_form.html.slim index df2300c..629a4c6 100644 --- a/app/views/leader_skills/_form.html.slim +++ b/app/views/admin/leader_skills/_form.html.slim @@ -1,4 +1,4 @@ -= simple_form_for @leader_skill do |f| += simple_form_for [:admin, @leader_skill] do |f| .form-inputs = f.input :description .form-actions diff --git a/app/views/leader_skills/edit.html.slim b/app/views/admin/leader_skills/edit.html.slim similarity index 100% rename from app/views/leader_skills/edit.html.slim rename to app/views/admin/leader_skills/edit.html.slim diff --git a/app/views/leader_skills/index.html.slim b/app/views/admin/leader_skills/index.html.slim similarity index 68% rename from app/views/leader_skills/index.html.slim rename to app/views/admin/leader_skills/index.html.slim index 6ed13d6..5508532 100644 --- a/app/views/leader_skills/index.html.slim +++ b/app/views/admin/leader_skills/index.html.slim @@ -2,7 +2,7 @@ .row .col-md-12 .pull-right - = link_to 'New Leader Skill', new_leader_skill_path, class: 'btn btn-primary' + = link_to 'New Leader Skill', new_admin_leader_skill_path, class: 'btn btn-primary' .row .col-md-12 @@ -17,11 +17,11 @@ td= leader_skill.description td - if policy(:leader_skill).edit? - = link_to glyph('edit', classes: 'control-icon'), edit_leader_skill_path(leader_skill) + = link_to glyph('edit', classes: 'control-icon'), edit_admin_leader_skill_path(leader_skill) - if policy(:leader_skill).destroy? - = link_to glyph('trash', classes: 'control-icon'), leader_skill_path(leader_skill), method: :delete + = link_to glyph('trash', classes: 'control-icon'), admin_leader_skill_path(leader_skill), method: :delete - if policy(:leader_skill).new? .row .col-md-12 - = link_to 'New Leader Skill', new_leader_skill_path, class: 'btn btn-primary' + = link_to 'New Leader Skill', new_admin_leader_skill_path, class: 'btn btn-primary' diff --git a/app/views/leader_skills/new.html.slim b/app/views/admin/leader_skills/new.html.slim similarity index 100% rename from app/views/leader_skills/new.html.slim rename to app/views/admin/leader_skills/new.html.slim diff --git a/app/views/passive_skills/_form.html.slim b/app/views/admin/links/_form.html.slim similarity index 71% rename from app/views/passive_skills/_form.html.slim rename to app/views/admin/links/_form.html.slim index 1f52871..6279e2b 100644 --- a/app/views/passive_skills/_form.html.slim +++ b/app/views/admin/links/_form.html.slim @@ -1,4 +1,4 @@ -= simple_form_for @passive_skill do |f| += simple_form_for [:admin, @link] do |f| .form-inputs = f.input :name = f.input :description diff --git a/app/views/links/edit.html.slim b/app/views/admin/links/edit.html.slim similarity index 100% rename from app/views/links/edit.html.slim rename to app/views/admin/links/edit.html.slim diff --git a/app/views/links/index.html.slim b/app/views/admin/links/index.html.slim similarity index 73% rename from app/views/links/index.html.slim rename to app/views/admin/links/index.html.slim index 86b4e4d..a96c8ee 100644 --- a/app/views/links/index.html.slim +++ b/app/views/admin/links/index.html.slim @@ -2,7 +2,7 @@ .row .col-md-12 .pull-right - = link_to 'New Link', new_link_path, class: 'btn btn-primary' + = link_to 'New Link', new_admin_link_path, class: 'btn btn-primary' .row .col-md-12 @@ -19,11 +19,11 @@ td= link.description td - if policy(:link).edit? - = link_to glyph('edit', classes: 'control-icon'), edit_link_path(link) + = link_to glyph('edit', classes: 'control-icon'), edit_admin_link_path(link) - if policy(:link).destroy? - = link_to glyph('trash', classes: 'control-icon'), link_path(link), method: :delete + = link_to glyph('trash', classes: 'control-icon'), admin_link_path(link), method: :delete - if policy(:link).new? .row .col-md-12 - = link_to 'New Link', new_link_path, class: 'btn btn-primary' + = link_to 'New Link', new_admin_link_path, class: 'btn btn-primary' diff --git a/app/views/links/new.html.slim b/app/views/admin/links/new.html.slim similarity index 100% rename from app/views/links/new.html.slim rename to app/views/admin/links/new.html.slim diff --git a/app/views/admin/passive_skills/_form.html.slim b/app/views/admin/passive_skills/_form.html.slim new file mode 100644 index 0000000..7824f6c --- /dev/null +++ b/app/views/admin/passive_skills/_form.html.slim @@ -0,0 +1,6 @@ += simple_form_for [:admin, @passive_skill] do |f| + .form-inputs + = f.input :name + = f.input :description + .form-actions + = f.button :button diff --git a/app/views/passive_skills/edit.html.slim b/app/views/admin/passive_skills/edit.html.slim similarity index 100% rename from app/views/passive_skills/edit.html.slim rename to app/views/admin/passive_skills/edit.html.slim diff --git a/app/views/passive_skills/index.html.slim b/app/views/admin/passive_skills/index.html.slim similarity index 69% rename from app/views/passive_skills/index.html.slim rename to app/views/admin/passive_skills/index.html.slim index 049cef0..f759990 100644 --- a/app/views/passive_skills/index.html.slim +++ b/app/views/admin/passive_skills/index.html.slim @@ -2,7 +2,7 @@ .row .col-md-12 .pull-right - = link_to 'New Passive Skill', new_passive_skill_path, class: 'btn btn-primary' + = link_to 'New Passive Skill', new_admin_passive_skill_path, class: 'btn btn-primary' .row .col-md-12 @@ -19,11 +19,11 @@ td= passive_skill.description td - if policy(:passive_skill).edit? - = link_to glyph('edit', classes: 'control-icon'), edit_passive_skill_path(passive_skill) + = link_to glyph('edit', classes: 'control-icon'), edit_admin_passive_skill_path(passive_skill) - if policy(:passive_skill).destroy? - = link_to glyph('trash', classes: 'control-icon'), passive_skill_path(passive_skill), method: :delete + = link_to glyph('trash', classes: 'control-icon'), admin_passive_skill_path(passive_skill), method: :delete - if policy(:passive_skill).new? .row .col-md-12 - = link_to 'New Passive Skill', new_passive_skill_path, class: 'btn btn-primary' + = link_to 'New Passive Skill', new_admin_passive_skill_path, class: 'btn btn-primary' diff --git a/app/views/passive_skills/new.html.slim b/app/views/admin/passive_skills/new.html.slim similarity index 100% rename from app/views/passive_skills/new.html.slim rename to app/views/admin/passive_skills/new.html.slim diff --git a/app/views/links/_form.html.slim b/app/views/admin/rarities/_form.html.slim similarity index 70% rename from app/views/links/_form.html.slim rename to app/views/admin/rarities/_form.html.slim index e868a8b..e74ef34 100644 --- a/app/views/links/_form.html.slim +++ b/app/views/admin/rarities/_form.html.slim @@ -1,4 +1,4 @@ -= simple_form_for @link do |f| += simple_form_for [:admin, @rarity] do |f| .form-inputs = f.input :name = f.input :description diff --git a/app/views/rarities/edit.html.slim b/app/views/admin/rarities/edit.html.slim similarity index 100% rename from app/views/rarities/edit.html.slim rename to app/views/admin/rarities/edit.html.slim diff --git a/app/views/rarities/index.html.slim b/app/views/admin/rarities/index.html.slim similarity index 72% rename from app/views/rarities/index.html.slim rename to app/views/admin/rarities/index.html.slim index e1a9102..d2a2cc6 100644 --- a/app/views/rarities/index.html.slim +++ b/app/views/admin/rarities/index.html.slim @@ -2,7 +2,7 @@ .row .col-md-12 .pull-right - = link_to 'New Rarity', new_rarity_path, class: 'btn btn-primary' + = link_to 'New Rarity', new_admin_rarity_path, class: 'btn btn-primary' .row .col-md-12 @@ -19,11 +19,11 @@ td= rarity.description td - if policy(:rarity).edit? - = link_to glyph('edit', classes: 'control-icon'), edit_rarity_path(rarity) + = link_to glyph('edit', classes: 'control-icon'), edit_admin_rarity_path(rarity) - if policy(:rarity).destroy? - = link_to glyph('trash', classes: 'control-icon'), rarity_path(rarity), method: :delete + = link_to glyph('trash', classes: 'control-icon'), admin_rarity_path(rarity), method: :delete - if policy(:rarity).new? .row .col-md-12 - = link_to 'New Rarity', new_rarity_path, class: 'btn btn-primary' + = link_to 'New Rarity', new_admin_rarity_path, class: 'btn btn-primary' diff --git a/app/views/rarities/new.html.slim b/app/views/admin/rarities/new.html.slim similarity index 100% rename from app/views/rarities/new.html.slim rename to app/views/admin/rarities/new.html.slim diff --git a/app/views/super_attacks/_form.html.slim b/app/views/admin/super_attacks/_form.html.slim similarity index 67% rename from app/views/super_attacks/_form.html.slim rename to app/views/admin/super_attacks/_form.html.slim index b62f2b2..15166d2 100644 --- a/app/views/super_attacks/_form.html.slim +++ b/app/views/admin/super_attacks/_form.html.slim @@ -1,4 +1,4 @@ -= simple_form_for @super_attack do |f| += simple_form_for [:admin, @super_attack] do |f| .form-inputs = f.input :name = f.input :description diff --git a/app/views/super_attacks/edit.html.slim b/app/views/admin/super_attacks/edit.html.slim similarity index 100% rename from app/views/super_attacks/edit.html.slim rename to app/views/admin/super_attacks/edit.html.slim diff --git a/app/views/super_attacks/index.html.slim b/app/views/admin/super_attacks/index.html.slim similarity index 69% rename from app/views/super_attacks/index.html.slim rename to app/views/admin/super_attacks/index.html.slim index 66f7084..63ab747 100644 --- a/app/views/super_attacks/index.html.slim +++ b/app/views/admin/super_attacks/index.html.slim @@ -2,7 +2,7 @@ .row .col-md-12 .pull-right - = link_to 'New Super Attack', new_super_attack_path, class: 'btn btn-primary' + = link_to 'New Super Attack', new_admin_super_attack_path, class: 'btn btn-primary' .row .col-md-12 @@ -19,11 +19,11 @@ td= super_attack.description td - if policy(:super_attack).edit? - = link_to glyph('edit', classes: 'control-icon'), edit_super_attack_path(super_attack) + = link_to glyph('edit', classes: 'control-icon'), edit_admin_super_attack_path(super_attack) - if policy(:super_attack).destroy? - = link_to glyph('trash', classes: 'control-icon'), super_attack_path(super_attack), method: :delete + = link_to glyph('trash', classes: 'control-icon'), admin_super_attack_path(super_attack), method: :delete - if policy(:super_attack).new? .row .col-md-12 - = link_to 'New Super Attack', new_super_attack_path, class: 'btn btn-primary' + = link_to 'New Super Attack', new_admin_super_attack_path, class: 'btn btn-primary' diff --git a/app/views/super_attacks/new.html.slim b/app/views/admin/super_attacks/new.html.slim similarity index 100% rename from app/views/super_attacks/new.html.slim rename to app/views/admin/super_attacks/new.html.slim diff --git a/app/views/rarities/_form.html.slim b/app/views/admin/types/_form.html.slim similarity index 71% rename from app/views/rarities/_form.html.slim rename to app/views/admin/types/_form.html.slim index dbbac98..d5f10b7 100644 --- a/app/views/rarities/_form.html.slim +++ b/app/views/admin/types/_form.html.slim @@ -1,4 +1,4 @@ -= simple_form_for @rarity do |f| += simple_form_for [:admin, @type] do |f| .form-inputs = f.input :name = f.input :description diff --git a/app/views/types/edit.html.slim b/app/views/admin/types/edit.html.slim similarity index 100% rename from app/views/types/edit.html.slim rename to app/views/admin/types/edit.html.slim diff --git a/app/views/types/index.html.slim b/app/views/admin/types/index.html.slim similarity index 73% rename from app/views/types/index.html.slim rename to app/views/admin/types/index.html.slim index cb1afbe..bffae52 100644 --- a/app/views/types/index.html.slim +++ b/app/views/admin/types/index.html.slim @@ -2,7 +2,7 @@ .row .col-md-12 .pull-right - = link_to 'New Type', new_type_path, class: 'btn btn-primary' + = link_to 'New Type', new_admin_type_path, class: 'btn btn-primary' .row .col-md-12 @@ -19,11 +19,11 @@ td= type.description td - if policy(:type).edit? - = link_to glyph('edit', classes: 'control-icon'), edit_type_path(type) + = link_to glyph('edit', classes: 'control-icon'), edit_admin_type_path(type) - if policy(:type).destroy? - = link_to glyph('trash', classes: 'control-icon'), type_path(type), method: :delete + = link_to glyph('trash', classes: 'control-icon'), admin_type_path(type), method: :delete - if policy(:type).new? .row .col-md-12 - = link_to 'New Type', new_type_path, class: 'btn btn-primary' + = link_to 'New Type', new_admin_type_path, class: 'btn btn-primary' diff --git a/app/views/types/new.html.slim b/app/views/admin/types/new.html.slim similarity index 100% rename from app/views/types/new.html.slim rename to app/views/admin/types/new.html.slim diff --git a/app/views/users/_form.html.slim b/app/views/admin/users/_form.html.slim similarity index 70% rename from app/views/users/_form.html.slim rename to app/views/admin/users/_form.html.slim index 6ace3b6..cfbf9e3 100644 --- a/app/views/users/_form.html.slim +++ b/app/views/admin/users/_form.html.slim @@ -1,4 +1,4 @@ -= simple_form_for @user do |f| += simple_form_for [:admin, @user] do |f| .form-inputs = f.association :roles, as: :check_boxes .form-actions diff --git a/app/views/users/edit.html.slim b/app/views/admin/users/edit.html.slim similarity index 100% rename from app/views/users/edit.html.slim rename to app/views/admin/users/edit.html.slim diff --git a/app/views/users/index.html.slim b/app/views/admin/users/index.html.slim similarity index 86% rename from app/views/users/index.html.slim rename to app/views/admin/users/index.html.slim index d833b33..ac71c37 100644 --- a/app/views/users/index.html.slim +++ b/app/views/admin/users/index.html.slim @@ -11,6 +11,6 @@ td= user.nickname td - if policy(:user).edit? - = link_to glyph('edit', classes: 'control-icon'), edit_user_path(user) + = link_to glyph('edit', classes: 'control-icon'), edit_admin_user_path(user) - if policy(:user).destroy? - = link_to glyph('trash', classes: 'control-icon'), user_path(user), method: :delete + = link_to glyph('trash', classes: 'control-icon'), admin_user_path(user), method: :delete diff --git a/app/views/application/_navbar.html.slim b/app/views/application/_navbar.html.slim index 76d560f..ce36b64 100644 --- a/app/views/application/_navbar.html.slim +++ b/app/views/application/_navbar.html.slim @@ -9,44 +9,8 @@ = link_to 'DBZDokkan', root_path, class: 'navbar-brand' .collapse.navbar-collapse ul.nav.navbar-nav.navbar-right - - if policy(:user).index? - li.dropdown - a href='#' class='dropdown-toggle' data-toggle='dropdown' - = 'Admin ' - span class='caret' - ul.dropdown-menu - - if policy(:user).index? - li= link_to 'Users', users_path - - if policy(:link).index? || policy(:leader_skill).index? || policy(:passive_skill).index? || policy(:super_attack).index? - li.dropdown - a href='#' class='dropdown-toggle' data-toggle='dropdown' - = 'Abilities ' - span class='caret' - ul.dropdown-menu - - if policy(:link).index? - li= link_to 'Links', links_path - - if policy(:leader_skill).index? - li= link_to 'Leader Skills', leader_skills_path - - if policy(:passive_skill).index? - li= link_to 'Passive Skills', passive_skills_path - - if policy(:super_attack).index? - li= link_to 'Super Attacks', super_attacks_path - - if policy(:card).index? - li= nav_link_to 'Cards', cards_path - - if policy(:character).index? - li= nav_link_to 'Characters', characters_path - - if policy(:awaken_type).index? || policy(:rarity).index? || policy(:type).index? - li.dropdown - a href='#' class='dropdown-toggle' data-toggle='dropdown' - = 'Others ' - span class='caret' - ul.dropdown-menu - - if policy(:awaken_type).index? - li= link_to 'Awaken Types', awaken_types_path - - if policy(:rarity).index? - li= link_to 'Rarities', rarities_path - - if policy(:type).index? - li= link_to 'Types', types_path + - if policy(:admin_dashboard).index? + li= nav_link_to 'Administration', admin_root_path - if logged_in? li= link_to 'Log Out', logout_path, method: :delete - else diff --git a/app/views/layouts/admin.html.slim b/app/views/layouts/admin.html.slim new file mode 100644 index 0000000..b4338cb --- /dev/null +++ b/app/views/layouts/admin.html.slim @@ -0,0 +1,18 @@ +doctype html +html + head + meta charset="utf-8" + meta http-equiv="X-UA-Compatible" content="IE=edge" + meta name="viewport" content="width=device-width, initial-scale=1" + title= "DBZDokkan - #{page_title}" + = stylesheet_link_tag 'application', media: 'all' + = javascript_include_tag 'application' + = csrf_meta_tags + + body + == render 'admin/navbar' + .container + == render 'flash_messages', flash: flash + .container + h1= page_title + = yield diff --git a/app/views/types/_form.html.slim b/app/views/types/_form.html.slim deleted file mode 100644 index e78f58e..0000000 --- a/app/views/types/_form.html.slim +++ /dev/null @@ -1,6 +0,0 @@ -= simple_form_for @type do |f| - .form-inputs - = f.input :name - = f.input :description - .form-actions - = f.button :button diff --git a/config/routes.rb b/config/routes.rb index 390ddd9..be64e71 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,20 +3,27 @@ Rails.application.routes.draw do get 'auth/failure', to: 'sessions#failure' delete 'logout', to: 'sessions#destroy', as: 'logout' - resources :awaken_types - resources :cards - resources :characters - resources :leader_skills - resources :links - resources :passive_skills - resources :rarities - resources :super_attacks - resources :types - resources :users, except: [:new, :create] - resources :welcome, only: [:index] + get '/welcome', to: 'welcome#index' root to: 'welcome#index' + namespace :admin do + root to: 'dashboard#index' + + get '/dashboard', to: 'dashboard#index' + + resources :awaken_types + resources :cards + resources :characters + resources :leader_skills + resources :links + resources :passive_skills + resources :rarities + resources :super_attacks + resources :types + resources :users, except: [:new, :create] + end + namespace :api do namespace :v1 do resources :cards, only: [:index, :show]