master
E. Almqvist 3 years ago
parent 8b15c0aadf
commit 67838b149c
  1. 5
      src/app.rb
  2. 68
      src/views/admin/index.slim
  3. 13
      src/views/stylesheets/style.sass

@ -220,7 +220,6 @@ get "/auctions/:id" do
end
end
# Admin panel
get "/admin" do
flags = get_current_user.flags
@ -238,7 +237,7 @@ end
def role_check(id)
no_go_away if ROLE_IDS.include? id
auth_denied if get_current_user.permitted? :roleman
auth_denied unless get_current_user.permitted? :roleman
end
get "/admin/roles/:id/delete" do
@ -274,7 +273,7 @@ end
post "/admin/roles/:id/update" do
id = params[:id].to_i
user = get_current_user
auth_denied if user.permitted? :roleman
auth_denied unless user.permitted? :roleman
flags = params[:flags].to_i
flags = verify_flags(flags, user.flags)

@ -1,5 +1,46 @@
h1 Admin Panel
header
h1 Admin Panel
nav
ul.button-container
li
a.button href="#users" = "Manage Users"
li
a.button href="#roles" = "Roles"
li
a.button href="#auctions" = "Auctions"
li
a.button href="#categories" = "Category Settings"
#admin-panel
h2#users User Management
.management-container
article.card.border
h2 Add User to Role
.form-container
form action="/admin/roles/give" method="post"
label Select User
select name="user_id"
- User.get_all.each do |seluser|
option value="#{seluser.id}"
| #{seluser.name} (id=#{seluser.id})
label Select Role
select name="role_id"
- if session_user.admin?
- Role.get_all.each do |selrole|
option value="#{selrole.id}"
| #{selrole.name} (id=#{selrole.id})
- else
- session_user.roles.each do |selrole|
option value="#{selrole.id}"
| #{selrole.name} (id=#{selrole.id})
input type="submit" value="Add User"
h2#roles Role Management
.management-container
article.card.border
h2 Create Role
@ -16,6 +57,7 @@ h1 Admin Panel
input type="submit" value="Create role"
article.card.border
h2 Manage Roles
ul.list-container
@ -26,27 +68,3 @@ h1 Admin Panel
| [EDIT]
a.inlbutton href="/admin/roles/#{role.id}/delete"
| [DELETE]
article.card.border
h2 Add User to Role
.form-container
form action="/admin/roles/give" method="post"
label Select User
select name="user_id"
- User.get_all.each do |seluser|
option value="#{seluser.id}"
| #{seluser.name} (id=#{seluser.id})
label Select Role
select name="role_id"
- if session_user.admin?
- Role.get_all.each do |selrole|
option value="#{selrole.id}"
| #{selrole.name} (id=#{selrole.id})
- else
- session_user.roles.each do |selrole|
option value="#{selrole.id}"
| #{selrole.name} (id=#{selrole.id})
input type="submit" value="Add User"

@ -42,6 +42,13 @@ html
width: auto
height: 100%
header
background: $bg_clr
margin-bottom: 2rem
h1
text-align: center
.fade-in
animation: fade-in .5s ease-in alternate
@ -51,7 +58,6 @@ body
height: 100%
header
height: 48px
background-color: $bg_clr
padding: .1rem .8rem
white-space: nowrap
@ -421,6 +427,11 @@ ul.list-container
border: $border_size solid $border_clr
#admin-panel
h2
text-align: center
border-bottom: $border_size solid $shadow_clr
.management-container
display: flex
flex-wrap: wrap
justify-content: center

Loading…
Cancel
Save