From 289caaa1c82db4895efaf01b33160712d169bc84 Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Thu, 6 Mar 2014 12:07:17 -0500 Subject: Minor visual changes --- app/assets/stylesheets/custom.css.scss | 2 +- app/views/layouts/application.html.erb | 2 +- app/views/tournaments/new.html.erb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/custom.css.scss b/app/assets/stylesheets/custom.css.scss index d4c81a0..ab86ce9 100644 --- a/app/assets/stylesheets/custom.css.scss +++ b/app/assets/stylesheets/custom.css.scss @@ -20,7 +20,7 @@ header > nav { @extend .navbar-form; @extend .navbar-right; input[type="submit"] { - @extend .btn-warning; + @extend .btn-warning; margin-top: -3px; margin-right: 8px; } } } diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7578d82..976ee85 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -33,7 +33,7 @@
<%= yield %>
<%= debug(params) if Rails.env.development? %> diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb index 428487a..3d6d142 100644 --- a/app/views/tournaments/new.html.erb +++ b/app/views/tournaments/new.html.erb @@ -2,7 +2,7 @@

New Tournament

-<%= select_tag 'tournament_id', options_for_select(["Select a Game Type"] + Game.all.collect {|game| game.name}), :onchange => 'populate()' %> <%= link_to 'Select', 'new?game=1', :class => "btn btn-warning btn-lg" %> +<%= select_tag 'tournament_id', options_for_select(["Select a Game Type"] + Game.all.collect {|game| game.name}), :onchange => 'populate()' %> <%= link_to 'Select', 'new?game=1', :class => "btn btn-success btn-xs" %> @@ -14,6 +14,6 @@

-<%= link_to 'Select', 'selected', :class => "btn btn-warning btn-lg" %> +<%= link_to 'Select', 'selected', :class => "btn btn-success btn-xs" %> <%= link_to 'Back', tournaments_path %> -- cgit v1.1-4-g5e80 From cd020cb3c9f8a1d40af4958c26dcdfb97e1a80c1 Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Thu, 6 Mar 2014 14:23:11 -0500 Subject: Users can now log in with user_name and email but I could not make one text box for both --- app/controllers/sessions_controller.rb | 24 +++++++++++++++--------- app/views/sessions/new.html.erb | 7 +++++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index b5ea29b..f857f27 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -11,7 +11,13 @@ class SessionsController < ApplicationController # POST /sessions.json def create # find the user... - @user = User.find_by(email: params[:session][:email].downcase) + + @user = User.find_by(email: params[:session][:email]) + + if @user.nil? + @user = User.find_by_user_name(params[:session][:user_name]) + end + #@session = Session.new(@user) # ... and create a new session respond_to do |format| @@ -39,13 +45,13 @@ class SessionsController < ApplicationController private - # Use callbacks to share common setup or constraints between actions. - def set_session - #@session = Session.find(cookies[:remember_token]) - end + # 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_password) - 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 end diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 550a54d..6d73b1f 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,13 +1,16 @@

Sign in

<% if @user.nil? %> -

The username or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current username and password.

+

The email or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current email and password.

