rails 4 and tons of stuff
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Blogpost < ActiveRecord::Base
|
||||
attr_accessible :title, :content, :author, :editor
|
||||
|
||||
validates_presence_of :title, :content, :author
|
||||
belongs_to :user_author, class_name: "User", foreign_key: "user_author_id"
|
||||
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Comment < ActiveRecord::Base
|
||||
attr_accessible :content, :author, :blogpost, :post
|
||||
|
||||
|
||||
validates_presence_of :content, :author, :blogpost
|
||||
validates_length_of :content, in: 4..1000
|
||||
|
||||
@@ -4,8 +4,6 @@ class Forum < ActiveRecord::Base
|
||||
belongs_to :role_read, class_name: "Role", foreign_key: "role_read_id"
|
||||
belongs_to :role_write, class_name: "Role", foreign_key: "role_write_id"
|
||||
|
||||
attr_accessible :name, :position, :role_read, :role_write, :role_read_id, :role_write_id, :forumgroup, :forumgroup_id
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class Forumgroup < ActiveRecord::Base
|
||||
belongs_to :role_write, class_name: "Role", foreign_key: "role_write_id"
|
||||
accepts_nested_attributes_for :forums
|
||||
|
||||
attr_accessible :name, :position, :role_read, :role_write, :role_read_id, :role_write_id
|
||||
|
||||
|
||||
validates_presence_of :name, :position
|
||||
validates_length_of :name, in: 2..20
|
||||
|
||||
@@ -4,7 +4,7 @@ class Forumthread < ActiveRecord::Base
|
||||
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
||||
has_many :threadreplies
|
||||
|
||||
attr_accessible :title, :content, :sticky, :locked, :user_author, :user_editor, :forum
|
||||
|
||||
|
||||
validates_presence_of :title, :author, :forum
|
||||
validates_presence_of :content
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Role < ActiveRecord::Base
|
||||
include Comparable
|
||||
has_many :users
|
||||
attr_accessible :name, :value
|
||||
|
||||
|
||||
def to_s
|
||||
self.name
|
||||
|
||||
@@ -3,7 +3,7 @@ class Threadreply < ActiveRecord::Base
|
||||
belongs_to :user_author, class_name: "User", foreign_key: "user_author_id"
|
||||
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
||||
|
||||
attr_accessible :title, :content, :sticky, :locked, :user_author, :user_editor, :forumthread
|
||||
|
||||
|
||||
validates_presence_of :content
|
||||
validates_length_of :content, in: 2..10000
|
||||
|
||||
@@ -3,7 +3,7 @@ class User < ActiveRecord::Base
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
belongs_to :role
|
||||
attr_accessible :uuid, :confirmed, :name, :password, :password_confirmation, :ign, :email, :email_token, :about, :last_ip, :skype, :skype_public, :youtube, :youtube_channelname, :twitter, :last_seen, :role, :role_id
|
||||
|
||||
|
||||
has_secure_password
|
||||
|
||||
@@ -17,8 +17,8 @@ class User < ActiveRecord::Base
|
||||
validates_length_of :about, maximum: 5000
|
||||
validates_length_of :ign, minimum: 2, maximum: 16
|
||||
|
||||
validates :email, uniqueness: {case_sensitive: false}, format: {with: /^.+@.+\..{2,}$/i, message: "That doesn't look like an email adress."}
|
||||
validates :ign, uniqueness: {case_sensitive: false}, format: {with: /^[a-z\d_]+$/i, message: "That is probably not your username."}
|
||||
validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@.+\..{2,}\z/i, message: "That doesn't look like an email adress."}
|
||||
validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "That is probably not your username."}
|
||||
|
||||
validate :has_paid, :if => lambda {|user| user.ign_changed? }
|
||||
|
||||
@@ -101,12 +101,10 @@ class User < ActiveRecord::Base
|
||||
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)
|
||||
if session_profile["legacy"] == true
|
||||
return open("https://minecraft.net/haspaid.jsp?#{{user: self.ign}.to_query}", read_timeout: 0.5).read == "true"
|
||||
else
|
||||
return true
|
||||
end
|
||||
# unpaid accounts are called 'demo' accounts
|
||||
return session_profile["demo"] == true
|
||||
elsif response.status[0] == "204"
|
||||
# user doesn't exist
|
||||
return false
|
||||
else
|
||||
puts "---"
|
||||
|
||||
Reference in New Issue
Block a user