-
-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #493 from rubyforgood/326-admins-controller
WIP Fixes #326 Admins Controller, namespaced separately
- Loading branch information
Showing
107 changed files
with
2,210 additions
and
954 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,4 @@ pdx_db_test | |
.DS_Store | ||
.ruby-gemset | ||
/spec/example_failures.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
class Admin::BarcodeItemsController < AdminController | ||
def edit | ||
@barcode_item = BarcodeItem.find(params[:id]) | ||
end | ||
|
||
def update | ||
@barcode_item = BarcodeItem.find(params[:id]) | ||
if @barcode_item.update(barcode_item_params) | ||
redirect_to admin_barcode_items_path, notice: "Updated Barcode Item!" | ||
else | ||
flash[:error] = "Failed to update this Barcode Item." | ||
render :edit | ||
end | ||
end | ||
|
||
def index | ||
@barcode_items = BarcodeItem.all | ||
end | ||
|
||
def new | ||
@barcode_item = BarcodeItem.new | ||
end | ||
|
||
def create | ||
@barcode_item = BarcodeItem.create(barcode_item_params) | ||
if @barcode_item.save | ||
redirect_to admin_barcode_items_path, notice: "Barcode Item added!" | ||
else | ||
flash[:error] = "Failed to create Barcode Item." | ||
render :new | ||
end | ||
end | ||
|
||
def show | ||
@barcode_item = BarcodeItem.includes(items: [:organization]).find(params[:id]) | ||
@items = @barcode_item.items | ||
end | ||
|
||
def destroy | ||
@barcode_item = BarcodeItem.find(params[:id]) | ||
if @barcode_item.destroy | ||
redirect_to admin_barcode_items_path, notice: "Barcode Item deleted!" | ||
else | ||
redirect_to admin_barcode_items_path, alert: "Failed to delete Barcode Item." | ||
end | ||
end | ||
|
||
private | ||
|
||
def barcode_item_params | ||
params.require(:barcode_item).permit(:name, :key, :category) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class Admin::UsersController < AdminController | ||
def index | ||
@users = User.all | ||
end | ||
|
||
def update; end | ||
|
||
def new | ||
@user = User.new | ||
@organizations = Organization.all | ||
end | ||
|
||
def create | ||
@user = User.new(user_params) | ||
|
||
if @user.save | ||
@user.invite!(@user) | ||
redirect_to admin_users_path, notice: "Created a new user!" | ||
else | ||
flash[:error] = "Failed to create user" | ||
render "admin/users/new" | ||
end | ||
end | ||
|
||
def destroy | ||
@user = User.find_by(id: params[:id]) | ||
if @user.present? | ||
@user.destroy | ||
redirect_to admin_users_path, notice: "Deleted that user" | ||
else | ||
redirect_to admin_users_path, flash: { error: "Couldn't find that user, sorry" } | ||
end | ||
end | ||
|
||
private | ||
|
||
def user_params | ||
params.require(:user).permit(:name, :organization_id, :email, :password, :password_confirmation) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class AdminController < ApplicationController | ||
before_action :require_admin | ||
layout "admin" | ||
|
||
def require_admin | ||
verboten! unless current_user.super_admin? | ||
end | ||
|
||
def dashboard; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.