From e7464a3d47aa5a204943ccec669355fb4eede45b Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Mon, 17 Jan 2011 22:51:24 -0300 Subject: [PATCH] Multitask --- app/controllers/my_profile/tasks_controller.rb | 32 ++++++++++++++++++++++---------- app/helpers/application_helper.rb | 39 ++++++++++++++++++++++++++++++++++++++- app/models/add_friend.rb | 24 ++++++++++++++++++------ app/models/add_member.rb | 18 +++++++++++++++--- app/models/approve_article.rb | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- app/models/change_password.rb | 16 ++++++++++++---- app/models/community.rb | 4 ++++ app/models/create_community.rb | 33 +++++++++++++++++++++++++-------- app/models/create_enterprise.rb | 23 +++++++++++++++++++---- app/models/email_activation.rb | 16 ++++++++++++++-- app/models/enterprise_activation.rb | 16 ++++++++++++++++ app/models/invite_friend.rb | 16 ++++++++++++++-- app/models/invite_member.rb | 20 ++++++++++++++++++-- app/models/suggest_article.rb | 28 +++++++++++++++++++++++----- app/models/task.rb | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ app/models/task_mailer.rb | 6 +++--- app/models/ticket.rb | 2 +- app/views/pending_task_notifier/notification.rhtml | 2 +- app/views/profile_editor/_pending_tasks.rhtml | 4 +++- app/views/tasks/_add_friend.rhtml | 40 ---------------------------------------- app/views/tasks/_add_friend_accept_details.rhtml | 8 ++++++++ app/views/tasks/_add_member.rhtml | 38 -------------------------------------- app/views/tasks/_add_member_accept_details.rhtml | 8 ++++++++ app/views/tasks/_approve_article.rhtml | 43 ------------------------------------------- app/views/tasks/_approve_article_accept_details.rhtml | 14 ++++++++++++++ app/views/tasks/_create_community.rhtml | 47 ----------------------------------------------- app/views/tasks/_create_enterprise_reject_details.rhtml | 2 ++ app/views/tasks/_invite_friend.rhtml | 1 - app/views/tasks/_invite_friend_accept_details.rhtml | 1 + app/views/tasks/_invite_member.rhtml | 29 ----------------------------- app/views/tasks/_suggest_article.rhtml | 41 ----------------------------------------- app/views/tasks/_suggest_article_accept_details.rhtml | 18 ++++++++++++++++++ app/views/tasks/_task.rhtml | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- app/views/tasks/_task_reject_details.rhtml | 1 + app/views/tasks/_ticket.rhtml | 22 ---------------------- app/views/tasks/index.rhtml | 58 +++++++++++++++++++++++++++++++++++++++++++++++----------- app/views/tasks/list_requested.rhtml | 2 +- app/views/tasks/new.rhtml | 2 +- app/views/tasks/processed.rhtml | 2 +- features/approve_article.feature | 3 ++- features/create_community.feature | 15 +++------------ features/invitation.feature | 22 +++++++++++----------- features/publish_article.feature | 33 ++++++++++++++++++++++++++++++--- features/register_enterprise.feature | 23 ++++++++++++----------- features/step_definitions/create_community_steps.rb | 4 ++-- public/images/icons-app/article-minor.png | Bin 0 -> 3076 bytes public/images/icons-app/article-portrait.png | Bin 0 -> 2756 bytes public/images/icons-app/article-thumb.png | Bin 0 -> 4967 bytes public/images/icons-task/closed-arrow-hover.png | Bin 0 -> 216 bytes public/images/icons-task/closed-arrow.png | Bin 0 -> 204 bytes public/images/icons-task/opened-arrow-hover.png | Bin 0 -> 189 bytes public/images/icons-task/opened-arrow.png | Bin 0 -> 199 bytes public/img-source/article-icon.svg | 788 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/javascripts/tasks.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ public/stylesheets/application.css | 15 ++++++++++++++- public/stylesheets/tasks.css | 46 ++++++++++++++++++++++++++++++++++++++++++++++ test/functional/tasks_controller_test.rb | 92 +++++++++++++++++++++++++++++++++++++++++++------------------------------------------------- test/unit/add_friend_test.rb | 9 --------- test/unit/add_member_test.rb | 12 ------------ test/unit/application_helper_test.rb | 6 ++++++ test/unit/approve_article_test.rb | 2 +- test/unit/email_activation_test.rb | 9 +-------- test/unit/invite_friend_test.rb | 7 ------- test/unit/invite_member_test.rb | 13 ------------- test/unit/pending_task_notifier_test.rb | 4 ++-- test/unit/rss_feed_test.rb | 2 +- test/unit/suggest_article_test.rb | 6 ------ test/unit/task_mailer_test.rb | 16 ++++++++-------- test/unit/task_test.rb | 3 ++- 69 files changed, 1528 insertions(+), 513 deletions(-) delete mode 100644 app/views/tasks/_add_friend.rhtml create mode 100644 app/views/tasks/_add_friend_accept_details.rhtml delete mode 100644 app/views/tasks/_add_member.rhtml create mode 100644 app/views/tasks/_add_member_accept_details.rhtml delete mode 100644 app/views/tasks/_approve_article.rhtml create mode 100644 app/views/tasks/_approve_article_accept_details.rhtml delete mode 100644 app/views/tasks/_create_community.rhtml create mode 100644 app/views/tasks/_create_enterprise_reject_details.rhtml delete mode 100644 app/views/tasks/_invite_friend.rhtml create mode 120000 app/views/tasks/_invite_friend_accept_details.rhtml delete mode 100644 app/views/tasks/_invite_member.rhtml delete mode 100644 app/views/tasks/_suggest_article.rhtml create mode 100644 app/views/tasks/_suggest_article_accept_details.rhtml create mode 100644 app/views/tasks/_task_reject_details.rhtml delete mode 100644 app/views/tasks/_ticket.rhtml create mode 100644 public/images/icons-app/article-minor.png create mode 100644 public/images/icons-app/article-portrait.png create mode 100644 public/images/icons-app/article-thumb.png create mode 100644 public/images/icons-task/closed-arrow-hover.png create mode 100644 public/images/icons-task/closed-arrow.png create mode 100644 public/images/icons-task/opened-arrow-hover.png create mode 100644 public/images/icons-task/opened-arrow.png create mode 100644 public/img-source/article-icon.svg create mode 100644 public/javascripts/tasks.js create mode 100644 public/stylesheets/tasks.css diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index 353f213..8c5dc6a 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -4,26 +4,38 @@ class TasksController < MyProfileController def index @tasks = profile.all_pending_tasks.sort_by(&:created_at) + @failed = params ? params[:failed] : {} end def processed @tasks = profile.all_finished_tasks.sort_by(&:created_at) end - VALID_DECISIONS = [ 'finish', 'cancel' ] + VALID_DECISIONS = [ 'finish', 'cancel', 'skip' ] def close - decision = params[:decision] - if request.post? && VALID_DECISIONS.include?(decision) && params[:id] - task = profile.find_in_all_tasks(params[:id]) - task.update_attributes(params[:task]) - begin - task.send(decision) - rescue Exception => ex - session[:notice] = ex.clean_message + failed = {} + + params[:tasks].each do |id, value| + decision = value[:decision] + if request.post? && VALID_DECISIONS.include?(decision) && id && decision != 'skip' + task = profile.find_in_all_tasks(id) + task.update_attributes!(value[:task]) + begin + task.send(decision) + rescue Exception => ex + message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})" + failed[ex.clean_message] ? failed[ex.clean_message] << message : failed[ex.clean_message] = [message] + end end end - redirect_to :action => 'index' + + if failed.blank? + session[:notice] = _("All decisions were applied successfully.") + else + session[:notice] = _("Some tasks couldn't be applied.") + end + redirect_to params.merge!(:action => 'index', :failed => failed) end def new diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3b9b492..025f97b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -279,6 +279,19 @@ module ApplicationHelper end end + def partial_for_task_class(klass, action) + if klass.nil? + raise ArgumentError, 'No partial for object. Is there a partial for any class in the inheritance hierarchy?' + end + + name = "#{klass.name.underscore}_#{action.to_s}" + if File.exists?(File.join(RAILS_ROOT, 'app', 'views', params[:controller], "_#{name}.rhtml")) + name + else + partial_for_task_class(klass.superclass, action) + end + end + def user @controller.send(:user) end @@ -621,7 +634,16 @@ module ApplicationHelper end def select_folder(label, object, method, collection, html_options = {}, js_options = {}) - labelled_form_field(label, select(object, method, collection.map {|f| [ profile.identifier + '/' + f.full_name, f.id ] }, html_options.merge({:include_blank => "#{profile.identifier}"}), js_options)) + root = profile ? profile.identifier : _("root") + labelled_form_field(label, select(object, method, + collection.map {|f| [ root + '/' + f.full_name, f.id ]}, + {:include_blank => root}, html_options.merge(js_options))) + end + + def select_profile_folder(label, object, method, profile, html_options = {}, js_options = {}) + labelled_form_field(label, select(object, method, + profile.folders.map {|f| [ profile.identifier + '/' + f.full_name, f.id ]}, + {:include_blank => profile.identifier}, html_options.merge(js_options))) end def theme_option(opt = nil) @@ -1094,10 +1116,16 @@ module ApplicationHelper end def usermenu_logged_in + pending_tasks_count = '' + if user && user.all_pending_tasks.count > 0 + pending_tasks_count = link_to(user.all_pending_tasks.count.to_s, '/myprofile/{login}/tasks', :id => 'pending-tasks-count') + end + (_('Welcome, %s') % link_to('{login}', '/{login}', :id => "homepage-link", :title => _('Go to your homepage'))) + render_environment_features(:usermenu) + link_to('' + _('Administration') + '', { :controller => 'admin_panel', :action => 'index' }, :id => "controlpanel", :title => _("Configure the environment"), :class => 'admin-link', :style => 'display: none') + link_to('' + _('Control panel') + '', '/myprofile/{login}', :id => "controlpanel", :title => _("Configure your personal account and content")) + + pending_tasks_count + link_to('' + _('Logout') + '', { :controller => 'account', :action => 'logout'} , :id => "logout", :title => _("Leave the system")) end @@ -1164,4 +1192,13 @@ module ApplicationHelper content_tag(:div, _('Source: %s') % source_url, :id => 'article-source') unless source_url.nil? end + def task_information(task) + values = {} + values.merge!({:requestor => link_to(task.requestor.name, task.requestor.public_profile_url)}) if task.requestor + values.merge!({:subject => content_tag('span', task.subject, :class=>'task_target')}) if task.subject + values.merge!({:linked_subject => link_to(content_tag('span', task.linked_subject[:text], :class => 'task_target'), task.linked_subject[:url])}) if task.linked_subject + values.merge!(task.information[:variables]) if task.information[:variables] + task.information[:message] % values + end + end diff --git a/app/models/add_friend.rb b/app/models/add_friend.rb index c5718cf..25cef81 100644 --- a/app/models/add_friend.rb +++ b/app/models/add_friend.rb @@ -6,7 +6,7 @@ class AddFriend < Task validates_uniqueness_of :target_id, :scope => [ :requestor_id ] - validates_length_of :group_for_person, :group_for_friend, :maximum => 150, :allow_nil => true + validates_length_of :group_for_person, :group_for_friend, :maximum => 150, :allow_nil => true alias :person :requestor alias :person= :requestor= @@ -19,17 +19,29 @@ class AddFriend < Task requestor.add_friend(target, group_for_person) end - def description - _('%s wants to be your friend.') % requestor.name - end - def permission :manage_friends end def target_notification_message - description + "\n\n" + + _('%{requestor} wants to be your friend.') % {:requestor => requestor.name} + "\n\n" + _('You need to login to %{system} in order to accept %{requestor} as your friend.') % { :system => target.environment.name, :requestor => requestor.name } end + def title + _("New friend") + end + + def information + {:message => _('%{requestor} wants to be your friend.') } + end + + def accept_details + true + end + + def icon + {:type => :profile_image, :profile => requestor, :url => requestor.url} + end + end diff --git a/app/models/add_member.rb b/app/models/add_member.rb index 518817e..406d653 100644 --- a/app/models/add_member.rb +++ b/app/models/add_member.rb @@ -15,8 +15,20 @@ class AddMember < Task target.affiliate(requestor, self.roles.select{|r| !r.to_i.zero? }.map{|i| Role.find(i)}) end - def description - _('%s wants to be a member of "%s".') % [requestor.name, organization.name] + def title + _("New member") + end + + def information + {:message => _('%{requestor} wants to be a member of this community.')} + end + + def accept_details + true + end + + def icon + {:type => :profile_image, :profile => requestor, :url => requestor.url} end def permission @@ -24,7 +36,7 @@ class AddMember < Task end def target_notification_message - description + "\n\n" + + _('%{requestor} wants to be a member of this community.') % {:requestor => requestor.name} + "\n\n" + _('You will need login to %{system} in order to accept or reject %{requestor} as a member of %{organization}.') % { :system => target.environment.name, :requestor => requestor.name, :organization => organization.name } end diff --git a/app/models/approve_article.rb b/app/models/approve_article.rb index 1b70b75..fb9afaf 100644 --- a/app/models/approve_article.rb +++ b/app/models/approve_article.rb @@ -3,10 +3,6 @@ class ApproveArticle < Task validates_presence_of :requestor_id, :target_id - def description - _('%{author} wants to publish "%{article}" on %{community}') % { :author => requestor.name, :article => article_title, :community => target.name } - end - def article_title article ? article.title : _('(The original text was removed)') end @@ -24,7 +20,7 @@ class ApproveArticle < Task end def name - data[:name].blank? ? article.name : data[:name] + data[:name].blank? ? (article ? article.name : _("Article removed.")) : data[:name] end def name= value @@ -68,7 +64,7 @@ class ApproveArticle < Task end def abstract - data[:abstract].blank? ? article.abstract : data[:abstract] + data[:abstract].blank? ? (article ? article.abstract : '') : data[:abstract] end def body= value @@ -76,17 +72,63 @@ class ApproveArticle < Task end def body - data[:body].blank? ? article.body : data[:body] + data[:body].blank? ? (article ? article.body : "") : data[:body] end def perform article.copy!(:name => name, :abstract => abstract, :body => body, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted, :source => article.source) end + def title + _("New article") + end + + def icon + result = {:type => :defined_image, :src => '/images/icons-app/article-minor.png', :name => name} + result.merge({:url => article.url}) if article + return result + end + + def linked_subject + {:text => name, :url => article.url} if article + end + + def information + if article + {:message => _('%{requestor} wants to publish the article: %{linked_subject}.')} + else + {:message => _("The article was removed.")} + end + end + + def accept_details + true + end + + def default_decision + if article + 'skip' + else + 'reject' + end + end + + def accept_disabled? + article.blank? + end + def target_notification_message return nil if target.organization? && !target.moderated_articles? - description + "\n\n" + + _('%{requestor} wants to publish the article: %{article}.') % {:requestor => requestor.name, :article => article.name} + "\n\n" _('You need to login on %{system} in order to approve or reject this article.') % { :system => target.environment.name } end + def task_finished_message + if !closing_statment.blank? + _("Your request for publishing the article \"%{article}\" was approved. Here is the comment left by the admin who approved your article:\n\n%{comment} ") % {:article => name, :comment => closing_statment} + else + _('Your request for publishing the article "%{article}" was approved.') % {:article => name} + end + end + end diff --git a/app/models/change_password.rb b/app/models/change_password.rb index aa0a349..934eaf3 100644 --- a/app/models/change_password.rb +++ b/app/models/change_password.rb @@ -61,6 +61,18 @@ class ChangePassword < Task self[:data] = {} end + def title + _("Change password") + end + + def information + {:message => _('%{requestor} wants to change its password.')} + end + + def icon + {:type => :profile_image, :profile => requestor, :url => requestor.url} + end + def perform user = self.requestor.user user.force_change_password!(self.password, self.password_confirmation) @@ -87,10 +99,6 @@ class ChangePassword < Task end end - def description - _('Password change request') - end - def environment self.requestor.environment end diff --git a/app/models/community.rb b/app/models/community.rb index f18e2b7..5ca3a68 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -39,6 +39,10 @@ class Community < Organization end end + def display_name + self.name + end + def active_fields environment ? environment.active_community_fields : [] end diff --git a/app/models/create_community.rb b/app/models/create_community.rb index 69eee37..8f5c050 100644 --- a/app/models/create_community.rb +++ b/app/models/create_community.rb @@ -48,16 +48,34 @@ class CreateCommunity < Task community.add_admin(self.requestor) end - def description - _('%s wants to create community %s.') % [requestor.name, self.name] + def title + _("New community") end - def closing_statement - data[:closing_statement] + def icon + src = image ? image.public_filename(:minor) : '/images/icons-app/community-minor.png' + {:type => :defined_image, :src => src, :name => name} end - def closing_statement= value - data[:closing_statement] = value + def subject + name + end + + def information + if description.blank? + { :message => _('%{requestor} wants to create community %{subject} with no description.') } + else + { :message => _('%{requestor} wants to create community %{subject} with this description:

