[25806] users/jberry/mpwa/app

source_changes at macosforge.org source_changes at macosforge.org
Sat Jun 2 13:50:13 PDT 2007


Revision: 25806
          http://trac.macosforge.org/projects/macports/changeset/25806
Author:   jberry at macports.org
Date:     2007-06-02 13:50:13 -0700 (Sat, 02 Jun 2007)

Log Message:
-----------
mpwa: misc bug fixes and formatting

Modified Paths:
--------------
    users/jberry/mpwa/app/controllers/port_pkg_controller.rb
    users/jberry/mpwa/app/models/port_pkg.rb
    users/jberry/mpwa/app/views/port/show.rhtml
    users/jberry/mpwa/app/views/port_pkg/show.rhtml

Modified: users/jberry/mpwa/app/controllers/port_pkg_controller.rb
===================================================================
--- users/jberry/mpwa/app/controllers/port_pkg_controller.rb	2007-06-02 20:43:50 UTC (rev 25805)
+++ users/jberry/mpwa/app/controllers/port_pkg_controller.rb	2007-06-02 20:50:13 UTC (rev 25806)
@@ -67,7 +67,7 @@
             "MESSAGE: PortPkg submitted successfully\n" +
             "DOWNLOAD_URL: #{download_url}\n" +
             "HUMAN_URL: #{human_url}\n"
-    rescue PortPkgException => ex
+    rescue FileInfoException => ex
         render :text => "STATUS: 1\n" +
             "MESSAGE: Error during submit: #{ex}\n", :status => 400
     end
@@ -75,14 +75,14 @@
   
   def emit_portpkg
     port_pkg = PortPkg.find(params[:id])
-    redirect_to :controller => 'port_pkg_file', :action => 'emit',
-        :id => port_pkg.portpkg_file()
+    redirect_to :controller => 'file_ref', :action => 'emit',
+        :id => port_pkg.portpkg_file_ref()
   end
   
   def emit_portpkg_path
     port_pkg = PortPkg.find(params[:id])
-    redirect_to :controller => 'port_pkg_file', :action => 'emit',
-        :id => port_pkg.file_by_path(params[:path].join, '/')
+    redirect_to :controller => 'file_ref', :action => 'emit',
+        :id => port_pkg.file_ref_by_path(params[:path].join, '/')
   end
   
   private :create, :edit, :update, :destroy

Modified: users/jberry/mpwa/app/models/port_pkg.rb
===================================================================
--- users/jberry/mpwa/app/models/port_pkg.rb	2007-06-02 20:43:50 UTC (rev 25805)
+++ users/jberry/mpwa/app/models/port_pkg.rb	2007-06-02 20:50:13 UTC (rev 25806)
@@ -4,7 +4,8 @@
 
 require 'mpwa-conf'
 require 'port'
-require 'port_pkg_file'
+require 'file_ref'
+require 'file_info'
 require 'person'
 require 'variant'
 
@@ -131,14 +132,14 @@
         return self
      end
     
-    def file_by_path(file_path)
-        candidates = self.files.select { |f| f.file_path == file_path }
-        return candidates.first
+    def file_ref_by_path(file_path)
+        candidates = self.file_refs.select { |r| r.file_info.file_path == file_path }
+        return candidates ? candidates.first : nil
     end
     
     def portpkg_file_ref()
         candidates = self.file_refs.select { |r| r.is_port_pkg }
-        return candidates.first
+        return candidates ? candidates.first : nil
     end
     
     def data_file_refs()

Modified: users/jberry/mpwa/app/views/port/show.rhtml
===================================================================
--- users/jberry/mpwa/app/views/port/show.rhtml	2007-06-02 20:43:50 UTC (rev 25805)
+++ users/jberry/mpwa/app/views/port/show.rhtml	2007-06-02 20:50:13 UTC (rev 25806)
@@ -33,12 +33,15 @@
 		<th>Download</th>
 	</tr>
 	<% for pkg in @port.port_pkgs.sort.reverse %>
+    <% pkg_ver = pkg.epoch.to_i != 0 ?
+    	    "(#{pkg.epoch}) #{pkg.version}_#{pkg.revision}" :
+    	    "#{pkg.version}_#{pkg.revision}" %>
 		<tr>
-			<td><%= link_to pkg.id, :controller => 'port_pkg', :action => 'show', :id => pkg %></td>
-			<td><%=h "(#{pkg.epoch})" if pkg.epoch.to_i != 0 %> <%=h "#{pkg.version}_#{pkg.revision}" %></td>
+			<td><%= link_to pkg.id,  :controller => 'port_pkg', :action => 'show', :id => pkg %></td>
+			<td><%= link_to pkg_ver, :controller => 'port_pkg', :action => 'show', :id => pkg %></td>
 			<td><%= link_to pkg.submitter.user_name, :controller => 'person', :action => 'show',
 					:id => pkg.submitter %></td>
-			<td><%= link_to pkg.submitted_at.to_formatted_s(:long), :controller => 'port_pkg', :action => 'show', :id => pkg %></td>
+			<td><%= pkg.submitted_at.to_formatted_s(:long) %></td>
   		<td><%= link_to 'download', :controller => 'port_pkg', :action => 'emit_portpkg', :id => pkg %></td>
 		</tr>
 	<% end %>

Modified: users/jberry/mpwa/app/views/port_pkg/show.rhtml
===================================================================
--- users/jberry/mpwa/app/views/port_pkg/show.rhtml	2007-06-02 20:43:50 UTC (rev 25805)
+++ users/jberry/mpwa/app/views/port_pkg/show.rhtml	2007-06-02 20:50:13 UTC (rev 25806)
@@ -53,14 +53,22 @@
     <th>Length</th>
     <th>MIME-type</th>
     <th>Download</th>
-    <th>Download Count</th>
+    <th>Downloads</th>
   </tr>
 	<% for ref in @port_pkg.file_refs %>
 		<tr>
 		<td><%= link_to ref.file_info.file_path, :controller => 'file_info', :action => 'show', :id => ref.file_info %></td>
 		<td><%=h ref.file_info.length %></td>
 		<td><%=h ref.file_info.mime_type %></td>
-		<td><%= link_to 'download', :controller => 'file_ref', :action => 'emit', :id => ref %></td>
+		<td>
+		  <%=
+		    if ref.is_port_pkg
+		      link_to 'download', :controller => 'port_pkg', :action => 'emit_portpkg', :id => ref.port_pkg
+		    else
+		      link_to 'download', :controller => 'file_ref', :action => 'emit', :id => ref
+		    end
+		  %>
+		</td>
 		<td><%= ref.download_count %></td>
 		</tr>
 	<% end %>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070602/0e476adf/attachment.html


More information about the macports-changes mailing list