Commit
102338bc0f6f766e5e7df1ea050503ceeb4ff891
Exists in
staging
and in
42 other branches
all_pending_tasks_api, api-articles-period, api_roles, caching-rails4, captcha_serpro_plugin, comments_permissions, content-manager-hostspot, elasticsearch, elasticsearch_api, elasticsearch_categories, elasticsearch_filter, elasticsearch_sort, elasticsearch_to_merge, elasticsearch_view, environment-exposes-api, export-comment-api, export-comment-paragraph, export_data, external_followers, federation-webfinger, federation_followers, federation_followers_backend, federation_oauth_provider, federation_webfinger, fix_event_date_issue, fix_notification_email, fix_string_downcase_and_upcase, follower_permition, json_cookie_serializer, login-captcha, master, master_profile_followers, oauth_external_login, oauth_login, private-scraps, private-scraps-rebase, production, production-vendorized, profile_api_improvements, tasks_keep_filter_params, user_mention, webfinger_server
ActionItem4: basic managing tags
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@36 3f533792-8f58-4932-b0fe-aaf55b0a4547
|
| @@ -0,0 +1,27 @@ |
| @@ -0,0 +1,27 @@ |
|
| |
1
| +class ManageTagsController < ApplicationController |
|
| |
2
| + def index |
|
| |
3
| + list |
|
| |
4
| + render :action => 'list' |
|
| |
5
| + end |
|
| |
6
| + |
|
| |
7
| + def list |
|
| |
8
| + @tags = Tag.find_all |
|
| |
9
| + end |
|
| |
10
| + |
|
| |
11
| + def new |
|
| |
12
| + @tags = Tag.find_all |
|
| |
13
| + @tag = Tag.new |
|
| |
14
| + end |
|
| |
15
| + |
|
| |
16
| + def create |
|
| |
17
| + @tag = Tag.new |
|
| |
18
| + @tag.name = params[:tag][:name] |
|
| |
19
| + @tag.parent = Tag.find(params[:parent_id].to_i) if params[:parent_id] != "0" |
|
| |
20
| + if @tag.save |
|
| |
21
| + flash[:notice] = _('Tag was successfully created.') |
|
| |
22
| + redirect_to :action => 'list' |
|
| |
23
| + else |
|
| |
24
| + render :action => 'new' |
|
| |
25
| + end |
|
| |
26
| + end |
|
| |
27
| +end |
|
| @@ -0,0 +1,3 @@ |
| @@ -0,0 +1,3 @@ |
|
| |
1
| + |
|
| |
2
| +Name: <%= text_field 'tag', 'name' %> <br> |
|
| |
3
| +Parent tag: <%= select_tag 'parent_id', ['<option value="0"></option>'] + @tags.map {|n|"<option value=\"#{n.id}\">" + n.name + '</option>'} %> <br> |
|
| @@ -0,0 +1,8 @@ |
| @@ -0,0 +1,8 @@ |
|
| |
1
| +<li> |
|
| |
2
| +<%= a_tag.name %> |
|
| |
3
| +<ul> |
|
| |
4
| +<% a_tag.children.each do |child|%> |
|
| |
5
| +<%= render :partial =>'list', :locals => {:a_tag => child} %> |
|
| |
6
| +<% end %> |
|
| |
7
| +</ul> |
|
| |
8
| +</li> |
|
| @@ -0,0 +1,9 @@ |
| @@ -0,0 +1,9 @@ |
|
| |
1
| +<h2> <%= _("Listing tags") %> </h2> |
|
| |
2
| + |
|
| |
3
| +<ul> |
|
| |
4
| + <% @tags.select{|t| !t.parent }.each do |a_tag| %> |
|
| |
5
| + <%= render :partial => 'list', :locals => {:a_tag => a_tag} %> |
|
| |
6
| + <% end %> |
|
| |
7
| +</ul> |
|
| |
8
| + |
|
| |
9
| +<%= link_to _('New tag'), {:action => 'new'} %> |
|
| @@ -0,0 +1,6 @@ |
| @@ -0,0 +1,6 @@ |
|
| |
1
| +<h2> <%= _('New tag') %> </h2> |
|
| |
2
| + |
|
| |
3
| +<%= start_form_tag :action =>'create' %> |
|
| |
4
| + <%= render :partial => 'form' %> |
|
| |
5
| + <%= submit_tag 'Create' %> |
|
| |
6
| +<%= end_form_tag %> |
|
| @@ -0,0 +1,27 @@ |
| @@ -0,0 +1,27 @@ |
|
| |
1
| +class ActsAsTaggableMigration < ActiveRecord::Migration
|
|
| |
2
| + def self.up
|
|
| |
3
| + create_table :tags do |t|
|
|
| |
4
| + t.column :name, :string
|
|
| |
5
| + t.column :parent_id, :integer
|
|
| |
6
| + end
|
|
| |
7
| +
|
|
| |
8
| + create_table :taggings do |t|
|
|
| |
9
| + t.column :tag_id, :integer
|
|
| |
10
| + t.column :taggable_id, :integer
|
|
| |
11
| +
|
|
| |
12
| + # You should make sure that the column created is
|
|
| |
13
| + # long enough to store the required class names.
|
|
| |
14
| + t.column :taggable_type, :string
|
|
| |
15
| +
|
|
| |
16
| + t.column :created_at, :datetime
|
|
| |
17
| + end
|
|
| |
18
| +
|
|
| |
19
| + add_index :taggings, :tag_id
|
|
| |
20
| + add_index :taggings, [:taggable_id, :taggable_type]
|
|
| |
21
| + end
|
|
| |
22
| +
|
|
| |
23
| + def self.down
|
|
| |
24
| + drop_table :taggings
|
|
| |
25
| + drop_table :tags
|
|
| |
26
| + end
|
|
| |
27
| +end |