summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMrYummy <elemental428@gmail.com>2017-06-02 19:31:15 +0200
committerMrYummy <elemental428@gmail.com>2017-06-18 13:11:36 -0400
commit79ad8b201edeecfa8c3402b302fa43af0c802328 (patch)
tree5ed7bd8de15de7de413de09ccd28a5b45a6cd9cd
parentb99e62b7e7de3cc6c020a7a89a9d4066f6b0d797 (diff)
Changed 'no badge' check to be more reliable, added rake task for creating superadmin users
-rw-r--r--app/views/users/_username.html.erb2
-rw-r--r--db/migrate/20140617183701_create_roles.rb2
-rw-r--r--db/migrate/20140617183702_create_users.rb2
-rw-r--r--db/schema.rb26
-rw-r--r--db/seeds.rb14
-rw-r--r--lib/tasks/create_admin_user.rake18
6 files changed, 34 insertions, 30 deletions
diff --git a/app/views/users/_username.html.erb b/app/views/users/_username.html.erb
index 4e78673..724e921 100644
--- a/app/views/users/_username.html.erb
+++ b/app/views/users/_username.html.erb
@@ -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>
diff --git a/db/migrate/20140617183701_create_roles.rb b/db/migrate/20140617183701_create_roles.rb
index 3a25ea7..ad89207 100644
--- a/db/migrate/20140617183701_create_roles.rb
+++ b/db/migrate/20140617183701_create_roles.rb
@@ -5,4 +5,4 @@ class CreateRoles < ActiveRecord::Migration
t.integer :value
end
end
-end \ No newline at end of file
+end
diff --git a/db/migrate/20140617183702_create_users.rb b/db/migrate/20140617183702_create_users.rb
index 1fefaf9..20e8a20 100644
--- a/db/migrate/20140617183702_create_users.rb
+++ b/db/migrate/20140617183702_create_users.rb
@@ -23,4 +23,4 @@ class CreateUsers < ActiveRecord::Migration
t.timestamps null: true
end
end
-end \ No newline at end of file
+end
diff --git a/db/schema.rb b/db/schema.rb
index aa35812..916c41f 100644
--- a/db/schema.rb
+++ b/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
diff --git a/db/seeds.rb b/db/seeds.rb
index 7b7530d..926d7b2 100644
--- a/db/seeds.rb
+++ b/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
-)
diff --git a/lib/tasks/create_admin_user.rake b/lib/tasks/create_admin_user.rake
new file mode 100644
index 0000000..28b7e9f
--- /dev/null
+++ b/lib/tasks/create_admin_user.rake
@@ -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