Role: progress

master
E. Almqvist 3 years ago
parent 9364de7040
commit 1747cbf8f0
  1. 1
      src/app.rb
  2. 6
      src/const.rb
  3. 22
      src/db_models.rb

@ -9,6 +9,7 @@ require "sqlite3" # db
require "sassc" # SASS -> CSS precompiler
require "colorize" # colors for debug
require "bcrypt" # password digest
# TODO: remove redcarpet dep
require "redcarpet" # markdown renderer
require "mini_magick" # image manipulation

@ -1,3 +1,9 @@
BAD_REP = -1
NEUTRAL_REP = 0
GOOD_REP = 1
PERM_LEVELS = {
post: 0, # allows the user to post auctions
rmpost: 1, # allows the user to remove other peoples auctions
roleman: 2 # allows the user to manage other peoples roles
}

@ -112,3 +112,25 @@ class User < EntityModel
return true, user.id
end
end
class Role < EntityModel
attr_reader :name, :color, :perm_level
def initialize(role_info)
super role_info
@name = role_info["name"]
@color = role_info["color"]
@perm_level = role_info["perm_level"]
# perm_level follow the UNIX perms system
end
def self.find_by_id(id)
data = self.get("*", "id = ?", id).first
data && Role.new(data)
end
def self.find_by_name(name)
data = self.get("*", "name = ?", name).first
data && Role.new(data)
end
end

Loading…
Cancel
Save