some New and some old

Added some new stuff (mainly the fix for the "new" ranks suffixes) and
removed some uneeded bits.
Also changed the gemfile so it will work on Windows too.
This commit is contained in:
Jonas Folvik
2016-01-11 18:21:21 +01:00
parent d9b971ab34
commit c35a36a5c5
9 changed files with 138 additions and 125 deletions
+7 -2
View File
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
gem 'rails', '4.1.0'
gem 'mysql2'
gem 'mysql2', '~> 0.3.18'
gem 'jquery-rails'
gem 'bcrypt-ruby' # To use ActiveModel's has_secure_password
gem 'sanitize'
@@ -15,6 +15,9 @@ gem 'activerecord-session_store'
gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails'
gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination
gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-rails' # @mentions
gem 'coffee-script-source', '1.8.0'
gem 'tzinfo'
gem 'tzinfo-data', '~> 1.2015', '>= 1.2015.7'
# Gems used only for assets and not required
# in production environments by default.
@@ -36,4 +39,6 @@ group :development do
end
# Use unicorn as the app server
gem 'unicorn'
group :production do
# gem 'unicorn'
end
+93 -66
View File
@@ -46,7 +46,7 @@ GEM
activemodel (= 4.1.0)
activesupport (= 4.1.0)
arel (~> 5.0.0)
activerecord-session_store (0.1.0)
activerecord-session_store (0.1.2)
actionpack (>= 4.0.0, < 5)
activerecord (>= 4.0.0, < 5)
railties (>= 4.0.0, < 5)
@@ -56,13 +56,17 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
arel (5.0.0)
bcrypt (3.1.7)
arel (5.0.1.20140414130214)
bcrypt (3.1.10)
bcrypt (3.1.10-x86-mingw32)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
better_errors (1.1.0)
bcrypt-ruby (3.1.5-x86-mingw32)
bcrypt (>= 3.1.3)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
@@ -73,49 +77,58 @@ GEM
capistrano-bundler (1.1.4)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-rails (1.1.2)
capistrano-rails (1.1.5)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rbenv (2.0.3)
capistrano-rbenv (2.0.4)
capistrano (~> 3.1)
sshkit (~> 1.3)
choice (0.1.6)
choice (0.2.0)
coderay (1.1.0)
coffee-rails (4.0.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.2.0)
railties (>= 4.0.0, < 5.1.x)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.7.0)
colorize (0.7.5)
coffee-script-source (1.8.0)
concurrent-ruby (1.0.0)
crass (1.0.2)
debug_inspector (0.0.2)
domain_name (0.5.25)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
execjs (2.0.2)
hike (1.2.3)
hirb (0.7.1)
i18n (0.6.9)
jquery-rails (3.1.0)
execjs (2.6.0)
ffi (1.9.10-x86-mingw32)
hirb (0.7.3)
http-cookie (1.0.2)
domain_name (~> 0.5)
i18n (0.7.0)
jquery-rails (3.1.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
kgio (2.9.2)
json (1.8.3)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
mini_portile (0.5.3)
minitest (5.3.2)
multi_json (1.9.2)
mysql2 (0.3.15)
mini_portile2 (2.0.0)
minitest (5.8.3)
mysql2 (0.3.20)
mysql2 (0.3.20-x86-mingw32)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
polyglot (0.3.4)
rack (1.5.2)
rack-test (0.6.2)
net-ssh (3.0.2)
netrc (0.11.0)
nokogiri (1.6.7.1)
mini_portile2 (~> 2.0.0.rc2)
nokogiri (1.6.7.1-x86-mingw32)
mini_portile2 (~> 2.0.0.rc2)
nokogumbo (1.4.7)
nokogiri
polyglot (0.3.5)
rack (1.5.5)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.1.0)
actionmailer (= 4.1.0)
@@ -127,65 +140,74 @@ GEM
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.0)
sprockets-rails (~> 2.0)
rails-erd (1.1.0)
activerecord (>= 3.0)
activesupport (>= 3.0)
choice (~> 0.1.6)
ruby-graphviz (~> 1.0.4)
rails-erd (1.4.4)
activerecord (>= 3.2)
activesupport (>= 3.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
railties (4.1.0)
actionpack (= 4.1.0)
activesupport (= 4.1.0)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.13.0)
rake (10.2.2)
rb-readline (0.5.1)
rake (10.4.2)
rb-readline (0.5.3)
redcarpet (3.2.3)
rest-client (1.6.7)
mime-types (>= 1.16)
ruby-graphviz (1.0.9)
sanitize (2.1.0)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rest-client (1.8.0-x86-mingw32)
ffi (~> 1.9)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
ruby-graphviz (1.2.2)
sanitize (4.0.1)
crass (~> 1.0.2)
nokogiri (>= 1.4.4)
sass (3.2.19)
sass-rails (4.0.3)
nokogumbo (~> 1.4.1)
sass (3.4.20)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2.0)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0)
sprockets (2.11.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.1.3)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sprockets (3.5.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sshkit (1.7.1)
colorize (>= 0.7.0)
sprockets (>= 2.8, < 4.0)
sshkit (1.8.1)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
strip_attributes (1.5.1)
strip_attributes (1.7.1)
activemodel (>= 3.0, < 5.0)
thor (0.19.1)
thread_safe (0.3.3)
tilt (1.4.1)
thread_safe (0.3.5)
tilt (2.0.2)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (1.1.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.5.0)
tzinfo-data (1.2015.7)
tzinfo (>= 1.0.0)
uglifier (2.7.2)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicorn (4.8.3)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
unf_ext (0.0.7.1-x86-mingw32)
webrick (1.3.1)
PLATFORMS
ruby
x86-mingw32
DEPENDENCIES
activerecord-session_store
@@ -196,12 +218,13 @@ DEPENDENCIES
capistrano-rails (~> 1.1.2)
capistrano-rbenv (~> 2.0)
coffee-rails
coffee-script-source (= 1.8.0)
highlight_js-rails!
hirb
jquery-rails
jquery-textcomplete-rails!
kaminari!
mysql2
mysql2 (~> 0.3.18)
rails (= 4.1.0)
rails-erd
rb-readline
@@ -210,6 +233,10 @@ DEPENDENCIES
sanitize
sass-rails
strip_attributes
tzinfo
tzinfo-data (~> 1.2015, >= 1.2015.7)
uglifier
unicorn
webrick
BUNDLED WITH
1.11.2
+9 -9
View File
@@ -17,9 +17,9 @@ class ApplicationController < ActionController::Base
helper_method :superadmin?
helper_method :donor?
helper_method :retired?
helper_method :developer?
helper_method :trainingmod?
helper_method :lead_mod?
helper_method :mit?
helper_method :dev?
helper_method :lead?
helper_method :confirmed?
@@ -79,16 +79,16 @@ class ApplicationController < ActionController::Base
!!(current_user && current_user.retired?)
end
def developer?
!!(current_user && current_user.developer?)
def mit?
!!(current_user && current_user.mit?)
end
def trainingmod?
!!(current_user && current_user.trainingmod?)
def dev?
!!(current_user && current_user.dev?)
end
def lead_mod?
!!(current_user && current_user.lead_mod?)
def lead?
!!(current_user && current_user.lead?)
end
def confirmed?
+9 -1
View File
@@ -12,6 +12,14 @@ class UsersController < ApplicationController
@users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i)
elsif params[:role].downcase == "donor"
@users = User.joins(:role).where(donor: true)
elsif params[:role].downcase == "retired"
@users = User.joins(:role).where(retired: true)
elsif params[:role].downcase == "mit"
@users = User.joins(:role).where(mit: true)
elsif params[:role].downcase == "dev"
@users = User.joins(:role).where(dev: true)
elsif params[:role].downcase == "lead"
@users = User.joins(:role).where(lead: true)
else
if role = Role.get(params[:role])
@users = User.joins(:role).where(role: role)
@@ -140,7 +148,7 @@ class UsersController < ApplicationController
def update
if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?)
if mod?
userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :role, :confirmed, :donor])
userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :role, :confirmed, :donor, :retired, :dev, :mit, :lead])
else
userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about])
end
+6 -41
View File
@@ -21,8 +21,6 @@ class User < ActiveRecord::Base
validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[[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, _)."}
validate :account_exists?, :if => lambda {|user| user.ign_changed? }
has_many :blogposts
has_many :comments
@@ -39,16 +37,16 @@ class User < ActiveRecord::Base
!!self.retired
end
def developer?
!!self.developer
def dev?
!!self.dev
end
def trainingmod?
!!self.trainingmod
def mit?
!!self.mit
end
def lead_mod?
!!self.lead_mod
def lead?
!!self.lead
end
def confirmed?
@@ -129,32 +127,6 @@ class User < ActiveRecord::Base
end
end
# def haspaid?
# begin
# response = open("https://sessionserver.mojang.com/session/minecraft/profile/#{CGI.escape(self.uuid)}", read_timeout: 0.5)
# if response.status[0] == "200"
# session_profile = JSON.load(response.read)
# # unpaid accounts are called 'demo' accounts
# return session_profile["demo"] == true
# elsif response.status[0] == "204"
# # user doesn't exist
# return false
# else
# Rails.logger.error "---"
# Rails.logger.error "ERROR: unexpected response code while checking '#{self.uuid}' for premium account"
# Rails.logger.error "code: #{reponse.status}, body: '#{reponse.read}'"
# Rails.logger.error "---"
# end
# rescue => e
# Rails.logger.error "---"
# Rails.logger.error "ERROR: failed to check for premium account for '#{self.uuid}'. Minecraft servers down?"
# Rails.logger.error e.message
# Rails.logger.error "---"
# end
# # mojang servers have trouble
# return true
# end
# def correct_case?(ign)
# begin
# http = Net::HTTP.start("skins.minecraft.net")
@@ -220,13 +192,6 @@ class User < ActiveRecord::Base
self.name ||= self.ign
end
def account_exists?
profile = self.get_profile
if !profile || profile["demo"] == true
errors.add(:ign, "'#{self.ign}' is not a paid account!")
end
end
def strip_whitespaces
self.name.strip! if self.name
self.ign.strip! if self.ign
+5 -4
View File
@@ -50,21 +50,22 @@
<tr>
<td>Developer</td>
<td>
<%= f.select :developer, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %>
<%= f.select :dev, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %>
</td>
</tr>
<tr>
<td>TrainingMod</td>
<td>Mod In Training</td>
<td>
<%= f.select :trainingmod, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %>
<%= f.select :mit, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %>
</td>
</tr>
<tr>
<td>Lead Mod</td>
<td>
<%= f.select :lead_mod, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %>
<%= f.select :lead, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %>
</td>
</tr>
<% end %>
<tr>
<td>Skype username</td>
+4
View File
@@ -14,6 +14,10 @@ class CreateUsers < ActiveRecord::Migration
t.string :youtube_channelname
t.string :twitter
t.boolean :donor, default: false
t.boolean :retired, default: false
t.boolean :mit, default: false
t.boolean :dev, default: false
t.boolean :lead, default: false
t.string :email_token
t.boolean :confirmed, default: false
t.datetime :last_seen
+5 -1
View File
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150826002927) do
ActiveRecord::Schema.define(version: 20150825232749) do
create_table "blogposts", force: true do |t|
t.string "title"
@@ -124,6 +124,10 @@ ActiveRecord::Schema.define(version: 20150826002927) do
t.string "youtube_channelname"
t.string "twitter"
t.boolean "donor", default: false
t.boolean "mit", default: false
t.boolean "retired", default: false
t.boolean "dev", default: false
t.boolean "lead", default: false
t.string "email_token"
t.boolean "confirmed", default: false
t.datetime "last_seen"
-1
View File
@@ -12,7 +12,6 @@ Role.create!([
userpw = SecureRandom.hex(36)
# fallback profile for deleted users
deleted_user = User.create!(
uuid: "8667ba71b85a4004af54457a9734eed7",