mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-26 03:01:00 +00:00
Temporary commit
This commit is contained in:
parent
07c53b7469
commit
0b53968d3d
12 changed files with 160 additions and 100 deletions
2
Gemfile
2
Gemfile
|
@ -3,7 +3,7 @@ source 'http://rubygems.org'
|
|||
ruby '2.2.10'
|
||||
|
||||
gem 'dotenv-rails', '~> 0.10.0'
|
||||
gem 'rails', '~> 4.0.13'
|
||||
gem 'rails', '~> 4.1.16'
|
||||
gem 'mysql2', '~> 0.3.18'
|
||||
gem 'dalli', '~> 2.7.0'
|
||||
gem 'puma', '~> 2.11.1'
|
||||
|
|
99
Gemfile.lock
99
Gemfile.lock
|
@ -9,36 +9,38 @@ GIT
|
|||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
actionmailer (4.0.13)
|
||||
actionpack (= 4.0.13)
|
||||
actionmailer (4.1.16)
|
||||
actionpack (= 4.1.16)
|
||||
actionview (= 4.1.16)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
actionpack (4.0.13)
|
||||
activesupport (= 4.0.13)
|
||||
builder (~> 3.1.0)
|
||||
erubis (~> 2.7.0)
|
||||
actionpack (4.1.16)
|
||||
actionview (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
rack (~> 1.5.2)
|
||||
rack-test (~> 0.6.2)
|
||||
actionview (4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
active_link_to (1.0.2)
|
||||
actionpack
|
||||
activemodel (4.0.13)
|
||||
activesupport (= 4.0.13)
|
||||
builder (~> 3.1.0)
|
||||
activerecord (4.0.13)
|
||||
activemodel (= 4.0.13)
|
||||
activerecord-deprecated_finders (~> 1.0.2)
|
||||
activesupport (= 4.0.13)
|
||||
arel (~> 4.0.0)
|
||||
activerecord-deprecated_finders (1.0.4)
|
||||
activesupport (4.0.13)
|
||||
activemodel (4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.1.16)
|
||||
activemodel (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
arel (~> 5.0.0)
|
||||
activesupport (4.1.16)
|
||||
i18n (~> 0.6, >= 0.6.9)
|
||||
minitest (~> 4.2)
|
||||
multi_json (~> 1.3)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 0.3.37)
|
||||
tzinfo (~> 1.1)
|
||||
annotate (2.6.3)
|
||||
activerecord (>= 2.3.0)
|
||||
rake (>= 0.8.7)
|
||||
arel (4.0.2)
|
||||
arel (5.0.1.20140414130214)
|
||||
bbcoder (1.0.1)
|
||||
better_errors (1.1.0)
|
||||
coderay (>= 1.0.0)
|
||||
|
@ -49,7 +51,7 @@ GEM
|
|||
bourbon (3.1.8)
|
||||
sass (>= 3.2.0)
|
||||
thor
|
||||
builder (3.1.4)
|
||||
builder (3.2.3)
|
||||
byebug (2.7.0)
|
||||
columnize (~> 0.3)
|
||||
debugger-linecache (~> 1.2)
|
||||
|
@ -91,6 +93,7 @@ GEM
|
|||
execjs
|
||||
coffee-script-source (1.9.1.1)
|
||||
columnize (0.8.9)
|
||||
concurrent-ruby (1.1.5)
|
||||
dalli (2.7.1)
|
||||
database_cleaner (1.2.0)
|
||||
debug_inspector (0.0.2)
|
||||
|
@ -116,7 +119,8 @@ GEM
|
|||
sass (~> 3.2)
|
||||
haml (4.0.5)
|
||||
tilt
|
||||
i18n (0.7.0)
|
||||
i18n (0.9.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
i18n-country-translations (1.2.2)
|
||||
i18n (~> 0.5)
|
||||
railties (>= 3.0)
|
||||
|
@ -129,13 +133,16 @@ GEM
|
|||
thor (~> 0.14)
|
||||
json (1.8.3)
|
||||
libv8 (3.16.14.19)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
method_source (0.8.2)
|
||||
mime-types (2.6.1)
|
||||
mime-types (3.2.2)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2018.0812)
|
||||
mini_mime (1.0.1)
|
||||
mini_portile (0.6.2)
|
||||
minitest (4.7.5)
|
||||
multi_json (1.11.2)
|
||||
minitest (5.11.3)
|
||||
multi_json (1.13.1)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
mysql2 (0.3.21)
|
||||
|
@ -171,22 +178,24 @@ GEM
|
|||
rack (1.5.5)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (4.0.13)
|
||||
actionmailer (= 4.0.13)
|
||||
actionpack (= 4.0.13)
|
||||
activerecord (= 4.0.13)
|
||||
activesupport (= 4.0.13)
|
||||
rails (4.1.16)
|
||||
actionmailer (= 4.1.16)
|
||||
actionpack (= 4.1.16)
|
||||
actionview (= 4.1.16)
|
||||
activemodel (= 4.1.16)
|
||||
activerecord (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.0.13)
|
||||
railties (= 4.1.16)
|
||||
sprockets-rails (~> 2.0)
|
||||
rails_autolink (1.1.5)
|
||||
rails (> 3.1)
|
||||
railties (4.0.13)
|
||||
actionpack (= 4.0.13)
|
||||
activesupport (= 4.0.13)
|
||||
railties (4.1.16)
|
||||
actionpack (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.4.2)
|
||||
rake (12.3.2)
|
||||
ref (2.0.0)
|
||||
rmagick (2.13.4)
|
||||
rspec-core (3.3.2)
|
||||
|
@ -226,9 +235,10 @@ GEM
|
|||
simplecov-html (~> 0.7.1)
|
||||
simplecov-html (0.7.1)
|
||||
slop (3.5.0)
|
||||
sprockets (3.3.1)
|
||||
rack (~> 1.0)
|
||||
sprockets-rails (2.3.2)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (2.3.3)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
|
@ -243,14 +253,15 @@ GEM
|
|||
therubyracer (0.12.3)
|
||||
libv8 (~> 3.16.14.15)
|
||||
ref
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
thor (0.20.3)
|
||||
thread_safe (0.3.6)
|
||||
tilt (1.4.1)
|
||||
timecop (0.7.1)
|
||||
tins (1.1.0)
|
||||
tinymce-rails (3.5.9)
|
||||
railties (>= 3.1.1)
|
||||
tzinfo (0.3.44)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (2.5.0)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
|
@ -303,7 +314,7 @@ DEPENDENCIES
|
|||
pry-byebug (~> 1.3.2)
|
||||
puma (~> 2.11.1)
|
||||
quiet_assets (~> 1.0.2)
|
||||
rails (~> 4.0.13)
|
||||
rails (~> 4.1.16)
|
||||
rails_autolink (~> 1.1.5)
|
||||
rmagick (~> 2.13.4)
|
||||
rspec-rails (~> 3.3.3)
|
||||
|
|
|
@ -35,26 +35,26 @@ class Article < ActiveRecord::Base
|
|||
|
||||
attr_protected :id, :updated_at, :created_at, :user_id, :version
|
||||
|
||||
scope :recent, order: 'created_at DESC', limit: 8
|
||||
scope :with_comments,
|
||||
select: "articles.*, COUNT(C.id) AS comment_num",
|
||||
joins: "LEFT JOIN comments C ON C.commentable_type = 'Article' AND C.commentable_id = articles.id",
|
||||
group: "articles.id"
|
||||
scope :ordered, order: 'articles.created_at DESC'
|
||||
scope :limited, limit: 5
|
||||
scope :nodrafts, conditions: { status: STATUS_PUBLISHED }
|
||||
scope :drafts, conditions: { status: STATUS_DRAFT }
|
||||
scope :articles, conditions: ["category_id IN (SELECT id FROM categories WHERE domain = ?)", Category::DOMAIN_ARTICLES]
|
||||
scope :onlynews, conditions: ["category_id IN (SELECT id FROM categories WHERE domain = ?)", Category::DOMAIN_NEWS]
|
||||
scope :category, lambda { |cat| { conditions: { category_id: cat } } }
|
||||
scope :domain, lambda { |domain| { includes: 'category', conditions: { "categories.domain" => domain } } }
|
||||
scope :nospecial, conditions: ["category_id != ?", Category::SPECIAL]
|
||||
scope :interviews, conditions: ["category_id = ?", Category::INTERVIEWS]
|
||||
scope :recent, -> { order('created_at DESC').limit(8) }
|
||||
scope :with_comments, -> {
|
||||
select("articles.*, COUNT(C.id) AS comment_num").
|
||||
joins("LEFT JOIN comments C ON C.commentable_type = 'Article' AND C.commentable_id = articles.id").
|
||||
group("articles.id") }
|
||||
scope :ordered, -> { order('articles.created_at DESC') }
|
||||
scope :limited, -> { limit(5) }
|
||||
scope :nodrafts, -> { where(status: STATUS_PUBLISHED) }
|
||||
scope :drafts, -> { where(status: STATUS_DRAFT) }
|
||||
scope :articles, -> { where(["category_id IN (SELECT id FROM categories WHERE domain = ?)", Category::DOMAIN_ARTICLES]) }
|
||||
scope :onlynews, -> { where(category_id: Category.select(:id).where.not(domain: Category::DOMAIN_NEWS)) }
|
||||
scope :category, -> (cat) { where(category_id: cat) }
|
||||
scope :domain, -> (domain) { includes(:category).where("categories.domain = '?'", domain) }
|
||||
#scope :nospecial, -> { where("category_id != ?", Category::SPECIAL) }
|
||||
scope :interviews, -> { where(category_id: Category::INTERVIEWS) }
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :category
|
||||
has_many :comments, as: :commentable, order: 'created_at ASC', dependent: :destroy
|
||||
has_many :files, class_name: 'DataFile', order: 'created_at DESC', dependent: :destroy
|
||||
has_many :comments, as: :commentable, dependent: :destroy
|
||||
has_many :files, class_name: 'DataFile', dependent: :destroy
|
||||
|
||||
validates_length_of :title, :in => 1..50
|
||||
validates_length_of :text, :in => 1..16000000
|
||||
|
|
|
@ -33,16 +33,16 @@ class Category < ActiveRecord::Base
|
|||
validates_length_of :name, :in => 1..30
|
||||
validate :validate_domain
|
||||
|
||||
scope :ordered, :order => "sort ASC, created_at DESC"
|
||||
scope :domain, lambda { |domain| {:conditions => {:domain => domain}} }
|
||||
scope :nospecial, :conditions => ["name != 'Special'"]
|
||||
scope :newest, :include => :articles, :order => "articles.created_at DESC"
|
||||
scope :page, lambda { |page| {:limit => "#{(page-1)*PER_PAGE}, #{(page-1)*PER_PAGE+PER_PAGE}"} }
|
||||
scope :of_user, lambda { |user| {:conditions => {"articles.user_id" => user.id}, :include => :articles} }
|
||||
scope :ordered, -> { order("sort ASC, created_at DESC") }
|
||||
scope :domain, -> (domain) { where(domain: domain) }
|
||||
scope :nospecial, -> { where.not(name: 'Special') }
|
||||
scope :newest, -> { include(:articles).order("articles.created_at DESC") }
|
||||
# scope :page, lambda { |page| {:limit => "#{(page-1)*PER_PAGE}, #{(page-1)*PER_PAGE+PER_PAGE}"} }
|
||||
#scope :of_user, lambda { |user| {:conditions => {"articles.user_id" => user.id}, :include => :articles} }
|
||||
|
||||
has_many :articles, :order => "created_at DESC"
|
||||
has_many :issues, :order => "created_at DESC"
|
||||
has_many :forums, :order => "forums.position"
|
||||
has_many :articles, -> { order("created_at DESC") }
|
||||
has_many :issues, -> { order("created_at DESC") }
|
||||
has_many :forums, -> { order("forums.position") }
|
||||
has_many :movies
|
||||
has_many :maps
|
||||
has_many :gathers
|
||||
|
|
|
@ -45,17 +45,16 @@ class User < ActiveRecord::Base
|
|||
has_many :groups, :through => :groupers
|
||||
has_many :shoutmsgs, :dependent => :destroy
|
||||
has_many :issues, :foreign_key => "author_id", :dependent => :destroy
|
||||
has_many :open_issues, :class_name => "Issue", :foreign_key => "assigned_id",
|
||||
:conditions => ["issues.status = ?", Issue::STATUS_OPEN]
|
||||
has_many :assigned_issues, :class_name => "Issue", :foreign_key => "assigned_id",
|
||||
has_many :posted_comments, :dependent => :destroy, :class_name => "Comment"
|
||||
has_many :comments, :class_name => "Comment", :as => :commentable, :order => "created_at ASC", :dependent => :destroy
|
||||
has_many :teamers, :dependent => :destroy
|
||||
has_many :active_teams, :through => :teamers, :source => "team",
|
||||
:conditions => ["teamers.rank >= ? AND teams.active = ?", Teamer::RANK_MEMBER, true]
|
||||
has_many :active_contesters, :through => :active_teams, :source => "contesters",
|
||||
:conditions => {"contesters.active" => true}
|
||||
has_many :active_contests, :through => :active_contesters, :source => "contest",
|
||||
:conditions => ["contests.status != ?", Contest::STATUS_CLOSED]
|
||||
has_many :active_teams, :through => :teamers, :source => "team", ->
|
||||
{ where("teamers.rank >= ? AND teams.active = ?", Teamer::RANK_MEMBER, true) }
|
||||
has_many :active_contesters, :through => :active_teams, :source => "contesters", ->
|
||||
{ where({"contesters.active = ?", true} }
|
||||
has_many :active_contests, :through => :active_contesters, :source => "contest", ->
|
||||
{ where("contests.status != ?", Contest::STATUS_CLOSED) }
|
||||
has_many :past_teams, :through => :teamers, :source => "team", :group => "user_id, team_id"
|
||||
has_many :matchers, :dependent => :destroy
|
||||
has_many :matches, :through => :matchers
|
||||
|
@ -76,22 +75,22 @@ class User < ActiveRecord::Base
|
|||
has_many :sent_team_messages, :through => :active_teams, :source => :sent_messages
|
||||
has_many :match_teams, :through => :matchers, :source => :teams, :uniq => true
|
||||
|
||||
scope :active, :conditions => {:banned => false}
|
||||
scope :with_age,
|
||||
:select => "DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(birthdate)), '%Y')+0 AS aged, COUNT(*) as num, username",
|
||||
:group => "aged",
|
||||
:having => "num > 8 AND aged > 0"
|
||||
scope :country_stats,
|
||||
:select => "country, COUNT(*) as num",
|
||||
:conditions => "country is not null and country != '' and country != '--'",
|
||||
:group => "country",
|
||||
:having => "num > 15",
|
||||
:order => "num DESC"
|
||||
scope :posts_stats,
|
||||
:select => "users.id, username, COUNT(posts.id) as num",
|
||||
:joins => "LEFT JOIN posts ON posts.user_id = users.id",
|
||||
:group => "users.id",
|
||||
:order => "num DESC"
|
||||
scope :active, -> { where(banned: false) }
|
||||
scope :with_age, ->
|
||||
{where("DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(birthdate)), '%Y')+0 AS aged, COUNT(*) as num, username").
|
||||
.group("aged").
|
||||
.having("num > 8 AND aged > 0")}
|
||||
scope :country_stats, ->
|
||||
{select("country, COUNT(*) as num").
|
||||
.where("country is not null and country != '' and country != '--'").
|
||||
.group("country").
|
||||
.having("num > 15").
|
||||
.order("num DESC") }
|
||||
scope :posts_stats, ->
|
||||
{ select("users.id, username, COUNT(posts.id) as num").
|
||||
.joins("LEFT JOIN posts ON posts.user_id = users.id").
|
||||
.group("users.id").
|
||||
.order("num DESC") }
|
||||
scope :banned,
|
||||
:joins => "LEFT JOIN bans ON bans.user_id = users.id AND expiry > UTC_TIMESTAMP()",
|
||||
:conditions => "bans.id IS NOT NULL"
|
||||
|
@ -201,15 +200,18 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def caster?
|
||||
groups.exists? :id => Group::CASTERS
|
||||
groups.exists? :id SL/ensl.org
|
||||
|
||||
end
|
||||
|
||||
def verified?
|
||||
# created_at < DateTime.now.ago(VERIFICATION_TIME)
|
||||
# created_at < DaSL/ensl.org
|
||||
N_TIME)
|
||||
true
|
||||
end
|
||||
|
||||
def has_access? group
|
||||
def has_access? groupSL/ensl.org
|
||||
|
||||
admin? or groups.exists?(:id => group)
|
||||
end
|
||||
|
||||
|
|
|
@ -224,9 +224,9 @@
|
|||
<%= render partial: "issues/list", locals: { issues: @user.issues } %>
|
||||
<% end %>
|
||||
|
||||
<% if @user.open_issues.size > 0 %>
|
||||
<% if @user.asssigned_issues.size > 0 %>
|
||||
<h4>Open issues assigned to you</h4>
|
||||
<%= render partial: "issues/list", locals: { issues: @user.open_issues } %>
|
||||
<%= render partial: "issues/list", locals: { issues: @user.asssigned_issues } %>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'New issue', new_issue_path, class: 'button' %>
|
||||
|
|
7
config/initializers/backtrace_silencers.rb
Normal file
7
config/initializers/backtrace_silencers.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
||||
|
||||
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
||||
# Rails.backtrace_cleaner.remove_silencers!
|
4
config/initializers/filter_parameter_logging.rb
Normal file
4
config/initializers/filter_parameter_logging.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
Rails.application.config.filter_parameters += [:password]
|
16
config/initializers/inflections.rb
Normal file
16
config/initializers/inflections.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new inflection rules using the following format. Inflections
|
||||
# are locale specific, and you may define rules for as many different
|
||||
# locales as you wish. All of these examples are active by default:
|
||||
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
# inflect.plural /^(ox)$/i, '\1en'
|
||||
# inflect.singular /^(ox)en/i, '\1'
|
||||
# inflect.irregular 'person', 'people'
|
||||
# inflect.uncountable %w( fish sheep )
|
||||
# end
|
||||
|
||||
# These inflection rules are supported but not enabled by default:
|
||||
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
# inflect.acronym 'RESTful'
|
||||
# end
|
5
config/initializers/mime_types.rb
Normal file
5
config/initializers/mime_types.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new mime types for use in respond_to blocks:
|
||||
# Mime::Type.register "text/richtext", :rtf
|
||||
# Mime::Type.register_alias "text/html", :iphone
|
12
config/initializers/secret_token.rb
Normal file
12
config/initializers/secret_token.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Your secret key is used for verifying the integrity of signed cookies.
|
||||
# If you change this key, all old signed cookies will become invalid!
|
||||
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
# You can use `rake secret` to generate a secure secret key.
|
||||
|
||||
# Make sure your secret_key_base is kept private
|
||||
# if you're sharing your code publicly.
|
||||
Ensl::Application.config.secret_key_base = '356eee0f950cf925a0c1cbc8f15c1dfddc337a55f177388056906aea7de379f8bc5155e3f8a9d6d716f708b74f912305fc3276d4f290bdf66eadf56a61679c4c'
|
3
config/initializers/session_store.rb
Normal file
3
config/initializers/session_store.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
Ensl::Application.config.session_store :cookie_store, key: '_ensl_session'
|
Loading…
Reference in a new issue