Commit 4b5140d0c0a7539d5e6cbaea3016da930520a9f4
1 parent
bfc0d0ed
Exists in
master
and in
28 other branches
Show different messages for expired forms
(ActionItem2969)
Showing
6 changed files
with
54 additions
and
6 deletions
Show diff stats
plugins/custom_forms/lib/custom_forms_plugin/form.rb
@@ -43,6 +43,10 @@ class CustomFormsPlugin::Form < Noosfero::Plugin::ActiveRecord | @@ -43,6 +43,10 @@ class CustomFormsPlugin::Form < Noosfero::Plugin::ActiveRecord | ||
43 | (begining.present? && Time.now < begining) || (ending.present? && Time.now > ending) | 43 | (begining.present? && Time.now < begining) || (ending.present? && Time.now > ending) |
44 | end | 44 | end |
45 | 45 | ||
46 | + def will_open? | ||
47 | + begining.present? && Time.now < begining | ||
48 | + end | ||
49 | + | ||
46 | def accessible_to(target) | 50 | def accessible_to(target) |
47 | return true if access.nil? || target == profile | 51 | return true if access.nil? || target == profile |
48 | return false if target.nil? | 52 | return false if target.nil? |
plugins/custom_forms/test/functional/custom_forms_plugin_profile_controller_test.rb
@@ -35,7 +35,23 @@ class CustomFormsPluginProfileControllerTest < ActionController::TestCase | @@ -35,7 +35,23 @@ class CustomFormsPluginProfileControllerTest < ActionController::TestCase | ||
35 | 35 | ||
36 | get :show, :profile => profile.identifier, :id => form.id | 36 | get :show, :profile => profile.identifier, :id => form.id |
37 | 37 | ||
38 | - assert_tag :tag => 'h2', :content => 'Sorry, you can\'t fill this form right now' | ||
39 | assert_tag :tag => 'input', :attributes => {:disabled => 'disabled'} | 38 | assert_tag :tag => 'input', :attributes => {:disabled => 'disabled'} |
40 | end | 39 | end |
40 | + | ||
41 | + should 'show expired message' do | ||
42 | + form = CustomFormsPlugin::Form.create!(:profile => profile, :name => 'Free Software', :begining => Time.now + 1.day) | ||
43 | + form.fields << CustomFormsPlugin::TextField.create(:name => 'Field Name', :form => form, :default_value => "First Field") | ||
44 | + | ||
45 | + get :show, :profile => profile.identifier, :id => form.id | ||
46 | + | ||
47 | + assert_tag :tag => 'h2', :content => 'Sorry, you can\'t fill this form yet' | ||
48 | + | ||
49 | + form.begining = Time.now - 2.days | ||
50 | + form.ending = Time.now - 1.days | ||
51 | + form.save | ||
52 | + | ||
53 | + get :show, :profile => profile.identifier, :id => form.id | ||
54 | + | ||
55 | + assert_tag :tag => 'h2', :content => 'Sorry, you can\'t fill this form anymore' | ||
56 | + end | ||
41 | end | 57 | end |
plugins/custom_forms/test/unit/custom_forms_plugin/form_test.rb
@@ -89,6 +89,22 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase | @@ -89,6 +89,22 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase | ||
89 | assert !form.expired? | 89 | assert !form.expired? |
90 | end | 90 | end |
91 | 91 | ||
92 | + should 'define if form will still open' do | ||
93 | + form = CustomFormsPlugin::Form.new | ||
94 | + assert !form.will_open? | ||
95 | + | ||
96 | + form.begining = Time.now + 1.day | ||
97 | + assert form.will_open? | ||
98 | + | ||
99 | + form.begining = Time.now - 1.day | ||
100 | + assert !form.will_open? | ||
101 | + | ||
102 | + form.begining = Time.now - 2.day | ||
103 | + form.ending = Time.now - 1.day | ||
104 | + assert form.expired? | ||
105 | + assert !form.will_open? | ||
106 | + end | ||
107 | + | ||
92 | should 'validates format of access' do | 108 | should 'validates format of access' do |
93 | form = CustomFormsPlugin::Form.new | 109 | form = CustomFormsPlugin::Form.new |
94 | form.valid? | 110 | form.valid? |
plugins/custom_forms/views/custom_forms_plugin_profile/show.html.erb
@@ -3,7 +3,11 @@ | @@ -3,7 +3,11 @@ | ||
3 | 3 | ||
4 | <% if @submission.id.nil? %> | 4 | <% if @submission.id.nil? %> |
5 | <% if @form.expired? %> | 5 | <% if @form.expired? %> |
6 | - <h2><%= _('Sorry, you can\'t fill this form right now') %></h2> | 6 | + <% if @form.will_open? %> |
7 | + <h2><%= _('Sorry, you can\'t fill this form yet') %></h2> | ||
8 | + <% else %> | ||
9 | + <h2><%= _('Sorry, you can\'t fill this form anymore') %></h2> | ||
10 | + <% end %> | ||
7 | <% end %> | 11 | <% end %> |
8 | 12 | ||
9 | <%= error_messages_for :submission %> | 13 | <%= error_messages_for :submission %> |
plugins/custom_forms/views/tasks/custom_forms_plugin/_membership_survey_accept_details.html.erb
@@ -4,7 +4,11 @@ | @@ -4,7 +4,11 @@ | ||
4 | <h2><%= @form.name %></h2> | 4 | <h2><%= @form.name %></h2> |
5 | <p><%= @form.description %></p> | 5 | <p><%= @form.description %></p> |
6 | <% if @form.expired? %> | 6 | <% if @form.expired? %> |
7 | - <h3><%= _('Sorry, you can\'t fill this form right now') %></h3> | 7 | + <% if @form.will_open? %> |
8 | + <h3><%= _('Sorry, you can\'t fill this form yet') %></h3> | ||
9 | + <% else %> | ||
10 | + <h3><%= _('Sorry, you can\'t fill this form anymore') %></h3> | ||
11 | + <% end %> | ||
8 | <% end %> | 12 | <% end %> |
9 | 13 | ||
10 | <% f.fields_for :submission do |fi| %> | 14 | <% f.fields_for :submission do |fi| %> |
po/pt/noosfero.po
@@ -11497,9 +11497,13 @@ msgstr "Nome do autor" | @@ -11497,9 +11497,13 @@ msgstr "Nome do autor" | ||
11497 | msgid "Author email" | 11497 | msgid "Author email" |
11498 | msgstr "Email do autor" | 11498 | msgstr "Email do autor" |
11499 | 11499 | ||
11500 | -#: plugins/custom_forms/views/custom_forms_plugin_profile/show.html.erb:5 | ||
11501 | -msgid "Sorry, you can't fill this form right now" | ||
11502 | -msgstr "Desculpe, você não pode preencher esse formulário no momento" | 11500 | +#: plugins/custom_forms/views/custom_forms_plugin_profile/show.html.erb:7 |
11501 | +msgid "Sorry, you can't fill this form yet" | ||
11502 | +msgstr "Desculpe, você não pode preencher esse formulário ainda" | ||
11503 | + | ||
11504 | +#: plugins/custom_forms/views/custom_forms_plugin_profile/show.html.erb:9 | ||
11505 | +msgid "Sorry, you can't fill this form anymore" | ||
11506 | +msgstr "Desculpe, você não pode mais preencher esse formulário" | ||
11503 | 11507 | ||
11504 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_empty_field.html.erb:8 | 11508 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_empty_field.html.erb:8 |
11505 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_field.html.erb:10 | 11509 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_field.html.erb:10 |