Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/.rakeTasks

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .idea/nightzone.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

542 changes: 189 additions & 353 deletions .idea/workspace.xml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ gem 'selenium-webdriver'

gem 'activeadmin', github: 'gregbell/active_admin'

gem 'poltergeist'
gem 'poltergeist'
gem 'faye-rails', '~> 1.0.6'
26 changes: 26 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.6.3)
cookiejar (0.3.0)
cucumber (1.3.10)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
Expand All @@ -88,16 +89,38 @@ GEM
thread_safe (~> 0.1)
warden (~> 1.2.3)
diff-lcs (1.2.5)
em-http-request (1.1.2)
addressable (>= 2.3.4)
cookiejar
em-socksify (>= 0.3)
eventmachine (>= 1.0.3)
http_parser.rb (>= 0.6.0)
em-socksify (0.3.0)
eventmachine (>= 1.0.0.beta.4)
email_spec (1.5.0)
launchy (~> 2.1)
mail (~> 2.2)
erubis (2.7.0)
eventmachine (1.0.3)
execjs (2.0.2)
factory_girl (4.3.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.3.0)
factory_girl (~> 4.3.0)
railties (>= 3.0.0)
faye (0.8.9)
cookiejar (>= 0.3.0)
em-http-request (>= 0.3.0)
eventmachine (>= 0.12.0)
faye-websocket (>= 0.4.0)
rack (>= 1.0.0)
yajl-ruby (>= 1.0.0)
faye-rails (1.0.10)
eventmachine (~> 1.0.0)
faye (~> 0.8.9)
faye-websocket (0.7.2)
eventmachine (>= 0.12.0)
websocket-driver (>= 0.3.1)
ffi (1.9.3)
formtastic (2.3.0.rc2)
actionpack (>= 3.0)
Expand All @@ -107,6 +130,7 @@ GEM
actionpack (>= 3.2, < 5)
activesupport (>= 3.2, < 5)
hike (1.2.3)
http_parser.rb (0.6.0)
i18n (0.6.9)
inherited_resources (1.4.1)
has_scope (~> 0.6.0.rc)
Expand Down Expand Up @@ -250,6 +274,7 @@ GEM
websocket-driver (0.3.2)
xpath (2.0.0)
nokogiri (~> 1.3)
yajl-ruby (1.2.0)

PLATFORMS
ruby
Expand All @@ -263,6 +288,7 @@ DEPENDENCIES
devise
email_spec
factory_girl_rails (~> 4.0)
faye-rails (~> 1.0.6)
jbuilder (~> 1.2)
jquery-rails
mysql2
Expand Down
4 changes: 4 additions & 0 deletions app/admin/admin_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
f.actions
end

controller do
layout 'application'
end

end
10 changes: 2 additions & 8 deletions app/admin/dashboard.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
ActiveAdmin.register_page "Dashboard" do

menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") }
menu false

content :title => proc{ I18n.t("active_admin.dashboard") } do
div :class => "blank_slate_container", :id => "dashboard_default_message" do
span :class => "blank_slate" do
span I18n.t("active_admin.dashboard_welcome.welcome")
small I18n.t("active_admin.dashboard_welcome.call_to_action")
end
end

# Here is an example of a simple dashboard with columns and panels.
#
Expand All @@ -31,6 +25,6 @@
# end
end # content
controller do
layout 'application' # <-- here
layout 'application'
end
end
3 changes: 3 additions & 0 deletions app/assets/javascripts/task_hints.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/tasks.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/user_hints.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/user_tasks.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Place all the styles related to the game_codes controller here.
// Place all the styles related to the game_tasks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/task_codes.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the task_codes controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/task_hints.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the task_hints controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Place all the styles related to the GameHints controller here.
// Place all the styles related to the tasks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
2 changes: 1 addition & 1 deletion app/assets/stylesheets/user_games.css.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Place all the styles related to the UserGames controller here.
// Place all the styles related to the user_games controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/user_hints.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the user_hints controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/user_tasks.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the user_tasks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
2 changes: 1 addition & 1 deletion app/controllers/admin_games_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ def set_admin_game

