Commit ce556ceea32c2298fa520b9b14f09c47e78c8caf
1 parent
7212edfa
Exists in
master
and in
22 other branches
ActionItem4: Reimplemented some parts of the acts_as_taggable plugins specially …
…the find_tagged_with method git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@370 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
11 additions
and
12 deletions
Show diff stats
app/controllers/manage_tags_controller.rb
| @@ -10,12 +10,12 @@ class ManageTagsController < ApplicationController | @@ -10,12 +10,12 @@ class ManageTagsController < ApplicationController | ||
| 10 | def list | 10 | def list |
| 11 | @parent = Tag.find(params[:parent]) if params[:parent] | 11 | @parent = Tag.find(params[:parent]) if params[:parent] |
| 12 | @tags = @parent ? @parent.children : Tag.roots | 12 | @tags = @parent ? @parent.children : Tag.roots |
| 13 | - @pending_tags = Tag.find_pendings | 13 | + @pending_tags = Tag.find_all_by_pending(true) |
| 14 | end | 14 | end |
| 15 | 15 | ||
| 16 | # Prompt for data to a new tag | 16 | # Prompt for data to a new tag |
| 17 | def new | 17 | def new |
| 18 | - @parent_tags = Tag.find(:all) | 18 | + @parent_tags = Tag.find_all_by_pending(false) |
| 19 | @tag = Tag.new | 19 | @tag = Tag.new |
| 20 | end | 20 | end |
| 21 | 21 | ||
| @@ -26,20 +26,20 @@ class ManageTagsController < ApplicationController | @@ -26,20 +26,20 @@ class ManageTagsController < ApplicationController | ||
| 26 | flash[:notice] = _('Tag was successfully created.') | 26 | flash[:notice] = _('Tag was successfully created.') |
| 27 | redirect_to :action => 'list' | 27 | redirect_to :action => 'list' |
| 28 | else | 28 | else |
| 29 | - @parent_tags = Tag.find(:all) | 29 | + @parent_tags = Tag.find_all_by_pending(false) |
| 30 | render :action => 'new' | 30 | render :action => 'new' |
| 31 | end | 31 | end |
| 32 | end | 32 | end |
| 33 | 33 | ||
| 34 | # Prompt for modifications on the attributes of a tag | 34 | # Prompt for modifications on the attributes of a tag |
| 35 | def edit | 35 | def edit |
| 36 | - @tag = Tag.find_with_pendings(params[:id]) | 36 | + @tag = Tag.find(params[:id]) |
| 37 | @parent_tags = @tag.parent_candidates | 37 | @parent_tags = @tag.parent_candidates |
| 38 | end | 38 | end |
| 39 | 39 | ||
| 40 | # Do the modifications collected by edit | 40 | # Do the modifications collected by edit |
| 41 | def update | 41 | def update |
| 42 | - @tag = Tag.find_with_pendings(params[:id]) | 42 | + @tag = Tag.find(params[:id]) |
| 43 | if @tag.update_attributes(params[:tag]) | 43 | if @tag.update_attributes(params[:tag]) |
| 44 | flash[:notice] = _('Tag was successfully updated.') | 44 | flash[:notice] = _('Tag was successfully updated.') |
| 45 | redirect_to :action => 'list' | 45 | redirect_to :action => 'list' |
| @@ -51,7 +51,7 @@ class ManageTagsController < ApplicationController | @@ -51,7 +51,7 @@ class ManageTagsController < ApplicationController | ||
| 51 | 51 | ||
| 52 | # Destroy a tag and all its children | 52 | # Destroy a tag and all its children |
| 53 | def destroy | 53 | def destroy |
| 54 | - @tag = Tag.find_with_pendings(params[:id]) | 54 | + @tag = Tag.find(params[:id]) |
| 55 | if @tag.destroy | 55 | if @tag.destroy |
| 56 | flash[:notice] = _('Tag was successfuly destroyed') | 56 | flash[:notice] = _('Tag was successfuly destroyed') |
| 57 | end | 57 | end |
| @@ -60,7 +60,7 @@ class ManageTagsController < ApplicationController | @@ -60,7 +60,7 @@ class ManageTagsController < ApplicationController | ||
| 60 | 60 | ||
| 61 | # Approve a pending tag so now ita can be used to tag things | 61 | # Approve a pending tag so now ita can be used to tag things |
| 62 | def approve | 62 | def approve |
| 63 | - @tag = Tag.find_with_pendings(params[:id]) | 63 | + @tag = Tag.find(params[:id]) |
| 64 | if @tag.update_attribute(:pending, false) | 64 | if @tag.update_attribute(:pending, false) |
| 65 | flash[:notice] = _('Tag was successfuly approved') | 65 | flash[:notice] = _('Tag was successfuly approved') |
| 66 | redirect_to :action => 'list' | 66 | redirect_to :action => 'list' |
| @@ -69,6 +69,6 @@ class ManageTagsController < ApplicationController | @@ -69,6 +69,6 @@ class ManageTagsController < ApplicationController | ||
| 69 | 69 | ||
| 70 | # Full-text search for tags that have the query terms | 70 | # Full-text search for tags that have the query terms |
| 71 | def search | 71 | def search |
| 72 | - @tags_found = Tag.find_by_contents(params[:query]) | 72 | + @tags_found = Tag.find_all_by_name_and_pending(params[:query], false) |
| 73 | end | 73 | end |
| 74 | end | 74 | end |
app/views/layouts/application.rhtml
| @@ -48,7 +48,7 @@ | @@ -48,7 +48,7 @@ | ||
| 48 | <div id="footer"> | 48 | <div id="footer"> |
| 49 | <!-- <a name='footer'/></a> --> | 49 | <!-- <a name='footer'/></a> --> |
| 50 | <%= footer %> | 50 | <%= footer %> |
| 51 | - <%= design_display_icon('back', _('Back') , :action => 'list')%> | 51 | + <%= design_display_icon('back', :action => 'list')%> |
| 52 | </div> | 52 | </div> |
| 53 | </div> | 53 | </div> |
| 54 | </div> | 54 | </div> |
config/environment.rb
| @@ -53,7 +53,6 @@ end | @@ -53,7 +53,6 @@ end | ||
| 53 | # Include your application configuration below | 53 | # Include your application configuration below |
| 54 | 54 | ||
| 55 | require 'gettext/rails' | 55 | require 'gettext/rails' |
| 56 | -#require 'extended_tag' | ||
| 57 | Tag.hierarchical = true | 56 | Tag.hierarchical = true |
| 58 | 57 | ||
| 59 | Comatose.configure do |config| | 58 | Comatose.configure do |config| |
test/functional/manage_tags_controller_test.rb
| @@ -103,13 +103,13 @@ class ManageTagsControllerTest < Test::Unit::TestCase | @@ -103,13 +103,13 @@ class ManageTagsControllerTest < Test::Unit::TestCase | ||
| 103 | post :approve, :id => pending_tag.id | 103 | post :approve, :id => pending_tag.id |
| 104 | assert_response :redirect | 104 | assert_response :redirect |
| 105 | assert_redirected_to :action => 'list' | 105 | assert_redirected_to :action => 'list' |
| 106 | - assert ( not Tag.find_with_pendings(pending_tag.id).pending? ) | 106 | + assert ( not Tag.find(pending_tag.id).pending? ) |
| 107 | end | 107 | end |
| 108 | 108 | ||
| 109 | def test_search | 109 | def test_search |
| 110 | found_tag = Tag.create(:name => 'found_tag') | 110 | found_tag = Tag.create(:name => 'found_tag') |
| 111 | lost_tag = Tag.create(:name => 'lost_tag') | 111 | lost_tag = Tag.create(:name => 'lost_tag') |
| 112 | - post :search, :query => 'found*' | 112 | + post :search, :query => 'found_tag' |
| 113 | assert_not_nil assigns(:tags_found) | 113 | assert_not_nil assigns(:tags_found) |
| 114 | assert assigns(:tags_found).include?(found_tag) | 114 | assert assigns(:tags_found).include?(found_tag) |
| 115 | assert (not assigns(:tags_found).include?(lost_tag)) | 115 | assert (not assigns(:tags_found).include?(lost_tag)) |