[Git][noosfero/noosfero][master-1.x] 2 commits: [CustomForms] Uses date helper on query views

Rodrigo Souto gitlab at mg.gitlab.com
Mon May 28 16:02:40 BRT 2018


Rodrigo Souto pushed to branch master-1.x at Noosfero / noosfero


Commits:
ec5e956b by Gabriel Silva at 2018-05-24T15:24:40Z
[CustomForms] Uses date helper on query views

Signed-off-by: Gabriel Silva <gabriel93.silva at gmail.com>

- - - - -
a25503b6 by Rodrigo Souto at 2018-05-28T19:02:30Z
Merge branch 'custom-forms-remaining' into 'master-1.x'

[CustomForms] Uses date helper on query views

See merge request noosfero/noosfero!1503
- - - - -


9 changed files:

- plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb
- plugins/custom_forms/controllers/custom_forms_plugin_profile_controller.rb
- plugins/custom_forms/lib/custom_forms_plugin/form.rb
- plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb
- plugins/custom_forms/views/custom_forms_plugin_myprofile/index.html.erb
- plugins/custom_forms/views/custom_forms_plugin_myprofile/pending.html.erb
- plugins/custom_forms/views/custom_forms_plugin_myprofile/submissions.html.erb
- plugins/custom_forms/views/custom_forms_plugin_profile/_queries_content.html.erb
- plugins/custom_forms/views/custom_forms_plugin_profile/review.html.erb


Changes:

=====================================
plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb
=====================================
--- a/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb
+++ b/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb
@@ -1,8 +1,7 @@
 require 'csv'
 
 class CustomFormsPluginMyprofileController < MyProfileController
-
-  include CustomFormsPlugin::Helper
+  helper CustomFormsPlugin::Helper
 
   protect 'post_content', :profile
 


=====================================
plugins/custom_forms/controllers/custom_forms_plugin_profile_controller.rb
=====================================
--- a/plugins/custom_forms/controllers/custom_forms_plugin_profile_controller.rb
+++ b/plugins/custom_forms/controllers/custom_forms_plugin_profile_controller.rb
@@ -1,9 +1,9 @@
 class CustomFormsPluginProfileController < ProfileController
+  helper CustomFormsPlugin::Helper
+
   before_filter :has_access, :only => [:show]
   before_filter :can_view_results, :only => [:review]
 
-  include CustomFormsPlugin::Helper
-
   def show
     profile = Profile.find_by(identifier: params[:profile])
     @form = profile.forms.find_by(identifier: params[:id])


=====================================
plugins/custom_forms/lib/custom_forms_plugin/form.rb
=====================================
--- a/plugins/custom_forms/lib/custom_forms_plugin/form.rb
+++ b/plugins/custom_forms/lib/custom_forms_plugin/form.rb
@@ -117,27 +117,6 @@ class CustomFormsPlugin::Form < ApplicationRecord
     image.present? ? image.full_path : default_img_url
   end
 
-  def duration_in_days
-    if begining == nil and ending == nil
-      return _("This query has no ending date")
-    end
-    seconds_to_days = 86400
-    days = (ending.to_i - begining.to_i) / seconds_to_days
-    if days < 1
-      return _("Ends today")
-    end
-
-    if days >= 1 && days < 2
-      return _("Ends tomorow")
-    end
-
-    if days < 0
-      return _("Already closed")
-    end
-
-    return _("%s days left") % days
-  end
-
   def status
     if begining.try(:future?)
       :not_open


=====================================
plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb
=====================================
--- a/plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb
+++ b/plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb
@@ -1,5 +1,3 @@
-<% self.extend(CustomFormsPlugin::Helper) %>
-
 <%= error_messages_for :form %>
 <%= required labelled_form_field _('Name'), f.text_field(:name) %>
 <% address_field = content_tag('code', "/profile/#{profile.identifier}/query/".html_safe + f.text_field(:identifier)).html_safe %>


=====================================
plugins/custom_forms/views/custom_forms_plugin_myprofile/index.html.erb
=====================================
--- a/plugins/custom_forms/views/custom_forms_plugin_myprofile/index.html.erb
+++ b/plugins/custom_forms/views/custom_forms_plugin_myprofile/index.html.erb
@@ -1,5 +1,3 @@
-<% self.extend CustomFormsPlugin::Helper %>
-
 <h1><%= _('Manage queries') %></h1>
 
 <% tabs = [] %>


=====================================
plugins/custom_forms/views/custom_forms_plugin_myprofile/pending.html.erb
=====================================
--- a/plugins/custom_forms/views/custom_forms_plugin_myprofile/pending.html.erb
+++ b/plugins/custom_forms/views/custom_forms_plugin_myprofile/pending.html.erb
@@ -1,5 +1,3 @@
-<% self.extend CustomFormsPlugin::Helper %>
-
 <h1><%= _('Pending submissions for %s') % @form.name %></h1>
 
 <% if @pendings.empty? %>


=====================================
plugins/custom_forms/views/custom_forms_plugin_myprofile/submissions.html.erb
=====================================
--- a/plugins/custom_forms/views/custom_forms_plugin_myprofile/submissions.html.erb
+++ b/plugins/custom_forms/views/custom_forms_plugin_myprofile/submissions.html.erb
@@ -1,5 +1,3 @@
-<% self.extend CustomFormsPlugin::Helper %>
-
 <h3><%= _('Submissions for %s') % @form.name %></h3>
 
 <% if @form.submissions.empty? %>


=====================================
plugins/custom_forms/views/custom_forms_plugin_profile/_queries_content.html.erb
=====================================
--- a/plugins/custom_forms/views/custom_forms_plugin_profile/_queries_content.html.erb
+++ b/plugins/custom_forms/views/custom_forms_plugin_profile/_queries_content.html.erb
@@ -1,5 +1,3 @@
-<% self.extend(CustomFormsPlugin::Helper) %>
-
 <div id='queries'>
   <ul class="results-list">
     <% if @forms.present? %>


=====================================
plugins/custom_forms/views/custom_forms_plugin_profile/review.html.erb
=====================================
--- a/plugins/custom_forms/views/custom_forms_plugin_profile/review.html.erb
+++ b/plugins/custom_forms/views/custom_forms_plugin_profile/review.html.erb
@@ -3,7 +3,7 @@
 
   <div class="query-header">
     <i class="fa fa-hourglass" aria-hidden="true"></i>
-      <span><%= @form.duration_in_days %></span>
+      <span><%= time_status(@form) %></span>
     <span class="bullet">•</span>
     <i class="fa fa-users" aria-hidden="true"></i>
     <span><%= _(pluralize(@form.submissions.count, 'participant')) %></span>



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/e3abfab53d341500d39ebd25c78386843435d356...a25503b61fa8e41c4c076031f2195518d40f134e

-- 
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/e3abfab53d341500d39ebd25c78386843435d356...a25503b61fa8e41c4c076031f2195518d40f134e
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180528/e2de6ba7/attachment-0001.html>


More information about the Noosfero-dev mailing list