From 9574e0fdcd8b7693fdf5ad4541b8976f4db96239 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Thu, 18 Dec 2008 14:12:29 -0300 Subject: [PATCH] ActionItem862: small enhancements and bugfixes --- app/controllers/my_profile/cms_controller.rb | 5 ++--- app/controllers/public/search_controller.rb | 2 +- app/helpers/application_helper.rb | 3 ++- app/models/article.rb | 14 ++++++++++++-- app/models/comment.rb | 23 +++++++++++++++-------- app/models/profile.rb | 2 +- app/views/account/_signup_form.rhtml | 4 ++-- app/views/account/accept_terms.rhtml | 2 +- app/views/blocks/profile_image.rhtml | 6 ++++++ app/views/blocks/profile_info_actions/person.rhtml | 4 +--- app/views/cms/_textile_article.rhtml | 4 ++-- app/views/cms/_tiny_mce_article.rhtml | 4 ++-- app/views/comment/notifier/mail.rhtml | 12 ++++-------- app/views/profile_editor/index.rhtml | 7 +++++-- app/views/tasks/index.rhtml | 4 ++-- public/stylesheets/controller_profile_editor.css | 7 +++++++ public/stylesheets/forms.css | 5 +++-- test/functional/cms_controller_test.rb | 6 ++++++ test/unit/article_test.rb | 20 ++++++++++++++++---- test/unit/comment_notifier_test.rb | 8 -------- test/unit/comment_test.rb | 10 ++++++++++ test/unit/profile_test.rb | 4 ++-- 22 files changed, 102 insertions(+), 54 deletions(-) diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index c8d2d39..cdd7f82 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -22,7 +22,6 @@ class CmsController < MyProfileController articles = [ TinyMceArticle, TextileArticle, - UploadedFile, Event ] parent_id = params ? params[:parent_id] : nil @@ -39,7 +38,7 @@ class CmsController < MyProfileController end def special_article_types - [Blog] + [Blog, UploadedFile] end def view @@ -195,7 +194,7 @@ class CmsController < MyProfileController def record_creating_from_public_view referer = request.referer - if (referer =~ Regexp.new("^#{(url_for(profile.url).sub('https:', 'https?:'))}")) + if (referer =~ Regexp.new("^#{(url_for(profile.url).sub('https:', 'https?:'))}")) || params[:back_to] == 'public_view' @back_to = 'public_view' @back_url = referer end diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb index e8c376b..2ac6927 100644 --- a/app/controllers/public/search_controller.rb +++ b/app/controllers/public/search_controller.rb @@ -116,7 +116,7 @@ class SearchController < PublicController def limit searching = @searching.values.select{|v|v} if params[:display] == 'map' - 100 + 1200 else (searching.size == 1) ? 20 : 6 end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 52f8a01..6091096 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -432,7 +432,8 @@ module ApplicationHelper profile.url, :onclick => 'document.location.href = this.href', # work-arround for ie. :class => 'profile_link url', - :help => _('Click on this icon to go to the %s\'s home page') % profile.name ), + :help => _('Click on this icon to go to the %s\'s home page') % profile.name, + :title => profile.name ), :class => 'vcard' end diff --git a/app/models/article.rb b/app/models/article.rb index ab716f2..47a1731 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -4,9 +4,10 @@ class Article < ActiveRecord::Base before_save :sanitize_tag_list belongs_to :profile - validates_presence_of :profile_id, :name, :slug, :path + validates_presence_of :profile_id, :name + validates_presence_of :slug, :path, :if => lambda { |article| !article.name.blank? } - 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.') + 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? } belongs_to :last_changed_by, :class_name => 'Person', :foreign_key => 'last_changed_by_id' @@ -15,6 +16,15 @@ class Article < ActiveRecord::Base has_many :article_categorizations, :conditions => [ 'articles_categories.virtual = ?', false ] has_many :categories, :through => :article_categorizations + def self.human_attribute_name(attrib) + case attrib.to_sym + when :name + _('Title') + else + _(self.superclass.human_attribute_name(attrib)) + end + end + def pending_categorizations @pending_categorizations ||= [] end diff --git a/app/models/comment.rb b/app/models/comment.rb index 0a53176..b63927f 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -31,6 +31,10 @@ class Comment < ActiveRecord::Base author ? author.email : email end + def author_link + author ? author.url : email + end + def url article.url.merge(:anchor => anchor) end @@ -58,15 +62,18 @@ class Comment < ActiveRecord::Base class Notifier < ActionMailer::Base def mail(comment) profile = comment.article.profile - recipients profile.email + # FIXME hardcoded + email = profile.person? ? profile.email : profile.contact_email + return unless email + recipients email + from "#{profile.environment.name} <#{profile.environment.contact_email}>" - subject _("%s - New comment in '%s'") % [profile.environment.name, comment.article.title] - headers['Reply-To'] = comment.author_email - body :name => comment.author_name, - :email => comment.author_email, - :title => comment.title, - :body => comment.body, - :article_url => comment.url, + subject _("[%s] you got a new comment!") % [profile.environment.name, comment.article.title] + body :recipient => profile.nickname || profile.name, + :sender => comment.author_name, + :sender_link => comment.author_link, + :article_title => comment.article.name, + :comment_url => comment.url, :environment => profile.environment.name, :url => profile.environment.top_url end diff --git a/app/models/profile.rb b/app/models/profile.rb index 742cad0..e9ef9b3 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -454,7 +454,7 @@ class Profile < ActiveRecord::Base include ActionView::Helpers::TextHelper def short_name if self[:nickname].blank? - truncate self.identifier, 15, '...' + truncate self.name, 15, '...' else self[:nickname] end diff --git a/app/views/account/_signup_form.rhtml b/app/views/account/_signup_form.rhtml index c9b118e..9d7fae8 100644 --- a/app/views/account/_signup_form.rhtml +++ b/app/views/account/_signup_form.rhtml @@ -39,9 +39,9 @@ in this environment.') % [environment.name, __('communities'), __('enterprises') <%= icaptcha_field() %> <% if @terms_of_use %> -

+

<%= @terms_of_use %> -

+

<%= check_box 'user', 'terms_accepted' %> <%= _('I accept the terms of use') %> diff --git a/app/views/account/accept_terms.rhtml b/app/views/account/accept_terms.rhtml index 42278a2..c68e8be 100644 --- a/app/views/account/accept_terms.rhtml +++ b/app/views/account/accept_terms.rhtml @@ -13,7 +13,7 @@

<%= _('Enterprise activation') + ' - ' + (logged_in? ? _('part 2 of 2') : _(' part 2 of 3')) %>

-
<%= @terms_of_enterprise_use %>
+
<%= @terms_of_enterprise_use %>
<% form_tag :action => 'activate_enterprise' do %> <%= hidden_field_tag :enterprise_code, params[:enterprise_code] %> diff --git a/app/views/blocks/profile_image.rhtml b/app/views/blocks/profile_image.rhtml index 3374d05..7597051 100644 --- a/app/views/blocks/profile_image.rhtml +++ b/app/views/blocks/profile_image.rhtml @@ -10,4 +10,10 @@
+<% if !user.nil? and user.has_permission?('edit_profile', profile) %> +
+ <%= link_to _('Control panel'), :controller => 'profile_editor' %> +
+<% end %> + diff --git a/app/views/blocks/profile_info_actions/person.rhtml b/app/views/blocks/profile_info_actions/person.rhtml index 0fa80e1..d43cc65 100644 --- a/app/views/blocks/profile_info_actions/person.rhtml +++ b/app/views/blocks/profile_info_actions/person.rhtml @@ -1,8 +1,6 @@