Permalink
Browse files

move edit controllers to setup module

  • Loading branch information...
1 parent 2de8e8e commit e4e6c318bd90b62cfc31c96fd7962878b3a49aa5 @geraldb geraldb committed Jul 7, 2012
@@ -0,0 +1,43 @@
+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
@@ -0,0 +1,52 @@
+# encoding: utf-8
+
+class Db::EventsController < Db::BaseController
+
+ # GET /events
+ def index
+ @events = Event.all
+ end
+
+ # GET /events/new
+ def new
+ @event = Event.new
+ end
+
+ # POST /events
+ def create
+ @event = Event.new( params[:event] )
+
+ if @event.save
+ redirect_to events_path(), notice: 'Veranstaltung erfolgreich gespeichert.'
+ else
+ render action: 'new'
+ end
+ end
+
+ # GET /events/1/edit
+ def edit
+ @event = Event.find( params[:id] )
+ end
+
+ # PUT /events/1
+ def update
+ @event = Event.find( params[:id] )
+
+ if @event.update_attributes(params[:event])
+ redirect_to events_path(), notice: 'Veranstaltung erfolgreich gespeichert.'
+ else
+ render action: 'edit'
+ end
+ end
+
+ # POST /events/1/add_team_to
+ def add_team_to # rename to add_team or similar?
+ event = Event.find( params[:id] )
+ team = Team.find( params[:team_id] )
+
+ event.teams << team
+
+ redirect_to events_path(), :notice => 'Team erfolgreich hinzugefügt.'
+ end
+
+end # class EventsController
@@ -0,0 +1,48 @@
+class Db::GamesController < Db::BaseController
+
+ # GET /games
+ def index
+ @events = Event.all
+ 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()
+ end
+
+end # class GamesController
@@ -0,0 +1,48 @@
+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
@@ -0,0 +1,48 @@
+class Db::TeamsController < Db::BaseController
+
+ # GET /teams
+ def index
+ @teams = Team.all
+ end
+
+ # GET /teams/new
+ def new
+ @team = Team.new
+ end
+
+ # POST /teams
+ def create
+ @team = Team.new(params[:team])
+
+ if @team.save
+ redirect_to teams_path(), notice: 'Team erfolgreich gespeichert.'
+ else
+ render action: 'new'
+ end
+ end
+
+ # GET /teams/1/edit
+ def edit
+ @team = Team.find(params[:id])
+ end
+
+ # PUT /teams/1
+ def update
+ @team = Team.find(params[:id])
+
+ if @team.update_attributes(params[:team])
+ redirect_to teams_path(), notice: 'Team erfolgreich gespeichert.'
+ else
+ render action: 'edit'
+ end
+ end
+
+ # DELETE /teams/1
+ def destroy
+ @team = Team.find(params[:id])
+ @team.destroy
+
+ redirect_to teams_path()
+ end
+
+end # class TeamsController
View
@@ -77,6 +77,14 @@
scope :module => 'setup' do
resources :bonus_rounds
+ resources :rounds
+ resources :games
+ resources :calc_games
+ resources :teams
+
+ resources :events do
+ post 'add_team_to', :on => :member
+ end
end

0 comments on commit e4e6c31

Please sign in to comment.