Changed 'no badge' check to be more reliable, added rake task for creating superadmin users
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<div class="user">
|
||||
<%= link_to user.name, user, class: "role #{user.role.name} #{"banned" if user.banned?} #{"disabled" if user.disabled?} #{"unconfirmed" unless user.confirmed?}", title: "#{user.ign} – #{user.role}", style: "color: #{fcolor(user.role.color)}; background-color: #{user.role.color}" %>
|
||||
<%= link_to user.badge.symbol, users_path(badge: user.badge.name), class: "role badge", title: user.badge.name, style: "color: #{fcolor(user.badge.color)}; background-color: #{user.badge.color}" unless user.badge.value == 0 %>
|
||||
<%= link_to user.badge.symbol, users_path(badge: user.badge.name), class: "role badge", title: user.badge.name, style: "color: #{fcolor(user.badge.color)}; background-color: #{user.badge.color}" unless user.badge.symbol.blank? %>
|
||||
</div>
|
||||
|
||||
@@ -5,4 +5,4 @@ class CreateRoles < ActiveRecord::Migration
|
||||
t.integer :value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,4 +23,4 @@ class CreateUsers < ActiveRecord::Migration
|
||||
t.timestamps null: true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
26
db/schema.rb
26
db/schema.rb
@@ -13,6 +13,12 @@
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170522210610) do
|
||||
|
||||
create_table "badges", force: :cascade do |t|
|
||||
t.string "name", limit: 191
|
||||
t.string "symbol", limit: 191
|
||||
t.string "color", limit: 191
|
||||
end
|
||||
|
||||
create_table "blogposts", force: :cascade do |t|
|
||||
t.string "title", limit: 191
|
||||
t.text "content", limit: 65535
|
||||
@@ -44,7 +50,7 @@ ActiveRecord::Schema.define(version: 20170522210610) do
|
||||
t.integer "role_read_id", limit: 4
|
||||
t.integer "role_write_id", limit: 4
|
||||
t.integer "forumgroup_id", limit: 4
|
||||
t.integer "necro_length", limit: 4, default: -1
|
||||
t.integer "necro_length", limit: 4
|
||||
end
|
||||
|
||||
create_table "forums_labels", id: false, force: :cascade do |t|
|
||||
@@ -95,12 +101,6 @@ ActiveRecord::Schema.define(version: 20170522210610) do
|
||||
t.string "color", limit: 191
|
||||
end
|
||||
|
||||
create_table "badges", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "symbol"
|
||||
t.string "color"
|
||||
end
|
||||
|
||||
create_table "sessions", force: :cascade do |t|
|
||||
t.string "session_id", limit: 191, null: false
|
||||
t.text "data", limit: 65535
|
||||
@@ -132,14 +132,13 @@ ActiveRecord::Schema.define(version: 20170522210610) do
|
||||
t.string "last_ip", limit: 191
|
||||
t.string "skype", limit: 191
|
||||
t.boolean "skype_public", default: false
|
||||
t.string "youtube"
|
||||
t.string "youtube_channelname"
|
||||
t.string "twitter"
|
||||
t.string "email_token"
|
||||
t.string "youtube", limit: 191
|
||||
t.string "youtube_channelname", limit: 191
|
||||
t.string "twitter", limit: 191
|
||||
t.string "email_token", limit: 191
|
||||
t.boolean "confirmed", default: false
|
||||
t.datetime "last_seen"
|
||||
t.integer "role_id", limit: 4, null: false
|
||||
t.integer "badge_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.boolean "mail_own_thread_reply", default: true
|
||||
@@ -147,8 +146,9 @@ ActiveRecord::Schema.define(version: 20170522210610) do
|
||||
t.boolean "mail_own_blogpost_comment", default: true
|
||||
t.boolean "mail_other_blogpost_comment", default: true
|
||||
t.boolean "mail_mention", default: true
|
||||
t.boolean "header_scroll", default: false
|
||||
t.integer "badge_id", limit: 4, default: 0
|
||||
t.boolean "utc_time", default: false
|
||||
t.boolean "header_scroll", default: false
|
||||
t.boolean "dark", default: false
|
||||
end
|
||||
|
||||
|
||||
14
db/seeds.rb
14
db/seeds.rb
@@ -42,17 +42,3 @@ deleted_user = User.create!(
|
||||
dark: false
|
||||
)
|
||||
deleted_user.update_attribute(:ign, "Steve")
|
||||
|
||||
User.create!(
|
||||
uuid: "ae795aa86327408e92ab25c8a59f3ba1",
|
||||
ign: "jomo",
|
||||
email: "jomo@example.com",
|
||||
password: "123456789", # high seructity!
|
||||
password_confirmation: "123456789",
|
||||
role: Role.get(:superadmin),
|
||||
header_scroll: false,
|
||||
utc_time: false,
|
||||
dark: false
|
||||
badge: Badge.get(:donor),
|
||||
confirmed: true
|
||||
)
|
||||
|
||||
18
lib/tasks/create_admin_user.rake
Normal file
18
lib/tasks/create_admin_user.rake
Normal file
@@ -0,0 +1,18 @@
|
||||
desc "Creates a superadmin user. Usage: rake create:create_admin_user[uuid, ign, email, pass]"
|
||||
namespace :create do
|
||||
task :create_admin_user, [:uuid, :ign, :email, :pass] => :environment do |task, args|
|
||||
User.create!(
|
||||
uuid: args.uuid,
|
||||
ign: args.ign,
|
||||
email: args.email,
|
||||
password: args.pass,
|
||||
password_confirmation: args.pass,
|
||||
role: Role.get(:superadmin),
|
||||
header_scroll: false,
|
||||
utc_time: false,
|
||||
dark: false,
|
||||
badge: Badge.get(:donor),
|
||||
confirmed: true
|
||||
)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user