summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorguntasgrewal <guntasgrewal@gmail.com>2014-03-25 17:30:10 -0400
committerguntasgrewal <guntasgrewal@gmail.com>2014-03-25 17:30:10 -0400
commit0c22c4bd9a0b4a0b0ff5840c1af41c0b320e3529 (patch)
tree2fc2082814e513ec5d68b22e7fa07d268df6d788 /app
parent8435c0a5ec9889a9da6ede2e24c044d64b279095 (diff)
added match status
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/ajax.js19
-rw-r--r--app/assets/stylesheets/application.css12
-rw-r--r--app/assets/stylesheets/custom.css.scss53
-rw-r--r--app/assets/stylesheets/scaffolds.css.scss40
-rw-r--r--app/assets/stylesheets/static.css.scss9
-rw-r--r--app/assets/stylesheets/tournaments.css.scss9
-rw-r--r--app/controllers/alerts_controller.rb10
-rw-r--r--app/controllers/application_controller.rb3
-rw-r--r--app/controllers/matches_controller.rb25
-rw-r--r--app/controllers/servers_controller.rb10
-rw-r--r--app/controllers/sessions_controller.rb122
-rw-r--r--app/controllers/static_controller.rb2
-rw-r--r--app/controllers/tournaments_controller.rb77
-rw-r--r--app/controllers/users_controller.rb30
-rw-r--r--app/helpers/sessions_helper.rb71
-rw-r--r--app/models/match.rb6
-rw-r--r--app/models/team.rb2
-rw-r--r--app/models/tournament.rb41
-rw-r--r--app/models/user.rb149
-rw-r--r--app/views/alerts/show.html.erb2
-rw-r--r--app/views/application/permission_denied.html.erb1
-rw-r--r--app/views/common/_error_messages.html.erb11
-rw-r--r--app/views/games/index.html.erb6
-rw-r--r--app/views/games/show.html.erb2
-rw-r--r--app/views/layouts/application.html.erb28
-rw-r--r--app/views/matches/_form.html.erb23
-rw-r--r--app/views/matches/index.html.erb14
-rw-r--r--app/views/matches/index.json.jbuilder2
-rw-r--r--app/views/matches/new.html.erb2
-rw-r--r--app/views/matches/show.html.erb34
-rw-r--r--app/views/matches/show.json.jbuilder2
-rw-r--r--app/views/pms/show.html.erb2
-rw-r--r--app/views/servers/show.html.erb2
-rw-r--r--app/views/sessions/_form.html.erb21
-rw-r--r--app/views/sessions/edit.html.erb6
-rw-r--r--app/views/sessions/index.html.erb27
-rw-r--r--app/views/sessions/index.json.jbuilder4
-rw-r--r--app/views/sessions/new.html.erb24
-rw-r--r--app/views/sessions/show.html.erb9
-rw-r--r--app/views/sessions/show.json.jbuilder1
-rw-r--r--app/views/static/homepage.html.erb18
-rw-r--r--app/views/tournaments/_selected.html.erb21
-rw-r--r--app/views/tournaments/index.html.erb47
-rw-r--r--app/views/tournaments/join.html.erb2
-rw-r--r--app/views/tournaments/new.html.erb15
-rw-r--r--app/views/tournaments/show.html.erb35
-rw-r--r--app/views/users/already_signed_in.html.erb1
-rw-r--r--app/views/users/index.html.erb6
-rw-r--r--app/views/users/new.html.erb33
-rw-r--r--app/views/users/show.html.erb2
50 files changed, 260 insertions, 833 deletions
diff --git a/app/assets/javascripts/ajax.js b/app/assets/javascripts/ajax.js
deleted file mode 100644
index 040c100..0000000
--- a/app/assets/javascripts/ajax.js
+++ /dev/null
@@ -1,19 +0,0 @@
-function populate() {
- //populate optionArray
- //make a form element
- var e = document.getElementById("tournament_id");
- var gameType = e.options[e.selectedIndex].text;
- if (gameType != "Select a Game Type") {
- alert(gameType + " was Selected!");
- //populate optionArray via AJAX
- //select * from tournament_settings where gametype = GameType
- for(var option in optionArray){
- //identify the number of
- ;
- }
- };
-
-//$.ajax(url: "/selected").done (html) -> $("#ajax-form").append html
-
-}
-
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index b3f5d46..3192ec8 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -11,15 +11,3 @@
*= require_self
*= require_tree .
*/
-
-#query{
- background-color: white;
- border: 2px solid #ED9C28;
- border-radius: 5px;
- color: #FFF;
- font-weight: bold;
- height: 30px;
-}
-.navbar{
- background-color: white;
-}
diff --git a/app/assets/stylesheets/custom.css.scss b/app/assets/stylesheets/custom.css.scss
deleted file mode 100644
index 1a9b09a..0000000
--- a/app/assets/stylesheets/custom.css.scss
+++ /dev/null
@@ -1,53 +0,0 @@
-@import "bootstrap";
-
-header > nav {
- @extend .navbar;
- @extend .navbar-inverse;
- color: white;
-
- #log-buttons {
- margin-top: 8px;
- form { display: inline; }
- }
- form.search {
- @extend .navbar-form;
- @extend .navbar-right;
- input[type="submit"] {
- @extend .btn-warning; margin-top: -3px; margin-right: 8px;
- }
- }
-}
-
-a, input[type="submit"] {
- @extend .btn;
- &.user { @extend .btn-info; }
- &.signup { @extend .btn-success; }
- &.signin { @extend .btn-info; }
- &.signout { @extend .btn-danger; }
-}
-
-p.errors {
- background-color: #FCF8C7;
- color: red;
- border-radius: 7px;
- padding: 10px;
-}
-
-#errorExplanation {
- h2 {
- font-size: 1em;
- color: red;
- font-weight: bold;
- }
- li {
- font-size: 1em;
- color: red;
- font-style: italic;
- }
-
-}
-
-#notice {
- text-align: center;
- font-weight: bold;
-} \ No newline at end of file
diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss
index 6700fef..6ec6a8f 100644
--- a/app/assets/stylesheets/scaffolds.css.scss
+++ b/app/assets/stylesheets/scaffolds.css.scss
@@ -1,5 +1,3 @@
-@import "bootstrap";
-
body {
background-color: #fff;
color: #333;
@@ -8,10 +6,6 @@ body {
line-height: 18px;
}
-h1, h2, h3, h4, h5{
- color: #0f0f0f;
-}
-
p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
@@ -27,11 +21,11 @@ pre {
a {
color: #000;
&:visited {
- color: #000;
+ color: #666;
}
&:hover {
- color: green;
- text-decoration: none;
+ color: #fff;
+ background-color: #000;
}
}
@@ -46,9 +40,8 @@ div {
}
.field_with_errors {
- padding: 1px;
- background-color: #FF4C4C;
- box-shadow: 0px 0px 5px red;
+ padding: 2px;
+ background-color: red;
display: table;
}
@@ -74,26 +67,3 @@ div {
list-style: square;
}
}
-
-.navbar-brand {
- @extend .no-dec;
- a{
- color: white;
- &:hover, &:active, &:focus {
- color: white;
- font-weight: normal;
- text-decoration: none;
- }
- }
-}
-
-footer {
- text-align: center;
- border-top: solid 1px #999999;
- padding-top: 18px;
- margin-top: 18px;
-}
-
-button, input[type="submit"] {
- @extend .btn;
-}
diff --git a/app/assets/stylesheets/static.css.scss b/app/assets/stylesheets/static.css.scss
index d73e77d..5a803c8 100644
--- a/app/assets/stylesheets/static.css.scss
+++ b/app/assets/stylesheets/static.css.scss
@@ -1,12 +1,3 @@
// Place all the styles related to the static controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
-
-.jumbotron {
- background-color: #FFF;
-
- p {
- line-height: 1.5em;
- }
-
-}
diff --git a/app/assets/stylesheets/tournaments.css.scss b/app/assets/stylesheets/tournaments.css.scss
index 458897e..e372b90 100644
--- a/app/assets/stylesheets/tournaments.css.scss
+++ b/app/assets/stylesheets/tournaments.css.scss
@@ -1,12 +1,3 @@
// Place all the styles related to the tournaments controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
-
-p.default-field {
- display: inline;
-}
-
-span.default-explanation {
- color: gray;
- font-style: italic;
-}
diff --git a/app/controllers/alerts_controller.rb b/app/controllers/alerts_controller.rb
index ac11854..873e9b7 100644
--- a/app/controllers/alerts_controller.rb
+++ b/app/controllers/alerts_controller.rb
@@ -1,6 +1,5 @@
class AlertsController < ApplicationController
before_action :set_alert, only: [:show, :edit, :update, :destroy]
- before_action :check_perms, only: [:new, :create, :edit, :update, :destroy]
# GET /alerts
# GET /alerts.json
@@ -68,15 +67,6 @@ class AlertsController < ApplicationController
@alert = Alert.find(params[:id])
end
- def check_perms
- unless (signed_in? and (current_user.in_group?(:admin) or current_user.in_group?(:host)))
- respond_to do |format|
- format.html { render action: 'permission_denied', status: :forbidden }
- format.json { render json: "Permission denied", status: :forbidden }
- end
- end
- end
-
# Never trust parameters from the scary internet, only allow the white list through.
def alert_params
params.require(:alert).permit(:author_id, :message)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 7487f87..d83690e 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,7 +2,4 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
-
- #include sessionhelper for the session controller and view
- include SessionsHelper
end
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index 1f0d964..d79a7fc 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -1,10 +1,10 @@
class MatchesController < ApplicationController
- before_action :set_tournament, only: [:index, :new, :create]
before_action :set_match, only: [:show, :edit, :update, :destroy]
+
# GET /matches
# GET /matches.json
def index
- @matches = @tournament.matches
+ @matches = Match.all
end
# GET /matches/1
@@ -14,7 +14,7 @@ class MatchesController < ApplicationController
# GET /matches/new
def new
-
+ @match = Match.new
end
# GET /matches/1/edit
@@ -24,11 +24,11 @@ class MatchesController < ApplicationController
# POST /matches
# POST /matches.json
def create
- @match = @tournament.matches.build(match_params)
+ @match = Match.new(match_params)
respond_to do |format|
if @match.save
- format.html { redirect_to tournament_matches_path, notice: 'Match was successfully created.' }
+ format.html { redirect_to @match, notice: 'Match was successfully created.' }
format.json { render action: 'show', status: :created, location: @match }
else
format.html { render action: 'new' }
@@ -42,7 +42,7 @@ class MatchesController < ApplicationController
def update
respond_to do |format|
if @match.update(match_params)
- format.html { redirect_to [@tournament, @match], notice: 'Match was successfully updated.' }
+ format.html { redirect_to @match, notice: 'Match was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
@@ -54,24 +54,21 @@ class MatchesController < ApplicationController
# DELETE /matches/1
# DELETE /matches/1.json
def destroy
-
@match.destroy
respond_to do |format|
- format.html { redirect_to tournament_matches_path }
+ format.html { redirect_to matches_url }
+ format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_match
- @tournament = Tournament.find(params[:tournament_id])
- @match = @tournament.matches.find(params[:id]);
- end
- def set_tournament
- @tournament = Tournament.find(params[:tournament_id])
+ @match = Match.find(params[:id])
end
+
# Never trust parameters from the scary internet, only allow the white list through.
def match_params
- params.require(:match).permit(:tournament_id, :name, :winner_id)
+ params.require(:match).permit(:status, :tournament_id, :name, :winner_id)
end
end
diff --git a/app/controllers/servers_controller.rb b/app/controllers/servers_controller.rb
index bb5d5f7..7d54eb6 100644
--- a/app/controllers/servers_controller.rb
+++ b/app/controllers/servers_controller.rb
@@ -1,6 +1,5 @@
class ServersController < ApplicationController
before_action :set_server, only: [:show, :edit, :update, :destroy]
- before_action :check_perms
# GET /servers
# GET /servers.json
@@ -68,15 +67,6 @@ class ServersController < ApplicationController
@server = Server.find(params[:id])
end
- def check_perms
- unless (signed_in? and current_user.in_group?(:admin))
- respond_to do |format|
- format.html { render action: 'permission_denied', status: :forbidden }
- format.json { render json: "Permission denied", status: :forbidden }
- end
- end
- end
-
# Never trust parameters from the scary internet, only allow the white list through.
def server_params
params[:server]
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 7cb16e8..2f72bf7 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,52 +1,74 @@
class SessionsController < ApplicationController
- before_action :set_session, only: [:destroy]
-
- # GET /sessions/new
- def new
- @user = User.new
- #@session = Session.new
- end
-
- # POST /sessions
- # POST /sessions.json
- def create
- # find the user...
- @user = User.find_by_email(params[:session][:username_or_email]) || User.find_by_user_name(params[:session][:username_or_email])
-
- #@session = Session.new(@user)
- # ... and create a new session
- respond_to do |format|
- if @user && @user.authenticate(params[:session][:password])
- sign_in @user
- format.html { redirect_to root_path }
- #format.json { #TODO }
- else
- format.html { render action: 'new' }
- format.json { render json: @user.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /sessions/1
- # DELETE /sessions/1.json
- def destroy
- #@session.destroy
- sign_out
- respond_to do |format|
- format.html { redirect_to root_path }
- format.json { head :no_content }
- end
- end
-
- private
-
- # Use callbacks to share common setup or constraints between actions.
- def set_session
- #@session = Session.find(cookies[:remember_token])
- end
-
- # Never trust parameters from the scary internet, only allow the white list through.
- def session_params
- params.require(:session).permit(:session_email, :session_user_name, :session_password)
- end
+ before_action :set_session, only: [:show, :edit, :update, :destroy]
+
+ # GET /sessions
+ # GET /sessions.json
+ def index
+ @sessions = Session.all
+ end
+
+ # GET /sessions/1
+ # GET /sessions/1.json
+ def show
+ end
+
+ # GET /sessions/new
+ def new
+ @session = Session.new
+ end
+
+ # GET /sessions/1/edit
+ def edit
+ end
+
+ # POST /sessions
+ # POST /sessions.json
+ def create
+ @session = Session.new(session_params)
+
+ respond_to do |format|
+ if @session.save
+ format.html { redirect_to @session, notice: 'Session was successfully created.' }
+ format.json { render action: 'show', status: :created, location: @session }
+ else
+ format.html { render action: 'new' }
+ format.json { render json: @session.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /sessions/1
+ # PATCH/PUT /sessions/1.json
+ def update
+ respond_to do |format|
+ if @session.update(session_params)
+ format.html { redirect_to @session, notice: 'Session was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: 'edit' }
+ format.json { render json: @session.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /sessions/1
+ # DELETE /sessions/1.json
+ def destroy
+ @session.destroy
+ respond_to do |format|
+ format.html { redirect_to sessions_url }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_session
+ @session = Session.find(params[:id])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def session_params
+ params.require(:session).permit(:user_id)
+ end
end
diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb
index 6fc9490..c6df11e 100644
--- a/app/controllers/static_controller.rb
+++ b/app/controllers/static_controller.rb
@@ -1,4 +1,2 @@
class StaticController < ApplicationController
- def homepage
- end
end
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 8d90758..d7db632 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -1,6 +1,5 @@
class TournamentsController < ApplicationController
- before_action :set_tournament, only: [:show, :edit, :update, :destroy, :join]
- before_action :check_perms, only: [:new, :create, :edit, :destroy]
+ before_action :set_tournament, only: [:show, :edit, :update, :destroy]
# GET /tournaments
# GET /tournaments.json
@@ -11,37 +10,24 @@ class TournamentsController < ApplicationController
# GET /tournaments/1
# GET /tournaments/1.json
def show
- case @tournament.status
- when 0
- when 1..2
- redirect_to "/tournaments/" + @tournament.id.to_s + "/matches" #tournament_matches_page(@tournament)
- end
end
# GET /tournaments/new
def new
- @games = Game.all
- @tournament = Tournament.new(game: Game.find_by_id(params[:game]))
+ @tournament = Tournament.new
end
# GET /tournaments/1/edit
def edit
- if params['close_action'] == 'close'
- @tournament.status = 1
- @tournament.save
- @tournament.setup(@tournament)
- redirect_to "/tournaments"
- end
end
# POST /tournaments
# POST /tournaments.json
def create
@tournament = Tournament.new(tournament_params)
- @tournament.status = 0
+
respond_to do |format|
if @tournament.save
- @tournament.hosts.push(current_user)
format.html { redirect_to @tournament, notice: 'Tournament was successfully created.' }
format.json { render action: 'show', status: :created, location: @tournament }
else
@@ -54,45 +40,13 @@ class TournamentsController < ApplicationController
# PATCH/PUT /tournaments/1
# PATCH/PUT /tournaments/1.json
def update
-
- if params[:update_action].nil?
- check_perms
- respond_to do |format|
- if @tournament.update(tournament_params)
- format.html { redirect_to @tournament, notice: 'Tournament was successfully updated.' }
- format.json { head :no_content }
- else
- format.html { render action: 'edit' }
- format.json { render json: @tournament.errors, status: :unprocessable_entity }
- end
- end
- else
- case params[:update_action]
- when "join"
- respond_to do |format|
- if @tournament.join(current_user)
- format.html { render action: 'show', notice: 'You have joined this tournament.' }
- format.json { head :no_content }
- end
- format.html { render action: 'permission_denied', status: :forbidden }
- format.json { render json: "Permission denied", status: :forbidden }
- end
- when "open"
- respond_to do |format|
- if @tournament.setup
- format.html { render action: 'show', notice: 'You have joined this tournament.' }
- format.json { head :no_content }
- end
- format.html { render action: 'permission_denied', status: :forbidden }
- format.json { render json: "Permission denied", status: :forbidden }
- end
- #when "close"
- # TODO
+ respond_to do |format|
+ if @tournament.update(tournament_params)
+ format.html { redirect_to @tournament, notice: 'Tournament was successfully updated.' }
+ format.json { head :no_content }
else
- respond_to do |format|
- format.html { render action: 'show', notice: "Invalid action", status: :unprocessable_entity }
- format.json { render json: @tournament.errors, status: :unprocessable_entity }
- end
+ format.html { render action: 'edit' }
+ format.json { render json: @tournament.errors, status: :unprocessable_entity }
end
end
end
@@ -113,19 +67,8 @@ class TournamentsController < ApplicationController
@tournament = Tournament.find(params[:id])
end
- def check_perms
- unless (signed_in? and current_user.in_group?(:host))
- respond_to do |format|
- format.html { render action: 'permission_denied', status: :forbidden }
- format.json { render json: "Permission denied", status: :forbidden }
- end
- end
- end
-
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
-
- params.require(:tournament).permit(:game, :name, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams)
-
+ params.require(:tournament).permit(:name, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams)
end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 70facca..b18efed 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,7 +1,5 @@
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
- before_action :perms_edit, only: [:edit, :update, :destroy]
- before_action :perms_create, only: [:new, :create]
# GET /users
# GET /users.json
@@ -12,7 +10,6 @@ class UsersController < ApplicationController
# GET /users/1
# GET /users/1.json
def show
- @user = User.find(params[:id])
end
# GET /users/new
@@ -28,14 +25,13 @@ class UsersController < ApplicationController
# POST /users.json
def create
@user = User.new(user_params)
- @user.groups = 0
+
respond_to do |format|
if @user.save
- sign_in @user
- format.html { redirect_to root_path, notice: 'User was successfully created.' }
+ format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render action: 'show', status: :created, location: @user }
else
- format.html { render action: 'new', status: :unprocessable_entity }
+ format.html { render action: 'new' }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
@@ -71,26 +67,8 @@ class UsersController < ApplicationController
@user = User.find(params[:id])
end
- def perms_edit
- unless (current_user == @user) or (signed_in? and current_user.in_group? :admin)
- respond_to do |format|
- format.html { render action: 'permission_denied', status: :forbidden }
- format.json { render json: "Permission denied", status: :forbidden }
- end
- end
- end
-
- def perms_create
- if signed_in?
- respond_to do |format|
- format.html { render action: 'already_signed_in', status: :unprocessable_entity }
- format.json { render json: "Already signed in", status: :unprocessable_entity }
- end
- end
- end
-
# Never trust parameters from the scary internet, only allow the white list through.
def user_params
- params.require(:user).permit(:name, :email, :user_name, :password, :password_confirmation)
+ params.require(:user).permit(:name, :email, :user_name)
end
end
diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb
index 046ca6f..309f8b2 100644
--- a/app/helpers/sessions_helper.rb
+++ b/app/helpers/sessions_helper.rb
@@ -1,73 +1,2 @@
module SessionsHelper
-
- def sign_in(user)
- #create a new remember token
- remember_token = User.new_remember_token
- #place token inside of the browser
- cookies.permanent[:remember_token] = remember_token
- #save the hashed token to the database
- user.update_attribute(:remember_token,
- User.hash(remember_token))
- #set the current user to be the given user
- self.current_user = user
- end
-
-# The curret_user=(user) is the conversion of self.current_user = user
- def current_user=(user)
- @current_user = user
- end
-
-# sets the @current_user instance virable to the user corresponding
-# to the remember token, but only if @current_user is undefined
-# since the remember token is hashed, we need to hash the cookie
-# to find match the remember token
- def current_user
- remember_token = User.hash(cookies[:remember_token])
- @current_user ||= User.find_by(remember_token: remember_token)
- end
-
- # checks if someone is currently signed in
- def signed_in?
- !current_user.nil?
- end
-
- def sign_out
- current_user.update_attribute(:remember_token, User.hash(User.new_remember_token))
- cookies.delete(:remember_token)
- self.current_user = nil
- end
-
-=begin
-
-This is for anyone that cares about how long a user is signed
-in:
-
-Currently I have a user to be signed in forever unless they
-log out (cookies.permanent....).
-
-If you want to change that, change line 7 to this:
-
-cookies[:remember_token] = { value: remember_token,
- expires: 20.years.from_now.utc }
-
-which will expire the cookie in 20 years from its date of
-creation.
-
-Oddly enough, this line above is equivalent to the:
-
-cookies.permanent
-
-This is just a short cut for this line since most people
-create permanent cookies these days.
-
-Other times are:
-
-10.weeks.from_now
-
-5.days.ago
-
-etc...
-
-=end
-
end
diff --git a/app/models/match.rb b/app/models/match.rb
index 782dce8..bb814c1 100644
--- a/app/models/match.rb
+++ b/app/models/match.rb
@@ -1,8 +1,4 @@
class Match < ActiveRecord::Base
belongs_to :tournament
-
- has_and_belongs_to_many :teams
-
- belongs_to :winner, class_name: "Team"
-
+ belongs_to :winner
end
diff --git a/app/models/team.rb b/app/models/team.rb
index 2348de5..9e71557 100644
--- a/app/models/team.rb
+++ b/app/models/team.rb
@@ -1,5 +1,3 @@
class Team < ActiveRecord::Base
belongs_to :match
- has_and_belongs_to_many :matches
- has_and_belongs_to_many :users
end
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 69bedf5..cc915a0 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -1,42 +1,3 @@
class Tournament < ActiveRecord::Base
- belongs_to :game
- has_many :matches
- has_and_belongs_to_many :players, class_name: "User", association_foreign_key: "player_id", join_table: "players_tournaments"
- has_and_belongs_to_many :hosts, class_name: "User", association_foreign_key: "host_id", join_table: "hosts_tournaments"
-
- def open?
- return true
- end
-
- def joinable_by?(user)
- return ((not user.nil?) and user.in_group?(:player) and open?)
- end
-
- def join(user)
- unless joinable_by?(user)
- return false
- end
- players.push(user)
- end
-
- def setup(tournament)
- num_teams = (self.players.count/self.max_players_per_team).floor
- num_matches = num_teams - 1
- for i in 1..num_matches
- self.matches.create(name: "Match #{i}")
- end
- match_num = 0
- team_num = 0
- self.players.each_slice(tournament.max_players_per_team) do |players|
- self.matches[match_num].teams.push(Team.create(users: players))
- if (team_num != 0 and team_num % tournament.max_teams_per_match == 0)
- match_num += 1
- team_num = 0
- else
- team_num += 1
- end
- end
- end
-
-
+ belongs_to :game
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 6e439fb..4a57cf0 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,151 +1,2 @@
class User < ActiveRecord::Base
- has_and_belongs_to_many :tournaments_played, class_name: "Tournament", foreign_key: "player_id", join_table: "players_tournaments"
- has_and_belongs_to_many :tournaments_hosted, class_name: "Tournament", foreign_key: "host_id", join_table: "hosts_tournaments"
- has_and_belongs_to_many :teams
-
- before_save { self.email = email.downcase }
- before_save { self.user_name = user_name }
-
- ##
- # Rails looks for the create_remember_token and runs the method
- # before anything else.
- #
- # This method cannot be called by a user since it is denoted
- # as private.
- before_create :create_remember_token
-
- def in_group?(group)
- case group
- when :admin
- return ((groups & 2) != 0)
- when :host
- return true #((groups & 1) != 0)
- when :player
- return true
- when :specator
- return true
- else
- return false
- end
- end
-
- def join_groups(join=[])
- # FIXME: race condition
- join.each do |group|
- case group
- when :admin
- groups |= 2
- when :host
- groups |= 1
- else
- end
- end
- end
-
- def leave_groups(leave=[])
- # FIXME: race condition
- leave.each do |group|
- case group
- when :admin
- groups &= ~ 2
- when :host
- groups &= ~ 1
- else
- end
- end
- end
-
- ##
- # VAILD_EMAIL is the regex used to validate a user given email.
- VALID_EMAIL_REG = /\A\S+@\S+\.\S+\z/i
-
- ##
- # VALID_USER_NAME checks to make sure a user's user_name
- # is in the proper format.
- VALID_USER_NAME_REG = /\A[a-zA-Z0-9\-]+\z/
-
- ##
- # The following lines put a user account through a series of
- # validations in order to make sure all of their information
- # is in the proper format.
- #
- # validates :symbol_to_be_validated
- #
- # - presence: determines whether or not a symbol is filled or not
- # - length: ensures there is a length limit on the symbol
- # - format: checks the format of given information to ensure
- # validity
- validates(:name, presence: true, length: { maximum: 50 })
- validates(:email, presence: true, format: {with:
- VALID_EMAIL_REG},
- uniqueness: { case_sensitive: false })
- validates(:user_name, presence: true, length:{maximum: 50},
- format: {with: VALID_USER_NAME_REG },
- uniqueness: {case_sensitive: false })
-
- ##
- # Instead of adding password and password_confirmation
- # attributes, requiring the presence of a password,
- # requiring that pw and pw_com match, and add an authenticate
- # method to compare an encrypted password to the
- # password_digest to authenticate users, I can just add
- # has_secure_password which does all of this for me.
- has_secure_password
-
- validates :password, length: { minimum: 6 }
-
- ##
- # Create a random remember token for the user. This will be
- # changed every time the user creates a new session.
- #
- # By changing the cookie every new session, any hijacked sessions
- # (where the attacker steals a cookie to sign in as a certain
- # user) will expire the next time the user signs back in.
- #
- # The random string is of length 16 composed of A-Z, a-z, 0-9
- # This is the browser's cookie value.
- def User.new_remember_token
- SecureRandom.urlsafe_base64
- end
-
- ##
- # Encrypt the remember token.
- # This is the encrypted version of the cookie stored on
- # the database.
- #
- # The reasoning for storing a hashed token is so that even if
- # the database is compromised, the attacker won't be able to use
- # the remember tokens to sign in.
- def User.hash(token)
- Digest::SHA1.hexdigest(token.to_s)
- end
-
- ##
- # SHA-1 (Secure Hash Algorithm) is a US engineered hash
- # function that produces a 20 byte hash value which typically
- # forms a hexadecimal number 40 digits long.
- # The reason I am not using the Bcrypt algorithm is because
- # SHA-1 is much faster and I will be calling this on
- # every page a user accesses.
- #
- # https://en.wikipedia.org/wiki/SHA-1
-
-
- # Everything under private is hidden so you cannot call.
- private
-
- ##
- # Create_remember_token in order to ensure a user always has
- # a remember token.
- def create_remember_token
- self.remember_token = User.hash(User.new_remember_token)
- end
-
- ##
- # In order to ensure that someone did not accidentally submit
- # two accounts rapidly (which would throw off the validates
- # for user_name and email), I added an index to the Users
- # email and user_name in the database to ensure uniqueness
- # This also gives and index to the user_name and email
- # so finding a user SHOULD be easier for the database.
end
diff --git a/app/views/alerts/show.html.erb b/app/views/alerts/show.html.erb
index 5dda2c9..eeab7f7 100644
--- a/app/views/alerts/show.html.erb
+++ b/app/views/alerts/show.html.erb
@@ -1,3 +1,5 @@
+<p id="notice"><%= notice %></p>
+
<p>
<strong>Author:</strong>
<%= @alert.author %>
diff --git a/app/views/application/permission_denied.html.erb b/app/views/application/permission_denied.html.erb
deleted file mode 100644
index 1ef883c..0000000
--- a/app/views/application/permission_denied.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<h1>Permission denied</h1>
diff --git a/app/views/common/_error_messages.html.erb b/app/views/common/_error_messages.html.erb
deleted file mode 100644
index 731f62c..0000000
--- a/app/views/common/_error_messages.html.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-<%# http://railscasts.com/episodes/211-validations-in-rails-3 %>
-<% if target.errors.any? %>
-<div id="errorExplanation">
- <h2><%= pluralize(target.errors.count, "error") %> prohibited this form from being submitted:</h2>
- <ul>
- <% target.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
-</div>
-<% end %>
diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb
index 79acd1e..27c5860 100644
--- a/app/views/games/index.html.erb
+++ b/app/views/games/index.html.erb
@@ -1,6 +1,6 @@
<h1>Listing games</h1>
-<table class="table table-hover">
+<table>
<thead>
<tr>
<th>Name</th>
@@ -36,6 +36,4 @@
<br>
-
-<%= link_to 'New Game', new_game_path, {:class => "btn btn-warning"} %>
-
+<%= link_to 'New Game', new_game_path %>
diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb
index 39d4a97..1f1a154 100644
--- a/app/views/games/show.html.erb
+++ b/app/views/games/show.html.erb
@@ -1,3 +1,5 @@
+<p id="notice"><%= notice %></p>
+
<p>
<strong>Name:</strong>
<%= @game.name %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 976ee85..cefd1be 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -5,36 +5,10 @@
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
- <%= yield :head %>
</head>
<body>
-<header><nav>
- <div class="navbar-brand"><%= link_to('Leaguer', root_path) %></div>
- <div>
- <%= form_tag("/search", method: "get", :class => "search") do %>
- <%= text_field_tag(:query, nil, :placeholder => "Search") %>
- <%= submit_tag("Go") %>
- <% end %>
- </div>
- <div id="log-buttons">
- <% if signed_in? %>
- <%= link_to current_user.user_name, current_user, :class => "user" %>
- <%= link_to "Sign out", session_path("current"), method: "delete", :class => "signout" %>
- <% else %>
- <%= link_to "Log in", new_session_path, :class => "signin" %>
- <%= link_to "Sign up", new_user_path, :class => "signup" %>
- <% end %>
- </div>
-</nav></header>
+<%= yield %>
-<% if notice %><div id="notice"><p><%= notice %></p></div><% end %>
-
-<div class="container"><%= yield %></div>
-
-<footer>
- <p>Leaguer &copy; 2014, Tomer Kimia, Andrew Murrell, Luke Shumaker, Nathaniel Foy, Davis Webb, and Guntas Grewal</p>
-</footer>
-<%= debug(params) if Rails.env.development? %>
</body>
</html>
diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb
index 015aed0..727c002 100644
--- a/app/views/matches/_form.html.erb
+++ b/app/views/matches/_form.html.erb
@@ -1,5 +1,20 @@
-<%= form_for([@tournament, @tournament.matches.build]) do |f| %>
-
+<%= form_for(@match) do |f| %>
+ <% if @match.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:</h2>
+
+ <ul>
+ <% @match.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :status %><br>
+ <%= f.number_field :status %>
+ </div>
<div class="field">
<%= f.label :tournament_id %><br>
<%= f.text_field :tournament_id %>
@@ -8,6 +23,10 @@
<%= f.label :name %><br>
<%= f.text_field :name %>
</div>
+ <div class="field">
+ <%= f.label :winner_id %><br>
+ <%= f.text_field :winner_id %>
+ </div>
<div class="actions">
<%= f.submit %>
</div>
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb
index 60df1b5..400efb4 100644
--- a/app/views/matches/index.html.erb
+++ b/app/views/matches/index.html.erb
@@ -3,6 +3,7 @@
<table>
<thead>
<tr>
+ <th>Status</th>
<th>Tournament</th>
<th>Name</th>
<th>Winner</th>
@@ -13,14 +14,15 @@
</thead>
<tbody>
- <% @tournament.matches.each do |match| %>
+ <% @matches.each do |match| %>
<tr>
- <td><%= match.tournament.id %></td>
+ <td><%= match.status %></td>
+ <td><%= match.tournament %></td>
<td><%= match.name %></td>
<td><%= match.winner %></td>
- <td><%= link_to 'Show', tournament_match_path(@tournament, match) %></td>
- <td><%= link_to 'Edit', edit_tournament_match_path(@tournament, match) %></td>
- <td><%= link_to 'Destroy', tournament_match_path(@tournament, match), method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ <td><%= link_to 'Show', match %></td>
+ <td><%= link_to 'Edit', edit_match_path(match) %></td>
+ <td><%= link_to 'Destroy', match, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
@@ -28,4 +30,4 @@
<br>
-<%= link_to 'New Match', new_tournament_match_path %>
+<%= link_to 'New Match', new_match_path %>
diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder
index 0b2bfcd..1a63f5f 100644
--- a/app/views/matches/index.json.jbuilder
+++ b/app/views/matches/index.json.jbuilder
@@ -1,4 +1,4 @@
json.array!(@matches) do |match|
- json.extract! match, :id, :tournament_id, :name, :winner_id
+ json.extract! match, :id, :status, :tournament_id, :name, :winner_id
json.url match_url(match, format: :json)
end
diff --git a/app/views/matches/new.html.erb b/app/views/matches/new.html.erb
index 74e7e3a..bd4c78c 100644
--- a/app/views/matches/new.html.erb
+++ b/app/views/matches/new.html.erb
@@ -1,3 +1,5 @@
<h1>New match</h1>
<%= render 'form' %>
+
+<%= link_to 'Back', matches_path %>
diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb
index b6930ea..f3fc822 100644
--- a/app/views/matches/show.html.erb
+++ b/app/views/matches/show.html.erb
@@ -1,6 +1,13 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <strong>Status:</strong>
+ <%= @match.status %>
+</p>
+
<p>
<strong>Tournament:</strong>
- <%= @match.tournament.id %>
+ <%= @match.tournament %>
</p>
<p>
@@ -8,23 +15,10 @@
<%= @match.name %>
</p>
-<% if (@tournament.hosts.include?(current_user) and @match.winner.nil?) %>
- <%= form_for([@tournament, @match], method: "put") do |f| %>
- <ul>
- <% @match.teams.each do |team| %>
- <li><label><%= f.radio_button(:winner, team.id) %>
- <%= team.users.collect{|u| u.user_name}.join(", ") %></label></li>
- <% end %>
- </ul>
- <%= f.submit("Select winner") %>
- <% end %>
-<% end %>
-
-<% unless @match.winner.nil? %>
- <p>
- <strong>Winner:</strong>
- <%= @match.winner.users.collect{|u| u.user_name}.join(", ") %>
- </p>
-<% end %>
+<p>
+ <strong>Winner:</strong>
+ <%= @match.winner %>
+</p>
-<%= link_to 'Back', tournament_matches_path %>
+<%= link_to 'Edit', edit_match_path(@match) %> |
+<%= link_to 'Back', matches_path %>
diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder
index fe14010..a3ef588 100644
--- a/app/views/matches/show.json.jbuilder
+++ b/app/views/matches/show.json.jbuilder
@@ -1 +1 @@
-json.extract! @match, :id, :tournament_id, :name, :winner_id, :created_at, :updated_at
+json.extract! @match, :id, :status, :tournament_id, :name, :winner_id, :created_at, :updated_at
diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb
index 2a03716..5ee483f 100644
--- a/app/views/pms/show.html.erb
+++ b/app/views/pms/show.html.erb
@@ -1,3 +1,5 @@
+<p id="notice"><%= notice %></p>
+
<p>
<strong>Author:</strong>
<%= @pm.author %>
diff --git a/app/views/servers/show.html.erb b/app/views/servers/show.html.erb
index 67f7647..039cd8f 100644
--- a/app/views/servers/show.html.erb
+++ b/app/views/servers/show.html.erb
@@ -1,2 +1,4 @@
+<p id="notice"><%= notice %></p>
+
<%= link_to 'Edit', edit_server_path(@server) %> |
<%= link_to 'Back', servers_path %>
diff --git a/app/views/sessions/_form.html.erb b/app/views/sessions/_form.html.erb
new file mode 100644
index 0000000..1b94e77
--- /dev/null
+++ b/app/views/sessions/_form.html.erb
@@ -0,0 +1,21 @@
+<%= form_for(@session) do |f| %>
+ <% if @session.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@session.errors.count, "error") %> prohibited this session from being saved:</h2>
+
+ <ul>
+ <% @session.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :user_id %><br>
+ <%= f.text_field :user_id %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
diff --git a/app/views/sessions/edit.html.erb b/app/views/sessions/edit.html.erb
new file mode 100644
index 0000000..bbd8407
--- /dev/null
+++ b/app/views/sessions/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing session</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @session %> |
+<%= link_to 'Back', sessions_path %>
diff --git a/app/views/sessions/index.html.erb b/app/views/sessions/index.html.erb
new file mode 100644
index 0000000..707a47d
--- /dev/null
+++ b/app/views/sessions/index.html.erb
@@ -0,0 +1,27 @@
+<h1>Listing sessions</h1>
+
+<table>
+ <thead>
+ <tr>
+ <th>User</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <% @sessions.each do |session| %>
+ <tr>
+ <td><%= session.user %></td>
+ <td><%= link_to 'Show', session %></td>
+ <td><%= link_to 'Edit', edit_session_path(session) %></td>
+ <td><%= link_to 'Destroy', session, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
+
+<br>
+
+<%= link_to 'New Session', new_session_path %>
diff --git a/app/views/sessions/index.json.jbuilder b/app/views/sessions/index.json.jbuilder
new file mode 100644
index 0000000..18fd4fa
--- /dev/null
+++ b/app/views/sessions/index.json.jbuilder
@@ -0,0 +1,4 @@
+json.array!(@sessions) do |session|
+ json.extract! session, :id, :user_id
+ json.url session_url(session, format: :json)
+end
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
index b4acf77..55c9eca 100644
--- a/app/views/sessions/new.html.erb
+++ b/app/views/sessions/new.html.erb
@@ -1,23 +1,5 @@
-<h1>Sign in</h1>
-<% if @user.nil? %>
- <p class="errors"> The email/username or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current email/username and password. </p>
-<% end %>
+<h1>New session</h1>
- <div class="span6 offset3">
- <%= form_for(:session, url: sessions_path) do |f| %>
- <p>
- <%= f.label(:username_or_email, "Username/Email") %><br/>
- <%= f.text_field :username_or_email%>
- </p>
- <p>
- <%= f.label :password %><br/>
- <%= f.password_field :password %>
- </p>
- <p>
- <%= f.submit "Sign in", class: "btn btn-large btn-primary" %>
- </p>
- <% end %>
-
- <p>New user? <%= link_to("Sign up now!", new_user_path) %></p>
- </div>
+<%= render 'form' %>
+<%= link_to 'Back', sessions_path %>
diff --git a/app/views/sessions/show.html.erb b/app/views/sessions/show.html.erb
new file mode 100644
index 0000000..5176869
--- /dev/null
+++ b/app/views/sessions/show.html.erb
@@ -0,0 +1,9 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <strong>User:</strong>
+ <%= @session.user %>
+</p>
+
+<%= link_to 'Edit', edit_session_path(@session) %> |
+<%= link_to 'Back', sessions_path %>
diff --git a/app/views/sessions/show.json.jbuilder b/app/views/sessions/show.json.jbuilder
new file mode 100644
index 0000000..4ebf936
--- /dev/null
+++ b/app/views/sessions/show.json.jbuilder
@@ -0,0 +1 @@
+json.extract! @session, :id, :user_id, :created_at, :updated_at
diff --git a/app/views/static/homepage.html.erb b/app/views/static/homepage.html.erb
deleted file mode 100644
index 3ca8176..0000000
--- a/app/views/static/homepage.html.erb
+++ /dev/null
@@ -1,18 +0,0 @@
-<div role="main" class="container theme-showcase">
-
- <div class="jumbotron">
- <h1>Welcome to Leaguer</h1>
- <p>This is a tournment management system designed to be used for any team sport. Our peer review system ensures that the best players move on to the next round! Try creating a new tournament and having people sign up for it. </p>
- <p id="jumbo-buttons">
- <% if !signed_in? %>
- <%= link_to 'Log In', new_session_path, :class => "btn btn-warning btn-lg", :role => "button" %>
- <%= link_to 'Sign Up', new_user_path, :class => "btn btn-warning btn-lg", :role => "button" %>
- <% else %>
- <%= link_to 'Start a Tournament', new_tournament_path, :class => "btn btn-warning btn-lg", :role => "button" %>
- <% end %>
- <%= link_to 'See Ongoing Tournaments', tournaments_path, :class => "btn btn-warning btn-lg", :role => "button" %>
-
- </p>
- </div>
-
- </div>
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb
deleted file mode 100644
index 8734b14..0000000
--- a/app/views/tournaments/_selected.html.erb
+++ /dev/null
@@ -1,21 +0,0 @@
-<%= form_for(@tournament) do |f| %>
- <%= render "common/error_messages", :target => @tournament %>
- <%= f.hidden_field(:game_id) %>
-
- <% @chosen = Game.find_by(params[:game]) %>
- <% @tournament.attributes.each do |name, value| %>
- <% if (name == "id") or (name =~ /.*_at$/) or (name == "game_id") or (name == "status") %>
- <% next %>
- <% end %>
- <p>
- <%= f.label name %><br>
- <% if !@chosen.attributes[name].nil? %>
- <%= f.text_field(name, :value => @chosen.attributes[name] ) %>
- <% else %>
- <%= f.text_field name %>
- <% end %>
- </p>
- <% end %>
-
- <%= f.submit %>
-<% end %>
diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb
index 90c3d7a..f8f21e7 100644
--- a/app/views/tournaments/index.html.erb
+++ b/app/views/tournaments/index.html.erb
@@ -1,14 +1,16 @@
-<h1>Listing Tournaments</h1>
+<h1>Listing tournaments</h1>
-<% if @tournaments.length > 0 %>
-<table class="table table-hover">
+<table>
<thead>
<tr>
<th>Name</th>
<th>Game</th>
<th>Status</th>
- <th>Players per team</th>
- <th>Teams per match</th>
+ <th>Min players per team</th>
+ <th>Max players per team</th>
+ <th>Min teams per match</th>
+ <th>Max teams per match</th>
+ <th>Set rounds</th>
<th>Randomized teams</th>
<th></th>
<th></th>
@@ -20,28 +22,13 @@
<% @tournaments.each do |tournament| %>
<tr>
<td><%= tournament.name %></td>
- <td><% case tournament.status
- when 0 %>
- <%= form_tag(tournament_path(tournament), method: "put") do %>
- <input type="hidden" name="update_action" value="join">
- <%= submit_tag("Join") %>
- <% end %>
- <% when 1 %>
- Ongoing
- <% else %>
- Closed
- <%end %>
- </td>
- <td><%= tournament.min_players_per_team %>
- <% if tournament.min_players_per_team != tournament.max_players_per_team %>
- to <%= tournament.max_players_per_team %>
- <% end %>
- </td>
- <td><%= tournament.min_teams_per_match %>
- <% if tournament.min_teams_per_match != tournament.max_teams_per_match %>
- to <%= tournament.max_teams_per_match %>
- <% end %>
- </td>
+ <td><%= tournament.game %></td>
+ <td><%= tournament.status %></td>
+ <td><%= tournament.min_players_per_team %></td>
+ <td><%= tournament.max_players_per_team %></td>
+ <td><%= tournament.min_teams_per_match %></td>
+ <td><%= tournament.max_teams_per_match %></td>
+ <td><%= tournament.set_rounds %></td>
<td><%= tournament.randomized_teams %></td>
<td><%= link_to 'Show', tournament %></td>
<td><%= link_to 'Edit', edit_tournament_path(tournament) %></td>
@@ -50,9 +37,7 @@
<% end %>
</tbody>
</table>
-<% else %>
- <p class="no-entries"> No tournaments going on right now... Why not start your own? </p>
-<% end %>
+
<br>
-<%= link_to 'New Tournament', new_tournament_path, :class => "btn btn-warning btn-lg" %>
+<%= link_to 'New Tournament', new_tournament_path %>
diff --git a/app/views/tournaments/join.html.erb b/app/views/tournaments/join.html.erb
deleted file mode 100644
index 1d38d68..0000000
--- a/app/views/tournaments/join.html.erb
+++ /dev/null
@@ -1,2 +0,0 @@
- <%= @user.name %>
-
diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb
index 8c74068..2a60539 100644
--- a/app/views/tournaments/new.html.erb
+++ b/app/views/tournaments/new.html.erb
@@ -1,16 +1,5 @@
-<h1>New Tournament</h1>
+<h1>New tournament</h1>
-<%= form_tag(new_tournament_path, method: "get") do %>
- <%= select_tag('game',
- options_from_collection_for_select(@games, 'id', 'name', @tournament.game.nil? || @tournament.game.id),
- :prompt => "Select a Game Type") %>
- <%= submit_tag("Select", :class => "btn btn-success btn-xs") %>
-<% end %>
-
-<div id='ajax-form'>
- <% if not @tournament.game.nil? %>
- <%= render 'selected' %>
- <% end %>
-</div>
+<%= render 'form' %>
<%= link_to 'Back', tournaments_path %>
diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb
index 3de0623..3cb6179 100644
--- a/app/views/tournaments/show.html.erb
+++ b/app/views/tournaments/show.html.erb
@@ -1,19 +1,5 @@
-<% if @tournament.joinable_by?(current_user) %>
- <%= form_tag(tournament_path(@tournament), method: "put") do %>
- <input type="hidden" name="update_action" value="join">
- <%= current_user.name %><%= submit_tag("Join") %>
- <% end %>
-<% end %>
+<p id="notice"><%= notice %></p>
-
-<div class="progress">
- <%= tag("div", {:class => "progress-bar progress-bar-warning", :style => "width: " +(@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s + "%", "aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => (@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s, "role" => "progressbar"}) %>
- <span class="sr-only">60% Complete (warning)</span>
- </div>
-</div>
-<p><%= @tournament.players.count %> have signed up. <%= @tournament.min_players_per_team * @tournament.min_teams_per_match %> needed. </p>
-
-<% if current_user.in_group?(:host) %>
<p>
<strong>Name:</strong>
<%= @tournament.name %>
@@ -21,7 +7,7 @@
<p>
<strong>Game:</strong>
- <%= @tournament.id %>
+ <%= @tournament.game %>
</p>
<p>
@@ -59,22 +45,5 @@
<%= @tournament.randomized_teams %>
</p>
-<p>
- <strong>Status:</strong>
- <%= @tournament.status %>
-</p>
-
-<%= form_tag(tournaments_path.to_s + "/" + @tournament.id.to_s + "/edit", method: "get") do %>
- <input type="hidden" name="close_action" value="close">
- <% if @tournament.players.count >= @tournament.min_players_per_team * @tournament.min_teams_per_match %>
- <%= submit_tag("Close Tournament Registration") %>
- <% else %>
- <%= submit_tag("Close Tournament Registration", disabled: true) %>
- <% end %>
-<% end %>
-
<%= link_to 'Edit', edit_tournament_path(@tournament) %> |
<%= link_to 'Back', tournaments_path %>
-
-<% end %>
-
diff --git a/app/views/users/already_signed_in.html.erb b/app/views/users/already_signed_in.html.erb
deleted file mode 100644
index 04b4248..0000000
--- a/app/views/users/already_signed_in.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<h1>You are currently signed in</h1>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
index 89e369a..3692112 100644
--- a/app/views/users/index.html.erb
+++ b/app/views/users/index.html.erb
@@ -1,9 +1,8 @@
<h1>Listing users</h1>
-<table class="table table-hover">
+<table>
<thead>
<tr>
- <th>Username</th>
<th>Name</th>
<th>Email</th>
<th>User name</th>
@@ -16,9 +15,8 @@
<tbody>
<% @users.each do |user| %>
<tr>
- <td><%= link_to("#{user.user_name}", user, nil) %></td>
<td><%= user.name %></td>
- <td> ******* </td>
+ <td><%= user.email %></td>
<td><%= user.user_name %></td>
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
index c23f76d..efc0404 100644
--- a/app/views/users/new.html.erb
+++ b/app/views/users/new.html.erb
@@ -1,32 +1,5 @@
-<h1> Sign Up </h1>
+<h1>New user</h1>
-<%= form_for @user do |f| %>
- <%= render "common/error_messages", :target => @user %>
- <p>
- <%= f.label :name %><br>
- <%= f.text_field :name %>
- </p>
- <p>
- <%= f.label :email %><br>
- <%= f.text_field :email %>
- </p>
- <p>
- <%= f.label :user_name %><br>
- <%= f.text_field :user_name %>
- </p>
- <p>
- <%= f.label :password %><br>
- <%= f.password_field :password %>
- </p>
- <p>
- <%= f.label(:password_confirmation, "Confirm Password") %><br>
- <%= f.password_field :password_confirmation %>
- </p>
- <p>
- <%= f.submit("Be a Leaguer", :class => "signup") %>
- </p>
-<% end %>
-
-
-<%= link_to 'Already Have an Account? Log in', new_session_path, :class => "signin" %>
+<%= render 'form' %>
+<%= link_to 'Back', users_path %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index d8cc82b..9455a3c 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -1,3 +1,5 @@
+<p id="notice"><%= notice %></p>
+
<p>
<strong>Name:</strong>
<%= @user.name %>