<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/turns/_form.html.erb</filename>
    </added>
    <added>
      <filename>app/views/turns/edit.html.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,7 +2,7 @@ class GamesController &lt; ApplicationController
   before_filter :login_required
 
   def index
-    @games = Game.find(:all, :order =&gt; &quot;created_at DESC&quot;, :include =&gt; [:user, :players, :turns])
+    @games = Game.find(:all, :order =&gt; &quot;created_at DESC&quot;)
   end
 
   def show
@@ -11,7 +11,7 @@ class GamesController &lt; ApplicationController
       :all,
       :conditions =&gt; &quot;player_id in (#{@game.player_ids.join(&quot;,&quot;)})&quot;,
       :order =&gt; &quot;position desc&quot;,
-      :include =&gt; {:player =&gt; :user},
+      :include =&gt; {:player =&gt; [:user, {:game =&gt; :players}]},
       :limit =&gt; params[:all] ? 1000 : (@game.players.size * 4) + @game.turns_in_current_round + 1)
   end
 </diff>
      <filename>app/controllers/games_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,23 @@ class TurnsController &lt; ApplicationController
 
     if @turn.save
       flash[:notice] = 'Turn was successfully created.'
-      redirect_to(turn.player.game)
+      redirect_to(@turn.player.game)
+    else
+      render :action =&gt; &quot;new&quot;
+    end
+  end
+
+  def edit
+    @turn = Turn.find(params[:id])
+    @game = @turn.player.game
+  end
+
+  def update
+    @turn = Turn.new(params[:turn])
+
+    if @turn.save
+      flash[:notice] = 'Turn was successfully created.'
+      redirect_to(@turn.player.game)
     else
       render :action =&gt; &quot;new&quot;
     end</diff>
      <filename>app/controllers/turns_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -32,4 +32,4 @@ class Game &lt; ActiveRecord::Base
   def turns_in_current_round
     @turns_in_current_round ||= turns.reverse.select{|t| t.round(self) == current_round }.size
   end
-end
+end
\ No newline at end of file</diff>
      <filename>app/models/game.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,16 @@ class Turn &lt; ActiveRecord::Base
   has_attached_file :game_file
   validates_attachment_presence :game_file
 
+  validate :proper_file_name
+  def proper_file_name
+    this_player = player.game.next_player
+    last_year = player.turns.size == 0 ? 4001 : player.turns.last.year
+    player_alias = player.turns.size == 0 ? player.user.name : player.game.turns.last.to_player
+    if game_file_file_name.include?(player_alias) || (ce == &quot;BC&quot; ? year &gt; last_year : last_year &gt; year)
+      errors.add_to_base(&quot;You've uploaded the wrong file, dingbat!&quot;)
+    end
+  end
+
   before_save :set_position
   def set_position
     self.position = player.game.turns.count
@@ -24,6 +34,10 @@ class Turn &lt; ActiveRecord::Base
     TurnNotification.deliver_turn_notification(player.game.next_player, game_file)
   end
 
+  def to_player
+    game_file_file_name.split(&quot;.&quot;).first.split(&quot;_&quot;).last
+  end
+
   def full_year
     &quot;#{year} #{ce}&quot; rescue &quot;?&quot;
   end
@@ -37,7 +51,7 @@ class Turn &lt; ActiveRecord::Base
   end
 
   def year
-    game_file_file_name.split(&quot;-&quot;)[year_index+1].split(&quot;_&quot;).first.to_i rescue 0
+    game_file_file_name.split(&quot;-&quot;)[year_index+1].split(&quot;_&quot;).first.to_i rescue 4000
   end
 
   def ce #Calendar Era</diff>
      <filename>app/models/turn.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,20 +1,6 @@
-&lt;h1&gt;New Turn&lt;/h1&gt;
-
 &lt;% form_for(@turn, :html =&gt; {:multipart =&gt; true}) do |f| %&gt;
   &lt;%= f.error_messages %&gt;
-  &lt;%= f.hidden_field :player_id %&gt;
-  &lt;p&gt;
-    &lt;b&gt;Game&lt;/b&gt;&lt;br /&gt;
-    &lt;%= @turn.game.name %&gt;
-  &lt;/p&gt;
-
-  &lt;p&gt;
-    &lt;%= f.label :game_file %&gt;&lt;br /&gt;
-    &lt;%= f.file_field :game_file %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.submit 'Upload' %&gt;
-  &lt;/p&gt;
+  &lt;%= render :partial =&gt; &quot;form&quot;, :locals =&gt; {:f =&gt; f}%&gt;
 &lt;% end %&gt;
 
-&lt;%= link_to 'Back', current_game %&gt;
\ No newline at end of file
+&lt;%= link_to 'Back', @game %&gt;
\ No newline at end of file</diff>
      <filename>app/views/turns/new.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -13,5 +13,7 @@ config.action_controller.consider_all_requests_local = true
 config.action_view.debug_rjs                         = true
 config.action_controller.perform_caching             = false
 
+config.action_mailer.delivery_method = :test
+
 # Don't care if the mailer can't send
 config.action_mailer.raise_delivery_errors = false
\ No newline at end of file</diff>
      <filename>config/environments/development.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>212835b662456d8dafaf513c91a99f2ba0f93d17</id>
    </parent>
  </parents>
  <author>
    <name>Erik Peterson</name>
    <email>erik@subwindow.com</email>
  </author>
  <url>http://github.com/subwindow/Civ4-Game-Repo/commit/13a5b70d90b5bfb88c3278e5ee11b081784a81e0</url>
  <id>13a5b70d90b5bfb88c3278e5ee11b081784a81e0</id>
  <committed-date>2009-05-20T16:38:37-07:00</committed-date>
  <authored-date>2009-05-20T16:38:37-07:00</authored-date>
  <message>Various improvements</message>
  <tree>d2f46100f5aa2e7ebe07b09dacd42adb6154f9cd</tree>
  <committer>
    <name>Erik Peterson</name>
    <email>erik@subwindow.com</email>
  </committer>
</commit>
