Changeset 38291


Ignore:
Timestamp:
Jul 15, 2008, 4:43:14 AM (11 years ago)
Author:
digx@…
Message:

Rename PortPkg to Package

Location:
branches/gsoc08-mpwa/app
Files:
1 edited
3 moved

Legend:

Unmodified
Added
Removed
  • branches/gsoc08-mpwa/app/controllers/packages_controller.rb

    r38264 r38291  
    1 require 'port_pkg'
    2 
    3 class PortPkgController < ApplicationController
     1class PackagesController < ApplicationController
    42  def index
    5     list
    6     render :action => 'list'
    7   end
    8 
    9   # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
    10   verify :method => :post, :only => [ :destroy, :create, :update ],
    11          :redirect_to => { :action => :list }
    12 
    13   def list
    14     @port_pkg_pages, @port_pkgs = paginate :port_pkgs, :per_page => 10
     3    Package.paginate :page => params[:page], :per_page => 10
    154  end
    165
    176  def show
    18     @port_pkg = PortPkg.find(params[:id])
     7    @port_pkg = Package.find(params[:id])
    198  end
    209
    2110  def new
    22     @port_pkg = PortPkg.new
     11    @port_pkg = Package.new
    2312  end
    2413
    2514  def create
    26     @port_pkg = PortPkg.new(params[:port_pkg])
     15    @port_pkg = Package.new(params[:port_pkg])
    2716    if @port_pkg.save
    28       flash[:notice] = 'PortPkg was successfully created.'
     17      flash[:notice] = 'Package was successfully created.'
    2918      redirect_to :action => 'list'
    3019    else
     
    3423
    3524  def edit
    36     @port_pkg = PortPkg.find(params[:id])
     25    @port_pkg = Package.find(params[:id])
    3726  end
    3827
    3928  def update
    40     @port_pkg = PortPkg.find(params[:id])
     29    @port_pkg = Package.find(params[:id])
    4130    if @port_pkg.update_attributes(params[:port_pkg])
    42       flash[:notice] = 'PortPkg was successfully updated.'
     31      flash[:notice] = 'Package was successfully updated.'
    4332      redirect_to :action => 'show', :id => @port_pkg
    4433    else
     
    4837
    4938  def destroy
    50     PortPkg.find(params[:id]).destroy
     39    Package.find(params[:id]).destroy
    5140    redirect_to :action => 'list'
    5241  end
     
    6049
    6150        # Create a package from the file
    62         @port_pkg = PortPkg.create_from_file(portpkg)
     51        @port_pkg = Package.create_from_file(portpkg)
    6352       
    6453        download_url = portpkg_url(:id => @port_pkg)
    6554        human_url = url_for(:controller => "port_pkg", :action => "show", :id => @port_pkg)
    6655        render :text => "STATUS: 0\n" +
    67             "MESSAGE: PortPkg submitted successfully\n" +
     56            "MESSAGE: Package submitted successfully\n" +
    6857            "DOWNLOAD_URL: #{download_url}\n" +
    6958            "HUMAN_URL: #{human_url}\n"
     
    7463  end
    7564 
    76   def emit_portpkg
    77     port_pkg = PortPkg.find(params[:id])
     65  def download
     66    port_pkg = Package.find(params[:id])
    7867    redirect_to :controller => 'file_ref', :action => 'emit',
    7968        :id => port_pkg.portpkg_file_ref()
    8069  end
    8170 
    82   def emit_portpkg_path
    83     port_pkg = PortPkg.find(params[:id])
     71  def download_path
     72    port_pkg = Package.find(params[:id])
    8473    redirect_to :controller => 'file_ref', :action => 'emit',
    8574        :id => port_pkg.file_ref_by_path(params[:path].join, '/')
     
    8776 
    8877  def tag
    89     port_pkg = PortPkg.find(params[:id])
     78    port_pkg = Package.find(params[:id])
    9079    params[:tags].split(/,?[ ]+/).each do |t|
    9180      if t =~ /\-(.*)/
     
    9988 
    10089  def add_comment
    101     port_pkg = PortPkg.find(params[:id])
     90    port_pkg = Package.find(params[:id])
    10291    text = params[:text]
    10392   
  • branches/gsoc08-mpwa/app/models/package.rb

    r38290 r38291  
    2323end
    2424
    25 class PortPkg < ActiveRecord::Base
     25class Package < ActiveRecord::Base
    2626    belongs_to :port
    2727    belongs_to :submitter, :class_name => 'Person', :foreign_key => 'submitter_id'
     
    3232    has_and_belongs_to_many :comments
    3333   
    34     def PortPkg.create_from_file(file)
    35         portpkg = PortPkg.new
     34    def self.create_from_file(file)
     35        portpkg = Package.new
    3636        portpkg.import_from_file(file)
    3737    end
    3838   
    39     def PortPkg.extract_pkg_meta_from_file(f)
     39    def self.extract_pkg_meta_from_file(f)
    4040        # This function parses the xml metadata file from a portpkg,
    4141        # and creates a canonical internal form for our exclusive use
     
    101101        # Parse the meta information       
    102102        meta = nil
    103         File.open(metaPath, "r") { |f| meta = PortPkg.extract_pkg_meta_from_file(f) }
     103        File.open(metaPath, "r") { |f| meta = Package.extract_pkg_meta_from_file(f) }
    104104       
    105105        # Fill-in portpkg information from metadata
  • branches/gsoc08-mpwa/app/views/packages/show.rhtml

    r38165 r38291  
    4141<p>
    4242        <strong>Submitter:</strong>
    43          <%= link_to email_obfuscate(@port_pkg.submitter.user_name),
    44                      :controller => 'person', :action => 'show',
    45                      :id => @port_pkg.submitter %>
     43         <%= link_to @port_pkg.submitter.user_name, @port_pkg.submitter %>
    4644</p>
    4745
Note: See TracChangeset for help on using the changeset viewer.