-
Notifications
You must be signed in to change notification settings - Fork 2
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 #451 from wearepal/admin-panel
basic admin panel
- Loading branch information
Showing
8 changed files
with
113 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the admin controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: https://sass-lang.com/ |
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 @@ | ||
class AdminController < ApplicationController | ||
|
||
def index | ||
if current_user.admin? | ||
@users = User.all | ||
@teams = Team.all | ||
authorize! | ||
else | ||
redirect_to root_path | ||
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module AdminHelper | ||
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<div class="card"> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Email</th> | ||
<th>Admin</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% User.order(:name).each do |user| %> | ||
<tr> | ||
<td><%= user.name %></td> | ||
<td><%= user.email %></td> | ||
<td><%= user.admin? ? "✅" : "❌" %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Kew RGB 25cm</th> | ||
<th>Kew Samples</th> | ||
<th>DEFRA Hedgerows</th> | ||
<th>NATMAP</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @teams.each do |team| %> | ||
<tr> | ||
<td><%= team.name %></td> | ||
<td> | ||
<%= button_to team.permission('kew_rgb25cm') ? "✅" : "❌", | ||
toggle_permission_team_path(team, permission_key: 'kew_rgb25cm'), | ||
method: :patch, | ||
class: "btn btn-sm btn-light" %> | ||
</td> | ||
<td> | ||
<%= button_to team.permission('kew_samples') ? "✅" : "❌", | ||
toggle_permission_team_path(team, permission_key: 'kew_samples'), | ||
method: :patch, | ||
class: "btn btn-sm btn-light" %> | ||
</td> | ||
<td> | ||
<%= button_to team.permission('defra_hedgerows') ? "✅" : "❌", | ||
toggle_permission_team_path(team, permission_key: 'defra_hedgerows'), | ||
method: :patch, | ||
class: "btn btn-sm btn-light" %> | ||
</td> | ||
<td> | ||
<%= button_to team.permission('natmap_soil') ? "✅" : "❌", | ||
toggle_permission_team_path(team, permission_key: 'natmap_soil'), | ||
method: :patch, | ||
class: "btn btn-sm btn-light" %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> |
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