From 9e918fa3dca6ab82b5a587b0739e861ba717149f Mon Sep 17 00:00:00 2001 From: nilsding Date: Fri, 26 Dec 2014 13:04:05 +0100 Subject: [PATCH] added moderator to users --- Rakefile | 20 +++++++++++++++++++ app/assets/stylesheets/scss/user.scss | 7 +++++++ app/views/user/_profile_info.html.haml | 4 ++++ .../20141226115905_add_moderator_to_users.rb | 5 +++++ db/schema.rb | 3 ++- 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20141226115905_add_moderator_to_users.rb diff --git a/Rakefile b/Rakefile index 7f7ed899..9634c893 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/app/assets/stylesheets/scss/user.scss b/app/assets/stylesheets/scss/user.scss index 896a8f4b..4dddb8c9 100644 --- a/app/assets/stylesheets/scss/user.scss +++ b/app/assets/stylesheets/scss/user.scss @@ -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; } diff --git a/app/views/user/_profile_info.html.haml b/app/views/user/_profile_info.html.haml index a9c59c48..f1a93121 100644 --- a/app/views/user/_profile_info.html.haml +++ b/app/views/user/_profile_info.html.haml @@ -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? diff --git a/db/migrate/20141226115905_add_moderator_to_users.rb b/db/migrate/20141226115905_add_moderator_to_users.rb new file mode 100644 index 00000000..4d8d77f1 --- /dev/null +++ b/db/migrate/20141226115905_add_moderator_to_users.rb @@ -0,0 +1,5 @@ +class AddModeratorToUsers < ActiveRecord::Migration + def change + add_column :users, :moderator, :boolean, default: false, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 472c55c1..4a7662d1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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