%{description}

'), + :variables => {:description => description} } + end + end + + def reject_details + true + end + + def display_name + self.name end # tells if this request was rejected @@ -71,7 +89,6 @@ class CreateCommunity < Task end def target_notification_message - description + "\n\n" + _("User \"%{user}\" just requested to create community %{community}. You have to approve or reject it through the \"Pending Validations\" section in your control panel.\n") % { :user => self.requestor.name, :community => self.name } end @@ -82,7 +99,7 @@ class CreateCommunity < Task end def task_cancelled_message - _("Your request for registering community %{community} at %{environment} was not approved by the environment administrator. The following explanation was given: \n\n%{explanation}") % { :community => self.name, :environment => self.environment, :explanation => self.closing_statement } + _("Your request for registering community %{community} at %{environment} was not approved by the environment administrator. The following explanation was given: \n\n%{explanation}") % { :community => self.name, :environment => self.environment, :explanation => self.reject_explanation } end def task_finished_message diff --git a/app/models/create_enterprise.rb b/app/models/create_enterprise.rb index 63d0b54..dc9f8f3 100644 --- a/app/models/create_enterprise.rb +++ b/app/models/create_enterprise.rb @@ -11,7 +11,7 @@ class CreateEnterprise < Task N_('Economic activity') N_('Management information') - DATA_FIELDS = Enterprise.fields + %w[name identifier region_id reject_explanation] + DATA_FIELDS = Enterprise.fields + %w[name identifier region_id] serialize :data, Hash attr_protected :data @@ -48,7 +48,6 @@ class CreateEnterprise < Task # check for explanation when rejecting validates_presence_of :reject_explanation, :if => (lambda { |record| record.status == Task::Status::CANCELLED } ) - xss_terminate :only => [ :acronym, :address, :contact_person, :contact_phone, :economic_activity, :legal_form, :management_information, :name ], :on => 'validation' def validate @@ -153,8 +152,24 @@ class CreateEnterprise < Task enterprise.add_admin(enterprise.user.person) end - def description - __('Enterprise registration: "%s"') % self.name + def title + _("Enterprise registration") + end + + def icon + {:type => :defined_image, :src => '/images/icons-app/enterprise-minor.png', :name => name} + end + + def subject + name + end + + def information + {:message => _('%{requestor} wants to create enterprise %{subject}.')} + end + + def reject_details + true end def task_created_message diff --git a/app/models/email_activation.rb b/app/models/email_activation.rb index 616834c..0526124 100644 --- a/app/models/email_activation.rb +++ b/app/models/email_activation.rb @@ -11,8 +11,20 @@ class EmailActivation < Task end end - def description - _("'%{user} wants to activate email '%{email}'") % { :user => person.name, :email => person.email_addresses.join(', ') } + def title + _("Email activation") + end + + def subject + person.email_addresses.join(', ') + end + + def information + {:message => _("%{requestor} wants to activate the following email: %{subject}.")} + end + + def icon + {:type => :profile_image, :profile => requestor, :url => requestor.url} end def perform diff --git a/app/models/enterprise_activation.rb b/app/models/enterprise_activation.rb index ff16568..99d3e6f 100644 --- a/app/models/enterprise_activation.rb +++ b/app/models/enterprise_activation.rb @@ -20,4 +20,20 @@ class EnterpriseActivation < Task self.enterprise.enable(requestor) end + def title + _("Enterprise activation") + end + + def linked_subject + {:text => target.name, :url => target.public_profile_url} + end + + def information + {:message => _('%{requestor} wants to activate enterprise %{linked_subject}.')} + end + + def icon + {:type => :profile_image, :profile => requestor, :url => requestor.url} + end + end diff --git a/app/models/invite_friend.rb b/app/models/invite_friend.rb index 9432b82..0e401ec 100644 --- a/app/models/invite_friend.rb +++ b/app/models/invite_friend.rb @@ -7,8 +7,20 @@ class InviteFriend < Invitation friend.add_friend(person, group_for_friend) end - def description - _('%s invited you to join %s') % [person.name, person.environment.name] + def title + _("New friend") + end + + def information + {:message => _('%{requestor} wants to be your friend.')} + end + + def accept_details + true + end + + def icon + {:type => :profile_image, :profile => requestor, :url => requestor.url} end def permission diff --git a/app/models/invite_member.rb b/app/models/invite_member.rb index 2063200..c3214ed 100644 --- a/app/models/invite_member.rb +++ b/app/models/invite_member.rb @@ -15,8 +15,24 @@ class InviteMember < Invitation community.add_member(friend) end - def description - _('%s invited you to join the community %s') % [person.name, community.name] + def title + _("Community invitation") + end + + def linked_subject + {:text => community.name, :url => community.public_profile_url} + end + + def information + {:message => _('%{requestor} invited you to join %{linked_subject}.')} + end + + def url + community.url + end + + def icon + {:type => :profile_image, :profile => community, :url => community.url} end def expanded_message diff --git a/app/models/suggest_article.rb b/app/models/suggest_article.rb index afe362b..35cb2dd 100644 --- a/app/models/suggest_article.rb +++ b/app/models/suggest_article.rb @@ -7,10 +7,6 @@ class SuggestArticle < Task validates_presence_of :target_id, :article_name, :email, :name, :article_body - def description - _('%{sender} suggested to publish "%{article}" on %{community}') % { :sender => sender, :article => article_name, :community => target.name } - end - settings_items :email, :type => String settings_items :name, :type => String settings_items :article_name, :type => String @@ -39,8 +35,30 @@ class SuggestArticle < Task ) end + def title + _("Article suggestion") + end + + def subject + article_name + end + + def information + { :message => _('%{sender} suggested the publication of the article: %{subject}.'), + :variables => {:sender => sender} } + end + + def accept_details + true + end + + def icon + result = {:type => :defined_image, :src => '/images/icons-app/article-minor.png', :name => article_name} + end + def target_notification_message - description + "\n\n" + + _('%{sender} suggested the publication of the article: %{article}.') % + {:sender => sender, :article => article_name} + "\n\n" + _('You need to login on %{system} in order to approve or reject this article.') % { :system => target.environment.name } end diff --git a/app/models/task.rb b/app/models/task.rb index 4a8c65e..a6fd5f0 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -11,6 +11,8 @@ # will need to declare itself). class Task < ActiveRecord::Base + acts_as_having_settings :field => :data + module Status # the status of tasks just created ACTIVE = 1 @@ -86,6 +88,14 @@ class Task < ActiveRecord::Base def after_finish end + def reject_explanation=(reject_explanation='') + self.data[:reject_explanation] = reject_explanation + end + + def reject_explanation + self.data[:reject_explanation] + end + # this method cancels the task. At the end a message (as returned by # #cancel_message) is sent to the requestor with #notify_requestor. def cancel @@ -101,13 +111,50 @@ class Task < ActiveRecord::Base end end + # Here are the tasks customizable options. - # Returns the description of the task. - # - # This method +must+ be overriden in subclasses to return something - # meaningful for each kind of task - def description - _('Generic task') + def title + _("Task") + end + + def subject + nil + end + + def linked_subject + nil + end + + def information + {:message => _('%{requestor} sent you a task.')} + end + + def accept_details + false + end + + def reject_details + false + end + + def icon + {:type => :defined_image, :src => "/images/icons-app/user-minor.png", :name => requestor.name, :url => requestor.url} + end + + def default_decision + 'skip' + end + + def accept_disabled? + false + end + + def reject_disabled? + false + end + + def skip_disabled? + false end # The message that will be sent to the requestor of the task when the task is diff --git a/app/models/task_mailer.rb b/app/models/task_mailer.rb index 1dcd5b7..0af6991 100644 --- a/app/models/task_mailer.rb +++ b/app/models/task_mailer.rb @@ -17,7 +17,7 @@ class TaskMailer < ActionMailer::Base url_for_tasks_list = task.target.kind_of?(Environment) ? '' : url_for(task.target.url.merge(:controller => 'tasks', :action => 'index')) from self.class.generate_from(task) - subject '[%s] %s' % [task.environment.name, task.description] + subject '[%s] %s' % [task.environment.name, task.information] body :target => task.target.name, :message => msg, :environment => task.environment.name, @@ -32,7 +32,7 @@ class TaskMailer < ActionMailer::Base recipients task.friend_email from self.class.generate_from(task) - subject '[%s] %s' % [ task.requestor.environment.name, task.description ] + subject '[%s] %s' % [ task.requestor.environment.name, task.information ] body :message => msg end @@ -52,7 +52,7 @@ class TaskMailer < ActionMailer::Base recipients task.requestor.notification_emails from self.class.generate_from(task) - subject '[%s] %s' % [task.requestor.environment.name, task.description] + subject '[%s] %s' % [task.requestor.environment.name, task.information] body :requestor => task.requestor.name, :message => text, :environment => task.requestor.environment.name, diff --git a/app/models/ticket.rb b/app/models/ticket.rb index ffc22a9..7e690b1 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -1,4 +1,4 @@ class Ticket < Task acts_as_having_settings :field => :data - settings_items :title, :description, :closing_statment + settings_items :title, :message end diff --git a/app/views/pending_task_notifier/notification.rhtml b/app/views/pending_task_notifier/notification.rhtml index c649b4a..852e985 100644 --- a/app/views/pending_task_notifier/notification.rhtml +++ b/app/views/pending_task_notifier/notification.rhtml @@ -11,7 +11,7 @@ <% pending_tasks = @person.pending_tasks_for_organization(organization) %> <%= _("%s has %d pending task(s).") % [organization.name, pending_tasks.size] %> -<%= pending_tasks.map{|i| " * #{i.description}"}.join("\n") %> +<%= pending_tasks.map{|i| " * #{i.information}"}.join("\n") %> <%= _("Click in address below to process task(s):") %> diff --git a/app/views/profile_editor/_pending_tasks.rhtml b/app/views/profile_editor/_pending_tasks.rhtml index 9ec05fd..9a13ee0 100644 --- a/app/views/profile_editor/_pending_tasks.rhtml +++ b/app/views/profile_editor/_pending_tasks.rhtml @@ -1,8 +1,10 @@ +<%= stylesheet_link_tag 'tasks' %> + <% unless @pending_tasks.empty? %>