<% end %>
<%= form_for(:session, url: sessions_path) do |f| %> <%= f.label :email %> - <%= f.text_field :email %> + <%= f.text_field :email%> + + <%= f.label :user_name %> + <%= f.text_field :user_name%> <%= f.label :password %> <%= f.password_field :password %> -- cgit v1.1-4-g5e80 From a421aace7383bb6718d23eed1bde02659a7a93ff Mon Sep 17 00:00:00 2001 From: Tomer Kimia Date: Thu, 6 Mar 2014 15:57:26 -0500 Subject: login fixed and some views look better --- app/assets/stylesheets/custom.css.scss | 17 +++++++++-------- app/controllers/sessions_controller.rb | 6 +----- app/models/tournament.rb | 1 + app/views/games/index.html.erb | 2 +- app/views/sessions/new.html.erb | 22 +++++++++++----------- app/views/tournaments/_selected.html.erb | 2 +- app/views/users/new.html.erb | 6 +++--- 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/app/assets/stylesheets/custom.css.scss b/app/assets/stylesheets/custom.css.scss index ab86ce9..4ea86d4 100644 --- a/app/assets/stylesheets/custom.css.scss +++ b/app/assets/stylesheets/custom.css.scss @@ -7,14 +7,7 @@ header > nav { #log-buttons { margin-top: 8px; - form { display: inline; } - a, input[type="submit"] { - @extend .btn; - &.user { @extend .btn-info; } - &.signup { @extend .btn-success; } - &.signin { @extend .btn-info; } - &.signout { @extend .btn-danger; } - } + form { display: inline; } } form.search { @extend .navbar-form; @@ -25,6 +18,14 @@ header > nav { } } +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; diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index f857f27..d5c59d4 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -12,11 +12,7 @@ class SessionsController < ApplicationController def create # find the user... - @user = User.find_by(email: params[:session][:email]) - - if @user.nil? - @user = User.find_by_user_name(params[:session][:user_name]) - end + @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 diff --git a/app/models/tournament.rb b/app/models/tournament.rb index cc915a0..5e8ddfe 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -1,3 +1,4 @@ class Tournament < ActiveRecord::Base belongs_to :game + has_many :matches end diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb index 7ee69d1..9893cbc 100644 --- a/app/views/games/index.html.erb +++ b/app/views/games/index.html.erb @@ -1,6 +1,6 @@

Listing games

- +
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 6d73b1f..6439b9f 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -2,22 +2,22 @@ <% if @user.nil? %>

The email or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current email and password.

<% end %> -
+
<%= form_for(:session, url: sessions_path) do |f| %> - - <%= f.label :email %> - <%= f.text_field :email%> - - <%= f.label :user_name %> - <%= f.text_field :user_name%> - - <%= f.label :password %> +

+ <%= f.label(:username_or_email, "Username/Email") %>
+ <%= f.text_field :username_or_email%> +

+

+ <%= f.label :password %>
<%= f.password_field :password %> - +

+

<%= f.submit "Sign in", class: "btn btn-large btn-primary" %> +

<% end %>

New user? <%= link_to "Sign up now!", new_user_path %>

-
+ diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb index 4277d8e..5058c56 100644 --- a/app/views/tournaments/_selected.html.erb +++ b/app/views/tournaments/_selected.html.erb @@ -18,7 +18,7 @@ <% next %> <% end %> <% if name == "created_at" %> - <% break %> + <% break %> <% end %>

diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 704aa10..c23f76d 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -19,14 +19,14 @@ <%= f.password_field :password %>

- <%= f.label :password_confirm %>
+ <%= f.label(:password_confirmation, "Confirm Password") %>
<%= f.password_field :password_confirmation %>

- <%= f.submit %> + <%= f.submit("Be a Leaguer", :class => "signup") %>

<% end %> -<%= link_to 'Already Have an Account? Log in', new_session_path, :class => "btn btn-warning btn-lg" %> +<%= link_to 'Already Have an Account? Log in', new_session_path, :class => "signin" %> -- cgit v1.1-4-g5e80 From 240d8602fb6aaf249b33db7b0c2f8a72add63658 Mon Sep 17 00:00:00 2001 From: Tomer Kimia Date: Thu, 6 Mar 2014 16:09:22 -0500 Subject: tournaments table only shows if tournaments exits --- app/views/sessions/new.html.erb | 2 +- app/views/tournaments/index.html.erb | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 6439b9f..398cb49 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -18,6 +18,6 @@

<% end %> -

New user? <%= link_to "Sign up now!", new_user_path %>

+

New user? <%= link_to("Sign up now!", new_user_path) %>

diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb index 26d0643..e9147f6 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -1,6 +1,7 @@ -

Listing tournaments

+

Listing Tournaments

-
Name
+<% if @tournaments.length > 0 %> +
@@ -21,7 +22,9 @@ <% end %>
Tournament ID
- +<% else %> +

No tournaments going on right now... Why not start your own?

+<% end %>
<%= link_to 'New Tournament', new_tournament_path, :class => "btn btn-warning btn-lg" %> -- cgit v1.1-4-g5e80 From fe7d5ad458b4cabd8fd57b47f81abc56dd8532ad Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Thu, 6 Mar 2014 17:37:35 -0500 Subject: update db/seeds.rb --- db/seeds.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds.rb b/db/seeds.rb index ab130a8..c1e0057 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,6 +6,6 @@ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) # -Game.create(name: "League of Legends", players_per_team: 5, teams_per_match: 2, set_rounds: 1, randomized_teams: 0) +Game.create(name: "League of Legends",min_players_per_team: 5, max_players_per_team: 5, min_teams_per_match: 5, max_teams_per_match: 5, set_rounds: nil, randomized_teams: false) -- cgit v1.1-4-g5e80 From 110d67f433c091a3b739c5bbebe110d963efaa73 Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Thu, 6 Mar 2014 17:38:47 -0500 Subject: no --- app/controllers/sessions_controller.rb | 9 ++------- app/views/sessions/new.html.erb | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index f857f27..4bd69a5 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -11,13 +11,8 @@ class SessionsController < ApplicationController # POST /sessions.json def create # find the user... - - @user = User.find_by(email: params[:session][:email]) - - if @user.nil? - @user = User.find_by_user_name(params[:session][:user_name]) - end - + #find by email + @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| diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 6d73b1f..2b40ed9 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,23 +1,22 @@

Sign in

<% if @user.nil? %> -

The email or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current email and password.

+

The email/username or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current email/username and password.

<% end %> -
+
<%= form_for(:session, url: sessions_path) do |f| %> - - <%= f.label :email %> - <%= f.text_field :email%> - - <%= f.label :user_name %> - <%= f.text_field :user_name%> - - <%= f.label :password %> +

