Commit ce556ceea32c2298fa520b9b14f09c47e78c8caf
1 parent
7212edfa
Exists in
master
and in
29 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 | 10 | def list |
11 | 11 | @parent = Tag.find(params[:parent]) if params[:parent] |
12 | 12 | @tags = @parent ? @parent.children : Tag.roots |
13 | - @pending_tags = Tag.find_pendings | |
13 | + @pending_tags = Tag.find_all_by_pending(true) | |
14 | 14 | end |
15 | 15 | |
16 | 16 | # Prompt for data to a new tag |
17 | 17 | def new |
18 | - @parent_tags = Tag.find(:all) | |
18 | + @parent_tags = Tag.find_all_by_pending(false) | |
19 | 19 | @tag = Tag.new |
20 | 20 | end |
21 | 21 | |
... | ... | @@ -26,20 +26,20 @@ class ManageTagsController < ApplicationController |
26 | 26 | flash[:notice] = _('Tag was successfully created.') |
27 | 27 | redirect_to :action => 'list' |
28 | 28 | else |
29 | - @parent_tags = Tag.find(:all) | |
29 | + @parent_tags = Tag.find_all_by_pending(false) | |
30 | 30 | render :action => 'new' |
31 | 31 | end |
32 | 32 | end |
33 | 33 | |
34 | 34 | # Prompt for modifications on the attributes of a tag |
35 | 35 | def edit |
36 | - @tag = Tag.find_with_pendings(params[:id]) | |
36 | + @tag = Tag.find(params[:id]) | |
37 | 37 | @parent_tags = @tag.parent_candidates |
38 | 38 | end |
39 | 39 | |
40 | 40 | # Do the modifications collected by edit |
41 | 41 | def update |
42 | - @tag = Tag.find_with_pendings(params[:id]) | |
42 | + @tag = Tag.find(params[:id]) | |
43 | 43 | if @tag.update_attributes(params[:tag]) |
44 | 44 | flash[:notice] = _('Tag was successfully updated.') |
45 | 45 | redirect_to :action => 'list' |
... | ... | @@ -51,7 +51,7 @@ class ManageTagsController < ApplicationController |
51 | 51 | |
52 | 52 | # Destroy a tag and all its children |
53 | 53 | def destroy |
54 | - @tag = Tag.find_with_pendings(params[:id]) | |
54 | + @tag = Tag.find(params[:id]) | |
55 | 55 | if @tag.destroy |
56 | 56 | flash[:notice] = _('Tag was successfuly destroyed') |
57 | 57 | end |
... | ... | @@ -60,7 +60,7 @@ class ManageTagsController < ApplicationController |
60 | 60 | |
61 | 61 | # Approve a pending tag so now ita can be used to tag things |
62 | 62 | def approve |
63 | - @tag = Tag.find_with_pendings(params[:id]) | |
63 | + @tag = Tag.find(params[:id]) | |
64 | 64 | if @tag.update_attribute(:pending, false) |
65 | 65 | flash[:notice] = _('Tag was successfuly approved') |
66 | 66 | redirect_to :action => 'list' |
... | ... | @@ -69,6 +69,6 @@ class ManageTagsController < ApplicationController |
69 | 69 | |
70 | 70 | # Full-text search for tags that have the query terms |
71 | 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 | 73 | end |
74 | 74 | end | ... | ... |
app/views/layouts/application.rhtml
config/environment.rb
test/functional/manage_tags_controller_test.rb
... | ... | @@ -103,13 +103,13 @@ class ManageTagsControllerTest < Test::Unit::TestCase |
103 | 103 | post :approve, :id => pending_tag.id |
104 | 104 | assert_response :redirect |
105 | 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 | 107 | end |
108 | 108 | |
109 | 109 | def test_search |
110 | 110 | found_tag = Tag.create(:name => 'found_tag') |
111 | 111 | lost_tag = Tag.create(:name => 'lost_tag') |
112 | - post :search, :query => 'found*' | |
112 | + post :search, :query => 'found_tag' | |
113 | 113 | assert_not_nil assigns(:tags_found) |
114 | 114 | assert assigns(:tags_found).include?(found_tag) |
115 | 115 | assert (not assigns(:tags_found).include?(lost_tag)) | ... | ... |