Commit 7b1191e39c2f2a2b86ac656833f971cb5419335f
1 parent
f78c0086
Exists in
master
and in
28 other branches
ActionItem31: adding tags and abstract for articles
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@998 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
6 changed files
with
12 additions
and
15 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -19,7 +19,7 @@ class CmsController < MyProfileController | @@ -19,7 +19,7 @@ class CmsController < MyProfileController | ||
19 | end | 19 | end |
20 | 20 | ||
21 | def edit | 21 | def edit |
22 | - @article = Article.find(params[:id]) | 22 | + @article = profile.articles.find(params[:id]) |
23 | if request.post? | 23 | if request.post? |
24 | @article.last_changed_by = user | 24 | @article.last_changed_by = user |
25 | if @article.update_attributes(params[:article]) | 25 | if @article.update_attributes(params[:article]) |
@@ -32,7 +32,7 @@ class CmsController < MyProfileController | @@ -32,7 +32,7 @@ class CmsController < MyProfileController | ||
32 | end | 32 | end |
33 | 33 | ||
34 | def new | 34 | def new |
35 | - # FIXME until now, use text/html by default | 35 | + # FIXME need to display a page and let the user choose a type of article. |
36 | type = params[:type] || 'text/html' | 36 | type = params[:type] || 'text/html' |
37 | 37 | ||
38 | @article = Article.new(params[:article]) | 38 | @article = Article.new(params[:article]) |
app/helpers/cms_helper.rb
1 | module CmsHelper | 1 | module CmsHelper |
2 | 2 | ||
3 | - def link_to_edit_article(article) | ||
4 | - button('edit', _("Edit"), url_for_edit_article(article)) | ||
5 | - end | ||
6 | - | ||
7 | - def url_for_edit_article(article) | ||
8 | - action = mime_type_to_action_name(article.mime_type) + '_edit' | ||
9 | - url_for(:action => action, :id => article.id) | ||
10 | - end | ||
11 | - | ||
12 | def link_to_new_article(mime_type) | 3 | def link_to_new_article(mime_type) |
13 | action = mime_type_to_action_name(mime_type) + '_new' | 4 | action = mime_type_to_action_name(mime_type) + '_new' |
14 | button('new', _("New %s") % mime_type, :action => action, :parent_id => params[:parent_id]) | 5 | button('new', _("New %s") % mime_type, :action => action, :parent_id => params[:parent_id]) |
app/models/article.rb
@@ -8,6 +8,7 @@ class Article < ActiveRecord::Base | @@ -8,6 +8,7 @@ class Article < ActiveRecord::Base | ||
8 | belongs_to :last_changed_by, :class_name => Person.name, :foreign_key => 'last_changed_by_id' | 8 | belongs_to :last_changed_by, :class_name => Person.name, :foreign_key => 'last_changed_by_id' |
9 | 9 | ||
10 | acts_as_taggable | 10 | acts_as_taggable |
11 | + N_('Tag list') | ||
11 | 12 | ||
12 | acts_as_filesystem | 13 | acts_as_filesystem |
13 | 14 |
app/views/cms/text_html_new.rhtml
@@ -6,11 +6,15 @@ | @@ -6,11 +6,15 @@ | ||
6 | 6 | ||
7 | <%= hidden_field_tag('parent_id', params[:parent_id]) if params[:parent_id] %> | 7 | <%= hidden_field_tag('parent_id', params[:parent_id]) if params[:parent_id] %> |
8 | 8 | ||
9 | - <%= f.text_field 'name', :size => '64' %> | ||
10 | - | 9 | + <%= f.text_field('name', :size => '64') %> |
10 | + | ||
11 | + <%= f.text_area('abstract', :cols => 64, :rows => 5) %> | ||
12 | + | ||
13 | + <%= f.text_field('tag_list', :size => 64, :title => _('Separate tags with commas')) %> | ||
14 | + | ||
11 | <%= f.text_area('body', :cols => 64) %> | 15 | <%= f.text_area('body', :cols => 64) %> |
12 | 16 | ||
13 | <%= design_display_button_submit('save', _('Save')) %> | 17 | <%= design_display_button_submit('save', _('Save')) %> |
14 | - <%= design_display_button('cancel', _('Cancel'), :action => 'view', :id => @article) %> | 18 | + <%= design_display_button('cancel', _('Cancel'), :action => (@article.parent ? 'view' : 'index'), :id => @article.parent) %> |
15 | 19 | ||
16 | <% end %> | 20 | <% end %> |
app/views/cms/view.rhtml
@@ -58,7 +58,7 @@ | @@ -58,7 +58,7 @@ | ||
58 | </li> | 58 | </li> |
59 | </ul> | 59 | </ul> |
60 | 60 | ||
61 | - <%= link_to_edit_article(@article) %> | 61 | + <%= button('edit', _('Edit'), { :action => 'edit', :id => @article}) %> |
62 | <%= button('home', _('Use as homepage'), { :action => 'set_home_page', :id => @article }, { :method => :post }) %> | 62 | <%= button('home', _('Use as homepage'), { :action => 'set_home_page', :id => @article }, { :method => :post }) %> |
63 | <% end %> | 63 | <% end %> |
64 | <%= @article.to_html %> | 64 | <%= @article.to_html %> |
db/migrate/007_create_articles.rb
@@ -10,6 +10,7 @@ class CreateArticles < ActiveRecord::Migration | @@ -10,6 +10,7 @@ class CreateArticles < ActiveRecord::Migration | ||
10 | 10 | ||
11 | # main data | 11 | # main data |
12 | t.column :body, :text | 12 | t.column :body, :text |
13 | + t.column :abstract, :text | ||
13 | 14 | ||
14 | # belongs to profile | 15 | # belongs to profile |
15 | t.column :profile_id, :integer | 16 | t.column :profile_id, :integer |