Permalink
Browse files

Verlegungsmodul aktualisiert

  • Loading branch information...
1 parent 74d3d45 commit 8b93716ac9058089ac5d429fd59e3be66a403048 JRod committed Mar 14, 2012
Showing with 483 additions and 342 deletions.
  1. +24 −2 app/controllers/admin/distances_controller.rb
  2. +1 −1 app/controllers/application_controller.rb
  3. +1 −1 app/controllers/clubs_controller.rb
  4. +3 −3 app/controllers/federations_controller.rb
  5. +1 −1 app/controllers/games_controller.rb
  6. +0 −1 app/controllers/leagues_controller.rb
  7. +7 −3 app/controllers/seasons_controller.rb
  8. +12 −62 app/controllers/umpires_controller.rb
  9. +38 −19 app/models/club.rb
  10. +57 −121 app/models/game.rb
  11. +2 −2 app/models/license.rb
  12. +9 −5 app/models/permissions.rb
  13. +3 −2 app/models/reschedule.rb
  14. +92 −17 app/models/season.rb
  15. +25 −6 app/models/team.rb
  16. +25 −17 app/models/umpire.rb
  17. +8 −0 app/views/clubs/_form.html.haml
  18. +12 −12 app/views/games/_search_form.html.haml
  19. +14 −14 app/views/layouts/application.html.haml
  20. +7 −0 app/views/reschedules/_default_collection_menu.html.haml
  21. +25 −18 app/views/reschedules/_form.html.haml
  22. +2 −2 app/views/reschedules/_reschedule_list.html.haml
  23. +16 −4 app/views/reschedules/index.html.haml
  24. +2 −0 app/views/seasons/_default_member_menu.html.haml
  25. +27 −0 app/views/seasons/plan.html.haml
  26. +25 −0 app/views/seasons/show_empty_umpiregames.html.haml
  27. +1 −1 app/views/teams/edit.html.haml
  28. +3 −2 app/views/umpires/_default_collection_menu.html.haml
  29. +1 −5 app/views/umpires/_umpire.html.haml
  30. +8 −7 app/views/umpires/index.html.haml
  31. +23 −11 app/views/umpires/show_umpire_dates.html.haml
  32. +4 −0 config/environment.rb
  33. +2 −2 config/routes.rb
  34. +3 −1 db/schema.rb
