added moderator to users

This commit is contained in:
nilsding 2014-12-26 13:04:05 +01:00
parent f403a0a2f8
commit 9e918fa3dc
5 changed files with 38 additions and 1 deletions

View File

@ -72,6 +72,26 @@ namespace :justask do
user.save!
puts "#{user.screen_name} no longer an admin."
end
desc "Gives moderator status to an user."
task :mod, [:screen_name] => :environment do |t, args|
fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name])
fail "user #{args[:screen_name]} not found" if user.nil?
user.moderator = true
user.save!
puts "#{user.screen_name} is now an moderator."
end
desc "Removes moderator status from an user."
task :demod, [:screen_name] => :environment do |t, args|
fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name])
fail "user #{args[:screen_name]} not found" if user.nil?
user.moderator = false
user.save!
puts "#{user.screen_name} no longer an moderator."
end
desc "Lists all users."
task lusers: :environment do

View File

@ -22,6 +22,13 @@
font-size: 80%;
}
.profile--moderator {
color: $brand-warning;
text-transform: uppercase;
font-weight: bold;
font-size: 80%;
}
.profile--text {
margin-bottom: 2px;
}

View File

@ -13,6 +13,10 @@
%p.profile--admin
%i.fa.fa-flask
Admin
- if @user.moderator?
%p.profile--moderator
%i.fa.fa-users
Mod
- unless @user.bio.blank?
%p.profile--text= @user.bio
- unless @user.website.blank?

View File

@ -0,0 +1,5 @@
class AddModeratorToUsers < ActiveRecord::Migration
def change
add_column :users, :moderator, :boolean, default: false, null: false
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20141213182609) do
ActiveRecord::Schema.define(version: 20141226115905) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -127,6 +127,7 @@ ActiveRecord::Schema.define(version: 20141213182609) do
t.string "website", default: "", null: false
t.string "location", default: "", null: false
t.text "bio", default: "", null: false
t.boolean "moderator", default: false, null: false
end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree