]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/changeset_controller.rb
further work on 0.6 history (not quite complete yet)
[rails.git] / app / controllers / changeset_controller.rb
index f7f4dc9f0ac2ef46fa2094dda96dd322d60185da..b2ff42711db55a59f35056993647417494252be5 100644 (file)
@@ -1,9 +1,11 @@
 # The ChangesetController is the RESTful interface to Changeset objects
 
 class ChangesetController < ApplicationController
+  layout 'site'
   require 'xml/libxml'
 
-  session :off
+  session :off, :except => [:list]
+  before_filter :authorize_web, :only => [:list]
   before_filter :authorize, :only => [:create, :update, :delete, :upload, :include, :close]
   before_filter :check_write_availability, :only => [:create, :update, :delete, :upload, :include]
   before_filter :check_read_availability, :except => [:create, :update, :delete, :upload, :download, :query]
@@ -289,6 +291,21 @@ class ChangesetController < ApplicationController
     render ex.render_opts
   end
 
+  ##
+  # list edits belonging to a user
+  def list
+    user = User.find(:first, :conditions => [ "visible = ? and display_name = ?", true, params[:display_name]])
+    @edit_pages, @edits = paginate(:changesets,
+                                   :include => [:user, :changeset_tags],
+                                   :conditions => ["changesets.user_id = ? AND min_lat IS NOT NULL", user.id],
+                                   :order => "changesets.created_at DESC",
+                                   :per_page => 20)
+    
+    @action = 'list'
+    @display_name = user.display_name
+    # FIXME needs rescues in here
+  end
+
 private
   #------------------------------------------------------------
   # utility functions below.
@@ -378,8 +395,14 @@ private
 
   ##
   # restrict changes to those which are open
+  #
+  # at the moment this code assumes we're only interested in open
+  # changesets and gives no facility to query closed changesets. this
+  # would be reasonably simple to implement if anyone actually wants
+  # it?
   def conditions_open(open)
-    return open.nil? ? nil : ['closed_at >= ?', DateTime.now]
+    return open.nil? ? nil : ['closed_at >= ? and num_changes <= ?', 
+                              DateTime.now, Changeset::MAX_ELEMENTS]
   end
 
 end