Commit be1a989b25026313f2d59fb71c83542520b7c4b9
Exists in
master
and in
29 other branches
Merge branch 'stable' of https://gitlab.com/noosfero/noosfero into stable
Showing
8 changed files
with
36 additions
and
42 deletions
Show diff stats
app/helpers/comment_helper.rb
... | ... | @@ -2,7 +2,6 @@ module CommentHelper |
2 | 2 | |
3 | 3 | def article_title(article, args = {}) |
4 | 4 | title = article.title |
5 | - title = article.display_title if article.kind_of?(UploadedFile) && article.image? | |
6 | 5 | title = content_tag('h1', h(title), :class => 'title') |
7 | 6 | if article.belongs_to_blog? |
8 | 7 | unless args[:no_link] | ... | ... |
app/helpers/content_viewer_helper.rb
... | ... | @@ -14,8 +14,7 @@ module ContentViewerHelper |
14 | 14 | end |
15 | 15 | |
16 | 16 | def article_title(article, args = {}) |
17 | - title = article.display_title if article.kind_of?(UploadedFile) && article.image? | |
18 | - title = article.title if title.blank? | |
17 | + title = article.title | |
19 | 18 | title = content_tag('h1', h(title), :class => 'title') |
20 | 19 | if article.belongs_to_blog? || article.belongs_to_forum? |
21 | 20 | unless args[:no_link] | ... | ... |
app/models/uploaded_file.rb
... | ... | @@ -12,15 +12,12 @@ class UploadedFile < Article |
12 | 12 | |
13 | 13 | include ShortFilename |
14 | 14 | |
15 | - settings_items :title, :type => 'string' | |
16 | - xss_terminate :only => [ :title ] | |
17 | - | |
18 | - def title_with_default | |
19 | - title_without_default || short_filename(name, 60) | |
15 | + def title | |
16 | + if self.name.present? then self.name else self.filename end | |
17 | + end | |
18 | + def title= value | |
19 | + self.name = value | |
20 | 20 | end |
21 | - alias_method_chain :title, :default | |
22 | - | |
23 | - validates_size_of :title, :maximum => 60, :if => (lambda { |file| !file.title.blank? }) | |
24 | 21 | |
25 | 22 | sanitize_filename |
26 | 23 | |
... | ... | @@ -32,10 +29,6 @@ class UploadedFile < Article |
32 | 29 | self.image? ? self.full_filename(:display).gsub(File.join(RAILS_ROOT, 'public'), '') : nil |
33 | 30 | end |
34 | 31 | |
35 | - def display_title | |
36 | - title.blank? ? name : title | |
37 | - end | |
38 | - | |
39 | 32 | def first_paragraph |
40 | 33 | '' |
41 | 34 | end | ... | ... |
app/views/blocks/profile_image.rhtml
db/migrate/20140221142304_move_title_virtual_field_to_name_in_uploaded_file.rb
0 → 100644
... | ... | @@ -0,0 +1,12 @@ |
1 | +class MoveTitleVirtualFieldToNameInUploadedFile < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + UploadedFile.find_each do |uploaded_file| | |
4 | + uploaded_file.name = uploaded_file.setting.delete :title | |
5 | + uploaded_file.send :update_without_callbacks | |
6 | + end | |
7 | + end | |
8 | + | |
9 | + def self.down | |
10 | + say "this migration can't be reverted" | |
11 | + end | |
12 | +end | ... | ... |
plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb
1 | 1 | <h1> <%= _('Basket options') %> </h1> |
2 | 2 | |
3 | 3 | <% form_for(:settings, @settings, :url => {:action => 'edit'}, :html => {:method => 'post'}) do |f| %> |
4 | - <%= labelled_form_field(_('Enabled?'), f.check_box(:enabled)) %> | |
5 | - <%= labelled_form_field(_('Delivery?'), f.check_box(:delivery)) %> | |
4 | + <%= labelled_form_field(_('Enable shopping basket'), f.check_box(:enabled)) %> | |
5 | + <%= labelled_form_field(_('Enable delivery fields on orders'), f.check_box(:delivery)) %> | |
6 | 6 | <% display_delivery_settings = @settings.delivery ? 'auto' : 'none' %> |
7 | 7 | <fieldset id='delivery_settings' style="display: <%= display_delivery_settings %>"><legend><%=_('Delivery')%></legend> |
8 | 8 | <table> |
... | ... | @@ -33,8 +33,8 @@ |
33 | 33 | </tr> |
34 | 34 | </table> |
35 | 35 | |
36 | - <%= labelled_form_field(_('Free delivery price:'), f.text_field(:free_delivery_price)) %> | |
37 | - <%= content_tag('small', _('Empty stands for no free delivery price.')) %> | |
36 | + <%= labelled_form_field(_("Order's minimum price for free delivery:"), f.text_field(:free_delivery_price)) %> | |
37 | + <%= content_tag('small', _('Leave empty to always charge the delivery.')) %> | |
38 | 38 | </fieldset> |
39 | 39 | <br style='clear: both'/> |
40 | 40 | <br style='clear: both'/> | ... | ... |
po/pt/noosfero.po
... | ... | @@ -7218,8 +7218,8 @@ msgstr "Funcionalidade" |
7218 | 7218 | |
7219 | 7219 | #: app/views/features/index.rhtml:16 |
7220 | 7220 | #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb:4 |
7221 | -msgid "Enabled?" | |
7222 | -msgstr "Habilitada?" | |
7221 | +msgid "Enable shopping basket" | |
7222 | +msgstr "Habilitar cesto de compras" | |
7223 | 7223 | |
7224 | 7224 | #: app/views/features/index.rhtml:27 |
7225 | 7225 | msgid "Configure features" |
... | ... | @@ -12292,8 +12292,8 @@ msgid "Basket options" |
12292 | 12292 | msgstr "Opções do cesto" |
12293 | 12293 | |
12294 | 12294 | #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb:5 |
12295 | -msgid "Delivery?" | |
12296 | -msgstr "Entrega?" | |
12295 | +msgid "Enable delivery fields on orders" | |
12296 | +msgstr "Ativar campos de entrega para pedidos" | |
12297 | 12297 | |
12298 | 12298 | #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb:10 |
12299 | 12299 | msgid "Option" |
... | ... | @@ -12310,12 +12310,12 @@ msgid "ADD NEW OPTION" |
12310 | 12310 | msgstr "ADCIONAR NOVA OPÇÂO" |
12311 | 12311 | |
12312 | 12312 | #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb:36 |
12313 | -msgid "Free delivery price:" | |
12314 | -msgstr "Preço de entrega grátis:" | |
12313 | +msgid "Order's minimum price for free delivery:" | |
12314 | +msgstr "Preço mínimo do pedido para entrega grátis:" | |
12315 | 12315 | |
12316 | 12316 | #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb:37 |
12317 | -msgid "Empty stands for no free delivery price." | |
12318 | -msgstr "Vazio significa sem preço de frete grátis." | |
12317 | +msgid "Leave empty to always charge the delivery." | |
12318 | +msgstr "Deixe vazio para sempre cobrar a entrega." | |
12319 | 12319 | |
12320 | 12320 | #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/reports.html.erb:1 |
12321 | 12321 | msgid "Purchase Reports" | ... | ... |
test/unit/uploaded_file_test.rb
... | ... | @@ -119,24 +119,13 @@ class UploadedFileTest < ActiveSupport::TestCase |
119 | 119 | assert_equal 'my title', UploadedFile.new(:title => 'my title').title |
120 | 120 | end |
121 | 121 | |
122 | - should 'limit title to 140 characters' do | |
123 | - upload = UploadedFile.new | |
124 | - | |
125 | - upload.title = '+' * 61; upload.valid? | |
126 | - assert upload.errors[:title] | |
127 | - | |
128 | - upload.title = '+' * 60; upload.valid? | |
129 | - assert !upload.errors[:title] | |
130 | - | |
131 | - end | |
132 | - | |
133 | 122 | should 'always provide a display title' do |
134 | 123 | upload = UploadedFile.new(:uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) |
135 | - assert_equal 'test.txt', upload.display_title | |
124 | + assert_equal 'test.txt', upload.title | |
136 | 125 | upload.title = 'My text file' |
137 | - assert_equal 'My text file', upload.display_title | |
126 | + assert_equal 'My text file', upload.title | |
138 | 127 | upload.title = '' |
139 | - assert_equal 'test.txt', upload.display_title | |
128 | + assert_equal 'test.txt', upload.title | |
140 | 129 | end |
141 | 130 | |
142 | 131 | should 'use name as title by default' do | ... | ... |