Permalink
Browse files

move edit controllers to setup module cont.

  • Loading branch information...
1 parent 735d623 commit b3e99904400abca565fea2f2475ffbf27e524353 @geraldb geraldb committed Jul 7, 2012
@@ -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
@@ -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
@@ -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
@@ -1,4 +1,4 @@
-class Db::CalcGamesController < Db::BaseController
+class Setup::CalcGamesController < Setup::BaseController
# GET /calc_games/new
def new
@@ -1,6 +1,6 @@
# encoding: utf-8
-class Db::EventsController < Db::BaseController
+class Setup::EventsController < Setup::BaseController
# GET /events
def index
@@ -1,4 +1,4 @@
-class Db::GamesController < Db::BaseController
+class Setup::GamesController < Setup::BaseController
# GET /games
def index
@@ -1,4 +1,4 @@
-class Db::RoundsController < Db::BaseController
+class Setup::RoundsController < Setup::BaseController
# GET /rounds
def index
@@ -1,4 +1,4 @@
-class Db::TeamsController < Db::BaseController
+class Setup::TeamsController < Setup::BaseController
# GET /teams
def index
@@ -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 %>
@@ -1,3 +0,0 @@
-<h1>Spiel (Calc) Bearbeiten</h1>
-
-<%= render 'form' %>
@@ -1,3 +0,0 @@
-<h1>Neues Spiel (Calc)</h1>
-
-<%= render 'form' %>
@@ -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 %>
@@ -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 %>
Oops, something went wrong.

0 comments on commit b3e9990

Please sign in to comment.