<%= _('You have pending requests') %>

    - <%= @pending_tasks.map {|item| content_tag('li', item.description)} %> + <%= @pending_tasks.map {|task| content_tag('li', task_information(task))} %>
<%= button(:todo, _('Process requests'), :controller => 'tasks', :action => 'index') %>
diff --git a/app/views/tasks/_add_friend.rhtml b/app/views/tasks/_add_friend.rhtml deleted file mode 100644 index 496b802..0000000 --- a/app/views/tasks/_add_friend.rhtml +++ /dev/null @@ -1,40 +0,0 @@ -

<%= _('New friend') %>

- -<%= link_to( profile_image(task.requestor, :minor, :border => 0), task.requestor.public_profile_url ) %> - -<%= _('%s wants to be your friend.') % - content_tag('strong', link_to( task.requestor.name, task.requestor.public_profile_url ) ) %> - -<% form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %> - -
- - <%= radio_button_tag(:decision, 'finish', true, - :id => "decision-finish-#{task.id}", - :onclick => "Element.show('group-for-friend-#{task.id}')") %> - - -     - - <%= radio_button_tag(:decision, 'cancel', false, - :id => "decision-cancel-#{task.id}", - :onclick => "Element.hide('group-for-friend-#{task.id}')") %> - - - <% content_tag('div', :id => "group-for-friend-#{task.id}", :class => "add-friend-tags") do %> - <%= _('Classify your new friend:') %> - <%= text_field_with_local_autocomplete("task[group_for_friend]", - profile.suggested_friend_groups, - {:id => "field-group-for-friend-#{task.id}", :maxlength => 150}) %> - -

- <%= _('Suggestions: %s') % profile.suggested_friend_groups.join(', ') %> -

- <% end %> - -
- - <% button_bar do %> - <%= submit_button(:ok, _('Ok!')) %> - <% end %> -<% end %> diff --git a/app/views/tasks/_add_friend_accept_details.rhtml b/app/views/tasks/_add_friend_accept_details.rhtml new file mode 100644 index 0000000..68745c7 --- /dev/null +++ b/app/views/tasks/_add_friend_accept_details.rhtml @@ -0,0 +1,8 @@ +<%=_('Classify your new friend:') + +text_field_with_local_autocomplete("tasks[#{task.id}][task][group_for_friend]", + task.target.suggested_friend_groups, + {:id => "field-group-for-friend-#{task.id}", :maxlength => 150}) +%> +

+ <%=_('Suggestions: %s') % task.target.suggested_friend_groups.join(', ') %> +

diff --git a/app/views/tasks/_add_member.rhtml b/app/views/tasks/_add_member.rhtml deleted file mode 100644 index a3d8452..0000000 --- a/app/views/tasks/_add_member.rhtml +++ /dev/null @@ -1,38 +0,0 @@ -

