Commit 9574e0fdcd8b7693fdf5ad4541b8976f4db96239
1 parent
3ddde8cf
Exists in
master
and in
29 other branches
ActionItem862: small enhancements and bugfixes
Showing
22 changed files
with
102 additions
and
54 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -22,7 +22,6 @@ class CmsController < MyProfileController | @@ -22,7 +22,6 @@ class CmsController < MyProfileController | ||
22 | articles = [ | 22 | articles = [ |
23 | TinyMceArticle, | 23 | TinyMceArticle, |
24 | TextileArticle, | 24 | TextileArticle, |
25 | - UploadedFile, | ||
26 | Event | 25 | Event |
27 | ] | 26 | ] |
28 | parent_id = params ? params[:parent_id] : nil | 27 | parent_id = params ? params[:parent_id] : nil |
@@ -39,7 +38,7 @@ class CmsController < MyProfileController | @@ -39,7 +38,7 @@ class CmsController < MyProfileController | ||
39 | end | 38 | end |
40 | 39 | ||
41 | def special_article_types | 40 | def special_article_types |
42 | - [Blog] | 41 | + [Blog, UploadedFile] |
43 | end | 42 | end |
44 | 43 | ||
45 | def view | 44 | def view |
@@ -195,7 +194,7 @@ class CmsController < MyProfileController | @@ -195,7 +194,7 @@ class CmsController < MyProfileController | ||
195 | 194 | ||
196 | def record_creating_from_public_view | 195 | def record_creating_from_public_view |
197 | referer = request.referer | 196 | referer = request.referer |
198 | - if (referer =~ Regexp.new("^#{(url_for(profile.url).sub('https:', 'https?:'))}")) | 197 | + if (referer =~ Regexp.new("^#{(url_for(profile.url).sub('https:', 'https?:'))}")) || params[:back_to] == 'public_view' |
199 | @back_to = 'public_view' | 198 | @back_to = 'public_view' |
200 | @back_url = referer | 199 | @back_url = referer |
201 | end | 200 | end |
app/controllers/public/search_controller.rb
@@ -116,7 +116,7 @@ class SearchController < PublicController | @@ -116,7 +116,7 @@ class SearchController < PublicController | ||
116 | def limit | 116 | def limit |
117 | searching = @searching.values.select{|v|v} | 117 | searching = @searching.values.select{|v|v} |
118 | if params[:display] == 'map' | 118 | if params[:display] == 'map' |
119 | - 100 | 119 | + 1200 |
120 | else | 120 | else |
121 | (searching.size == 1) ? 20 : 6 | 121 | (searching.size == 1) ? 20 : 6 |
122 | end | 122 | end |
app/helpers/application_helper.rb
@@ -432,7 +432,8 @@ module ApplicationHelper | @@ -432,7 +432,8 @@ module ApplicationHelper | ||
432 | profile.url, | 432 | profile.url, |
433 | :onclick => 'document.location.href = this.href', # work-arround for ie. | 433 | :onclick => 'document.location.href = this.href', # work-arround for ie. |
434 | :class => 'profile_link url', | 434 | :class => 'profile_link url', |
435 | - :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name ), | 435 | + :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name, |
436 | + :title => profile.name ), | ||
436 | :class => 'vcard' | 437 | :class => 'vcard' |
437 | end | 438 | end |
438 | 439 |
app/models/article.rb
@@ -4,9 +4,10 @@ class Article < ActiveRecord::Base | @@ -4,9 +4,10 @@ class Article < ActiveRecord::Base | ||
4 | before_save :sanitize_tag_list | 4 | before_save :sanitize_tag_list |
5 | 5 | ||
6 | belongs_to :profile | 6 | belongs_to :profile |
7 | - validates_presence_of :profile_id, :name, :slug, :path | 7 | + validates_presence_of :profile_id, :name |
8 | + validates_presence_of :slug, :path, :if => lambda { |article| !article.name.blank? } | ||
8 | 9 | ||
9 | - validates_uniqueness_of :slug, :scope => ['profile_id', 'parent_id'], :message => _('%{fn} (the code generated from the article name) is already being used by another article.') | 10 | + validates_uniqueness_of :slug, :scope => ['profile_id', 'parent_id'], :message => _('%{fn} (the code generated from the article name) is already being used by another article.'), :if => lambda { |article| !article.slug.blank? } |
10 | 11 | ||
11 | belongs_to :last_changed_by, :class_name => 'Person', :foreign_key => 'last_changed_by_id' | 12 | belongs_to :last_changed_by, :class_name => 'Person', :foreign_key => 'last_changed_by_id' |
12 | 13 | ||
@@ -15,6 +16,15 @@ class Article < ActiveRecord::Base | @@ -15,6 +16,15 @@ class Article < ActiveRecord::Base | ||
15 | has_many :article_categorizations, :conditions => [ 'articles_categories.virtual = ?', false ] | 16 | has_many :article_categorizations, :conditions => [ 'articles_categories.virtual = ?', false ] |
16 | has_many :categories, :through => :article_categorizations | 17 | has_many :categories, :through => :article_categorizations |
17 | 18 | ||
19 | + def self.human_attribute_name(attrib) | ||
20 | + case attrib.to_sym | ||
21 | + when :name | ||
22 | + _('Title') | ||
23 | + else | ||
24 | + _(self.superclass.human_attribute_name(attrib)) | ||
25 | + end | ||
26 | + end | ||
27 | + | ||
18 | def pending_categorizations | 28 | def pending_categorizations |
19 | @pending_categorizations ||= [] | 29 | @pending_categorizations ||= [] |
20 | end | 30 | end |
app/models/comment.rb
@@ -31,6 +31,10 @@ class Comment < ActiveRecord::Base | @@ -31,6 +31,10 @@ class Comment < ActiveRecord::Base | ||
31 | author ? author.email : email | 31 | author ? author.email : email |
32 | end | 32 | end |
33 | 33 | ||
34 | + def author_link | ||
35 | + author ? author.url : email | ||
36 | + end | ||
37 | + | ||
34 | def url | 38 | def url |
35 | article.url.merge(:anchor => anchor) | 39 | article.url.merge(:anchor => anchor) |
36 | end | 40 | end |
@@ -58,15 +62,18 @@ class Comment < ActiveRecord::Base | @@ -58,15 +62,18 @@ class Comment < ActiveRecord::Base | ||
58 | class Notifier < ActionMailer::Base | 62 | class Notifier < ActionMailer::Base |
59 | def mail(comment) | 63 | def mail(comment) |
60 | profile = comment.article.profile | 64 | profile = comment.article.profile |
61 | - recipients profile.email | 65 | + # FIXME hardcoded |
66 | + email = profile.person? ? profile.email : profile.contact_email | ||
67 | + return unless email | ||
68 | + recipients email | ||
69 | + | ||
62 | from "#{profile.environment.name} <#{profile.environment.contact_email}>" | 70 | from "#{profile.environment.name} <#{profile.environment.contact_email}>" |
63 | - subject _("%s - New comment in '%s'") % [profile.environment.name, comment.article.title] | ||
64 | - headers['Reply-To'] = comment.author_email | ||
65 | - body :name => comment.author_name, | ||
66 | - :email => comment.author_email, | ||
67 | - :title => comment.title, | ||
68 | - :body => comment.body, | ||
69 | - :article_url => comment.url, | 71 | + subject _("[%s] you got a new comment!") % [profile.environment.name, comment.article.title] |
72 | + body :recipient => profile.nickname || profile.name, | ||
73 | + :sender => comment.author_name, | ||
74 | + :sender_link => comment.author_link, | ||
75 | + :article_title => comment.article.name, | ||
76 | + :comment_url => comment.url, | ||
70 | :environment => profile.environment.name, | 77 | :environment => profile.environment.name, |
71 | :url => profile.environment.top_url | 78 | :url => profile.environment.top_url |
72 | end | 79 | end |
app/models/profile.rb
@@ -454,7 +454,7 @@ class Profile < ActiveRecord::Base | @@ -454,7 +454,7 @@ class Profile < ActiveRecord::Base | ||
454 | include ActionView::Helpers::TextHelper | 454 | include ActionView::Helpers::TextHelper |
455 | def short_name | 455 | def short_name |
456 | if self[:nickname].blank? | 456 | if self[:nickname].blank? |
457 | - truncate self.identifier, 15, '...' | 457 | + truncate self.name, 15, '...' |
458 | else | 458 | else |
459 | self[:nickname] | 459 | self[:nickname] |
460 | end | 460 | end |
app/views/account/_signup_form.rhtml
@@ -39,9 +39,9 @@ in this environment.') % [environment.name, __('communities'), __('enterprises') | @@ -39,9 +39,9 @@ in this environment.') % [environment.name, __('communities'), __('enterprises') | ||
39 | <%= icaptcha_field() %> | 39 | <%= icaptcha_field() %> |
40 | 40 | ||
41 | <% if @terms_of_use %> | 41 | <% if @terms_of_use %> |
42 | - <p> | 42 | + <div style='height: 200px; overflow: auto;'> |
43 | <%= @terms_of_use %> | 43 | <%= @terms_of_use %> |
44 | - </p> | 44 | + </div> |
45 | <p> | 45 | <p> |
46 | <%= check_box 'user', 'terms_accepted' %> | 46 | <%= check_box 'user', 'terms_accepted' %> |
47 | <%= _('I accept the terms of use') %> | 47 | <%= _('I accept the terms of use') %> |
app/views/account/accept_terms.rhtml
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | <div class=activation-box> | 13 | <div class=activation-box> |
14 | <h2><%= _('Enterprise activation') + ' - ' + (logged_in? ? _('part 2 of 2') : _(' part 2 of 3')) %></h2> | 14 | <h2><%= _('Enterprise activation') + ' - ' + (logged_in? ? _('part 2 of 2') : _(' part 2 of 3')) %></h2> |
15 | 15 | ||
16 | - <div id='terms-of-enterprise-use'><%= @terms_of_enterprise_use %></div> | 16 | + <div id='terms-of-enterprise-use' class='height: 200px; overflow: auto;'><%= @terms_of_enterprise_use %></div> |
17 | 17 | ||
18 | <% form_tag :action => 'activate_enterprise' do %> | 18 | <% form_tag :action => 'activate_enterprise' do %> |
19 | <%= hidden_field_tag :enterprise_code, params[:enterprise_code] %> | 19 | <%= hidden_field_tag :enterprise_code, params[:enterprise_code] %> |
app/views/blocks/profile_image.rhtml
@@ -10,4 +10,10 @@ | @@ -10,4 +10,10 @@ | ||
10 | </div> | 10 | </div> |
11 | </div> | 11 | </div> |
12 | 12 | ||
13 | +<% if !user.nil? and user.has_permission?('edit_profile', profile) %> | ||
14 | + <div style='text-align: center; font-size: 75%; clear: both'> | ||
15 | + <%= link_to _('Control panel'), :controller => 'profile_editor' %> | ||
16 | + </div> | ||
17 | +<% end %> | ||
18 | + | ||
13 | </div><!-- end class="vcard" --> | 19 | </div><!-- end class="vcard" --> |
app/views/blocks/profile_info_actions/person.rhtml
1 | <ul> | 1 | <ul> |
2 | <%if logged_in? && (user != profile) %> | 2 | <%if logged_in? && (user != profile) %> |
3 | - <%if user.friends.include?(profile) %> | ||
4 | - <li> <%= link_to content_tag('span', _('Send request')), {:profile => user.identifier, :controller => 'tasks', :action => 'new', :target_id => profile.id}, :class => 'button with-text icon-menu-mail' %> </li> | ||
5 | - <% elsif !user.already_request_friendship?(profile) %> | 3 | + <% if !user.already_request_friendship?(profile) %> |
6 | <li><%= link_to content_tag('span', __('Add friend')), { :profile => user.identifier, :controller => 'friends', :action => 'add', :id => profile.id }, :class => 'button with-text icon-add' %></li> | 4 | <li><%= link_to content_tag('span', __('Add friend')), { :profile => user.identifier, :controller => 'friends', :action => 'add', :id => profile.id }, :class => 'button with-text icon-add' %></li> |
7 | <% end %> | 5 | <% end %> |
8 | <% end %> | 6 | <% end %> |
app/views/cms/_textile_article.rhtml
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | 2 | ||
3 | <%# TODO add Textile help here %> | 3 | <%# TODO add Textile help here %> |
4 | 4 | ||
5 | -<%= required f.text_field('name', :size => '64') %> | 5 | +<%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64')) %> |
6 | 6 | ||
7 | -<%= f.text_area('body', :cols => 64) %> | 7 | +<%= labelled_form_field(_('Text'), text_area(:article, 'body', :cols => 64)) %> |
8 | 8 |
app/views/cms/_tiny_mce_article.rhtml
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | 2 | ||
3 | <%= render :file => 'shared/tiny_mce' %> | 3 | <%= render :file => 'shared/tiny_mce' %> |
4 | 4 | ||
5 | -<%= required f.text_field('name', :size => '64') %> | 5 | +<%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64')) %> |
6 | 6 | ||
7 | -<%= f.text_area('body', :cols => 40, :style => 'width:99%') %> | 7 | +<%= labelled_form_field(_('Text'), text_area(:article, 'body', :cols => 40, :style => 'width:99%')) %> |
8 | 8 |
app/views/comment/notifier/mail.rhtml
1 | -<%= _('Name: %s') % @name %> | ||
2 | -<%= _('e-Mail: %s') % @email %> | ||
3 | -<%= _('Title: %s') % @title %> | ||
4 | -<%= _('Comment:') %> | ||
5 | --- | 1 | +<%= _('Hi, %{recipient}!') % { :recipient => @recipient } %> |
6 | 2 | ||
7 | -<%= @body %> | 3 | +<%= word_wrap(_('%{sender} (%{sender_link}) created a new comment on your article "%{article_title}".') % { :sender => @sender, :sender_link => url_for(@sender_link), :article_title => @article_title }) %> |
8 | 4 | ||
9 | --- | ||
10 | -<%= url_for @article_url %> | 5 | +<%= _('Access the address below to view this comment:') %> |
6 | +<%= url_for @comment_url %> | ||
11 | 7 | ||
12 | -- | 8 | -- |
13 | <%= _('%s environment system') % @environment %> | 9 | <%= _('%s environment system') % @environment %> |
app/views/profile_editor/index.rhtml
1 | <div id="profile-editor-index"> | 1 | <div id="profile-editor-index"> |
2 | 2 | ||
3 | -<h1 class="block-title"><%= _("%s's profile: control panel") % profile.name %></h1> | 3 | + <h1 class="block-title"> |
4 | + <div class='control-panel-title'><%= profile.name %></div> | ||
5 | + <div class='control-panel-subtitle'><%= _('Control Panel') %></div> | ||
6 | + </h1> | ||
4 | 7 | ||
5 | <%= render :partial => 'pending_tasks' %> | 8 | <%= render :partial => 'pending_tasks' %> |
6 | 9 | ||
@@ -8,7 +11,7 @@ | @@ -8,7 +11,7 @@ | ||
8 | 11 | ||
9 | <% file_manager do %> | 12 | <% file_manager do %> |
10 | 13 | ||
11 | - <%= file_manager_button(_('Profile settings'), 'icons-app/edit-profile.png', :controller => 'profile_editor', :action => 'edit') %> | 14 | + <%= file_manager_button(_('Info and settings'), 'icons-app/edit-profile.png', :controller => 'profile_editor', :action => 'edit') %> |
12 | 15 | ||
13 | <%= file_manager_button(_('Mail settings'), 'icons-app/mail.png', :controller => 'mailconf') if profile.person? && MailConf.enabled? %> | 16 | <%= file_manager_button(_('Mail settings'), 'icons-app/mail.png', :controller => 'mailconf') if profile.person? && MailConf.enabled? %> |
14 | 17 |
app/views/tasks/index.rhtml
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | 14 | ||
15 | <% button_bar do %> | 15 | <% button_bar do %> |
16 | <%= button(:edit, _('View processed tasks'), :action => 'processed') %> | 16 | <%= button(:edit, _('View processed tasks'), :action => 'processed') %> |
17 | - <%= button(:edit, _('View my requests'), :action => 'list_requested') %> | ||
18 | - <%= button('menu-mail', _('Send request'), :action => 'new') %> | 17 | + <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> |
18 | + <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> | ||
19 | <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> | 19 | <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> |
20 | <% end %> | 20 | <% end %> |
public/stylesheets/controller_profile_editor.css
public/stylesheets/forms.css
@@ -76,10 +76,11 @@ | @@ -76,10 +76,11 @@ | ||
76 | 76 | ||
77 | /*** REQUIRED FIELDS ***/ | 77 | /*** REQUIRED FIELDS ***/ |
78 | 78 | ||
79 | -#content form .required-field label.formlabel { | 79 | +.required-field label { |
80 | font-weight: bold; | 80 | font-weight: bold; |
81 | + color: #c00; | ||
81 | } | 82 | } |
82 | 83 | ||
83 | -#content form .required-field label.formlabel:after { | 84 | +.required-field label:after { |
84 | content: ' (*)'; | 85 | content: ' (*)'; |
85 | } | 86 | } |
test/functional/cms_controller_test.rb
@@ -544,6 +544,12 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -544,6 +544,12 @@ class CmsControllerTest < Test::Unit::TestCase | ||
544 | assert_redirected_to @profile.articles.find_by_name('new-article-from-public-view').url | 544 | assert_redirected_to @profile.articles.find_by_name('new-article-from-public-view').url |
545 | end | 545 | end |
546 | 546 | ||
547 | + should 'keep the back_to hint in unsuccessfull saves' do | ||
548 | + post :new, :profile => 'testinguser', :type => 'TextileArticle', :back_to => 'public_view', :article => { } | ||
549 | + assert_response :success | ||
550 | + assert_tag :tag => "input", :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' } | ||
551 | + end | ||
552 | + | ||
547 | should 'create a private article child of private folder' do | 553 | should 'create a private article child of private folder' do |
548 | folder = Folder.new(:name => 'my intranet', :public_article => false); profile.articles << folder; folder.save! | 554 | folder = Folder.new(:name => 'my intranet', :public_article => false); profile.articles << folder; folder.save! |
549 | 555 |
test/unit/article_test.rb
@@ -19,17 +19,29 @@ class ArticleTest < Test::Unit::TestCase | @@ -19,17 +19,29 @@ class ArticleTest < Test::Unit::TestCase | ||
19 | assert !a.errors.invalid?(:profile_id) | 19 | assert !a.errors.invalid?(:profile_id) |
20 | end | 20 | end |
21 | 21 | ||
22 | - should 'require values for name, slug and path' do | 22 | + should 'require value for name' do |
23 | a = Article.new | 23 | a = Article.new |
24 | a.valid? | 24 | a.valid? |
25 | assert a.errors.invalid?(:name) | 25 | assert a.errors.invalid?(:name) |
26 | - assert a.errors.invalid?(:slug) | ||
27 | - assert a.errors.invalid?(:path) | ||
28 | 26 | ||
29 | a.name = 'my article' | 27 | a.name = 'my article' |
30 | a.valid? | 28 | a.valid? |
31 | assert !a.errors.invalid?(:name) | 29 | assert !a.errors.invalid?(:name) |
32 | - assert !a.errors.invalid?(:name) | 30 | + end |
31 | + | ||
32 | + should 'require value for slug and path if name is filled' do | ||
33 | + a = Article.new(:name => 'test article') | ||
34 | + a.slug = nil | ||
35 | + a.path = nil | ||
36 | + a.valid? | ||
37 | + assert a.errors.invalid?(:slug) | ||
38 | + assert a.errors.invalid?(:path) | ||
39 | + end | ||
40 | + | ||
41 | + should 'not require value for slug and path if name is blank' do | ||
42 | + a = Article.new | ||
43 | + a.valid? | ||
44 | + assert !a.errors.invalid?(:slug) | ||
33 | assert !a.errors.invalid?(:path) | 45 | assert !a.errors.invalid?(:path) |
34 | end | 46 | end |
35 | 47 |
test/unit/comment_notifier_test.rb
@@ -37,14 +37,6 @@ class CommentNotifierTest < Test::Unit::TestCase | @@ -37,14 +37,6 @@ class CommentNotifierTest < Test::Unit::TestCase | ||
37 | assert_match /user_comment_test/, sent.body | 37 | assert_match /user_comment_test/, sent.body |
38 | end | 38 | end |
39 | 39 | ||
40 | - should "add a Reply-To header set to the commenter e-mail" do | ||
41 | - p = create_user('user_comment_test', :email => 'my@email.com').person | ||
42 | - a = Article.create!(:name => 'Article test', :profile => p, :notify_comments => true) | ||
43 | - a.comments << Comment.new(:author => p, :title => 'test comment', :body => 'you suck!') | ||
44 | - sent = ActionMailer::Base.deliveries.first | ||
45 | - assert_equal ['my@email.com'], sent.reply_to | ||
46 | - end | ||
47 | - | ||
48 | should 'display unauthenticated author name and email in delivered mail' do | 40 | should 'display unauthenticated author name and email in delivered mail' do |
49 | p = create_user('user_comment_test').person | 41 | p = create_user('user_comment_test').person |
50 | a = Article.create!(:name => 'Article test', :profile => p, :notify_comments => true) | 42 | a = Article.create!(:name => 'Article test', :profile => p, :notify_comments => true) |
test/unit/comment_test.rb
@@ -87,6 +87,16 @@ class CommentTest < Test::Unit::TestCase | @@ -87,6 +87,16 @@ class CommentTest < Test::Unit::TestCase | ||
87 | assert_equal 'my@email.com', Comment.new(:email => 'my@email.com').author_email | 87 | assert_equal 'my@email.com', Comment.new(:email => 'my@email.com').author_email |
88 | end | 88 | end |
89 | 89 | ||
90 | + should 'provide author link for authenticated author' do | ||
91 | + author = Person.new | ||
92 | + author.expects(:url).returns('http://blabla.net/author') | ||
93 | + assert_equal 'http://blabla.net/author', Comment.new(:author => author).author_link | ||
94 | + end | ||
95 | + | ||
96 | + should 'provide author e-mail as author link for unauthenticated author' do | ||
97 | + assert_equal 'my@email.com', Comment.new(:email => 'my@email.com').author_link | ||
98 | + end | ||
99 | + | ||
90 | should 'provide url to comment' do | 100 | should 'provide url to comment' do |
91 | art = Article.new | 101 | art = Article.new |
92 | art.expects(:url).returns({ :controller => 'lala', :action => 'something' }) | 102 | art.expects(:url).returns({ :controller => 'lala', :action => 'something' }) |
test/unit/profile_test.rb
@@ -758,8 +758,8 @@ class ProfileTest < Test::Unit::TestCase | @@ -758,8 +758,8 @@ class ProfileTest < Test::Unit::TestCase | ||
758 | assert_equal 'code', p.nickname | 758 | assert_equal 'code', p.nickname |
759 | end | 759 | end |
760 | 760 | ||
761 | - should 'short_name return truncated identifier if nickname is blank' do | ||
762 | - p = Profile.new(:identifier => 'a123456789abcdefghij') | 761 | + should 'return truncated name in short_name if nickname is blank' do |
762 | + p = Profile.new(:name => 'a123456789abcdefghij') | ||
763 | assert_equal 'a123456789ab...', p.short_name | 763 | assert_equal 'a123456789ab...', p.short_name |
764 | end | 764 | end |
765 | 765 |