@@ -1,7 +1,7 @@
class Admin::DistancesController < ApplicationController
include Aegis::Controller
- permissions :systems
- #skip_permissions
+ #permissions :systems
+ skip_permissions
make_resourceful do
actions :all
end
@@ -17,5 +17,27 @@ def import
end
end
+ def from_google
+ uri=URI.parse("http://maps.googleapis.com")
+ request=Net::HTTP.new(uri.host,uri.port)
+ #dud=Club.find(:first,:conditions => {:club_short=>'DRS'})
+ dud=Club.find(:first,:conditions => {:club_short=>'DIP'})
+
+ Club.all.each do |nach|
+ d=Distance.find(:first,:conditions=>{:start_id=>dud,:ziel_id=>nach})
+ puts d
+ if d.nil?
+ ziel=nach.ort.gsub(/(\s)/, '+')
+ response = request.get("/maps/api/directions/json?origin=#{dud.ort}&destination=#{ziel}&sensor=true")
+ result=JSON.parse(response.body)
+ result["routes"][0]["legs"].each do |x|
+ puts "#{dud},#{nach},#{x["distance"]["value"]}"
+ entf=Distance.create(:start_id=>dud.id,:ziel_id=>nach.id,:entfernung=>(x["distance"]["value"]/1000).round)
+ entf2=Distance.create(:start_id=>nach.id,:ziel_id=>dud.id,:entfernung=>(x["distance"]["value"]/1000).round)
+ end
+ end
+ end
+
+ end
end
@@ -73,7 +73,7 @@ def current_user_session
def current_user
return @current_user if defined?(@current_user)
- @current_user = current_user_session && current_user_session.record
+ @current_user = (current_user_session && current_user_session.record) || User.new(:role_name => 'guest')
end
def current_season
@@ -101,7 +101,7 @@ def import_from_sxl
end
def import_from_opaso
- Club.find(:all).each do |c|
+ Club.find(:all,:conditions => ['federation_id=?',1]).each do |c|
c.import_from_opaso
end
respond_to do |format|
@@ -4,9 +4,9 @@ class FederationsController < ApplicationController
make_resourceful do
actions :all
before :show do
- @ligen=current_object.leagues.all(:order=>'bereich_id').group_by do |l|
- l.bereich
- end
+ #@ligen=current_object.leagues.all(:order=>'bereich_id').group_by do |l|
+ # l.bereich
+ #end
session[:fed]=current_object.id
end
end
@@ -276,7 +276,7 @@ def update_result
def search
@result=Game.find_by_spielnummer(params[:game][:spielnummer])
respond_to do |format|
- format.html { redirect_to(division_game_path(@result.division,@result)) }
+ format.html { redirect_to(division_game_path(@result.schedule.division,@result)) }
end
end
@@ -11,7 +11,6 @@ class LeaguesController < ApplicationController
end
before :index do
- logger.error(">>>>>>>>>>>>>NNNHJHHSHSH")
@baseball_ligen=League.baseball(parent_object).group_by do |l|
l.bereich
end
@@ -32,6 +32,9 @@ class SeasonsController < ApplicationController
#Ergebnisdienst
+ def show_empty_umpiregames
+ @games=Game.aktuelle_saison(current_season).all(:conditions=>['umpire_club_id is NULL'])
+ end
def assign
@@ -41,15 +44,16 @@ def assign
def reset_umpire_assignments
Game.all(:include=>[:schedule=>[:division]],:conditions=>['divisions.season_id=?',current_object]).each do |x|
x.update_attribute(:umpire_club,nil)
+ x.update_attribute(:kommentar,nil)
end
end
def assign_umpire
reset_umpire_assignments
- APPLOG.info(DateTime.now.to_s+" **********EINTEILUNG************************")
+
current_object.umpire_einteilen
flash[:info]="Umpire erfolgreich eingeteilt"
- APPLOG.info(DateTime.now.to_s+" **********ENDE************************")
+
respond_to do |format|
format.html { redirect_to(object_path) }
end
@@ -81,7 +85,7 @@ def copy_sxl
#TODO Refactor
def plan
respond_to do |format|
-
+ format.html
format.xls {
current_model.schedule_to_csv
redirect_to object_path
@@ -1,27 +1,29 @@
class UmpiresController < ApplicationController
- #include Aegis::Controller
+ include Aegis::Controller
permissions :umpires ,:object => :current_object
make_resourceful do
actions :all
belongs_to :club
+ before :index do
+ @umps=Umpire.all(:order=>'club_id').group_by do |u|
+ u.club
+ end
+ end
+
end
def import
-
- if params[:fed]=="5"
- filename='/home/jrod/Projekte/Onliso/public/downloads/Umpirelizenzen_2011.csv'
- Umpire.import_umpire(filename)
- end
- if params[:fed]=="4"
- filename='/home/jrod/Projekte/Onliso/public/downloads/Umpirelizenzen_2011_hbsv.csv'
- Umpire.import_umpire_hbsv(filename)
- end
+ Umpire.destroy_all
+
+ Umpire.import_umpire(filename)
respond_to do |format|
format.html { redirect_to(umpires_path) }
end
end
+
+
def show_umpire_dates
@clubs=Club.einteilung
respond_to do |format|
@@ -47,59 +49,7 @@ def print_umpire_dates
#TODO Refactor
def einteilen
- APPLOG.info(DateTime.now.to_s+" **********EINTEILUNG************************")
- @games= Game.find(:all, :order=>'datum,spielnummer,uhrzeit')
- @clubs= Club.find(:all) #Nur Clubs, die entsprechend lizensierte Umps haben und nicht am Spiel beteiligt sind
- softball_bereich=Bereich.find(2)
- baseball_bereich=Bereich.find(1)
- muss_nicht_baseball_umpen=Array.new
- muss_nicht_softball_umpen=Array.new
- @clubs.each do |club|
- if (club.mindesteinsaetze(baseball_bereich) == 0)
- muss_nicht_baseball_umpen<<club
- end
- if (club.mindesteinsaetze(softball_bereich) == 0)
- muss_nicht_softball_umpen<<club
- end
-# bb=@clubs - muss_nicht_baseball_umpen
-# sb=@clubs - muss_nicht_softball_umpen
-# if (club.bereich_lizenz_vorhanden?(baseball_bereich)
-#
-# end
-# if (club.bereich_lizenz_vorhanden?(softball_bereich)
-#
-# end
- end
- APPLOG.debug("muss_nicht_baseball_umpen::"+muss_nicht_baseball_umpen.to_s)
- APPLOG.debug("muss_nicht_softball_umpen::"+muss_nicht_softball_umpen.to_s)
- @games.each do |spiel|
- #if spiel.spielnummer.end_with?("-2")==false #WORKAROUND wg doppelte Einteilung beim 2.Spiel des DH
- if spiel.umpire_club_id==nil #noch nicht eingeteilt?
- APPLOG.info(spiel.to_s)
- if spiel.division.league.home_umpire==true
- APPLOG.info("Heimumpire")
- spiel.update_attribute(:umpire_club,spiel.heim_team.main_club)
- else
- APPLOG.info("[INFO] Suche Umpire für "+spiel.to_s)
- pool=spiel.division.league.bereich==baseball_bereich ? @clubs - muss_nicht_baseball_umpen : @clubs - muss_nicht_softball_umpen
- spiel.umpire_einteilen(pool)
- #get_league_clubs(spiel.league)
- #pool=@league_clubs-spiel.heim_team.preferred_umpires-spiel.heim_team.never_umpires
- #@p2=spiel.umpire_pool(pool) if @p1.count==0
- #@p3=spiel.umpire_pool(spiel.heim_team.egal_umpires) if @p2.count==0
- end
- #end
- end
- #spiel.umpire_club=_umps
- #spiel.save!
-# if spiel.league.playing_time_id==1 #Falls DH das zweite Spiel auch einteilen
-# spiel.umpire_for_double_header(_umps) if _umps!=nil
-# end
- end
- respond_to do |format|
- format.html { redirect_to(show_umpire_dates_season_path(3)) }
- end
end
View
@@ -20,8 +20,17 @@ class Club < ActiveRecord::Base
named_scope :einteilung, :include=>:umpire_games, :order=>'ort'
+ named_scope :eingeteilt, lambda {|datum| {
+ :include=>:umpire_games,
+ :conditions=>['games.datum=?', datum]}
+ }
+
+ named_scope :entfernung, lambda {|ziel|
+ {:include=>:ziele, :conditions=>['disntances.start_id=? and distances.ziel_id=?',self,ziel]}
+ }
has_many :umpire_games, :class_name=>'Game', :foreign_key=>'umpire_club_id',:order=>'datum, spielnummer,uhrzeit' do
+
def mindestanzahl_erreicht(bereich)
anz=proxy_owner.mindesteinsaetze(bereich)
einteilungen=find(:all,:include=>[:division=>[:league]],:conditions=>['leagues.bereich_id=?',bereich.id])
@@ -43,9 +52,7 @@ def mindestanzahl_erreicht(bereich)
end
- #def list_umpire_games
- # (find :all, :order=>('datum'))
- #end
+
def pro_bereich(bereich)
einteilungen=find(:all,:include=>[:division=>[:league]],:conditions=>['leagues.bereich_id=?',bereich.id])
@@ -138,14 +145,16 @@ def bisher_eingeteilt(saison,bereich)
def mindesteinsaetze(saison,bereich)
a=0
teams.gemeldet_bereich(saison,bereich).each do |x|
- a=a+x.home_games.count
+ a=a+x.mindesteinsaetze
end
return a/2 if bereich==2
a
#return teams.gemeldet_bereich(saison,bereich).collect{|x| x.home_games.count/2} if bereich==2
#return teams.gemeldet_bereich(saison,bereich).collect{|x| x.home_games.count} if bereich==1
end
+
+
#def mindesteinsaetze(bereich)
# c=0
# a=0
@@ -196,15 +205,16 @@ def other_teams_playing?(datum, team)
end
def is_umpiring?(datum)
- umpire_games.all(:conditions=>['datum=?', datum]).count > 0 #TODO Evtl. Bereichsfilter einfügen
+ eingeteilt(datum).count>0
+ #umpire_games.all(:conditions=>['datum=?', datum]).count > 0 #TODO Evtl. Bereichsfilter einfügen
end
def is_playing?(datum)
##TODO Nachwuchsspiele rausrechnen!
#club_homegames=self.teams.collect { |x| x.home_games.find(:all, :conditions=>['datum=? ', datum]) }
#club_visitorgames=self.teams.collect { |x| x.visitor_games.find(:all, :conditions=>['datum=?', datum]) }
#club_homegames.flatten.size>0 or club_visitorgames.flatten.size>0
- teams.all(:conditions=>['bereich_id=? or bereich_id=?',1,2]).select{|x|x.is_playing(datum)}.count > 0
+ teams.all(:conditions=>['bereich_id=? or bereich_id=?',1,2]).select{|x|x.is_playing?(datum)}.count > 0
end
@@ -231,19 +241,28 @@ def import_from_opaso
url="http://www.opaso.com/extern/vereinsinfo/?shortcut=#{self.club_short}"
puts url
data= Net::HTTP.get(URI.parse(url))
- puts data
-# name=1
-# ort=2
- # club_short=3
-# off_name=4
-# contact=5
-# strasse=6
-# plz=7
-# post_ort=9
-# mobil=10
-# fon=11
-# mail=12
-# homepage=13
+
+ x=data.split('";"')
+ data.split('";"').each do |y|
+ puts y
+ end
+ attr={
+
+ :name_off=>x[4]!=''? Iconv.new('UTF-8','ISO-8859-1').iconv(x[4]):'--',
+ :contact=>x[7]!=''?Iconv.new('UTF-8','ISO-8859-1').iconv(x[7]):'--',
+ :strasse=>x[8]!=''?Iconv.new('UTF-8','ISO-8859-1').iconv(x[8]):'--',
+ :plz=>x[9]!=''?Iconv.new('UTF-8','ISO-8859-1').iconv(x[9]):'--',
+ :post_ort=>x[10]!=''?Iconv.new('UTF-8','ISO-8859-1').iconv(x[10]):'--',
+ :phone=>x[11]!=''?Iconv.new('UTF-8','ISO-8859-1').iconv(x[11]):'--',
+ :fax=>x[12]!=''?Iconv.new('UTF-8','ISO-8859-1').iconv(x[12]):'--',
+ :web=>x[14]!=''?Iconv.new('UTF-8','ISO-8859-1').iconv(x[14]):'--',
+ :logo=>"#{name}.logo.gif"
+ }
+
+
+ update_attributes(attr)
+
+
#
end
Oops, something went wrong.

0 comments on commit 8b93716

Please sign in to comment.