-
-
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.
admin controller, #326, without tests
- Loading branch information
1 parent
4276198
commit 12769a4
Showing
29 changed files
with
297 additions
and
386 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
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,9 @@ | ||
class AdminController < ApplicationController | ||
before_action :require_admin | ||
|
||
def require_admin | ||
unless current_user.is_superadmin? | ||
redirect_to root_path, flash: { error: "Access Denied. Only for SuperAdmin." } | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,5 @@ | ||
class OrganizationsController < ApplicationController | ||
def edit | ||
@organization = current_organization | ||
end | ||
|
||
def update | ||
@organization = current_organization | ||
if @organization.update(organization_params) | ||
redirect_to edit_organization_path(organization_id: current_organization.to_param), notice: "Updated organization!" | ||
else | ||
flash[:error] = "Failed to update organization" | ||
render :edit | ||
end | ||
end | ||
|
||
private | ||
|
||
def organization_params | ||
params.require(:organization).permit(:name, :short_name, :street, :city, :state, :zipcode, :email, :url, :logo, :intake_location) | ||
def show | ||
render 'admin/organizations/show' | ||
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
app/views/canonical_items/_form.html.erb → ...iews/admin/canonical_items/_form.html.erb
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 |
---|---|---|
|
@@ -36,4 +36,5 @@ | |
</div><!-- /.row --> | ||
</div><!-- /.box-body --> | ||
</div><!-- /.box --> | ||
</div> | ||
</section><!-- /.content --> |
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,12 @@ | ||
<tr> | ||
<td><%= organization_row.name %></td> | ||
<td><%= link_to organization_row.email, "mailto:#{organization_row.email}" %></td> | ||
<td class="text-right"> | ||
<%= link_to edit_admin_organization_path(organization_row.id), class: "btn btn-info btn-xs" do %> | ||
<%= fa_icon "edit" %> Edit | ||
<% end %> | ||
<%= link_to admin_organization_path(organization_row.id), method: :delete, data: { confirm: confirm_delete_msg(organization_row.name) }, class: "btn btn-danger btn-xs" do %> | ||
<%= fa_icon "trash" %> Delete | ||
<% end unless (Organization.count <= 1) %> | ||
</td> | ||
</tr> |
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,50 @@ | ||
<section class="content-header"> | ||
<% content_for :title, "Admin - Organizations" %> | ||
<h1> | ||
All Diaperbase Organizations | ||
<small></small> | ||
</h1> | ||
<ol class="breadcrumb"> | ||
<li><%= link_to(dashboard_path(organization_id: current_user.organization)) do %> | ||
<i class="fa fa-dashboard"></i> Home | ||
<% end %> | ||
</li> | ||
<li><a href="#">All Diaperbase organizations</a></li> | ||
</ol> | ||
</section> | ||
|
||
<!-- Main content --> | ||
<section class="content"> | ||
<!-- Default box --> | ||
<div class="box"> | ||
<div class="box-body"> | ||
<div class="text-right"> | ||
<%= link_to new_admin_organization_path, class: "btn btn-success" do %> | ||
<%= fa_icon "plus" %> Add New Organization | ||
<% end %> | ||
</div> | ||
<div class="row"> | ||
<div class="col-xs-12"> | ||
<!-- /.box-header --> | ||
<div class="box-body table-responsive no-padding"> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th>Organization</th> | ||
<th>Contact E-mail</th> | ||
<th class="text-right">Actions</th> | ||
|
||
</tr> | ||
</thead> | ||
<tbody> | ||
<%= render partial: "organization_row", collection: @organizations %> | ||
</tbody> | ||
</table> | ||
<!-- /.box-body --> | ||
</div> | ||
<!-- /.box --> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> |
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.