# Never trust parameters from the scary internet, only allow the white list through.
def admin_game_params
params.require(:admin_game).permit(:admin_id, :game_id)
params.require(:admin_game).permit(:admin_user_id, :game_id)
end
end
45 changes: 28 additions & 17 deletions app/controllers/code_compares_controller.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
class CodeComparesController < ApplicationController
before_action :set_code_compare, only: [:destroy]
skip_before_filter :authorize_admin
def create
@code_compare = CodeCompare.new(code_compare_params)
before_filter :check_code_compare_creation, only: [:create]
before_filter :authenticate_user!

def create
@task = current_user.tasks.last
@game = @task.game
notice = @game.process(current_user, @task, params[:try_text])

respond_to do |format|
if @code_compare.save
format.html { head :no_content }
format.json { head :no_content }
else
format.html { head :no_content }
format.json { head :no_content }
end
format.html { redirect_to game_path(id: @game.id), notice: notice }
format.json { head :no_content }
end
end

Expand All @@ -24,13 +24,24 @@ def destroy
end

private
# Use callbacks to share common setup or constraints between actions.
def set_code_compare
@code_compare = CodeCompare.find(params[:id])
end
# Use callbacks to share common setup or constraints between actions.
def set_code_compare
@code_compare = CodeCompare.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def code_compare_params
params.require(:code_compare).permit(:user_id, :code_id)
end


protected

# Never trust parameters from the scary internet, only allow the white list through.
def code_compare_params
params.require(:code_compare).permit(:user_id, :code_id)
def check_code_compare_creation
unless params[:try_text] && params[:task]
@game = @task.game
redirect_to game_path(id: @game.game)
end
end
end

end
21 changes: 13 additions & 8 deletions app/controllers/codes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class CodesController < ApplicationController
before_action :set_code, only: [:show, :edit, :update, :destroy]
before_filter :check_game, only: [:new]
before_filter :check_game_create, only: [:create]
before_filter :check_task, only: [:new]
before_filter :check_task_create, only: [:create]
before_filter :no_codes, except: [:new, :create]

# GET /codes
Expand All @@ -13,10 +13,12 @@ def index
# GET /codes/1
# GET /codes/1.json
def show
@task = Task.find(@code.task_code.task_id)
end

# GET /codes/new
def new
@task = params[:task].to_i
@code = Code.new
end

Expand All @@ -28,10 +30,10 @@ def edit
# POST /codes.json
def create
@code = Code.new(code_params)
game = params.require(:code)[:game].to_i
task = params.require(:code)[:task].to_i
respond_to do |format|
if @code.save
if GameCode.create(game_id: game, code_id: @code.id)
if TaskCode.create(task_id: task, code_id: @code.id)
format.html { redirect_to @code, notice: 'Code was successfully created.' }
format.json { render action: 'show', status: :created, location: @code }
end
Expand Down Expand Up @@ -79,14 +81,17 @@ def code_params

protected

def check_game
unless params.require(:game)
def check_task
unless params.require(:task)
redirect_to games_path
end
if Task.find(params.require(:task).to_i).game.state != 0
redirect_to task_path(Task.find(params.require(:task).to_i)), notice: "You can't add new codes to tasks assigned with started or finished game"
end
end

def check_game_create
unless params.require(:code)
def check_task_create
unless params.require(:code)[:task]
redirect_to games_path
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class GameCodesController < ApplicationController
before_action :set_game_code, only: [:show, :edit, :update, :destroy]
class GameTasksController < ApplicationController
before_action :set_game_task, only: [:show, :edit, :update, :destroy]

# POST /game_codes
# POST /game_codes.json
# POST /game_tasks
# POST /game_tasks.json
def create
@game_code = GameCode.new(game_code_params)
@game_task = GameTask.new(game_task_params)

respond_to do |format|
if @game_code.save
if @game_task.save
format.html { head :no_content }
format.json { head :no_content }
else
Expand All @@ -17,11 +17,10 @@ def create
end
end


# DELETE /game_codes/1
# DELETE /game_codes/1.json
# DELETE /game_tasks/1
# DELETE /game_tasks/1.json
def destroy
@game_code.destroy
@game_task.destroy
respond_to do |format|
format.html { head :no_content }
format.json { head :no_content }
Expand All @@ -30,12 +29,12 @@ def destroy

private
# Use callbacks to share common setup or constraints between actions.
def set_game_code
@game_code = GameCode.find(params[:id])
def set_game_task
@game_task = GameTask.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def game_code_params
params.require(:game_code).permit(:game_id, :code_id)
def game_task_params
params.require(:game_task).permit(:game_id, :task_id)
end
end
Loading