Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
halida committed Mar 30, 2013
2 parents 51e4985 + ac1ec6b commit 96c7350
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 39 deletions.
9 changes: 9 additions & 0 deletions Gemfile
Expand Up @@ -32,6 +32,7 @@ gem 'cache_digests'
gem 'jbuilder' gem 'jbuilder'
gem "truncate_html", "~> 0.5.4" gem "truncate_html", "~> 0.5.4"
gem 'will_paginate', '~> 3.0.pre2' gem 'will_paginate', '~> 3.0.pre2'
gem 'state_machine'


gem 'sidekiq' gem 'sidekiq'
gem 'slim' gem 'slim'
Expand Down Expand Up @@ -63,3 +64,11 @@ group :development, :test do
gem 'rspec-rails', "~> 2.6" gem 'rspec-rails', "~> 2.6"
gem 'sextant' gem 'sextant'
end end

group :development do
gem "binding_of_caller"
gem "better_errors"
gem 'pry'
gem 'pry-rails'
gem 'pry-nav'
end
80 changes: 52 additions & 28 deletions Gemfile.lock
Expand Up @@ -49,7 +49,12 @@ GEM
arel (3.0.2) arel (3.0.2)
bbenezech-nested_form (0.0.6) bbenezech-nested_form (0.0.6)
bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1)
bootstrap-sass (2.3.0.1) better_errors (0.7.2)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.1)
debug_inspector (>= 0.0.1)
bootstrap-sass (2.3.1.0)
sass (~> 3.2) sass (~> 3.2)
builder (3.0.4) builder (3.0.4)
cache_digests (0.2.0) cache_digests (0.2.0)
Expand All @@ -58,19 +63,21 @@ GEM
celluloid (0.12.4) celluloid (0.12.4)
facter (>= 1.6.12) facter (>= 1.6.12)
timers (>= 1.0.0) timers (>= 1.0.0)
coderay (1.0.9)
coffee-rails (3.2.2) coffee-rails (3.2.2)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (~> 3.2.0) railties (~> 3.2.0)
coffee-script (2.2.0) coffee-script (2.2.0)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.5.0) coffee-script-source (1.6.2)
connection_pool (1.0.0) connection_pool (1.0.0)
debug_inspector (0.0.2)
devise (1.4.7) devise (1.4.7)
bcrypt-ruby (~> 3.0) bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3) orm_adapter (~> 0.0.3)
warden (~> 1.0.3) warden (~> 1.0.3)
diff-lcs (1.1.3) diff-lcs (1.2.1)
erubis (2.7.0) erubis (2.7.0)
execjs (1.4.0) execjs (1.4.0)
multi_json (~> 1.0) multi_json (~> 1.0)
Expand All @@ -85,7 +92,7 @@ GEM
railties (>= 3.1, < 4.1) railties (>= 3.1, < 4.1)
hike (1.2.1) hike (1.2.1)
i18n (0.6.4) i18n (0.6.4)
jbuilder (1.0.2) jbuilder (1.2.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
journey (1.0.4) journey (1.0.4)
jquery-rails (2.2.1) jquery-rails (2.2.1)
Expand All @@ -98,18 +105,27 @@ GEM
kaminari (0.14.1) kaminari (0.14.1)
actionpack (>= 3.0.0) actionpack (>= 3.0.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
kgio (2.7.4) kgio (2.8.0)
libv8 (3.11.8.13) libv8 (3.11.8.17)
mail (2.4.4) mail (2.4.4)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
method_source (0.8.1)
mime-types (1.21) mime-types (1.21)
multi_json (1.6.1) multi_json (1.7.2)
mysql2 (0.3.11) mysql2 (0.3.11)
nokogiri (1.5.6) nokogiri (1.5.9)
orm_adapter (0.0.7) orm_adapter (0.0.7)
polyglot (0.3.3) polyglot (0.3.3)
pry (0.9.12)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
pry-nav (0.2.3)
pry (~> 0.9.10)
pry-rails (0.2.2)
pry (>= 0.9.10)
rack (1.4.5) rack (1.4.5)
rack-cache (1.2) rack-cache (1.2)
rack (>= 0.4) rack (>= 0.4)
Expand Down Expand Up @@ -138,37 +154,37 @@ GEM
rdoc (~> 3.4) rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0) thor (>= 0.14.6, < 2.0)
raindrops (0.10.0) raindrops (0.10.0)
rake (10.0.3) rake (10.0.4)
rdoc (3.12.2) rdoc (3.12.2)
json (~> 1.4) json (~> 1.4)
redcarpet (1.17.2) redcarpet (1.17.2)
redis (3.0.3) redis (3.0.3)
redis-namespace (1.2.1) redis-namespace (1.2.1)
redis (~> 3.0.0) redis (~> 3.0.0)
ref (1.0.2) ref (1.0.4)
remotipart (1.0.5) remotipart (1.0.5)
rspec (2.12.0) rspec (2.13.0)
rspec-core (~> 2.12.0) rspec-core (~> 2.13.0)
rspec-expectations (~> 2.12.0) rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.12.0) rspec-mocks (~> 2.13.0)
rspec-core (2.12.2) rspec-core (2.13.1)
rspec-expectations (2.12.1) rspec-expectations (2.13.0)
diff-lcs (~> 1.1.3) diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.12.1) rspec-mocks (2.13.0)
rspec-rails (2.12.1) rspec-rails (2.13.0)
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
railties (>= 3.0) railties (>= 3.0)
rspec-core (~> 2.12.0) rspec-core (~> 2.13.0)
rspec-expectations (~> 2.12.0) rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.12.0) rspec-mocks (~> 2.13.0)
sass (3.2.6) sass (3.2.7)
sass-rails (3.2.6) sass-rails (3.2.6)
railties (~> 3.2.0) railties (~> 3.2.0)
sass (>= 3.1.10) sass (>= 3.1.10)
tilt (~> 1.3) tilt (~> 1.3)
settingslogic (2.0.9) settingslogic (2.0.9)
sextant (0.1.1) sextant (0.2.3)
activesupport (>= 3.2) activesupport (>= 3.2)
rails (>= 3.2) rails (>= 3.2)
sidekiq (2.9.0) sidekiq (2.9.0)
Expand All @@ -184,27 +200,29 @@ GEM
slim (1.3.6) slim (1.3.6)
temple (~> 0.5.5) temple (~> 0.5.5)
tilt (~> 1.3.3) tilt (~> 1.3.3)
slop (3.4.4)
sprockets (2.2.2) sprockets (2.2.2)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
state_machine (1.1.2)
temple (0.5.5) temple (0.5.5)
therubyracer (0.11.4) therubyracer (0.11.4)
libv8 (~> 3.11.8.12) libv8 (~> 3.11.8.12)
ref ref
thor (0.17.0) thor (0.18.0)
tilt (1.3.4) tilt (1.3.6)
timers (1.1.0) timers (1.1.0)
treetop (1.4.12) treetop (1.4.12)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
truncate_html (0.5.5) truncate_html (0.5.5)
tzinfo (0.3.35) tzinfo (0.3.37)
uglifier (1.3.0) uglifier (1.3.0)
execjs (>= 0.3.0) execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2) multi_json (~> 1.0, >= 1.0.2)
unicorn (4.5.0) unicorn (4.6.2)
kgio (~> 2.6) kgio (~> 2.6)
rack rack
raindrops (~> 0.7) raindrops (~> 0.7)
Expand All @@ -216,6 +234,8 @@ PLATFORMS
ruby ruby


