Commit f5703d915c051ab9d4358b51a5639bb85e5ca693
1 parent
2cd9c622
Exists in
master
and in
22 other branches
Improvements on article suggestion feature
* English text review
* Letting the administrator edit all fields which are going to be
published before accepting the article.
* Letting administrator highlight the new article.
* Making the size of the lead and body fields consistent with other
UI parts
* Removed inconsistent styling
* Updated database schema file
(ActionItem1732)
Showing
11 changed files
with
80 additions
and
34 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| ... | ... | @@ -289,7 +289,7 @@ class CmsController < MyProfileController |
| 289 | 289 | if request.post? |
| 290 | 290 | @task.target = profile |
| 291 | 291 | if @task.save |
| 292 | - session[:notice] = _('You make your suggestion successfully. Please wait the article approval.') | |
| 292 | + session[:notice] = _('Thanks for your suggestion. The community administrators were notified.') | |
| 293 | 293 | redirect_to @back_to |
| 294 | 294 | end |
| 295 | 295 | end | ... | ... |
app/models/suggest_article.rb
| ... | ... | @@ -8,7 +8,7 @@ class SuggestArticle < Task |
| 8 | 8 | validates_presence_of :target_id, :article_name, :email, :name, :article_body |
| 9 | 9 | |
| 10 | 10 | def description |
| 11 | - _('%{email} suggested to publish "%{article}" on %{community}') % { :email => email, :article => article_name, :community => target.name } | |
| 11 | + _('%{sender} suggested to publish "%{article}" on %{community}') % { :sender => sender, :article => article_name, :community => target.name } | |
| 12 | 12 | end |
| 13 | 13 | |
| 14 | 14 | settings_items :email, :type => String |
| ... | ... | @@ -18,9 +18,24 @@ class SuggestArticle < Task |
| 18 | 18 | settings_items :article_abstract, :type => String |
| 19 | 19 | settings_items :article_parent_id, :type => String |
| 20 | 20 | settings_items :source, :type => String |
| 21 | + settings_items :source_name, :type => String | |
| 22 | + settings_items :highlighted, :type => :boolean | |
| 23 | + | |
| 24 | + def sender | |
| 25 | + "#{name} (#{email})" | |
| 26 | + end | |
| 21 | 27 | |
| 22 | 28 | def perform |
| 23 | - TinyMceArticle.create!(:profile => target, :name => article_name, :body => article_body, :abstract => article_abstract, :parent_id => article_parent_id, :source => source, :source_name => name) | |
| 29 | + TinyMceArticle.create!( | |
| 30 | + :profile => target, | |
| 31 | + :name => article_name, | |
| 32 | + :body => article_body, | |
| 33 | + :abstract => article_abstract, | |
| 34 | + :parent_id => article_parent_id, | |
| 35 | + :source => source, | |
| 36 | + :source_name => source_name, | |
| 37 | + :highlighted => highlighted | |
| 38 | + ) | |
| 24 | 39 | end |
| 25 | 40 | |
| 26 | 41 | end | ... | ... |
app/views/cms/suggest_an_article.rhtml
| ... | ... | @@ -6,23 +6,25 @@ |
| 6 | 6 | |
| 7 | 7 | <% labelled_form_for 'task', @task do |f| %> |
| 8 | 8 | |
| 9 | - <%= required labelled_form_field(_('Title'), text_field(:task, 'article_name')) %> | |
| 9 | + <%= required labelled_form_field(_('Title'), text_field(:task, 'article_name', :size => 50)) %> | |
| 10 | 10 | |
| 11 | - <%= labelled_form_field(_('Url Source'), text_field(:task, 'source')) %> | |
| 11 | + <%= labelled_form_field(_('Source'), text_field(:task, 'source_name')) %> | |
| 12 | 12 | |
| 13 | - <%= required labelled_form_field(_('Name'), text_field(:task, 'name')) %> | |
| 13 | + <%= labelled_form_field(_('Source link'), text_field(:task, 'source')) %> | |
| 14 | + | |
| 15 | + <%= required labelled_form_field(_('Your name'), text_field(:task, 'name')) %> | |
| 14 | 16 | |
| 15 | 17 | <%= required labelled_form_field(_('Email'), text_field(:task, 'email')) %> |
| 16 | 18 | |
| 17 | 19 | <br style="clear: both;"/> |
| 18 | 20 | <%= button :add, _("Lead"), '#', :id => "lead-button", :style => "margin-left: 0px;" %> |
| 19 | - <em><%= _('Used when a short version your text is needed.') %></em> | |
| 21 | + <em><%= _('Used when a short version of your text is needed.') %></em> | |
| 20 | 22 | |
| 21 | 23 | <div id="article-lead"> |
| 22 | - <%= labelled_form_field(_('Lead'), text_area(:task , 'article_abstract', :style => 'width: 100%; height: 300px;')) %> | |
| 24 | + <%= labelled_form_field(_('Lead'), text_area(:task , 'article_abstract', :style => 'width: 100%; height: 200px;')) %> | |
| 23 | 25 | </div> |
| 24 | 26 | <div style="margin-top: 10px;"> |
| 25 | - <%= labelled_form_field(_('Text'), text_area(:task, 'article_body', :style => 'width:100%')) %> | |
| 27 | + <%= labelled_form_field(_('Text'), text_area(:task, 'article_body', :style => 'width:100%; height: 500px;')) %> | |
| 26 | 28 | </div> |
| 27 | 29 | |
| 28 | 30 | <div id="captcha"> | ... | ... |
app/views/content_viewer/view_page.rhtml
| ... | ... | @@ -46,7 +46,9 @@ |
| 46 | 46 | <% end %> |
| 47 | 47 | </div> |
| 48 | 48 | <% else %> |
| 49 | - <%= link_to content_tag( 'span', _('Suggest an article') ), profile.admin_url.merge({ :controller => 'cms', :action => 'suggest_an_article'}), :class => 'button with-text icon-new' %> | |
| 49 | + <% if profile.community? %> | |
| 50 | + <%= link_to content_tag( 'span', _('Suggest an article') ), profile.admin_url.merge({ :controller => 'cms', :action => 'suggest_an_article'}), :class => 'button with-text icon-new' %> | |
| 51 | + <% end %> | |
| 50 | 52 | <% end %> |
| 51 | 53 | <div id="article-header"> |
| 52 | 54 | <%= link_to(image_tag('icons-mime/rss-feed.png'), @page.feed.url, :class => 'blog-feed-link') if @page.has_posts? && @page.feed %> | ... | ... |
app/views/tasks/_approve_article.rhtml
| ... | ... | @@ -26,7 +26,11 @@ |
| 26 | 26 | <%= labelled_form_field _('Name for publishing'), f.text_field(:name, :style => 'width:80%;') %> |
| 27 | 27 | |
| 28 | 28 | <%= select_folder(_('Select the folder where the article must be published'), 'task', 'article_parent_id', task.target.folders) %> |
| 29 | - <%= labelled_form_field( _('Highlight this article'), f.check_box(:highlighted)) %> | |
| 29 | + <div> | |
| 30 | + <%= f.check_box(:highlighted) %> | |
| 31 | + <label for="article_highlighted"><%= _('Highlight this article')%></label> | |
| 32 | + </div> | |
| 33 | + | |
| 30 | 34 | <%= labelled_form_field _('Comment for author'), f.text_field(:closing_statment, :style => 'width:80%;') %> |
| 31 | 35 | <%= render :partial => partial_for_class(task.article.class), :locals => { :f => f } %> |
| 32 | 36 | ... | ... |
app/views/tasks/_suggest_article.rhtml
| ... | ... | @@ -4,24 +4,24 @@ |
| 4 | 4 | |
| 5 | 5 | <% form_for('task', task, :url => { :action => 'close', :id => task.id}) do |f| %> |
| 6 | 6 | |
| 7 | - <p> <%= label_tag(_("Sent by: %s") % task.name) %> </p> | |
| 7 | + <p><%= label_tag(_("Sent by: %s") % task.name) %> </p> | |
| 8 | 8 | <p><%= label_tag(_("Email: %s") % task.email) %> </p> |
| 9 | - <p><%= label_tag(_("Source: %s") % task.source) %> </p> | |
| 10 | 9 | |
| 11 | - <%= required labelled_form_field(_('Title'), text_field_tag('task[article_name]', task.article_name)) %> | |
| 10 | + <%= required labelled_form_field(_('Title'), f.text_field(:article_name, :size => 50)) %> | |
| 11 | + <%= labelled_form_field(_('Source'), f.text_field(:source_name)) %> | |
| 12 | + <%= labelled_form_field(_("Source URL"), f.text_field(:source)) %> | |
| 12 | 13 | |
| 13 | 14 | <%= select_folder(_('Select the folder where the article must be published'), 'task', 'article_parent_id', task.target.folders) %> |
| 14 | 15 | |
| 15 | - | |
| 16 | 16 | <br style="clear: both;"/> |
| 17 | 17 | <%= button :add, _("Lead"), '#', :id => "lead-button", :style => "margin-left: 0px;" %> |
| 18 | 18 | <em><%= _('Used when a short version your text is needed.') %></em> |
| 19 | 19 | |
| 20 | 20 | <div id="article-lead"> |
| 21 | - <%= labelled_form_field(_('Lead'), text_area_tag('task[article_abstract]', task.article_abstract, :style => 'width: 100%; height: 300px;')) %> | |
| 21 | + <%= labelled_form_field(_('Lead'), text_area_tag('task[article_abstract]', task.article_abstract, :style => 'width: 100%; height: 200px;')) %> | |
| 22 | 22 | </div> |
| 23 | 23 | <div style="margin-top: 10px;"> |
| 24 | - <%= labelled_form_field(_('Text'), text_area_tag('task[article_body]', task.article_body, :style => 'width:100%')) %> | |
| 24 | + <%= labelled_form_field(_('Text'), text_area_tag('task[article_body]', task.article_body, :style => 'width:100%; height: 500px;')) %> | |
| 25 | 25 | </div> |
| 26 | 26 | |
| 27 | 27 | <div> | ... | ... |
db/schema.rb
| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | # |
| 10 | 10 | # It's strongly recommended to check this file into your version control system. |
| 11 | 11 | |
| 12 | -ActiveRecord::Schema.define(:version => 20101205034144) do | |
| 12 | +ActiveRecord::Schema.define(:version => 20101209001631) do | |
| 13 | 13 | |
| 14 | 14 | create_table "action_tracker", :force => true do |t| |
| 15 | 15 | t.integer "user_id" |
| ... | ... | @@ -74,6 +74,7 @@ ActiveRecord::Schema.define(:version => 20101205034144) do |
| 74 | 74 | t.boolean "is_image", :default => false |
| 75 | 75 | t.integer "translation_of_id" |
| 76 | 76 | t.string "language" |
| 77 | + t.string "source_name" | |
| 77 | 78 | end |
| 78 | 79 | |
| 79 | 80 | create_table "articles", :force => true do |t| |
| ... | ... | @@ -113,6 +114,7 @@ ActiveRecord::Schema.define(:version => 20101205034144) do |
| 113 | 114 | t.boolean "is_image", :default => false |
| 114 | 115 | t.integer "translation_of_id" |
| 115 | 116 | t.string "language" |
| 117 | + t.string "source_name" | |
| 116 | 118 | end |
| 117 | 119 | |
| 118 | 120 | add_index "articles", ["translation_of_id"], :name => "index_articles_on_translation_of_id" | ... | ... |
public/stylesheets/application.css
| ... | ... | @@ -5237,17 +5237,3 @@ h1#agenda-title { |
| 5237 | 5237 | .forum-posts .pagination { |
| 5238 | 5238 | margin-top: 20px; |
| 5239 | 5239 | } |
| 5240 | - | |
| 5241 | -#captcha input { | |
| 5242 | - border: 1px solid #ccc; | |
| 5243 | - margin: 4px 0px 2px 10px !important; | |
| 5244 | - padding: 0px !important; | |
| 5245 | - width: 150px !important; | |
| 5246 | - font-size: 24px; | |
| 5247 | - float: left; | |
| 5248 | -} | |
| 5249 | - | |
| 5250 | -#captcha label{ | |
| 5251 | - float: left; | |
| 5252 | - font-size: 24px; | |
| 5253 | -} | ... | ... |
test/factories.rb
| ... | ... | @@ -427,4 +427,8 @@ module Noosfero::Factory |
| 427 | 427 | { :profile_id => 1, :path => name, :name => name, :slug => name.to_slug }.merge(params) |
| 428 | 428 | end |
| 429 | 429 | |
| 430 | + def defaults_for_suggest_article | |
| 431 | + { :name => 'Sender', :email => 'sender@example.com', :article_name => 'Some title', :article_body => 'some body text', :article_abstract => 'some abstract text'} | |
| 432 | + end | |
| 433 | + | |
| 430 | 434 | end | ... | ... |
test/functional/cms_controller_test.rb
| ... | ... | @@ -1438,8 +1438,6 @@ class CmsControllerTest < Test::Unit::TestCase |
| 1438 | 1438 | c = Community.create!(:name => 'test comm', :identifier => 'test_comm', :moderated_articles => true) |
| 1439 | 1439 | get :suggest_an_article, :profile => c.identifier |
| 1440 | 1440 | assert_response :success |
| 1441 | - assert_template 'suggest_an_article' | |
| 1442 | - assert_tag :tag => 'input', :attributes => { :value => "https://colivre.net/profile/test_comm", :id => 'back_to' } | |
| 1443 | 1441 | end |
| 1444 | 1442 | |
| 1445 | 1443 | end | ... | ... |
test/unit/suggest_article_test.rb
| ... | ... | @@ -86,4 +86,37 @@ class SuggestArticleTest < ActiveSupport::TestCase |
| 86 | 86 | assert_equal count + 1, TinyMceArticle.count |
| 87 | 87 | end |
| 88 | 88 | |
| 89 | + should 'fill source name and URL into created article' do | |
| 90 | + t = build(SuggestArticle, :target => @profile) | |
| 91 | + t.source_name = 'GNU project' | |
| 92 | + t.source = 'http://www.gnu.org/' | |
| 93 | + t.perform | |
| 94 | + | |
| 95 | + article = TinyMceArticle.last | |
| 96 | + assert_equal 'GNU project', article.source_name | |
| 97 | + assert_equal 'http://www.gnu.org/', article.source | |
| 98 | + end | |
| 99 | + | |
| 100 | + should 'use sender name in description' do | |
| 101 | + t = build(SuggestArticle, :target => @profile) | |
| 102 | + t.stubs(:sender).returns('XYZ') | |
| 103 | + assert_match(/XYZ/, t.description) | |
| 104 | + end | |
| 105 | + | |
| 106 | + should 'use name and e-mail as sender info' do | |
| 107 | + t = build(SuggestArticle, :target => @profile) | |
| 108 | + t.name = 'Some One' | |
| 109 | + t.email = 'someone@example.com' | |
| 110 | + assert_match(/.*Some One.*someone@example.com/, t.sender) | |
| 111 | + end | |
| 112 | + | |
| 113 | + should 'highlight created article' do | |
| 114 | + t = build(SuggestArticle, :target => @profile) | |
| 115 | + t.highlighted = true | |
| 116 | + t.perform | |
| 117 | + | |
| 118 | + article = TinyMceArticle.last(:conditions => { :name => t.article_name}) # just to be sure | |
| 119 | + assert article.highlighted | |
| 120 | + end | |
| 121 | + | |
| 89 | 122 | end | ... | ... |