diff --git a/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb b/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb index ba32b14..4aedeb3 100644 --- a/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb +++ b/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb @@ -93,6 +93,14 @@ class CustomFormsPluginMyprofileController < MyProfileController @form = @submission.form end + def pending + @form = CustomFormsPlugin::Form.find(params[:id]) + @pendings = CustomFormsPlugin::AdmissionSurvey.from(@form.profile).pending.select {|task| task.form_id == @form.id}.map {|a| {:profile => a.target, :time => a.created_at} } + + @sort_by = params[:sort_by] + @pendings = @pendings.sort_by { |s| s[:profile].name } if @sort_by == 'user' + end + private def normalize_positions(form) diff --git a/plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb b/plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb index 9dfcb50..6a595bb 100644 --- a/plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb +++ b/plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb @@ -216,5 +216,14 @@ class CustomFormsPluginMyprofileControllerTest < ActionController::TestCase assert_not_nil assigns(:sort_by) assert_select 'table.action-table', /Author\W*Time\W*bob[\W\dh]*john[\W\dh]*/ end -end + should 'list pending submissions for a form' do + person = fast_create(Person) + form = CustomFormsPlugin::Form.create!(:profile => profile, :name => 'Free Software', :for_admission => true) + task = CustomFormsPlugin::AdmissionSurvey.create!(:form_id => form.id, :target => person, :requestor => profile) + + get :pending, :profile => profile.identifier, :id => form.id + + assert_tag :td, :content => person.name + end +end diff --git a/plugins/custom_forms/views/custom_forms_plugin_myprofile/index.html.erb b/plugins/custom_forms/views/custom_forms_plugin_myprofile/index.html.erb index 9b5dea9..acca2aa 100644 --- a/plugins/custom_forms/views/custom_forms_plugin_myprofile/index.html.erb +++ b/plugins/custom_forms/views/custom_forms_plugin_myprofile/index.html.erb @@ -17,7 +17,9 @@
+ <%= labelled_select(_('Sort by')+': ', :sort_by, :first, :last, @sort_by, [['time', _('Time')], ['user', _('User')]], :onchange => 'document.location.href = "?sort_by="+this.value') %> +
+<%= _('User') %> | +<%= _('Time') %> | +
---|---|
<%= link_to(pending[:profile].name, {:controller => :profile, :profile => pending[:profile].identifier}) %> | +<%= time_format(pending[:time]) %> | +