DEPENDENCIES DEPENDENCIES
better_errors
binding_of_caller
cache_digests cache_digests
cancan cancan
coffee-rails (~> 3.2.1) coffee-rails (~> 3.2.1)
Expand All @@ -226,6 +246,9 @@ DEPENDENCIES
jbuilder jbuilder
jquery-rails jquery-rails
mysql2 (>= 0.3) mysql2 (>= 0.3)
pry
pry-nav
pry-rails
rails (= 3.2.11) rails (= 3.2.11)
rails_admin! rails_admin!
redcarpet (= 1.17.2) redcarpet (= 1.17.2)
Expand All @@ -237,6 +260,7 @@ DEPENDENCIES
sidekiq sidekiq
sinatra (>= 1.3.0) sinatra (>= 1.3.0)
slim slim
state_machine
therubyracer therubyracer
truncate_html (~> 0.5.4) truncate_html (~> 0.5.4)
uglifier (>= 1.0.3) uglifier (>= 1.0.3)
Expand Down
21 changes: 15 additions & 6 deletions app/models/solution.rb
Expand Up @@ -7,11 +7,24 @@ class Solution < ActiveRecord::Base
LANGUAGES = ['C', 'Java', 'Python'] LANGUAGES = ['C', 'Java', 'Python']


validates :language, inclusion: LANGUAGES validates :language, inclusion: LANGUAGES

state_machine :status, :initial => :pending do
state :testing # the solution is now testing by SolutionCheck Worker
state :tested # SolutionCheck Worker run the solution and the result is given

event :start_test do
transition :pending => :testing
end

event :finish_test do
transition :testing => :tested
end
end


def self.tester_get def self.tester_get
solution = Solution.where(status: nil).first solution = Solution.with_status(:pending).first
return solution unless solution return solution unless solution
solution.update_attributes(status: 'Testing') solution.start_test
solution solution
end end


Expand All @@ -20,10 +33,6 @@ def token
self[:token] self[:token]
end end


def status
self[:status] || "Pending"
end

private private
def generate_token def generate_token
self[:token] = ::SecureRandom.hex(6) self[:token] = ::SecureRandom.hex(6)
Expand Down
4 changes: 1 addition & 3 deletions app/views/problems/show.html.haml
@@ -1,5 +1,3 @@
- admin = can? :manage, @challenge

%h1= @problem.name %h1= @problem.name


%p %p
Expand All @@ -16,7 +14,7 @@
%pre= @problem.demo_output %pre= @problem.demo_output


%p %p
- if admin - if can? :manage, @challenge
= link_to 'Edit', edit_challenge_problem_path(@challenge, @problem) = link_to 'Edit', edit_challenge_problem_path(@challenge, @problem)
\| \|
= link_to 'Back', challenge_path(@challenge) = link_to 'Back', challenge_path(@challenge)
Expand Down
3 changes: 1 addition & 2 deletions app/views/solutions/index.html.haml
Expand Up @@ -14,10 +14,9 @@
%tr %tr
- if @all - if @all
%td= solution.user.email %td= solution.user.email
%td= solution.created_at %td= l solution.created_at, :format => :short
%td= link_to solution.problem.name, [solution.problem.challenge, solution.problem] %td= link_to solution.problem.name, [solution.problem.challenge, solution.problem]
%td= solution.language %td= solution.language
%td %td
= solution_status_display solution.status = solution_status_display solution.status
= link_to solution.status, solution = link_to solution.status, solution

8 changes: 8 additions & 0 deletions config/locales/en.yml
Expand Up @@ -3,3 +3,11 @@


en: en:
hello: "Hello world" hello: "Hello world"

time:
am: am
formats:
default: ! '%a, %d %b %Y %H:%M:%S %z'
long: ! '%B %d, %Y %H:%M'
short: ! '%d %b %H:%M'
pm: pm

0 comments on commit 96c7350

Please sign in to comment.