Permalink
Browse files

merge

  • Loading branch information...
2 parents 51e4985 + ac1ec6b commit 96c7350719f122e2e74ea1124106d5daf317838c @halida committed Mar 30, 2013
Showing with 86 additions and 39 deletions.
  1. +9 −0 Gemfile
  2. +52 −28 Gemfile.lock
  3. +15 −6 app/models/solution.rb
  4. +1 −3 app/views/problems/show.html.haml
  5. +1 −2 app/views/solutions/index.html.haml
  6. +8 −0 config/locales/en.yml
View
@@ -32,6 +32,7 @@ gem 'cache_digests'
gem 'jbuilder'
gem "truncate_html", "~> 0.5.4"
gem 'will_paginate', '~> 3.0.pre2'
+gem 'state_machine'
gem 'sidekiq'
gem 'slim'
@@ -63,3 +64,11 @@ group :development, :test do
gem 'rspec-rails', "~> 2.6"
gem 'sextant'
end
+
+group :development do
+ gem "binding_of_caller"
+ gem "better_errors"
+ gem 'pry'
+ gem 'pry-rails'
+ gem 'pry-nav'
+end
View
@@ -49,7 +49,12 @@ GEM
arel (3.0.2)
bbenezech-nested_form (0.0.6)
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)
builder (3.0.4)
cache_digests (0.2.0)
@@ -58,19 +63,21 @@ GEM
celluloid (0.12.4)
facter (>= 1.6.12)
timers (>= 1.0.0)
+ coderay (1.0.9)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
- coffee-script-source (1.5.0)
+ coffee-script-source (1.6.2)
connection_pool (1.0.0)
+ debug_inspector (0.0.2)
devise (1.4.7)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
warden (~> 1.0.3)
- diff-lcs (1.1.3)
+ diff-lcs (1.2.1)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
@@ -85,7 +92,7 @@ GEM
railties (>= 3.1, < 4.1)
hike (1.2.1)
i18n (0.6.4)
- jbuilder (1.0.2)
+ jbuilder (1.2.0)
activesupport (>= 3.0.0)
journey (1.0.4)
jquery-rails (2.2.1)
@@ -98,18 +105,27 @@ GEM
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
- kgio (2.7.4)
- libv8 (3.11.8.13)
+ kgio (2.8.0)
+ libv8 (3.11.8.17)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
+ method_source (0.8.1)
mime-types (1.21)
- multi_json (1.6.1)
+ multi_json (1.7.2)
mysql2 (0.3.11)
- nokogiri (1.5.6)
+ nokogiri (1.5.9)
orm_adapter (0.0.7)
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-cache (1.2)
rack (>= 0.4)
@@ -138,37 +154,37 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
raindrops (0.10.0)
- rake (10.0.3)
+ rake (10.0.4)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (1.17.2)
redis (3.0.3)
redis-namespace (1.2.1)
redis (~> 3.0.0)
- ref (1.0.2)
+ ref (1.0.4)
remotipart (1.0.5)
- rspec (2.12.0)
- rspec-core (~> 2.12.0)
- rspec-expectations (~> 2.12.0)
- rspec-mocks (~> 2.12.0)
- rspec-core (2.12.2)
- rspec-expectations (2.12.1)
- diff-lcs (~> 1.1.3)
- rspec-mocks (2.12.1)
- rspec-rails (2.12.1)
+ rspec (2.13.0)
+ rspec-core (~> 2.13.0)
+ rspec-expectations (~> 2.13.0)
+ rspec-mocks (~> 2.13.0)
+ rspec-core (2.13.1)
+ rspec-expectations (2.13.0)
+ diff-lcs (>= 1.1.3, < 2.0)
+ rspec-mocks (2.13.0)
+ rspec-rails (2.13.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec-core (~> 2.12.0)
- rspec-expectations (~> 2.12.0)
- rspec-mocks (~> 2.12.0)
- sass (3.2.6)
+ rspec-core (~> 2.13.0)
+ rspec-expectations (~> 2.13.0)
+ rspec-mocks (~> 2.13.0)
+ sass (3.2.7)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
settingslogic (2.0.9)
- sextant (0.1.1)
+ sextant (0.2.3)
activesupport (>= 3.2)
rails (>= 3.2)
sidekiq (2.9.0)
@@ -184,27 +200,29 @@ GEM
slim (1.3.6)
temple (~> 0.5.5)
tilt (~> 1.3.3)
+ slop (3.4.4)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
+ state_machine (1.1.2)
temple (0.5.5)
therubyracer (0.11.4)
libv8 (~> 3.11.8.12)
ref
- thor (0.17.0)
- tilt (1.3.4)
+ thor (0.18.0)
+ tilt (1.3.6)
timers (1.1.0)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
truncate_html (0.5.5)
- tzinfo (0.3.35)
+ tzinfo (0.3.37)
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
- unicorn (4.5.0)
+ unicorn (4.6.2)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
@@ -216,6 +234,8 @@ PLATFORMS
ruby
DEPENDENCIES
+ better_errors
+ binding_of_caller
cache_digests
cancan
coffee-rails (~> 3.2.1)
@@ -226,6 +246,9 @@ DEPENDENCIES
jbuilder
jquery-rails
mysql2 (>= 0.3)
+ pry
+ pry-nav
+ pry-rails
rails (= 3.2.11)
rails_admin!
redcarpet (= 1.17.2)
@@ -237,6 +260,7 @@ DEPENDENCIES
sidekiq
sinatra (>= 1.3.0)
slim
+ state_machine
therubyracer
truncate_html (~> 0.5.4)
uglifier (>= 1.0.3)
View
@@ -7,11 +7,24 @@ class Solution < ActiveRecord::Base
LANGUAGES = ['C', 'Java', 'Python']
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
- solution = Solution.where(status: nil).first
+ solution = Solution.with_status(:pending).first
return solution unless solution
- solution.update_attributes(status: 'Testing')
+ solution.start_test
solution
end
@@ -20,10 +33,6 @@ def token
self[:token]
end
- def status
- self[:status] || "Pending"
- end
-
private
def generate_token
self[:token] = ::SecureRandom.hex(6)
@@ -1,5 +1,3 @@
-- admin = can? :manage, @challenge
-
%h1= @problem.name
%p
@@ -16,7 +14,7 @@
%pre= @problem.demo_output
%p
- - if admin
+ - if can? :manage, @challenge
= link_to 'Edit', edit_challenge_problem_path(@challenge, @problem)
\|
= link_to 'Back', challenge_path(@challenge)
@@ -14,10 +14,9 @@
%tr
- if @all
%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= solution.language
%td
= solution_status_display solution.status
= link_to solution.status, solution
-
View
@@ -3,3 +3,11 @@
en:
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.