+ <%= f.label(:username_or_email, "Username/Email") %>
+ <%= f.text_field :username_or_email%> +

+

+ <%= f.label :password %>
<%= f.password_field :password %> - +

+

<%= f.submit "Sign in", class: "btn btn-large btn-primary" %> +

<% end %> -

New user? <%= link_to "Sign up now!", new_user_path %>

+

New user? <%= link_to("Sign up now!", new_user_path) %>

-
-- cgit v1.1-4-g5e80 From 1ec0bbad344790e7181a586cd24914c677d20d32 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Thu, 6 Mar 2014 18:36:14 -0500 Subject: Here's Luke's stuff because he doesn't have wifi. --- app/controllers/tournaments_controller.rb | 21 +++++++++---------- app/models/user.rb | 2 +- app/views/tournaments/_selected.html.erb | 34 ++++++++----------------------- app/views/tournaments/new.html.erb | 14 ++++++------- 4 files changed, 27 insertions(+), 44 deletions(-) diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index cf618aa..4f79d44 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -15,9 +15,8 @@ class TournamentsController < ApplicationController # GET /tournaments/new def new - @game_names = Game.all.collect - @game = params[:game] - @tournament = Tournament.new + @games = Game.all + @tournament = Tournament.new(game: Game.find_by_id(params[:game])) end # GET /tournaments/1/edit @@ -70,14 +69,14 @@ 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 + 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 diff --git a/app/models/user.rb b/app/models/user.rb index 079b870..9288ef6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,7 +16,7 @@ class User < ActiveRecord::Base when :admin return ((groups & 2) != 0) when :host - return ((groups & 1) != 0) + return true #((groups & 1) != 0) when :player return true when :specator diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb index 5058c56..cfa91fa 100644 --- a/app/views/tournaments/_selected.html.erb +++ b/app/views/tournaments/_selected.html.erb @@ -1,31 +1,15 @@ <%= form_for(@tournament) do |f| %> - <% if @tournament.errors.any? %> -
-

<%= pluralize(@tournament.errors.count, "error") %> prohibited this tournament from being saved:

+ <%= render "common/error_messages", :target => @tournament %> + <%= f.hidden_field(:game_id) %> -
    - <% @tournament.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
- <% end %> - - <%# this is the dynamic script to output fields to the form %> - <% @chosen = Game.find(@game) %> - <% @chosen.attributes.each do |name, value| %> - <% if name == "id" %> + <% @tournament.attributes.each do |name, value| %> + <% if (name == "id") or (name =~ /.*_at$/) or (name == "game_id") %> <% next %> <% end %> - <% if name == "created_at" %> - <% break %> - <% end %> -

- -
- value=<%= value %>> -

+

+ <%= f.label name %>
+ <%= f.text_field name %> +

<% end %> - <%= f.submit %> -<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb index 3d6d142..1e80147 100644 --- a/app/views/tournaments/new.html.erb +++ b/app/views/tournaments/new.html.erb @@ -2,18 +2,18 @@

New Tournament

-<%= select_tag 'tournament_id', options_for_select(["Select a Game Type"] + Game.all.collect {|game| game.name}), :onchange => 'populate()' %> <%= link_to 'Select', 'new?game=1', :class => "btn btn-success btn-xs" %> +<%= 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 %> - -
- <% if not @game.nil? %> + <% if not @tournament.game.nil? %> <%= render 'selected' %> <% end %>
-

- -<%= link_to 'Select', 'selected', :class => "btn btn-success btn-xs" %> <%= link_to 'Back', tournaments_path %> -- cgit v1.1-4-g5e80 From 8e1ca0e4f9107a43fbdf0dac315e3467b0158356 Mon Sep 17 00:00:00 2001 From: Tomer Kimia Date: Thu, 6 Mar 2014 19:12:48 -0500 Subject: defaults now come in --- app/assets/stylesheets/tournaments.css.scss | 9 +++++++++ app/views/tournaments/_selected.html.erb | 13 ++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/tournaments.css.scss b/app/assets/stylesheets/tournaments.css.scss index e372b90..458897e 100644 --- a/app/assets/stylesheets/tournaments.css.scss +++ b/app/assets/stylesheets/tournaments.css.scss @@ -1,3 +1,12 @@ // 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/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb index cfa91fa..9b1b7f8 100644 --- a/app/views/tournaments/_selected.html.erb +++ b/app/views/tournaments/_selected.html.erb @@ -2,14 +2,21 @@ <%= 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") %> + <% if (name == "id") or (name =~ /.*_at$/) or (name == "game_id") or (name == "status") %> <% next %> <% end %>

<%= f.label name %>
- <%= f.text_field name %> + <% if !@chosen.attributes[name].nil? %> + <%= f.text_field(name, :value => @chosen.attributes[name] ) %> + <% else %> + <%= f.text_field name %> + <% end %> +

+ <% end %> <%= f.submit %> -<% end %> \ No newline at end of file +<% end %> -- cgit v1.1-4-g5e80