Permalink
Browse files

Update Terminsperren

  • Loading branch information...
1 parent 256605b commit 315d8ffabaeed66d792049b66705d10edf176df8 Jose Rodriguez committed Dec 27, 2011
View
20 app/controllers/application_controller.rb
@@ -4,32 +4,14 @@
class ApplicationController < ActionController::Base
include Aegis::Controller
require_permissions
- has_mobile_fu
+ # has_mobile_fu
#before_filter :authenticate
around_filter :rescue_access_denied
filter_parameter_logging :password
helper_method :current_user
- def update_termine
- t=Proc.new{|datum|
- attr={:datum=>datum,:gesperrt=>params[:termin][:gesperrt],:grund=>params[:termin][:grund]}
- parent_object.termins.find_by_datum(datum)!=nil ? Termin.update(termin,attr) : parent_object.termins<<Termin.create(attr)
- }
- if (params[:bis]=="")
- t.call(params[:von])
- else
- start = Date.parse(params[:von])
- ende = Date.parse(params[:bis])
- every_weekday(start, ende,0) { |datum|
- t.call(datum)
- }
- every_weekday(start, ende,6) { |datum|
- t.call(datum)
- }
- end
- end
def every_weekend(d1, d2)
View
3 app/controllers/clubs_controller.rb
@@ -51,9 +51,6 @@ def show_termine
@season=params[:season]
end
- def termine_sperren
- @season=params[:season]
- end
def team_meldung
session[:collab_teams]=Array.new if session[:collab_teams]==nil
View
24 app/controllers/fields_controller.rb
@@ -60,29 +60,7 @@ def create_fields
end
-
- def update_sperrtermine
- if (params[:bis]=="")
- update_termine(params[:von])
- else
- start = Date.parse(params[:von])
- ende = Date.parse(params[:bis])
- every_weekday(start, ende,6) { |x|
- update_termine(x)
- }
- every_weekday(start, ende,0) { |x|
- update_termine(x)
- }
- end
-
- respond_to do |format|
- format.html { redirect_to(termine_sperren_field_path(current_object)) }
- end
-
- end
-
-
- protected
+ protected
def update_termine(datum)
View
11 app/controllers/leagues_controller.rb
@@ -59,15 +59,4 @@ def search
end
-
-
- def update_sperrtermine
- update_termine
- flash[:notice] = 'Termine aktualisiert'
- respond_to do |format|
- format.html { redirect_to(termine_sperren_league_path(current_object)) }
- end
- end
-
-
end
View
22 app/controllers/teams_controller.rb
@@ -179,28 +179,6 @@ def list_umpire_pools
# end
#end
- #def update_sperrtermine
- # t=current_object.termins.find_by_datum(params[:termin][:datum]) #Auf Datumsformatierung achten
- # if t!=nil
- # Termin.update(t,:datum => params[:termin][:datum],
- # #:gesperrt=>params[:termin][:gesperrt],
- # :grund=>params[:termin][:grund],
- # :gesperrt_home=>params[:termin][:gesperrt_home],
- # :gesperrt_away=>params[:termin][:gesperrt_away])
- # else
- # current_object.termins<<Termin.create(:datum => params[:termin][:datum],:season_id=>session[:akt_saison],
- # #:gesperrt=>params[:res_termin]["#{kalender.id}"]['datum'],
- # :grund=>params[:termin][:grund],
- # :gesperrt_home=>params[:termin][:gesperrt_home],
- # :gesperrt_away=>params[:termin][:gesperrt_away])
- #
- # end
- #
- # respond_to do |format|
- # format.html { redirect_to(termine_sperren_team_path(current_object)) }
- # end
- #
- #end
# def __update_sperrtermine
# for kalender in @kalender
View
72 app/controllers/termins_controller.rb
@@ -9,30 +9,76 @@ class TerminsController < ApplicationController
belongs_to :season
belongs_to :federation
- before :index do
- current_objects.each do |x|
- puts x.resource_id
- end
- end
+ #before :index do
+ # current_objects.each do |x|
+ # puts x.resource_id
+ # end
+ #end
+ #
- before :new do
- puts current_object
- puts "UJJJJJJJJJJJj"
- end
after :create do
- update_termine
+ # update_termine
end
#response_for :update,:destroy do |format|
# format.html { redirect_to(termine_sperren_club_path(params[:club_id])) }
#end
end
+
+ #def update_sperrtermine
+ # t=current_object.termins.find_by_datum(params[:termin][:datum]) #Auf Datumsformatierung achten
+ # if t!=nil
+ # Termin.update(t,:datum => params[:termin][:datum],
+ # #:gesperrt=>params[:termin][:gesperrt],
+ # :grund=>params[:termin][:grund],
+ # :gesperrt_home=>params[:termin][:gesperrt_home],
+ # :gesperrt_away=>params[:termin][:gesperrt_away])
+ # else
+ # current_object.termins<<Termin.create(:datum => params[:termin][:datum],:season_id=>session[:akt_saison],
+ # #:gesperrt=>params[:res_termin]["#{kalender.id}"]['datum'],
+ # :grund=>params[:termin][:grund],
+ # :gesperrt_home=>params[:termin][:gesperrt_home],
+ # :gesperrt_away=>params[:termin][:gesperrt_away])
+ #
+ # end
+ #
+ # respond_to do |format|
+ # format.html { redirect_to :back }
+ # end
+ #
+ #end
+ #
def update_sperrtermine
- update_termine
- respond_to do |format|
- format.html { redirect_to(termine_sperren_season_path(current_object)) }
+
+ t=Proc.new{|datum|
+ attr={:resource_id=>params[:termin][:res_id],:resource_type=>params[:termin][:res_type],:datum=>datum,:gesperrt=>params[:termin][:gesperrt],:grund=>params[:termin][:grund]}
+
+ termin=Termin.find(:first,:conditions=>['resource_type=? and resource_id=? and datum=?',params[:termin][:res_type],params[:termin][:res_id],datum])
+ termin !=nil ? Termin.update(termin,attr) : Termin.create(attr)
+ }
+ if (params[:bis]=="")
+ t.call(params[:von])
+ else
+ start = Date.parse(params[:von])
+ ende = Date.parse(params[:bis])
+ every_weekday(start, ende,0) { |datum|
+ t.call(datum)
+ }
+ every_weekday(start, ende,6) { |datum|
+ t.call(datum)
+ }
end
+
+ respond_to do |format|
+ #format.html { redirect_to(:back) }
+ klazz= (params[:termin][:res_type]).downcase
+ format.html { redirect_to(eval("termine_sperren_#{klazz}_path(#{params[:termin][:res_type]}.find(#{params[:termin][:res_id]}))")) }
+ end
end
+ def object
+ @object ||= '#{params[:termin][:res_type]}'.find(params[:termin][:res_id])
+ end
+
end
View
12 app/models/permissions.rb
@@ -46,19 +46,28 @@ class Permissions < Aegis::Permissions
resources :termins do
allow :ligadirektor
+ action :update_sperrtermine, :collection=>true do
+ allow :ligadirektor
+ end
end
end
resources :termins do
allow :ligadirektor
+ action :update_sperrtermine do
+ allow :ligadirektor
+ end
end
resources :federations do
allow :ligadirektor
action :send_egd, :collection=>true do
allow :ligadirektor
end
+ action :show_termine,:termine_sperren do
+ allow :ligadirektor
+ end
resources :termins do
allow :ligadirektor
end
@@ -133,9 +142,10 @@ class Permissions < Aegis::Permissions
resources :teams do
- action :show_termine,:termine_sperren,:update_sperrtermine do
+ action :show_termine,:termine_sperren do
allow :ligadirektor
end
+
action :show_game_results, :show_upcoming_games do
allow
end
View
2 app/models/team.rb
@@ -9,7 +9,7 @@ class Team < ActiveRecord::Base
has_and_belongs_to_many :fields
-
+ has_many :termins, :as=> :resource
has_many :games
has_many :home_games, :class_name=>"Game", :foreign_key=>'home_id', :order=>'datum, spielnummer,uhrzeit'
has_many :visitor_games, :class_name=>"Game", :foreign_key=>'guest_id', :order=>'datum,spielnummer,uhrzeit'
View
28 app/views/clubs/##show_termine.html.haml
@@ -1,28 +0,0 @@
-- content_for (:sidebar) do
- = render :partial => "sidebar_clubs"
-
-%div[current_object]
- %h2
- Terminplan
- =current_object.name
-
-%div{:width=>'30%'}
- %table
- -@gKalender.each do |monat,tage|
- %th
- %h3
- =monat
- %tr
- -tage.each do |tag|
- %td{:width=>'50px'}
- %ul
- %li=tag.datum
- -term=current_object.termins.find_by_kalender_id(tag)
- -if term!=nil
- = list_of([term.gesperrt,term.gesperrt_home,term.gesperrt_away,term.grund]) do |i|
- =i
- -fieldterm=current_object.field.field_termins.find_by_kalender_id(tag)
- -if fieldterm!=nil
- = list_of([fieldterm.gesperrt,fieldterm.league.name]) do |y|
- =y
-
View
28 app/views/clubs/_club_termine_sperren.html.haml
@@ -1,28 +0,0 @@
-%table
- %tr
- %td Datum
- %td Grund
- - form_for(:termin, :url=>update_sperrtermine_club_url(current_object),:html => {:method => :put }) do |f|
- %tr
- %td
- =f.text_field :datum,:size=>10
- %td
- =f.text_field :grund
- %td
- = submit_tag "Sperren"
-
-
-
-%p= current_object.class
--#
- %table
- - form_for([current_object], :url=>{:action=>'update_sperrtermine'}) do |f|
- -@gKalender.each do |monat,tage|
- %th=monat
- %tr
- -tage.each do |tag|
- %td
- %ul
- %li=tag.datum
- %li=get_club_termin_sperren(current_object,tag.id)
-
View
16 app/views/clubs/termine_sperren.html.haml
@@ -1,16 +0,0 @@
--#
- - content_for (:sidebar) do
- = render :partial => "sidebar_clubs"
-
-%h2 Termine Sperren
-%h3=h current_object.full_name
-%table
- %th Datum
- %th Grund
- - @termine.each do |liste|
- %tr
- %td=liste.datum
- %td=liste.grund
- %td= link_to 'Löschen', club_termin_path(current_object,liste), :confirm => 'Termin wirklich löschen?', :method => :delete
-%div[current_object]
- = render :partial => "club_termine_sperren"
View
3 app/views/federations/termine_sperren.html.haml
@@ -0,0 +1,3 @@
+%h2 Termine Sperren
+%h3=h current_object.name
+= render :partial => "termins/termine_sperren"
View
31 app/views/fields/_field_termine_sperren.html.haml
@@ -1,31 +0,0 @@
-%table
- %tr
- %td Von
- %td Bis
- %td Grund
- - form_for(:termin, :url=>update_sperrtermine_field_url(current_object),:html => {:method => :put }) do |f|
- %tr
- %td
- =text_field_tag 'von'
- %td
- =text_field_tag 'bis'
- %td
- =f.text_field :grund
- %td
- = submit_tag "Sperren"
-
-
-
-%p= current_object.class
--#
- %table
- - form_for([current_object], :url=>{:action=>'update_sperrtermine'}) do |f|
- -@gKalender.each do |monat,tage|
- %th=monat
- %tr
- -tage.each do |tag|
- %td
- %ul
- %li=tag.datum
- %li=get_club_termin_sperren(current_object,tag.id)
-
View
51 app/views/fields/termine_sperren.html.haml
@@ -1,51 +0,0 @@
-%h2 Termine Sperren
-%h3=h current_object.name
-- form_for(:field, :url=>object_url(current_object),:html => {:method => :put }) do |f|
- %table
- %tr
- %td
- %label{:for => "sa_gesperrt"} samstags gesperrt:
- %td
- =f.check_box :sa_gesperrt, :checked=>current_object.sa_gesperrt
- %tr
- %td
- %label{:for => "so_gesperrt"} sonntags gesperrt:
- %td
- =f.check_box :so_gesperrt,:checked=>current_object.so_gesperrt
- %tr
- %td
- = submit_tag "Aktualisieren"
-%table
- %th Datum
- %th Grund
- - @termine.each do |liste|
- %tr
- %td=liste.datum
- %td=liste.grund
- %td= link_to 'Löschen', team_blocking_path(current_object,liste), :confirm => 'Termin wirklich löschen?', :method => :delete
-
-%div[current_object]
- = render :partial => "field_termine_sperren"
-
--#
- %div[current_object]
- %table
- %tr
- %td= link_to "Samstage sperren",we_sperren_team_path(current_object,:dow=>6)
- %td= link_to "Sonntage sperren",we_sperren_team_path(current_object,:dow=>0)
- - form_for([current_object,:team_termin], :url=>{:action=>'update_sperrtermine'}) do |f|
- %td=submit_tag "Update"
- %tr
- /=get_weekend_checkbox("Samstage")
- /=get_weekend_checkbox("Sonntage")
- -@gKalender.each do |monat,tage|
- %th=monat
- %tr
- -tage.each do |tag|
- %td
- %ul
- %li=tag.datum
- = surround '(',')' do
- =tag.datum.wday
- %li=get_team_sperrtermine(current_object,tag.id)
-
View
47 app/views/teams/_team_termine_sperren.html.haml
@@ -1,28 +1,25 @@
+
+
%table
- %tr
- %td Datum
- %td Grund
- - form_for(:termin, :url=>update_sperrtermine_team_url(current_object),:html => {:method => :put }) do |f|
- %tr
- %td
- =f.text_field :datum,:size=>10
- %td
- =f.text_field :grund
- %td
- = submit_tag "Sperren"
-
-
+ =table_header(["Name","Datum","Bezeichung","gesperrt?"],current_model)
+ =render :partial => "termins/termin", :collection => current_object.termins
-%p= current_object.class
--#
+%div
%table
- - form_for([current_object], :url=>{:action=>'update_sperrtermine'}) do |f|
- -@gKalender.each do |monat,tage|
- %th=monat
- %tr
- -tage.each do |tag|
- %td
- %ul
- %li=tag.datum
- %li=get_club_termin_sperren(current_object,tag.id)
-
+ %tr
+ %td Von
+ %td Bis
+ %td Grund
+ -#- form_for(:termin, :url=>update_sperrtermine_season_url(current_object),:html => {:method => :put }) do |f|
+ - form_for(:termin, :url=>update_sperrtermine_termins_url,:html => {:method => :put }) do |f|
+ = f.hidden_field :resource_id, :value=>current_object.id
+ %tr
+ %td
+ =text_field_tag 'von'
+ %td
+ =text_field_tag 'bis'
+ %td
+ =f.text_field :grund
+ %td
+ = submit_tag "Sperren"
+
View
34 app/views/teams/termine_sperren.html.haml
@@ -1,35 +1,3 @@
%h2 Termine Sperren
%h3=h current_object.full_name
-%table
- %th Datum
- %th Grund
- - @termine.each do |liste|
- %tr
- %td=liste.datum
- %td=liste.grund
- %td= link_to 'Löschen', team_termin_path(current_object,liste), :confirm => 'Termin wirklich löschen?', :method => :delete
-%div[current_object]
- = render :partial => "team_termine_sperren"
-
--#
- %div[current_object]
- %table
- %tr
- %td= link_to "Samstage sperren",we_sperren_team_path(current_object,:dow=>6)
- %td= link_to "Sonntage sperren",we_sperren_team_path(current_object,:dow=>0)
- - form_for([current_object,:team_termin], :url=>{:action=>'update_sperrtermine'}) do |f|
- %td=submit_tag "Update"
- %tr
- /=get_weekend_checkbox("Samstage")
- /=get_weekend_checkbox("Sonntage")
- -@gKalender.each do |monat,tage|
- %th=monat
- %tr
- -tage.each do |tag|
- %td
- %ul
- %li=tag.datum
- = surround '(',')' do
- =tag.datum.wday
- %li=get_team_sperrtermine(current_object,tag.id)
-
+= render :partial => "termins/termine_sperren"
View
11 app/views/seasons/#termine_sperren.html.haml → app/views/termins/_termine_sperren.html.haml
@@ -1,9 +1,4 @@
--content_for(:headline) do
- %h3
- Veranstaltungen
-= render :partial => 'default_member_menu'
-
%table
=table_header(["Name","Datum","Bezeichung","gesperrt?"],current_model)
@@ -16,8 +11,10 @@
%td Bis
%td Grund
-#- form_for(:termin, :url=>update_sperrtermine_season_url(current_object),:html => {:method => :put }) do |f|
- - form_for(:termin, :url=>termins_url,:html => {:method => :put }) do |f|
- = f.hidden_field :resource, :value=>current_object
+ - form_for(:termin, :url=>update_sperrtermine_termins_url) do |f|
+ = f.hidden_field :res_id, :value=>current_object.id
+ = f.hidden_field :res_type, :value=>current_model
+ = hidden_field_tag :resource_id, current_object.id
%tr
%td
=text_field_tag 'von'
View
4 config/environment.rb
@@ -48,8 +48,8 @@
# (by default production uses :info, the others :debug)
config.log_level = :debug
- APPLOG = Logger.new("#{RAILS_ROOT}/log/my-app.log")
- APPLOG.level = Logger::DEBUG
+ #APPLOG = Logger.new("#{RAILS_ROOT}/log/my-app.log")
+ #APPLOG.level = Logger::DEBUG
View
4 config/routes.rb
@@ -1,8 +1,6 @@
ActionController::Routing::Routes.draw do |map|
map.resources :schedules
-
-
map.resources :user_sessions
map.resources :users
@@ -40,7 +38,7 @@
map.resources :bereiches
- map.resources :termins
+ map.resources :termins, :collection=>{:update_sperrtermine => :get}
map.resources :seasons, :has_many=>[:leagues,:termins,:events],:member=>{:assign=>:get,:plan=>:get,:copy_sxl=>:get}
map.resources :seasons do |s|

0 comments on commit 315d8ff

Please sign in to comment.