<%= _('New member') %>

- -<%= link_to( profile_image(task.requestor, :minor, :border => 0), task.requestor.public_profile_url ) %> - -<%= _('%s wants to be a member of %s.') % - [content_tag('strong', link_to( task.requestor.name, task.requestor.public_profile_url ) ), - content_tag('strong', link_to( task.target.name, task.target.public_profile_url ) )] %> - -<% form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %> - -
- <%= radio_button_tag(:decision, 'finish', true, - :id => "decision-finish-#{task.id}", - :onclick => "Element.show('group-for-friend-#{task.id}')") %> - - -     - - <%= radio_button_tag(:decision, 'cancel', false, - :id => "decision-cancel-#{task.id}", - :onclick => "Element.hide('group-for-friend-#{task.id}')") %> - - -

- <%= _('Roles:') %>
- <% - @roles = task.target.environment.roles.find(:all).select{ |r| r.has_kind?('Profile') } - %> - <% @roles.each do |r| %> - <%= labelled_check_box(r.name, 'task[roles][]', r.id, ( task.target.members.empty? ? true : ( r.id == Profile::Roles.member(r.environment.id).id ) ) ) %>
- <% end %> -

-
- - <% button_bar do %> - <%= submit_button(:ok, _('Ok!')) %> - <% end %> -<% end %> diff --git a/app/views/tasks/_add_member_accept_details.rhtml b/app/views/tasks/_add_member_accept_details.rhtml new file mode 100644 index 0000000..8f586a3 --- /dev/null +++ b/app/views/tasks/_add_member_accept_details.rhtml @@ -0,0 +1,8 @@ +<%= content = _("Roles:")+"
" +roles = Profile::Roles.organization_member_roles(task.target.environment.id) +roles.each do |role| + content += labelled_check_box(role.name, "tasks[#{task.id}][roles][]", role.id, false)+"
" +end +content_tag('p', content, :class => 'member-classify-suggestion') +%> + diff --git a/app/views/tasks/_approve_article.rhtml b/app/views/tasks/_approve_article.rhtml deleted file mode 100644 index f7d3730..0000000 --- a/app/views/tasks/_approve_article.rhtml +++ /dev/null @@ -1,43 +0,0 @@ -

<%= _('New article') %>

- -<% form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %> - - <% if task.article.nil? %> - <%= _('%s wanted to publish some content, but this content was deleted and cannot be published anymore.') % content_tag('strong', link_to( task.requestor.name, task.requestor.public_profile_url ) ) %> - <%= hidden_field_tag(:decision, 'cancel') %> - <% else %> - <%= _('%s wants to publish content: %s.') % - [content_tag('strong', link_to( task.requestor.name, task.requestor.public_profile_url ) ), - content_tag('strong', link_to( task.article.name, task.article.url ) )] %> - -
- <%= radio_button_tag(:decision, 'finish', true, - :id => "decision-finish-#{task.id}", - :onclick => "Element.show('group-for-friend-#{task.id}')") %> - - -     - - <%= radio_button_tag(:decision, 'cancel', false, - :id => "decision-cancel-#{task.id}", - :onclick => "Element.hide('group-for-friend-#{task.id}')") %> - - - <%= labelled_form_field _('Name for publishing'), f.text_field(:name, :style => 'width:80%;') %> - - <%= select_folder(_('Select the folder where the article must be published'), 'task', 'article_parent_id', task.target.folders) %> -
- <%= f.check_box(:highlighted) %> - -
- - <%= labelled_form_field _('Comment for author'), f.text_field(:closing_statment, :style => 'width:80%;') %> - <%= render :partial => partial_for_class(task.article.class), :locals => { :f => f } %> - -
- <% end %> - - <% button_bar do %> - <%= submit_button(:ok, _('Ok!')) %> - <% end %> -<% end %> diff --git a/app/views/tasks/_approve_article_accept_details.rhtml b/app/views/tasks/_approve_article_accept_details.rhtml new file mode 100644 index 0000000..d6e5db6 --- /dev/null +++ b/app/views/tasks/_approve_article_accept_details.rhtml @@ -0,0 +1,14 @@ +<%= labelled_form_field(_('Name for publishing'), f.text_field(:name)) %> +<%= select_profile_folder(_('Select the folder where the article must be published'), "tasks[#{task.id}][task]", 'article_parent_id', task.target) %> +<%= labelled_form_field(_('Highlight this article'), f.check_box(:highlighted)) %> + +
+ <%= labelled_form_field(_('Lead'), f.text_area(:abstract, :style => 'width: 482px; height: 200px;')) %> +
+<%= _('Used when a short version your text is needed.') %> + +
+ <%= labelled_form_field(_('Text'), f.text_area(:body, :style => 'width:482px; height: 500px;')) %> +
+<%= labelled_form_field _('Comment for author'), f.text_field(:closing_statment, :style => 'width: 488px;') %> + diff --git a/app/views/tasks/_create_community.rhtml b/app/views/tasks/_create_community.rhtml deleted file mode 100644 index 494723a..0000000 --- a/app/views/tasks/_create_community.rhtml +++ /dev/null @@ -1,47 +0,0 @@ -

<%= _('New community') %>

- -<%= link_to( profile_image(task.requestor, :minor, :border => 0), task.requestor.public_profile_url ) %> - -<%= _('%s wants to create community %s.') % - [content_tag('strong', link_to( task.requestor.name, task.requestor.public_profile_url ) ), - content_tag('strong', task.name )] %> - -<% form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %> - -
- <% if !Profile.is_available?(task.name.to_slug, environment) %> -

<%= _('This name was already taken, this community cannot be approved') %>

- <%= hidden_field_tag(:decision, 'cancel') %> - <% else %> - <%= radio_button_tag(:decision, 'finish', true, - :id => "decision-finish-#{task.id}", - :onclick => "hide_closing_statement_area(#{task.id})") %> - - -     - - <%= radio_button_tag(:decision, 'cancel', false, - :id => "decision-cancel-#{task.id}", - :onclick => "show_closing_statement_area(#{task.id})") %> - - <% end %> - - - - - -
- - <% button_bar do %> - <%= submit_button(:ok, _('Ok!')) %> - <% end %> -<% end %> diff --git a/app/views/tasks/_create_enterprise_reject_details.rhtml b/app/views/tasks/_create_enterprise_reject_details.rhtml new file mode 100644 index 0000000..3dde979 --- /dev/null +++ b/app/views/tasks/_create_enterprise_reject_details.rhtml @@ -0,0 +1,2 @@ +<%= required labelled_form_field(_('Rejection explanation'), f.text_area(:reject_explanation, :rows => 5)) %> + diff --git a/app/views/tasks/_invite_friend.rhtml b/app/views/tasks/_invite_friend.rhtml deleted file mode 100644 index 10b812f..0000000 --- a/app/views/tasks/_invite_friend.rhtml +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => 'add_friend', :locals => {:task => task} %> diff --git a/app/views/tasks/_invite_friend_accept_details.rhtml b/app/views/tasks/_invite_friend_accept_details.rhtml new file mode 120000 index 0000000..b688e0c --- /dev/null +++ b/app/views/tasks/_invite_friend_accept_details.rhtml @@ -0,0 +1 @@ +_add_friend_accept_details.rhtml \ No newline at end of file diff --git a/app/views/tasks/_invite_member.rhtml b/app/views/tasks/_invite_member.rhtml deleted file mode 100644 index 9bdecf6..0000000 --- a/app/views/tasks/_invite_member.rhtml +++ /dev/null @@ -1,29 +0,0 @@ -

<%= _('Join community') %>

- -<%= link_to( profile_image(task.requestor, :minor, :border => 0), task.requestor.public_profile_url ) %> - -<%= _('%s invited you to join the community %s') % - [content_tag('strong', link_to( task.requestor.name, task.requestor.public_profile_url ) ), - content_tag('strong', link_to( task.community.name, task.community.public_profile_url ) )] %> - -<% form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %> - -
- <%= radio_button_tag(:decision, 'finish', true, - :id => "decision-finish-#{task.id}", - :onclick => "Element.show('group-for-friend-#{task.id}')") %> - - -     - - <%= radio_button_tag(:decision, 'cancel', false, - :id => "decision-cancel-#{task.id}", - :onclick => "Element.hide('group-for-friend-#{task.id}')") %> - - -
- - <% button_bar do %> - <%= submit_button(:ok, _('Ok!')) %> - <% end %> -<% end %> diff --git a/app/views/tasks/_suggest_article.rhtml b/app/views/tasks/_suggest_article.rhtml deleted file mode 100644 index 8e32ef5..0000000 --- a/app/views/tasks/_suggest_article.rhtml +++ /dev/null @@ -1,41 +0,0 @@ -

<%= _('Processing task: %s') % task.description %>

- -<%= render :file => 'shared/tiny_mce' %> - -<% form_for('task', task, :url => { :action => 'close', :id => task.id}) do |f| %> - - - <%= labelled_form_field(_("Sent by: "), f.text_field(:name)) %> -

<%= label_tag(_("Email: %s") % task.email) %>

- <%= required labelled_form_field(_('Title'), f.text_field(:article_name, :size => 50)) %> - <%= labelled_form_field(_('Source'), f.text_field(:source_name)) %> - <%= labelled_form_field(_("Source URL"), f.text_field(:source)) %> - - <%= select_folder(_('Select the folder where the article must be published'), 'task', 'article_parent_id', task.target.folders) %> - -
- <%= button :add, _("Lead"), '#', :id => "lead-button", :style => "margin-left: 0px;" %> - <%= _('Used when a short version your text is needed.') %> - -
- <%= labelled_form_field(_('Lead'), text_area_tag('task[article_abstract]', task.article_abstract, :style => 'width: 100%; height: 200px;')) %> -
-
- <%= labelled_form_field(_('Text'), text_area_tag('task[article_body]', task.article_body, :style => 'width:100%; height: 500px;')) %> -
- -
- <%= labelled_radio_button _('OK'), :decision, 'finish', true, :onclick => "if(this.checked) $('rejection-field-#{task.id}').style.display='none'" %> -
-
- <%= labelled_radio_button _('Cancel'), :decision, 'cancel', false, :onclick => "if(this.checked) $('rejection-field-#{task.id}').style.display='block'" %> -
- - <% button_bar do %> - <%= submit_button(:ok, _('OK')) %> - <% end %> - -<% end %> - -<%= javascript_include_tag 'article' %> - diff --git a/app/views/tasks/_suggest_article_accept_details.rhtml b/app/views/tasks/_suggest_article_accept_details.rhtml new file mode 100644 index 0000000..ba8c5e8 --- /dev/null +++ b/app/views/tasks/_suggest_article_accept_details.rhtml @@ -0,0 +1,18 @@ +<%= render :file => 'shared/tiny_mce' %> + +<%= labelled_form_field(_("Sent by: "), f.text_field(:name)) %> +

<%= label_tag(_("Email: %s") % task.email) %>

+<%= required labelled_form_field(_('Title'), f.text_field(:article_name, :size => 50)) %> +<%= labelled_form_field(_('Source'), f.text_field(:source_name)) %> +<%= labelled_form_field(_("Source URL"), f.text_field(:source)) %> + +<%= select_profile_folder(_('Select the folder where the article must be published'), "tasks[#{task.id}][task]", 'article_parent_id', task.target) %> + +
+ <%= labelled_form_field(_('Lead'), f.text_area(:article_abstract, :style => 'width: 482px; height: 200px;')) %> +
+<%= _('Used when a short version your text is needed.') %> + +
+ <%= labelled_form_field(_('Text'), f.text_area(:article_body, :style => 'width:482px; height: 500px;')) %> +
diff --git a/app/views/tasks/_task.rhtml b/app/views/tasks/_task.rhtml index 2884011..93ca7ac 100644 --- a/app/views/tasks/_task.rhtml +++ b/app/views/tasks/_task.rhtml @@ -1,21 +1,64 @@ -<%# a generic task solver %> -

<%= _('Processing task: %s') % task.description %>

+
-<% form_for('task', task, :url => { :action => 'close', :id => task.id}) do |f| %> +
+ <% + icon_info = task.icon + if icon_info[:type] == :profile_image + icon = profile_image(icon_info[:profile], :minor) + elsif icon_info[:type] == :defined_image + icon = "#{icon_info[:name]}" + end + %> + <%= + if icon_info[:url] + link_to(icon, icon_info[:url]) + else + icon + end + %> -
- <%= labelled_radio_button _('OK'), :decision, 'finish', true, :onclick => "if(this.checked) $('rejection-field-#{task.id}').style.display='none'" %> -
-
- <%= labelled_radio_button _('Cancel'), :decision, 'cancel', false, :onclick => "if(this.checked) $('rejection-field-#{task.id}').style.display='block'" %>
- diff --git a/app/views/tasks/_task_reject_details.rhtml b/app/views/tasks/_task_reject_details.rhtml new file mode 100644 index 0000000..13bc80c --- /dev/null +++ b/app/views/tasks/_task_reject_details.rhtml @@ -0,0 +1 @@ +<%= labelled_form_field(_('Rejection explanation'), f.text_area(:reject_explanation, :rows => 5)) %> diff --git a/app/views/tasks/_ticket.rhtml b/app/views/tasks/_ticket.rhtml deleted file mode 100644 index 817dcae..0000000 --- a/app/views/tasks/_ticket.rhtml +++ /dev/null @@ -1,22 +0,0 @@ -

<%= _('Processing ticket: %s') % task.title %>

- -<%= task.description %> - -<% form_for('task', task, :url => { :action => 'close', :id => task.id}) do |f| %> - - <%= labelled_form_field(_('Closing statment'), f.text_area(:closing_statment) ) %> - -
- <%= radio_button_tag(:decision, 'finish', true) %> - <%= _('OK') %> -
-
- <%= radio_button_tag(:decision, 'cancel', false) %> - <%= _('Cancel') %> -
- - <% button_bar do %> - <%= submit_button(:ok, _('OK')) %> - <% end %> - -<% end %> diff --git a/app/views/tasks/index.rhtml b/app/views/tasks/index.rhtml index 4991ced..0d6a6a0 100644 --- a/app/views/tasks/index.rhtml +++ b/app/views/tasks/index.rhtml @@ -1,20 +1,56 @@ -

<%= _("%s's pending tasks") % profile.name %>

+<%= stylesheet_link_tag 'tasks' %> +

<%= _("%s's pending tasks") % profile.name %>

+ +<% if !@failed.blank? %> +

+ <% @failed.each do |error, tasks_descriptions|%> +

<%= error %>

+

<%=_("This error happened with the following tasks: ")%>

+
    + <% tasks_descriptions.each do |description| %> +
  • <%= description %>
  • + <% end %> +
+ <% end %> +
+<% end %> + <% if @tasks.empty? %> <%= _('No pending tasks for %s') % profile.name %> <% else %> -
    - <% @tasks.each do |item| %> -
  • <%= render :partial => partial_for_class(item.class), :locals => { :task => item } %>
  • + <% form_tag :action => 'close' do%> + <% button_bar do %> + <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> + <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> + <%= submit_button :save, _("Apply!") %> + <%= button(:edit, _('View processed tasks'), :action => 'processed') %> + <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> <% end %> -
+ +
    +

    + <%= labelled_select(_("Set all to: "), 'set-decisions', 'downcase', 'to_s', nil, ["","Accept", "Reject", "Skip"], :id => "up-set-all-tasks-to") %> +

    + <% @tasks.each do |task| %> + <%= render :partial => 'task', :locals => { :task => task } %> + <% end %> +

    + <%= labelled_select(_("Set all to: "), 'set-decisions', 'downcase', 'to_s', nil, ["","Accept", "Reject", "Skip"], :id => "down-set-all-tasks-to") %> +

    +
+ + <% button_bar do %> + <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> + <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> + <%= submit_button :save, _("Apply!") %> + <%= button(:edit, _('View processed tasks'), :action => 'processed') %> + <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> + <% end %> + <% end %> <% end %>

-<% button_bar do %> - <%= button(:edit, _('View processed tasks'), :action => 'processed') %> - <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> - <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> - <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> -<% end %> + +<%= javascript_include_tag 'tasks' %> diff --git a/app/views/tasks/list_requested.rhtml b/app/views/tasks/list_requested.rhtml index 1e31064..8b4070f 100644 --- a/app/views/tasks/list_requested.rhtml +++ b/app/views/tasks/list_requested.rhtml @@ -3,7 +3,7 @@
    <% @tasks.each do |task| %>
  • - <%= task.respond_to?(:title) ? link_to( task.title, :action => 'ticket_details', :id => task.id) : task.description %>
    + <%= task.respond_to?(:title) ? link_to( task.title, :action => 'ticket_details', :id => task.id) : task.information %>
    <%= _('Created:') + ' ' + show_date(task.created_at) %>   —   diff --git a/app/views/tasks/new.rhtml b/app/views/tasks/new.rhtml index 7de4661..ac2a634 100644 --- a/app/views/tasks/new.rhtml +++ b/app/views/tasks/new.rhtml @@ -9,7 +9,7 @@ <% end %> <%= hidden_field_tag 'ticket[target_type]', 'Profile' %> <%= f.text_field :title, :style => 'width:80%;' %> - <%= f.text_area :description, :style => 'height:200px; width:80%;' %> + <%= f.text_area :message, :style => 'height:200px; width:80%;' %> <% button_bar do %> <%= submit_button(:ok, _('Send'), :cancel => {:action => 'index'}) %> diff --git a/app/views/tasks/processed.rhtml b/app/views/tasks/processed.rhtml index 979b918..a3821ab 100644 --- a/app/views/tasks/processed.rhtml +++ b/app/views/tasks/processed.rhtml @@ -7,7 +7,7 @@
      <% @tasks.each do |item| %>
    • - <%= item.description %>
      + <%= item.information %>
      <%= _('Created:') +' '+ show_date(item.created_at) %>   —   diff --git a/features/approve_article.feature b/features/approve_article.feature index 3667504..80c75b8 100644 --- a/features/approve_article.feature +++ b/features/approve_article.feature @@ -28,7 +28,8 @@ Feature: approve article And I go to Sample Community's control panel And I follow "Process requests" And I fill in "Text" with "This is an article edited" - And I press "Ok!" + And I choose "Accept" + And I press "Apply!" And I go to Sample Community's sitemap When I follow "Sample Article" Then I should see "This is an article edited" diff --git a/features/create_community.feature b/features/create_community.feature index 9de12c2..0c54499 100644 --- a/features/create_community.feature +++ b/features/create_community.feature @@ -51,8 +51,8 @@ Feature: create community And I go to the Control panel And I follow "Process requests" And I should see "admin_user wants to create community Community for approval" - And I choose "Approve" - When I press "Ok!" + And I choose "Accept" + When I press "Apply!" Then I should not see "admin_user wants to create community Community for approval" When I go to the Control panel And I follow "Manage my groups" @@ -66,7 +66,7 @@ Feature: create community And I follow "Process requests" And I should see "admin_user wants to create community Community for approval" And I choose "Reject" - When I press "Ok!" + When I press "Apply!" Then I should not see "admin_user wants to create community Community for approval" When I go to the Control panel And I follow "Manage my groups" @@ -89,12 +89,3 @@ Feature: create community When I go to the Control panel And I follow "Manage my groups" Then I should not see "Community for approval" - - Scenario: environment admin accepts new community task but identifier was already taken - Given I am logged in as admin - And feature "admin_must_approve_new_communities" is enabled on environment - And I create community "Community for approval" - And I create community "Community for approval" - When I approve community "Community for approval" - Then I should see "This name was already taken, this community cannot be approved" - And I should see "admin_user wants to create community Community for approval" diff --git a/features/invitation.feature b/features/invitation.feature index a660b94..a8507fb 100644 --- a/features/invitation.feature +++ b/features/invitation.feature @@ -93,7 +93,7 @@ Feature: invitation Given there are no pending jobs When I am logged in as "josesantos" And I go to the Control panel - And I should see "josesilva invited you to join the community 26 Bsslines" + And I should see "josesilva invited you to join 26 Bsslines." Scenario: noosfero user accepts to join community Given I invite email "santos@invalid.br" to join community "26 Bsslines" @@ -101,10 +101,10 @@ Feature: invitation When I am logged in as "josesantos" And I go to the Control panel And I follow "Process requests" - And I should see "josesilva invited you to join the community 26 Bsslines" + And I should see "josesilva invited you to join 26 Bsslines." And I choose "Accept" - When I press "Ok!" - Then I should not see "josesilva invited you to join the community 26 Bsslines" + When I press "Apply!" + Then I should not see "josesilva invited you to join 26 Bsslines." When I go to the Control panel And I follow "Manage my groups" Then I should see "26 Bsslines" @@ -115,10 +115,10 @@ Feature: invitation When I am logged in as "josesantos" And I go to the Control panel And I follow "Process requests" - And I should see "josesilva invited you to join the community 26 Bsslines" + And I should see "josesilva invited you to join 26 Bsslines." And I choose "Reject" - When I press "Ok!" - Then I should not see "josesilva invited you to join the community 26 Bsslines" + When I press "Apply!" + Then I should not see "josesilva invited you to join 26 Bsslines." When I go to the Control panel And I follow "Manage my groups" Then I should not see "26 Bsslines" @@ -135,7 +135,7 @@ Feature: invitation When I am logged in as "josesantos" And I go to the Control panel And I follow "Process requests" - And I should see "josesilva wants to be your friend." + Then I should see "josesilva wants to be your friend." Scenario: noosfero user accepts to be friend Given I invite email "santos@invalid.br" to be my friend @@ -145,7 +145,7 @@ Feature: invitation And I follow "Process requests" And I should see "josesilva wants to be your friend." And I choose "Accept" - When I press "Ok!" + When I press "Apply!" And I should not see "josesilva wants to be your friend." When I go to the Control panel And I follow "Manage friends" @@ -158,8 +158,8 @@ Feature: invitation And I go to the Control panel And I follow "Process requests" And I should see "josesilva wants to be your friend." - And I choose "Ignore" - When I press "Ok!" + And I choose "Reject" + When I press "Apply!" And I should not see "josesilva wants to be your friend." When I go to the Control panel And I follow "Manage friends" diff --git a/features/publish_article.feature b/features/publish_article.feature index 2876db0..5b62015 100644 --- a/features/publish_article.feature +++ b/features/publish_article.feature @@ -95,6 +95,33 @@ Feature: publish article When I go to Another Community2's sitemap Then I should see "Sample Article" + Scenario: publishing articles with the same name in a moderated community + Given I am logged in as "joaosilva" + And "Joao Silva" is a member of "Sample Community" + And "Joao Silva" is admin of "Sample Community" + And I am on Sample Community's control panel + And I follow "Community Info and settings" + And I choose "profile_data_moderated_articles_true" + And I press "Save" + And I am on Joao Silva's control panel + And I follow "Manage Content" + And I follow "Spread" + And I check "Sample Community" + And I press "Spread this" + And I am on Joao Silva's control panel + And I follow "Manage Content" + And I follow "Spread" + And I check "Sample Community" + And I press "Spread this" + And I am on Sample Community's control panel + And I follow "Tasks" + And I choose "Accept" + And I press "Apply!" + And I should not see "The title (article name) is already being used by another article, please use another title." + And I choose "Accept" + When I press "Apply!" + Then I should see "The title (article name) is already being used by another article, please use another title." + Scenario: ask to publish an article that was deleted before approval Given I am logged in as "joaosilva" And "Joao Silva" is admin of "Sample Community" @@ -110,6 +137,6 @@ Feature: publish article And "joaosilva" has no articles And I am on Sample Community's control panel When I follow "Tasks" - Then I should see /Joao Silva wanted.*deleted/ - And I press "Ok!" - Then I should not see /Joao Silva wanted.*deleted/ + Then I should see "The article was removed." + And I press "Apply!" + Then I should not see "The article was removed." diff --git a/features/register_enterprise.feature b/features/register_enterprise.feature index e81bb70..f01aa40 100644 --- a/features/register_enterprise.feature +++ b/features/register_enterprise.feature @@ -94,9 +94,10 @@ Feature: register enterprise And I am logged in as admin And I go to the Control panel When I follow "Tasks" - Then I should see /Processing task: Enterprise registration: "My Enterprise"/ + Then I should see "Joao Silva wants to create enterprise My Enterprise." And the first mail is to admin_user@example.com - And I press "Ok" + And I choose "Accept" + And I press "Apply!" Then the last mail is to joaosilva@example.com And I am logged in as "joaosilva" And I am on Joao Silva's control panel @@ -120,11 +121,11 @@ Feature: register enterprise And I am logged in as admin And I go to the Control panel When I follow "Tasks" - Then I should see /Processing task: Enterprise registration: "My Enterprise"/ + Then I should see "Joao Silva wants to create enterprise My Enterprise." And the first mail is to admin_user@example.com - And I choose "Cancel" + And I choose "Reject" And I fill in "Rejection explanation" with "This enterprise has some irregularities." - When I press "Ok" + And I press "Apply!" Then the last mail is to joaosilva@example.com And I am logged in as "joaosilva" And I am on Joao Silva's control panel @@ -157,9 +158,9 @@ Feature: register enterprise Then I should see "Enterprise registration completed" And I am on Validator's control panel When I follow "Tasks" - Then I should see /Processing task: Enterprise registration: "My Enterprise"/ - And I choose "Ok" - And I press "Ok" + Then I should see "Joao Silva wants to create enterprise My Enterprise." + And I choose "Accept" + And I press "Apply!" And I am on Joao Silva's control panel When I follow "Manage my groups" Then I should see "My Enterprise" @@ -190,10 +191,10 @@ Feature: register enterprise Then I should see "Enterprise registration completed" And I am on Validator's control panel When I follow "Tasks" - Then I should see /Processing task: Enterprise registration: "My Enterprise"/ - And I choose "Cancel" + Then I should see "Joao Silva wants to create enterprise My Enterprise." + And I choose "Reject" And I fill in "Rejection explanation" with "This enterprise has some irregularities." - And I press "Ok" + And I press "Apply" And I am on Joao Silva's control panel When I follow "Manage my groups" Then I should not see "My Enterprise" diff --git a/features/step_definitions/create_community_steps.rb b/features/step_definitions/create_community_steps.rb index 82c36d3..672fb5e 100644 --- a/features/step_definitions/create_community_steps.rb +++ b/features/step_definitions/create_community_steps.rb @@ -11,7 +11,7 @@ Given /^I approve community "(.+)"$/ do |community| Given 'I go to the Control panel' click_link('Process requests') choose("decision-finish-#{task.id}") - click_button('OK!') + click_button('Apply!') end Given /^I reject community "(.+)"$/ do |community| @@ -19,5 +19,5 @@ Given /^I reject community "(.+)"$/ do |community| Given 'I go to the Control panel' click_link('Process requests') choose("decision-cancel-#{task.id}") - click_button('OK!') + click_button('Apply!') end diff --git a/public/images/icons-app/article-minor.png b/public/images/icons-app/article-minor.png new file mode 100644 index 0000000..04f2680 Binary files /dev/null and b/public/images/icons-app/article-minor.png differ diff --git a/public/images/icons-app/article-portrait.png b/public/images/icons-app/article-portrait.png new file mode 100644 index 0000000..339c3ca Binary files /dev/null and b/public/images/icons-app/article-portrait.png differ diff --git a/public/images/icons-app/article-thumb.png b/public/images/icons-app/article-thumb.png new file mode 100644 index 0000000..0580ccb Binary files /dev/null and b/public/images/icons-app/article-thumb.png differ diff --git a/public/images/icons-task/closed-arrow-hover.png b/public/images/icons-task/closed-arrow-hover.png new file mode 100644 index 0000000..a797866 Binary files /dev/null and b/public/images/icons-task/closed-arrow-hover.png differ diff --git a/public/images/icons-task/closed-arrow.png b/public/images/icons-task/closed-arrow.png new file mode 100644 index 0000000..e2a51f7 Binary files /dev/null and b/public/images/icons-task/closed-arrow.png differ diff --git a/public/images/icons-task/opened-arrow-hover.png b/public/images/icons-task/opened-arrow-hover.png new file mode 100644 index 0000000..db9e2fe Binary files /dev/null and b/public/images/icons-task/opened-arrow-hover.png differ diff --git a/public/images/icons-task/opened-arrow.png b/public/images/icons-task/opened-arrow.png new file mode 100644 index 0000000..72f3edf Binary files /dev/null and b/public/images/icons-task/opened-arrow.png differ diff --git a/public/img-source/article-icon.svg b/public/img-source/article-icon.svg new file mode 100644 index 0000000..5232a84 --- /dev/null +++ b/public/img-source/article-icon.svg @@ -0,0 +1,788 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + rich + text + document + pdf + openoffice + word + rtf + + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/javascripts/tasks.js b/public/javascripts/tasks.js new file mode 100644 index 0000000..52f450b --- /dev/null +++ b/public/javascripts/tasks.js @@ -0,0 +1,49 @@ +(function($) { + + $("input.task_accept_radio").click(function(){ + task_id = this.getAttribute("task_id"); + $('#on-accept-information-' + task_id).show('fast'); + $('#on-reject-information-' + task_id).hide('fast'); + $('#on-skip-information-' + task_id).hide('fast'); + }) + + $("input.task_reject_radio").click(function(){ + task_id = this.getAttribute("task_id"); + $('#on-accept-information-' + task_id).hide('fast'); + $('#on-reject-information-' + task_id).show('fast'); + $('#on-skip-information-' + task_id).hide('fast'); + }) + + $("input.task_skip_radio").click(function(){ + task_id = this.getAttribute("task_id"); + $('#on-accept-information-' + task_id).hide('fast'); + $('#on-reject-information-' + task_id).hide('fast'); + $('#on-skip-information-' + task_id).show('fast'); + }) + + // There is probably an elegant way to do this... + $('#up-set-all-tasks-to').selectedIndex = 0; + $('#down-set-all-tasks-to').selectedIndex = 0; + + $('#down-set-all-tasks-to').change(function(){ + value = $('#down-set-all-tasks-to').selected().val(); + up = $('#up-set-all-tasks-to') + up.attr('value', value).change(); + }) + + $('#up-set-all-tasks-to').change(function(){ + value = $('#up-set-all-tasks-to').selected().val(); + down = $('#down-set-all-tasks-to') + down.attr('value', value); + $('.task_'+value+'_radio').each( function(){ + if(!this.disabled){ + $(this).attr('checked', 'checked').click(); + } + }) + }) + + $('.task_title').css('margin-right', $('.task_decisions').width()+'px'); + $('.task_title').css('margin-left', $('.task_arrow').width()+'px'); + +})(jQuery) + diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 5c3f508..5aa7bcc 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -305,7 +305,7 @@ div.auto-complete li.selected { color: #204A87; } -/* pending tasks list */ +/* pending tasks */ div.pending-tasks { padding: 10px; @@ -313,6 +313,19 @@ div.pending-tasks { margin-bottom: 20px; } +#pending-tasks-count { + padding-left: 5px; + padding-right: 5px; + margin-left: 2px; + text-decoration: none; + background-color: #F57900; + color: #FFFFFF; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + -khtml-border-radius: 2px; + border-radius: 2px; +} + /* sitemap and agenda */ .agenda-item a.icon, diff --git a/public/stylesheets/tasks.css b/public/stylesheets/tasks.css new file mode 100644 index 0000000..425117a --- /dev/null +++ b/public/stylesheets/tasks.css @@ -0,0 +1,46 @@ +.task_box { + position: relative; + border: 1px solid #888; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; + -khtml-border-radius: 10px; + border-radius: 10px; + padding: 6px 4px 9px 4px; + margin-top: 5px; + background: #EEE; +} + +.task_title { + margin: 0px; + display: block; + line-height: 28px; + font-size: 120%; +} + +.task_icon { + float: left; + margin-right: 10px; + width: 50px; + height: 50px; + text-align: center; +} + +.task_decisions { + float: right; + padding-right: 5px; +} + +.task_information { + line-height: 18px; + padding: 2px 0px; + clear: right; +} + +.task_information p { + margin: 0px; +} + +.task_target { + text-decoration: underline; + font-weight: bold; +} diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index 8641ae3..9b4948d 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -46,7 +46,7 @@ class TasksControllerTest < Test::Unit::TestCase should 'be able to finish a task' do t = profile.tasks.build; t.save! - post :close, :decision => 'finish', :id => t.id + post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}} assert_redirected_to :action => 'index' t.reload @@ -56,52 +56,46 @@ class TasksControllerTest < Test::Unit::TestCase should 'be able to cancel a task' do t = profile.tasks.build; t.save! - post :close, :decision => 'cancel', :id => t.id + post :close, :tasks => {t.id => {:decision => 'cancel', :task => {}}} assert_redirected_to :action => 'index' t.reload ok('task should be cancelled') { t.status == Task::Status::CANCELLED } end - should 'affiliate roles to user after finish add member task' do - t = AddMember.create!(:person => profile, :organization => profile) - count = profile.members.size - post :close, :decision => 'finish', :id => t.id - profile = Profile.find(@profile.id) - assert_equal count + 1, profile.members.size - end + should 'be able to skip a task' do + t = profile.tasks.build; t.save! - should 'display custom form to add members task' do - t = AddMember.create!(:person => profile, :organization => profile) - get :index, :profile => profile.identifier - assert_tag :tag => 'form', :attributes => { :action => "/myprofile/#{profile.identifier}/tasks/close/#{t.id}" } - end + post :close, :tasks => {t.id => {:decision => 'skip', :task => {}}} + assert_redirected_to :action => 'index' - should 'display member role checked if target has members' do - profile.affiliate(profile, Profile::Roles.admin(profile.environment.id)) - assert_equal 1, profile.members.size - t = AddMember.create!(:person => profile, :organization => profile) - get :index, :profile => profile.identifier - assert_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => Profile::Roles.member(profile.environment.id).id } + t.reload + ok('task should be skipped') { t.status == Task::Status::ACTIVE } end - should 'display roles besides role member unchecked if target has members' do - profile.affiliate(profile, Profile::Roles.admin(profile.environment.id)) - assert_equal 1, profile.members.size - t = AddMember.create!(:person => profile, :organization => profile) - get :index, :profile => profile.identifier - Role.find(:all).select{ |r| r.has_kind?('Profile') and r.id != Profile::Roles.member(profile.environment.id).id }.each do |i| - assert_no_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => i.id } - end + should 'be able to apply different decisions to multiples tasks at the same time' do + t1 = profile.tasks.build; t1.save! + t2 = profile.tasks.build; t2.save! + t3 = profile.tasks.build; t3.save! + + post :close, :tasks => {t1.id => {:decision => 'finish', :task => {}}, t2.id => {:decision => 'cancel', :task => {}}, t3.id => {:decision => 'skip', :task => {}}} + assert_redirected_to :action => 'index' + + t1.reload + t2.reload + t3.reload + + ok('task should be finished') { t1.status == Task::Status::FINISHED } + ok('task should be canceled') { t2.status == Task::Status::CANCELLED } + ok('task should be skipped') { t3.status == Task::Status::ACTIVE } end - should 'display all roles checked if target has no members' do - assert_equal 0, profile.members.size + should 'affiliate roles to user after finish add member task' do t = AddMember.create!(:person => profile, :organization => profile) - get :index, :profile => profile.identifier - Role.find(:all).select{ |r| r.has_kind?('Profile') }.each do |i| - assert_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => i.id } - end + count = profile.members.size + post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}} + profile = Profile.find(@profile.id) + assert_equal count + 1, profile.members.size end should 'display a create ticket form' do @@ -161,8 +155,8 @@ class TasksControllerTest < Test::Unit::TestCase article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile) - post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new name'} - assert_equal article, c.articles.find_by_name('new name').reference_article + post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name'}}} + assert_equal article, c.articles.find_by_name('new_name').reference_article end should 'create published article in folder after finish approve article task' do @@ -174,8 +168,8 @@ class TasksControllerTest < Test::Unit::TestCase article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile) - post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new name', :article_parent_id => folder.id} - assert_equal folder, c.articles.find_by_name('new name').parent + post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name', :article_parent_id => folder.id}}} + assert_equal folder, c.articles.find_by_name('new_name').parent end should 'be highlighted if asked when approving a published article' do @@ -187,8 +181,8 @@ class TasksControllerTest < Test::Unit::TestCase article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') t = ApproveArticle.create!(:article => article, :target => c, :requestor => profile) - post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new name', :article_parent_id => folder.id, :highlighted => true} - assert_equal true, c.articles.find_by_name('new name').highlighted + post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name', :article_parent_id => folder.id, :highlighted => true}}} + assert_equal true, c.articles.find_by_name('new_name').highlighted end should 'create article of same class after choosing root folder on approve article task' do @@ -199,8 +193,8 @@ class TasksControllerTest < Test::Unit::TestCase article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') t = ApproveArticle.create!(:article => article, :target => c, :requestor => profile) - post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new name', :article_parent_id => ""} - assert_equal article.class, c.articles.find_by_name('new name').class + post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name', :article_parent_id => ""}}} + assert_not_nil c.articles.find_by_name('new_name') end should 'handle blank names for published articles' do @@ -217,24 +211,24 @@ class TasksControllerTest < Test::Unit::TestCase assert_includes c.tasks, a assert_difference article.class, :count do - post :close, {"commit"=>"Ok!", "id"=> a.id.to_s, "task"=>{"name"=>"", "closing_statment"=>"", "highlighted"=>"0", "article_parent_id"=>c_blog2.id.to_s}, "decision"=>"finish"} + post :close, :tasks => {a.id => {:decision => 'finish', :task => {:name => "", :highlighted => "0", :article_parent_id => c_blog2.id.to_s}}} end assert p_article = article.class.find_by_reference_article_id(article.id) assert_includes c_blog2.children(true), p_article end - should 'cancel an enterprise registration task even if there is an enterprise with the same identifier' do + should 'raise error if there is an enterprise with the same identifier and keep the task active' do e = Environment.default e.add_admin(profile) task = CreateEnterprise.create!(:name => "My Enterprise", :identifier => "my-enterprise", :requestor => profile, :target => e) enterprise = fast_create(Enterprise, :name => "My Enterprise", :identifier => "my-enterprise") - assert_nothing_raised do - post :close, {:profile => profile.identifier, :id => task.id, :task => {:reject_explanation => "Bla bla"}, :decision => "cancel"} + assert_raise ActiveRecord::RecordInvalid do + post :close, :tasks => {task.id => { :task => {:reject_explanation => "Bla bla"}, :decision => "cancel"}} end task.reload - assert_equal Task::Status::CANCELLED, task.status + assert_equal Task::Status::ACTIVE, task.status end should 'create TinyMceArticle article after finish approve suggested article task' do @@ -245,7 +239,7 @@ class TasksControllerTest < Test::Unit::TestCase SuggestArticle.skip_captcha! t = SuggestArticle.create!(:article_name => 'test name', :article_body => 'test body', :name => 'some name', :email => 'test@localhost.com', :target => c) - post :close, :decision => 'finish', :id => t.id, :task => {} + post :close, :tasks => {t.id => { :task => {}, :decision => "finish"}} assert_not_nil TinyMceArticle.find(:first) end @@ -265,7 +259,7 @@ class TasksControllerTest < Test::Unit::TestCase t.target = c t.save! - post :close, :decision => 'finish', :id => t.id, :task => {:article_name => 'new article name', :article_body => 'new body', :source => 'http://www.noosfero.com', :source_name => 'new source', :name => 'new name'} + post :close, :tasks => {t.id => { :task => {:article_name => 'new article name', :article_body => 'new body', :source => 'http://www.noosfero.com', :source_name => 'new source', :name => 'new name'}, :decision => "finish"}} assert_equal 'new article name', TinyMceArticle.find(:first).name assert_equal 'new name', TinyMceArticle.find(:first).author_name assert_equal 'new body', TinyMceArticle.find(:first).body diff --git a/test/unit/add_friend_test.rb b/test/unit/add_friend_test.rb index 956d2ba..7799614 100644 --- a/test/unit/add_friend_test.rb +++ b/test/unit/add_friend_test.rb @@ -71,15 +71,6 @@ class AddFriendTest < ActiveSupport::TestCase task = AddFriend.create!(:person => p1, :friend => p2) end - should 'provide proper description' do - p1 = create_user('testuser1').person - p2 = create_user('testuser2').person - - task = fast_create(AddFriend, :requestor_id => p1.id, :target_id => p2.id) - - assert_equal 'testuser1 wants to be your friend.', task.description - end - should 'has permission to manage friends' do t = AddFriend.new assert_equal :manage_friends, t.permission diff --git a/test/unit/add_member_test.rb b/test/unit/add_member_test.rb index c6d76a2..7d09b40 100644 --- a/test/unit/add_member_test.rb +++ b/test/unit/add_member_test.rb @@ -49,18 +49,6 @@ class AddMemberTest < ActiveSupport::TestCase task = AddMember.create!(:person => p, :organization => c) end - should 'provide proper description' do - p = create_user('testuser1').person - c = fast_create(Community, :name => 'closed community') - c.update_attribute(:closed, true) - - TaskMailer.stubs(:deliver_target_notification) - - task = fast_create(AddMember, :requestor_id => p.id, :target_id => c.id, :target_type => 'Community') - - assert_equal 'testuser1 wants to be a member of "closed community".', task.description - end - should 'has permission to manage members' do t = AddMember.new assert_equal :manage_memberships, t.permission diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index e637854..42b76d9 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -588,6 +588,12 @@ class ApplicationHelperTest < Test::Unit::TestCase assert_equal ["1 for b", "2 for c", "3 for a"], unique_with_count(%w(a b c a c a)) end + should 'show task information with the requestor' do + person = create_user('usertest').person + task = Task.create(:requestor => person) + assert_match person.name, task_information(task) + end + protected def url_for(args = {}) diff --git a/test/unit/approve_article_test.rb b/test/unit/approve_article_test.rb index 0bcf1c1..e5f17ed 100644 --- a/test/unit/approve_article_test.rb +++ b/test/unit/approve_article_test.rb @@ -62,7 +62,7 @@ class ApproveArticleTest < ActiveSupport::TestCase article.destroy a.reload - assert_match /text was removed/, a.description + assert_equal "The article was removed.", a.information[:message] end should 'preserve article_parent' do diff --git a/test/unit/email_activation_test.rb b/test/unit/email_activation_test.rb index ba15261..9f3f7b5 100644 --- a/test/unit/email_activation_test.rb +++ b/test/unit/email_activation_test.rb @@ -37,7 +37,7 @@ class EmailActivationTest < Test::Unit::TestCase task = EmailActivation.create!(:requestor => ze.person, :target => Environment.default) task.finish - assert_equal ['zezinho@colivre.net'], ActionMailer::Base.deliveries.first.to + assert_equal ["zezinho@#{ze.email_domain}"], ActionMailer::Base.deliveries.first.to end should 'create only once pending task by user' do @@ -49,11 +49,4 @@ class EmailActivationTest < Test::Unit::TestCase assert !anothertask.save end - should 'display email address on description of task' do - ze = create_user('zezinho', :environment_id => Environment.default.id) - Environment.default.domains = [Domain.create!(:name => 'env_test.invalid')] - task = EmailActivation.new(:requestor => ze.person, :target => Environment.default) - assert_match /zezinho@env_test.invalid/, task.description - end - end diff --git a/test/unit/invite_friend_test.rb b/test/unit/invite_friend_test.rb index 85fd1a2..32d21a5 100644 --- a/test/unit/invite_friend_test.rb +++ b/test/unit/invite_friend_test.rb @@ -105,13 +105,6 @@ class InviteFriendTest < ActiveSupport::TestCase task = InviteFriend.create!(:person => p1, :friend => p2) end - should 'mention inviter in description' do - p1 = create_user('testuser1').person - task = InviteFriend.new(:person => p1) - - assert_match 'testuser1', task.description - end - should 'has permission to manage friends' do t = InviteFriend.new assert_equal :manage_friends, t.permission diff --git a/test/unit/invite_member_test.rb b/test/unit/invite_member_test.rb index b75dcf1..d0ef5d5 100644 --- a/test/unit/invite_member_test.rb +++ b/test/unit/invite_member_test.rb @@ -85,19 +85,6 @@ class InviteMemberTest < ActiveSupport::TestCase task = InviteMember.create!(:person => p1, :friend => p2, :community_id => fast_create(Community).id) end - should 'provide proper description' do - p1 = create_user('testuser1').person - p2 = create_user('testuser2').person - - TaskMailer.expects(:deliver_task_finished).never - TaskMailer.expects(:deliver_task_created).never - - community = fast_create(Community) - task = InviteMember.create!(:person => p1, :friend => p2, :community_id => community.id) - - assert_match(/#{p1.name}.*#{community.name}/, task.description) - end - should 'not invite yourself' do p = create_user('testuser1').person diff --git a/test/unit/pending_task_notifier_test.rb b/test/unit/pending_task_notifier_test.rb index ec56c3b..2643bba 100644 --- a/test/unit/pending_task_notifier_test.rb +++ b/test/unit/pending_task_notifier_test.rb @@ -23,10 +23,10 @@ class PendingTaskNotifierTest < Test::Unit::TestCase p = create_user('maelcum').person c = fast_create(Community) c.add_admin(p) - c.tasks << Task.new + c.tasks << Task.new(:requestor => p) response = PendingTaskNotifier.deliver_notification(p) - assert_match /Generic task/, response.body + assert_match /sent you a task/, response.body end private diff --git a/test/unit/rss_feed_test.rb b/test/unit/rss_feed_test.rb index 727f0b6..511e033 100644 --- a/test/unit/rss_feed_test.rb +++ b/test/unit/rss_feed_test.rb @@ -206,7 +206,7 @@ class RssFeedTest < Test::Unit::TestCase end should 'display the referenced body of a article published' do - article = fast_create(TextileArticle, :body => 'This is the content of the Sample Article.') + article = fast_create(TextileArticle, :body => 'This is the content of the Sample Article.', :profile_id => fast_create(Person).id) profile = fast_create(Profile) blog = fast_create(Blog, :profile_id => profile.id) a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => fast_create(Person)) diff --git a/test/unit/suggest_article_test.rb b/test/unit/suggest_article_test.rb index 96e99d0..aeb2c17 100644 --- a/test/unit/suggest_article_test.rb +++ b/test/unit/suggest_article_test.rb @@ -97,12 +97,6 @@ class SuggestArticleTest < ActiveSupport::TestCase assert_equal 'http://www.gnu.org/', article.source end - should 'use sender name in description' do - t = build(SuggestArticle, :target => @profile) - t.stubs(:sender).returns('XYZ') - assert_match(/XYZ/, t.description) - end - should 'use name and e-mail as sender info' do t = build(SuggestArticle, :target => @profile) t.name = 'Some One' diff --git a/test/unit/task_mailer_test.rb b/test/unit/task_mailer_test.rb index 224fa3c..d593a4d 100644 --- a/test/unit/task_mailer_test.rb +++ b/test/unit/task_mailer_test.rb @@ -17,7 +17,7 @@ class TaskMailerTest < Test::Unit::TestCase task = Task.new task.expects(:task_finished_message).returns('the message') - task.expects(:description).returns('the task') + task.expects(:information).returns('the task') requestor = mock() requestor.expects(:notification_emails).returns(['requestor@example.com']) @@ -40,7 +40,7 @@ class TaskMailerTest < Test::Unit::TestCase task = Task.new task.expects(:task_cancelled_message).returns('the message') - task.expects(:description).returns('the task') + task.expects(:information).returns('the task') requestor = mock() requestor.expects(:notification_emails).returns(['requestor@example.com']) @@ -64,7 +64,7 @@ class TaskMailerTest < Test::Unit::TestCase task = Task.new task.expects(:task_created_message).returns('the message') - task.expects(:description).returns('the task') + task.expects(:information).returns('the task') requestor = mock() requestor.expects(:notification_emails).returns(['requestor@example.com']) @@ -85,7 +85,7 @@ class TaskMailerTest < Test::Unit::TestCase should 'be able to send a "target notification" message' do task = Task.new - task.expects(:description).returns('the task') + task.expects(:information).returns('the task') target = mock() target.expects(:notification_emails).returns(['target@example.com']) @@ -104,18 +104,18 @@ class TaskMailerTest < Test::Unit::TestCase assert !ActionMailer::Base.deliveries.empty? end - should 'be able to send a "invitatiom notification" message' do + should 'be able to send a "invitation notification" message' do task = InviteFriend.new - task.expects(:description).returns('the task') task.expects(:code).returns('123456') - task.expects(:message).returns('Hello , invite you, please follow this link: ') + task.stubs(:message).returns('Hello , invite you, please follow this link: ') task.expects(:friend_email).returns('friend@exemple.com') task.expects(:friend_name).returns('friend name').at_least_once requestor = mock() - requestor.expects(:name).returns('my name') + requestor.stubs(:name).returns('my name') + requestor.stubs(:public_profile_url).returns('requestor_path') environment = mock() environment.expects(:contact_email).returns('sender@example.com') diff --git a/test/unit/task_test.rb b/test/unit/task_test.rb index ac91249..4af6436 100644 --- a/test/unit/task_test.rb +++ b/test/unit/task_test.rb @@ -87,7 +87,8 @@ class TaskTest < Test::Unit::TestCase end should 'provide a description method' do - assert_kind_of String, Task.new.description + requestor = create_user('requestor').person + assert_kind_of Hash, Task.new(:requestor => requestor).information end should 'notify just after the task is created' do -- libgit2 0.21.2