From b3a347392331727d551d69a29175a50fe98e96a3 Mon Sep 17 00:00:00 2001 From: Futseh Date: Fri, 22 Feb 2019 16:44:25 +0100 Subject: Removed skype field and added Discord on users. Also dropped unused table --- Gemfile.lock | 4 ++-- app/controllers/users_controller.rb | 4 ++-- app/models/user.rb | 2 +- app/views/users/edit.html.erb | 4 ++-- app/views/users/show.html.erb | 6 +++--- db/migrate/20190222152220_drop_forums_labels.rb | 5 +++++ .../20190222152638_remove_skype_add_discord_from_users.rb | 6 ++++++ db/schema.rb | 12 +++--------- db/seeds.rb | 4 ++-- 9 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 db/migrate/20190222152220_drop_forums_labels.rb create mode 100644 db/migrate/20190222152638_remove_skype_add_discord_from_users.rb diff --git a/Gemfile.lock b/Gemfile.lock index 99ea724..ef66509 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -196,7 +196,7 @@ GEM rails-html-sanitizer (1.0.4) loofah (~> 2.2, >= 2.2.2) raindrops (0.19.0) - rake (12.3.1) + rake (12.3.2) rb-fsevent (0.10.3) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) @@ -287,4 +287,4 @@ DEPENDENCIES webrick BUNDLED WITH - 1.17.1 + 1.17.3 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 28bdf7b..61613af 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -149,9 +149,9 @@ class UsersController < ApplicationController def update if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?) if mod? - userdata = user_params([:name, :skype, :youtube, :twitter, :about, :role, :badge, :confirmed, :header_scroll, :utc_time, :dark]) + userdata = user_params([:name, :discord, :youtube, :twitter, :about, :role, :badge, :confirmed, :header_scroll, :utc_time, :dark]) else - userdata = user_params([:name, :skype, :youtube, :twitter, :about, :header_scroll, :utc_time, :dark]) + userdata = user_params([:name, :discord, :youtube, :twitter, :about, :header_scroll, :utc_time, :dark]) end if User.find_by(name: userdata[:name]) && User.find_by(name: userdata[:name]) != @user flash[:alert] = "You have entered a name that belongs to someone else. Please try another." diff --git a/app/models/user.rb b/app/models/user.rb index 4f682c6..6100f44 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -168,7 +168,7 @@ class User < ActiveRecord::Base self.ign.strip! if self.ign self.email.strip! if self.email self.about.strip! if self.about - self.skype.strip! if self.skype + self.discord.strip! if self.discord self.youtube.strip! if self.youtube self.twitter.strip! if self.twitter end diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 3516cc9..cfbf229 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -43,9 +43,9 @@ <% end %> - Skype username + Discord username - <%= f.text_field :skype, placeholder: "Skype username", disabled: !can_edit? %> + <%= f.text_field :discord, placeholder: "Discord username", disabled: !can_edit? %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index cafe726..ae33c1a 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -54,10 +54,10 @@ Role <%= link_to @user.role, users_path(:role => @user.role.name) %> - <% if current_user && !@user.skype.blank? %> + <% if current_user && !@user.discord.blank? %> - Skype - <%= link_to @user.skype, "skype:#{@user.skype}?chat", target: "_blank" %> + Discord + <%= @user.discord %> <% end %> <% if !@user.youtube.blank? && !@user.youtube_channelname.blank? %> diff --git a/db/migrate/20190222152220_drop_forums_labels.rb b/db/migrate/20190222152220_drop_forums_labels.rb new file mode 100644 index 0000000..06d8c4a --- /dev/null +++ b/db/migrate/20190222152220_drop_forums_labels.rb @@ -0,0 +1,5 @@ +class DropForumsLabels < ActiveRecord::Migration + def change + drop_table :forums_labels + end +end diff --git a/db/migrate/20190222152638_remove_skype_add_discord_from_users.rb b/db/migrate/20190222152638_remove_skype_add_discord_from_users.rb new file mode 100644 index 0000000..34f1dea --- /dev/null +++ b/db/migrate/20190222152638_remove_skype_add_discord_from_users.rb @@ -0,0 +1,6 @@ +class RemoveSkypeAddDiscordFromUsers < ActiveRecord::Migration + def change + remove_column :users, :skype + add_column :users, :discord, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 1e4d5f4..0aef574 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: 20180606223258) do +ActiveRecord::Schema.define(version: 20190222152638) do create_table "badges", force: :cascade do |t| t.string "name", limit: 191 @@ -54,11 +54,6 @@ ActiveRecord::Schema.define(version: 20180606223258) do t.integer "necro_length", limit: 4 end - create_table "forums_labels", id: false, force: :cascade do |t| - t.integer "forum_id", limit: 4 - t.integer "label_id", limit: 4 - end - create_table "forumthreads", force: :cascade do |t| t.string "title", limit: 255 t.text "content", limit: 16777215 @@ -134,7 +129,6 @@ ActiveRecord::Schema.define(version: 20180606223258) do t.string "email", limit: 191 t.text "about", limit: 65535 t.string "last_ip", limit: 255 - t.string "skype", limit: 255 t.string "youtube", limit: 255 t.string "youtube_channelname", limit: 255 t.string "twitter", limit: 255 @@ -154,14 +148,14 @@ ActiveRecord::Schema.define(version: 20180606223258) do t.boolean "header_scroll", default: false t.boolean "dark", default: false t.text "public_key", limit: 65535 - t.string "totp_secret", limit: 255 + t.string "totp_secret", limit: 255 t.boolean "totp_enabled", default: false + t.string "discord", limit: 191 end add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["ign"], name: "index_users_on_ign", unique: true, using: :btree add_index "users", ["name"], name: "index_users_on_name", unique: true, using: :btree - add_index "users", ["skype"], name: "index_users_on_skype", unique: true, using: :btree add_index "users", ["twitter"], name: "index_users_on_twitter", unique: true, using: :btree add_index "users", ["uuid"], name: "index_users_on_uuid", unique: true, using: :btree add_index "users", ["youtube"], name: "index_users_on_youtube", unique: true, using: :btree diff --git a/db/seeds.rb b/db/seeds.rb index f6b731f..7ecb6de 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -32,7 +32,7 @@ deleted_user = User.create!( password_confirmation: userpw, role: Role.get(:disabled), badge: Badge.get(:none), - skype: "echo123", + discord: "echo123", last_ip: "0.0.0.0", confirmed: true, last_seen: Time.utc(0).to_datetime, @@ -40,4 +40,4 @@ deleted_user = User.create!( utc_time: false, dark: false ) -deleted_user.update_attribute(:ign, "Steve") +deleted_user.update_attribute(:ign, "Steve") \ No newline at end of file -- cgit v1.2.3 From 1c9f62fb978ea2effb1389be5d56f29191baeedd Mon Sep 17 00:00:00 2001 From: Futseh Date: Fri, 22 Feb 2019 19:07:34 +0100 Subject: Validates that the discord name is valid --- app/models/user.rb | 2 ++ db/schema.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 6100f44..85c154e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,9 +18,11 @@ class User < ActiveRecord::Base validates_length_of :name, in: 2..30 validates_length_of :about, maximum: 5000 validates_length_of :ign, minimum: 1, maximum: 16 + validates_length_of :discord, minimum: 2, maximum: 37 # The maximum length of a name is 32, but you need the # and four numbers validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[(IPv6)?[0-9a-f:.]+\])\z/i, message: "That doesn't look like an email address."} validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."} + validates :discord, uniqueness: {case_sensitive: false}, format: {with: /\A^(?!everyone|here|discordtag|.*```.*)([^@#:]{2,32}#[0-9]{4})$\z/i, message: "Discord name is invalid."} validates :public_key, format: {with: /\A(-----BEGIN PGP PUBLIC KEY BLOCK-----((.|\n)*?)-----END PGP PUBLIC KEY BLOCK-----)?\z/i, message: "That doesn't look like a PGP formatted public key."} diff --git a/db/schema.rb b/db/schema.rb index 0aef574..dba9247 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -156,6 +156,7 @@ ActiveRecord::Schema.define(version: 20190222152638) do add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["ign"], name: "index_users_on_ign", unique: true, using: :btree add_index "users", ["name"], name: "index_users_on_name", unique: true, using: :btree + add_index "users", ["discord"], name: "index_users_on_discord", unique: true, using: :btree add_index "users", ["twitter"], name: "index_users_on_twitter", unique: true, using: :btree add_index "users", ["uuid"], name: "index_users_on_uuid", unique: true, using: :btree add_index "users", ["youtube"], name: "index_users_on_youtube", unique: true, using: :btree -- cgit v1.2.3 From 6bfdf30f07dfdb9f331c16b52d78a6450ee3a300 Mon Sep 17 00:00:00 2001 From: Futseh Date: Fri, 22 Feb 2019 19:23:42 +0100 Subject: Changed the colour of the resend mail button to better fit our theme --- app/views/users/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index ae33c1a..1edf6db 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -25,7 +25,7 @@ <% if !@user.confirmed? %> <% if @user.is?(current_user) || mod? %> Please confirm your email <%= @user.email %> ! - <%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn dark", form_class: "inline-block", data: {confirm: "Did you check your spam folder?"} %> + <%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn blue", form_class: "inline-block", data: {confirm: "Did you check your spam folder?"} %> <% else %> This user hasn't confirmed their email yet! <% end %> -- cgit v1.2.3