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 | 22 | articles = [ |
23 | 23 | TinyMceArticle, |
24 | 24 | TextileArticle, |
25 | - UploadedFile, | |
26 | 25 | Event |
27 | 26 | ] |
28 | 27 | parent_id = params ? params[:parent_id] : nil |
... | ... | @@ -39,7 +38,7 @@ class CmsController < MyProfileController |
39 | 38 | end |
40 | 39 | |
41 | 40 | def special_article_types |
42 | - [Blog] | |
41 | + [Blog, UploadedFile] | |
43 | 42 | end |
44 | 43 | |
45 | 44 | def view |
... | ... | @@ -195,7 +194,7 @@ class CmsController < MyProfileController |
195 | 194 | |
196 | 195 | def record_creating_from_public_view |
197 | 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 | 198 | @back_to = 'public_view' |
200 | 199 | @back_url = referer |
201 | 200 | end | ... | ... |
app/controllers/public/search_controller.rb
app/helpers/application_helper.rb
... | ... | @@ -432,7 +432,8 @@ module ApplicationHelper |
432 | 432 | profile.url, |
433 | 433 | :onclick => 'document.location.href = this.href', # work-arround for ie. |
434 | 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 | 437 | :class => 'vcard' |
437 | 438 | end |
438 | 439 | ... | ... |
app/models/article.rb
... | ... | @@ -4,9 +4,10 @@ class Article < ActiveRecord::Base |
4 | 4 | before_save :sanitize_tag_list |
5 | 5 | |
6 | 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 | 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 | 16 | has_many :article_categorizations, :conditions => [ 'articles_categories.virtual = ?', false ] |
16 | 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 | 28 | def pending_categorizations |
19 | 29 | @pending_categorizations ||= [] |
20 | 30 | end | ... | ... |
app/models/comment.rb
... | ... | @@ -31,6 +31,10 @@ class Comment < ActiveRecord::Base |
31 | 31 | author ? author.email : email |
32 | 32 | end |
33 | 33 | |
34 | + def author_link | |
35 | + author ? author.url : email | |
36 | + end | |
37 | + | |
34 | 38 | def url |
35 | 39 | article.url.merge(:anchor => anchor) |
36 | 40 | end |
... | ... | @@ -58,15 +62,18 @@ class Comment < ActiveRecord::Base |
58 | 62 | class Notifier < ActionMailer::Base |
59 | 63 | def mail(comment) |
60 | 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 | 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 | 77 | :environment => profile.environment.name, |
71 | 78 | :url => profile.environment.top_url |
72 | 79 | end | ... | ... |
app/models/profile.rb
... | ... | @@ -454,7 +454,7 @@ class Profile < ActiveRecord::Base |
454 | 454 | include ActionView::Helpers::TextHelper |
455 | 455 | def short_name |
456 | 456 | if self[:nickname].blank? |
457 | - truncate self.identifier, 15, '...' | |
457 | + truncate self.name, 15, '...' | |
458 | 458 | else |
459 | 459 | self[:nickname] |
460 | 460 | end | ... | ... |
app/views/account/_signup_form.rhtml
... | ... | @@ -39,9 +39,9 @@ in this environment.') % [environment.name, __('communities'), __('enterprises') |
39 | 39 | <%= icaptcha_field() %> |
40 | 40 | |
41 | 41 | <% if @terms_of_use %> |
42 | - <p> | |
42 | + <div style='height: 200px; overflow: auto;'> | |
43 | 43 | <%= @terms_of_use %> |
44 | - </p> | |
44 | + </div> | |
45 | 45 | <p> |
46 | 46 | <%= check_box 'user', 'terms_accepted' %> |
47 | 47 | <%= _('I accept the terms of use') %> | ... | ... |
app/views/account/accept_terms.rhtml
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | <div class=activation-box> |
14 | 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 | 18 | <% form_tag :action => 'activate_enterprise' do %> |
19 | 19 | <%= hidden_field_tag :enterprise_code, params[:enterprise_code] %> | ... | ... |
app/views/blocks/profile_image.rhtml
... | ... | @@ -10,4 +10,10 @@ |
10 | 10 | </div> |
11 | 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 | 19 | </div><!-- end class="vcard" --> | ... | ... |
app/views/blocks/profile_info_actions/person.rhtml
1 | 1 | <ul> |
2 | 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 | 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 | 5 | <% end %> |
8 | 6 | <% end %> | ... | ... |
app/views/cms/_textile_article.rhtml
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | |
3 | 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 | 2 | |
3 | 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 | 9 | <%= _('%s environment system') % @environment %> | ... | ... |
app/views/profile_editor/index.rhtml
1 | 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 | 8 | <%= render :partial => 'pending_tasks' %> |
6 | 9 | |
... | ... | @@ -8,7 +11,7 @@ |
8 | 11 | |
9 | 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 | 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 | 14 | |
15 | 15 | <% button_bar do %> |
16 | 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 | 19 | <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> |
20 | 20 | <% end %> | ... | ... |
public/stylesheets/controller_profile_editor.css
public/stylesheets/forms.css
... | ... | @@ -76,10 +76,11 @@ |
76 | 76 | |
77 | 77 | /*** REQUIRED FIELDS ***/ |
78 | 78 | |
79 | -#content form .required-field label.formlabel { | |
79 | +.required-field label { | |
80 | 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 | 85 | content: ' (*)'; |
85 | 86 | } | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -544,6 +544,12 @@ class CmsControllerTest < Test::Unit::TestCase |
544 | 544 | assert_redirected_to @profile.articles.find_by_name('new-article-from-public-view').url |
545 | 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 | 553 | should 'create a private article child of private folder' do |
548 | 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 | 19 | assert !a.errors.invalid?(:profile_id) |
20 | 20 | end |
21 | 21 | |
22 | - should 'require values for name, slug and path' do | |
22 | + should 'require value for name' do | |
23 | 23 | a = Article.new |
24 | 24 | a.valid? |
25 | 25 | assert a.errors.invalid?(:name) |
26 | - assert a.errors.invalid?(:slug) | |
27 | - assert a.errors.invalid?(:path) | |
28 | 26 | |
29 | 27 | a.name = 'my article' |
30 | 28 | a.valid? |
31 | 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 | 45 | assert !a.errors.invalid?(:path) |
34 | 46 | end |
35 | 47 | ... | ... |
test/unit/comment_notifier_test.rb
... | ... | @@ -37,14 +37,6 @@ class CommentNotifierTest < Test::Unit::TestCase |
37 | 37 | assert_match /user_comment_test/, sent.body |
38 | 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 | 40 | should 'display unauthenticated author name and email in delivered mail' do |
49 | 41 | p = create_user('user_comment_test').person |
50 | 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 | 87 | assert_equal 'my@email.com', Comment.new(:email => 'my@email.com').author_email |
88 | 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 | 100 | should 'provide url to comment' do |
91 | 101 | art = Article.new |
92 | 102 | art.expects(:url).returns({ :controller => 'lala', :action => 'something' }) | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -758,8 +758,8 @@ class ProfileTest < Test::Unit::TestCase |
758 | 758 | assert_equal 'code', p.nickname |
759 | 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 | 763 | assert_equal 'a123456789ab...', p.short_name |
764 | 764 | end |
765 | 765 | ... | ... |