[38297] branches/gsoc08-mpwa/app
digx at macports.org
digx at macports.org
Mon Jul 14 21:46:24 PDT 2008
Revision: 38297
http://trac.macosforge.org/projects/macports/changeset/38297
Author: digx at macports.org
Date: 2008-07-14 21:46:24 -0700 (Mon, 14 Jul 2008)
Log Message:
-----------
Couple of updates and cleanups
Modified Paths:
--------------
branches/gsoc08-mpwa/app/controllers/ports_controller.rb
branches/gsoc08-mpwa/app/controllers/tags_controller.rb
branches/gsoc08-mpwa/app/models/person.rb
branches/gsoc08-mpwa/app/models/port.rb
Modified: branches/gsoc08-mpwa/app/controllers/ports_controller.rb
===================================================================
--- branches/gsoc08-mpwa/app/controllers/ports_controller.rb 2008-07-15 04:45:18 UTC (rev 38296)
+++ branches/gsoc08-mpwa/app/controllers/ports_controller.rb 2008-07-15 04:46:24 UTC (rev 38297)
@@ -52,29 +52,16 @@
def tag
port = Port.find(params[:id])
- params[:tags].split(/,?[ ]+/).each do |t|
- if t =~ /\-(.*)/
- port.remove_tag($1) if $1
- elsif t =~ /\+?(.+)/
- port.add_tag($1)
- end
- end
- redirect_to :action => 'show', :id => port
+ port.tag_list << params[:tag].downcase
+ port.save
+ redirect_to port
end
- def add_comment
+ def untag
port = Port.find(params[:id])
- text = params[:text]
-
- if text
- # TODO: Figure out the real maintainer
- port.comments << Comment.create(:commenter => port.maintainers.first, :comment => text)
- end
-
- redirect_to :action => 'show', :id => port
+ port.tag_list.delete(params[:tag].downcase)
+ port.save
+ redirect_to port
end
-
- private :add_comment
- private :create, :edit, :update, :destroy
end
Modified: branches/gsoc08-mpwa/app/controllers/tags_controller.rb
===================================================================
--- branches/gsoc08-mpwa/app/controllers/tags_controller.rb 2008-07-15 04:45:18 UTC (rev 38296)
+++ branches/gsoc08-mpwa/app/controllers/tags_controller.rb 2008-07-15 04:46:24 UTC (rev 38297)
@@ -5,41 +5,10 @@
end
def show
- @tag = Tag.find_by_name_or_id(params[:id])
+ Tag.new
+ raise ActiveRecord::RecordNotFound, "Couldn't find Tag with ID=#{params[:id]}" unless @tag = Tag.find_by_name(params[:id])
+ @ports = Port.paginate_tagged_with(@tag.name, :page => params[:ports_page], :per_page => 32)
+ @port_pkgs = Package.paginate_tagged_with(@tag.name, :page => params[:pkgs_page], :per_page => 32)
end
- def new
- @tag = Tag.new
- end
-
- def create
- @tag = Tag.new(params[:tag])
-
- if @tag.save
- flash[:notice] = 'Tag was successfully created.'
- redirect_to tags_url
- else
- render :action => 'new'
- end
- end
-
- def edit
- @tag = Tag.find(params[:id])
- end
-
- def update
- @tag = Tag.find(params[:id])
- if @tag.update_attributes(params[:tag])
- flash[:notice] = 'Tag was successfully updated.'
- redirect_to :action => 'show', :id => @tag
- else
- render :action => 'edit'
- end
- end
-
- def destroy
- Tag.find(params[:id]).destroy
- redirect_to :action => 'list'
- end
-
end
Modified: branches/gsoc08-mpwa/app/models/person.rb
===================================================================
--- branches/gsoc08-mpwa/app/models/person.rb 2008-07-15 04:45:18 UTC (rev 38296)
+++ branches/gsoc08-mpwa/app/models/person.rb 2008-07-15 04:46:24 UTC (rev 38297)
@@ -1,24 +1,21 @@
-require 'port'
-require 'port_pkg'
-
class Person < ActiveRecord::Base
- has_and_belongs_to_many :ports, :class_name => 'Port', :join_table => 'maintainers_ports'
- has_many :port_pkgs, :foreign_key => 'submitter_id'
+ has_and_belongs_to_many :ports, :class_name => 'Port', :join_table => 'maintainers_ports'
+ has_many :port_pkgs, :foreign_key => 'submitter_id'
- def Person.ensure_person_with_email(email, name = nil)
- person = Person.find_by_email(email)
- if person.nil?
- # build a new person using the supplied email address
- person = Person.new
-
- # Give it everything we know
- person.user_name = name.nil? || name.empty? ? email : name
- person.email = email
-
- # Save the person
- person.save
- end
+ def Person.ensure_person_with_email(email, name = nil)
+ person = Person.find_by_email(email)
+ if person.nil?
+ # build a new person using the supplied email address
+ person = Person.new
- return person
+ # Give it everything we know
+ person.user_name = name.nil? || name.empty? ? email : name
+ person.email = email
+
+ # Save the person
+ person.save
end
+
+ return person
+ end
end
Modified: branches/gsoc08-mpwa/app/models/port.rb
===================================================================
--- branches/gsoc08-mpwa/app/models/port.rb 2008-07-15 04:45:18 UTC (rev 38296)
+++ branches/gsoc08-mpwa/app/models/port.rb 2008-07-15 04:46:24 UTC (rev 38297)
@@ -1,14 +1,10 @@
-require 'comment'
-require 'person'
-require 'port_pkg'
-require 'tag'
-
class Port < ActiveRecord::Base
- has_many :port_pkgs, :dependent => :destroy
- has_and_belongs_to_many :tags
+ has_many :packages, :dependent => :destroy
has_and_belongs_to_many :maintainers, :class_name => 'Person', :join_table => 'maintainers_ports'
has_and_belongs_to_many :comments
+ acts_as_taggable_on :tags
+
def Port.ensure_port(name, meta)
port = Port.find_by_name(name)
if port.nil?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080714/2a31b5e3/attachment-0001.html
More information about the macports-changes
mailing list