Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move edit controllers to setup module cont.

  • Loading branch information...
commit b3e99904400abca565fea2f2475ffbf27e524353 1 parent 735d623
@geraldb geraldb authored
View
43 app/controllers/db/calc_games_controller.rb
@@ -1,43 +0,0 @@
-class Db::CalcGamesController < Db::BaseController
-
- # GET /calc_games/new
- def new
- @game = CalcGame.new
- end
-
- # POST /calc_games
- def create
- @game = CalcGame.new(params[:calc_game])
-
- if @game.save
- redirect_to games_path(), :notice => 'Spiel erfolgreich gespeichert.'
- else
- render :action => 'new'
- end
- end
-
- # GET /calc_games/1/edit
- def edit
- @game = CalcGame.find(params[:id])
- end
-
- # PUT /calc_games/1
- def update
- @game = CalcGame.find(params[:id])
-
- if @game.update_attributes(params[:calc_game])
- redirect_to games_path(), :notice => 'Spiel erfolgreich gespeichert.'
- else
- render :action => 'edit'
- end
- end
-
- # DELETE /calc_games/1
- def destroy
- @game = CalcGame.find(params[:id])
- @game.destroy
-
- redirect_to games_path()
- end
-
-end # class CalcGamesController
View
51 app/controllers/db/games_controller.rb
@@ -2,47 +2,18 @@ class Db::GamesController < Db::BaseController
# GET /games
def index
- @events = Event.all
+ # find next upcoming games
+ limit = params[:limit] || '50'
+
+ @games = Game.where( 'play_at > ?', Time.now ).order( 'play_at').limit(limit)
end
-
- # GET /games/new
- def new
- @game = Game.new
- end
-
- # POST /games
- def create
- @game = Game.new(params[:game])
-
- if @game.save
- redirect_to games_path(), notice: 'Spiel erfolgreich gespeichert.'
- else
- render action: 'new'
- end
- end
-
- # GET /games/1/edit
- def edit
- @game = Game.find(params[:id])
- end
-
- # PUT /games/1
- def update
- @game = Game.find(params[:id])
-
- if @game.update_attributes(params[:game])
- redirect_to games_path(), notice: 'Spiel erfolgreich gespeichert.'
- else
- render action: 'edit'
- end
- end
-
- # DELETE /games/1
- def destroy
- @game = Game.find(params[:id])
- @game.destroy
-
- redirect_to games_path()
+
+ # GET /games/past
+ def past
+ limit = params[:limit] || '50'
+ @games = Game.where( 'play_at < ?', Time.now ).order( 'play_at desc').limit(limit)
+
+ render :action => 'index'
end
end # class GamesController
View
48 app/controllers/db/rounds_controller.rb
@@ -1,48 +0,0 @@
-class Db::RoundsController < Db::BaseController
-
- # GET /rounds
- def index
- @events = Event.all
- end
-
- # GET /rounds/new
- def new
- @round = Round.new
- end
-
- # POST /rounds
- def create
- @round = Round.new(params[:round])
-
- if @round.save
- redirect_to rounds_path(), notice: 'Runde erfolgreich gespeichert.'
- else
- render action: 'new'
- end
- end
-
- # GET /rounds/1/edit
- def edit
- @round = Round.find(params[:id])
- end
-
- # PUT /rounds/1
- def update
- @round = Round.find(params[:id])
-
- if @round.update_attributes(params[:round])
- redirect_to rounds_path(), notice: 'Runde erfolgreich gespeichert.'
- else
- render action: 'edit'
- end
- end
-
- # DELETE /rounds/1
- def destroy
- @round = Round.find(params[:id])
- @round.destroy
-
- redirect_to rounds_path()
- end
-
-end # class RoundsController
View
2  app/controllers/setup/calc_games_controller.rb
@@ -1,4 +1,4 @@
-class Db::CalcGamesController < Db::BaseController
+class Setup::CalcGamesController < Setup::BaseController
# GET /calc_games/new
def new
View
2  app/controllers/setup/events_controller.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-class Db::EventsController < Db::BaseController
+class Setup::EventsController < Setup::BaseController
# GET /events
def index
View
2  app/controllers/setup/games_controller.rb
@@ -1,4 +1,4 @@
-class Db::GamesController < Db::BaseController
+class Setup::GamesController < Setup::BaseController
# GET /games
def index
View
2  app/controllers/setup/rounds_controller.rb
@@ -1,4 +1,4 @@
-class Db::RoundsController < Db::BaseController
+class Setup::RoundsController < Setup::BaseController
# GET /rounds
def index
View
2  app/controllers/setup/teams_controller.rb
@@ -1,4 +1,4 @@
-class Db::TeamsController < Db::BaseController
+class Setup::TeamsController < Setup::BaseController
# GET /teams
def index
View
73 app/views/db/calc_games/_form.html.erb
@@ -1,73 +0,0 @@
-
-<%= form_for(@game) do |f| %>
- <% if @game.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@game.errors.count, "error") %> prohibited this game from being saved:</h2>
-
- <ul>
- <% @game.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
- <table>
- <tr>
- <td><%= f.label :round_id, 'Runde:' %></td>
- <td>(<%= f.object.round_id %>)</td>
- <td><%= f.select :round_id, ([[ '- Runde wählen -', nil ]] + Round.all.map { |rec| [ "#{rec.event.title} / #{rec.title}", rec.id ] }) %></td>
- </tr>
- <tr>
- <td><%= f.label :pos, 'Lfd#:' %></td>
- <td></td>
- <td><%= f.text_field :pos, size: '3' %></td>
- </tr>
- <tr>
- <td><%= f.label :team1_id, 'Team 1:' %></td>
- <td>(<%= f.object.team1_id %>)</td>
- <td><%= f.select :team1_id, options_from_collection_for_select( Team.all, :id, :title, f.object.team1_id) %></td>
- </tr>
- <tr>
- <td><%= f.label :score1, 'Tore 1:' %></td>
- <td></td>
- <td><%= f.text_field :score1, size: '3' %></td>
- </tr>
- <tr>
- <td><%= f.label :score2, 'Tore 2:' %></td>
- <td></td>
- <td><%= f.text_field :score2, size: '3' %></td>
- </tr>
- <tr>
- <td><%= f.label :team2_id, 'Team 2:' %></td>
- <td>(<%= f.object.team2_id %>)</td>
- <td><%= f.select :team2_id, options_from_collection_for_select( Team.all, :id, :title, f.object.team2_id) %></td>
- </tr>
- <tr>
- <td><%= f.label :locked, 'Locked Flag:' %></td>
- <td></td>
- <td>
- <%= f.radio_button :locked, 'true' %><%= f.label :locked_true, 'Ja' %>
- <%= f.radio_button :locked, 'false' %><%= f.label :locked_false, 'Nein' %>
- </td>
- </tr>
- <tr>
- <td><%= f.label :knockout, 'Knockout Flag:' %></td>
- <td></td>
- <td>
- <%= f.radio_button :knockout, 'true' %><%= f.label :knockout_true, 'Ja' %>
- <%= f.radio_button :knockout, 'false' %><%= f.label :knockout_false, 'Nein' %>
- </td>
- </tr>
- <tr>
- <td><%= f.label :play_at, 'Datum:' %></td>
- <td></td>
- <td><%= f.text_field :play_at %></td>
- </tr>
- </table>
-
- <div class="actions">
- <%= f.submit 'Speichern', :class => 'btn-primary' %>
- <%= link_to 'Zurück', games_path(), :class => 'btn' %>
- </div>
-<% end %>
View
3  app/views/db/calc_games/edit.html.erb
@@ -1,3 +0,0 @@
-<h1>Spiel (Calc) Bearbeiten</h1>
-
-<%= render 'form' %>
View
3  app/views/db/calc_games/new.html.erb
@@ -1,3 +0,0 @@
-<h1>Neues Spiel (Calc)</h1>
-
-<%= render 'form' %>
View
73 app/views/db/games/_form.html.erb
@@ -1,73 +0,0 @@
-
-<%= form_for(@game) do |f| %>
- <% if @game.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@game.errors.count, "error") %> prohibited this game from being saved:</h2>
-
- <ul>
- <% @game.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
- <table>
- <tr>
- <td><%= f.label :round_id, 'Runde:' %></td>
- <td>(<%= f.object.round_id %>)</td>
- <td><%= f.select :round_id, ([[ '- Runde wählen -', nil ]] + Round.all.map { |rec| [ "#{rec.event.title} / #{rec.title}", rec.id ] }) %></td>
- </tr>
- <tr>
- <td><%= f.label :pos, 'Lfd#:' %></td>
- <td></td>
- <td><%= f.text_field :pos, size: '3' %></td>
- </tr>
- <tr>
- <td><%= f.label :team1_id, 'Team 1:' %></td>
- <td>(<%= f.object.team1_id %>)</td>
- <td><%= f.select :team1_id, options_from_collection_for_select( Team.all, :id, :title, f.object.team1_id) %></td>
- </tr>
- <tr>
- <td><%= f.label :score1, 'Tore 1:' %></td>
- <td></td>
- <td><%= f.text_field :score1, size: '3' %></td>
- </tr>
- <tr>
- <td><%= f.label :score2, 'Tore 2:' %></td>
- <td></td>
- <td><%= f.text_field :score2, size: '3' %></td>
- </tr>
- <tr>
- <td><%= f.label :team2_id, 'Team 2:' %></td>
- <td>(<%= f.object.team2_id %>)</td>
- <td><%= f.select :team2_id, options_from_collection_for_select( Team.all, :id, :title, f.object.team2_id) %></td>
- </tr>
- <tr>
- <td><%= f.label :locked, 'Locked Flag:' %></td>
- <td></td>
- <td>
- <%= f.radio_button :locked, 'true' %><%= f.label :locked_true, 'Ja' %>
- <%= f.radio_button :locked, 'false' %><%= f.label :locked_false, 'Nein' %>
- </td>
- </tr>
- <tr>
- <td><%= f.label :knockout, 'Knockout Flag:' %></td>
- <td></td>
- <td>
- <%= f.radio_button :knockout, 'true' %><%= f.label :knockout_true, 'Ja' %>
- <%= f.radio_button :knockout, 'false' %><%= f.label :knockout_false, 'Nein' %>
- </td>
- </tr>
- <tr>
- <td><%= f.label :play_at, 'Datum:' %></td>
- <td></td>
- <td><%= f.text_field :play_at %></td>
- </tr>
- </table>
-
- <div class="actions">
- <%= f.submit 'Speichern', :class => 'btn-primary' %>
- <%= link_to 'Zurück', games_path, :class => 'btn' %>
- </div>
-<% end %>
View
54 app/views/db/games/_games_upcoming.html.erb
@@ -0,0 +1,54 @@
+<h3>Nächsten Spiele</h3>
+
+<table>
+<% last_play_at = Time.local( 1999, 1, 1 )
+ games.each do |game| %>
+
+ <% unless last_play_at.year == game.play_at.year &&
+ last_play_at.month == game.play_at.month &&
+ last_play_at.day == game.play_at.day %>
+
+ <tr style='background-color: silver;'>
+ <td colspan='10'><%= game.play_at.strftime('%A, %d. %B %Y') %></td>
+ </tr>
+
+ <% end %>
+
+
+ <tr style='vertical-align: middle;'>
+ <td>
+ <%= game.play_at.strftime('%H:%M') %>
+ </td>
+ <td style='text-align: right;'>
+ <%= game.team1.title %>
+ <%= "(#{game.team1.title2})" if game.team1.title2.present? %>
+ </td>
+ <td>
+ <%= image_tag( game.team1.img ) if game.team1.img.present? %>
+ </td>
+ <td> - <%#= game.score_str %>
+ </td>
+ <td>
+ <%= image_tag( game.team2.img ) if game.team2.img.present? %>
+ </td>
+ <td>
+ <%= game.team2.title %>
+ <%= "(#{game.team2.title2})" if game.team2.title2.present? %>
+ </td>
+ <td>
+ (<%= game.round.event.title %> / <%= game.round.title %>)
+ </td>
+
+ </tr>
+<% last_play_at = game.play_at
+ end %><!-- each game -->
+</table>
+
+
+<% if games.count > 0 %>
+<p><%= link_to 'Mehr Spiele »', db_games_path(:limit => 100) %>
+</p>
+<% else %>
+<p>Noch keine Spiele bekannt.
+</p>
+<% end %>
View
3  app/views/db/games/edit.html.erb
@@ -1,3 +0,0 @@
-<h1>Spiel Bearbeiten</h1>
-
-<%= render 'form' %>
View
48 app/views/db/games/index.html.erb
@@ -1,49 +1,3 @@
-<h1><%= Game.count %> Spiele</h1>
-<%= link_to 'Neues Spiel', new_game_path(), :class => 'btn-primary' %>
-
-<table>
-<% @events.each do |event| %>
- <tr style='background-color: black; color: white; font-weight: bold; font-size: 140%;'>
- <td>(<%= event.id %>)</td>
- <td colspan='7'><%= event.title %></td>
- </tr>
- <% event.rounds.each do |round| %>
- <tr style='font-size: 120%; font-weight: bold;'>
- <td>(<%= round.id %>)</td>
- <td><%= round.pos %></td>
- <td colspan='6'><%= round.title %></td>
- </tr>
- <% round.games.each do |game| %>
-
- <tr>
- <td>(<%= game.id %>) <%= game.key %></td>
- <td><%= game.pos %></td>
- <td><%= game.team1.title %></td>
- <td><%= game.team2.title %></td>
- <td>
- (
- <%= if game.score1.present? then game.score1 else '-' end %>
- :
- <%= if game.score2.present? then game.score2 else '-' end %>
- )
- </td>
- <td><%= game.knockout? ? '(Knockout Flag)' : '' %>
- <%= game.locked? ? '(Locked Flag)' : '' %>
- </td>
- <td><%= game.play_at %></td>
- <td><%= game.play_at.utc %></td>
- <td><%= link_to 'Bearbeiten', game.calc? ? edit_calc_game_path(game) : edit_game_path( game ), :class => 'btn' %></td>
- </tr>
- <% end %><!-- games.each -->
- <% end %><!-- rounds.each -->
-<% end %><!-- events.each -->
-
-
-
-</table>
-
-<p></p>
-
-<%= link_to 'Neues Spiel', new_game_path(), :class => 'btn-primary' %>
+<%= render :partial => 'games_upcoming', :locals => { :games => @games } %>
View
3  app/views/db/games/new.html.erb
@@ -1,3 +0,0 @@
-<h1>Neues Spiel</h1>
-
-<%= render 'form' %>
View
44 app/views/db/rounds/_form.html.erb
@@ -1,44 +0,0 @@
-<%= form_for(@round) do |f| %>
- <% if @round.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@round.errors.count, "error") %> prohibited this round from being saved:</h2>
-
- <ul>
- <% @round.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
- <table>
- <tr>
- <td><%= f.label :event_id, 'Veranstaltung:' %></td>
- <td>(<%= f.object.event_id %>)</td>
- <td><%= f.select :event_id, options_from_collection_for_select( Event.all, :id, :title, f.object.event_id ) %></td>
- </tr>
- <tr>
- <td><%= f.label :pos, 'Lfd#:' %></td>
- <td></td>
- <td><%= f.text_field :pos, size: '3' %></td>
- </tr>
- <tr>
- <td><%= f.label :title, 'Titel:' %></td>
- <td></td>
- <td><%= f.text_field :title %></td>
- </tr>
- <tr>
- <td><%= f.label :calc, 'Calc Flag:' %></td>
- <td></td>
- <td>
- <%= f.radio_button :calc, 'true' %><%= f.label :calc_true, 'Ja' %>
- <%= f.radio_button :calc, 'false' %><%= f.label :calc_false, 'Nein' %>
- </td>
- </tr>
- </table>
-
- <div class="actions">
- <%= f.submit 'Speichern', :class => 'btn-primary' %>
- <%= link_to 'Zurück', rounds_path(), :class => 'btn' %>
- </div>
-<% end %>
View
3  app/views/db/rounds/edit.html.erb
@@ -1,3 +0,0 @@
-<h1>Runde Bearbeiten</h1>
-
-<%= render 'form' %>
View
25 app/views/db/rounds/index.html.erb
@@ -1,25 +0,0 @@
-<h1><%= Round.count %> Runden</h1>
-
-<%= link_to 'Neue Runde', new_round_path(), :class => 'btn-primary' %>
-
-<table>
-<% @events.each do |event| %>
- <tr style='background-color: black; color: white; font-weight: bold; font-size: 120%;'>
- <td>(<%= event.id %>)</td>
- <td colspan='4'><%= event.title %></td>
- </tr>
- <% event.rounds.each do |round| %>
- <tr>
- <td>(<%= round.id %>)</td>
- <td><%= round.pos %></td>
- <td><%= round.title %></td>
- <td><%= '(Calc Flag)' if round.calc == true %></td>
- <td><%= link_to 'Bearbeiten', edit_round_path( round ), :class => 'btn' %></td>
- </tr>
- <% end %><!-- rounds.each -->
-<% end %><!-- events.each -->
-</table>
-
-<p></p>
-
-<%= link_to 'Neue Runde', new_round_path(), :class => 'btn-primary' %>
View
3  app/views/db/rounds/new.html.erb
@@ -1,3 +0,0 @@
-<h1>Neue Runde</h1>
-
-<%= render 'form' %>
View
7 app/views/layouts/db.html.erb
@@ -41,10 +41,9 @@
<div>
- <%= link_to 'Events', events_path() %> &bull;
- <%= link_to 'Teams', teams_path() %> &bull;
- <%= link_to 'Rounds', rounds_path() %> &bull;
- <%= link_to 'Games', games_path() %>
+ <%= link_to 'Events', db_events_path() %> &bull;
+ <%= link_to 'Teams', db_teams_path() %> &bull;
+ <%= link_to 'Games', db_games_path() %>
<!-- todo: add some more links -->
</div>
View
6 app/views/layouts/setup.html.erb
@@ -43,7 +43,11 @@
<div>
- <%= link_to 'Bonus Rounds', bonus_rounds_path() %>
+ <%= link_to 'Events', events_path() %> &bull;
+ <%= link_to 'Teams', teams_path() %> &bull;
+ <%= link_to 'Rounds', rounds_path() %> &bull;
+ <%= link_to 'Bonus Rounds', bonus_rounds_path() %> &bull;
+ <%= link_to 'Games', games_path() %>
<!-- todo: add some more links -->
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.