Commit fc1161f0b9295e609c43f65dda016bb2d3272aa8

Authored by Luciano Prestes
1 parent c74fdadd
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Create new Institution's attribute to register the last modification date

Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Sygned-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
controllers/mpog_software_plugin_controller.rb
1 1 require 'csv'
2 2 class MpogSoftwarePluginController < ApplicationController
  3 + include InstitutionHelper
3 4  
4 5 def archive_software
5 6 per_page = 10
... ... @@ -158,6 +159,8 @@ class MpogSoftwarePluginController &lt; ApplicationController
158 159 institution.name = community[:name]
159 160 institution.community = community
160 161  
  162 + InstitutionHelper.register_institution_modification institution
  163 +
161 164 if institution.type == "PublicInstitution"
162 165 begin
163 166 govPower = GovernmentalPower.find params[:governmental][:power]
... ...
db/migrate/20140815194530_register_institution_modification.rb
1 1 class RegisterInstitutionModification < ActiveRecord::Migration
2 2 def up
  3 + change_table :institutions do |t|
  4 + t.string :date_modification
  5 + end
3 6 end
4 7  
5 8 def down
  9 + change_table :institutions do |t|
  10 + t.remove :date_modification
  11 + end
6 12 end
7 13 end
... ...
lib/institution_helper.rb
... ... @@ -47,6 +47,10 @@ module InstitutionHelper
47 47 end
48 48 end
49 49  
  50 + def self.register_institution_modification institution
  51 + institution.date_modification = current_date
  52 + end
  53 +
50 54 protected
51 55  
52 56 def self.web_service_info
... ... @@ -96,4 +100,9 @@ module InstitutionHelper
96 100 institution.governmental_sphere = GovernmentalSphere.where(:name=>self.retrieve_code(unit,"codigoEsfera")).first
97 101 institution
98 102 end
  103 +
  104 + def self.current_date
  105 + date = Time.now.day.to_s + "/" + Time.now.month.to_s + "/" + Time.now.year.to_s
  106 + date
  107 + end
99 108 end
... ...
lib/mpog_software_plugin.rb
... ... @@ -6,6 +6,7 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
6 6 include ActionView::Helpers::AssetTagHelper
7 7 include FormsHelper
8 8 include LibraryHelper
  9 + include InstitutionHelper
9 10  
10 11 def self.plugin_name
11 12 "MpogSoftwarePlugin"
... ... @@ -246,6 +247,7 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
246 247 def institution_transaction
247 248 if context.params.has_key?(:governmental_power)
248 249 context.profile.institution.governmental_power_id = context.params[:governmental_power]
  250 + InstitutionHelper.register_institution_modification context.profile.institution
249 251 context.profile.institution.save!
250 252 end
251 253  
... ...
test/unit/institution_helper_test.rb 0 → 100644
... ... @@ -0,0 +1,26 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +
  3 +class InstitutionHelperTest < ActiveSupport::TestCase
  4 +
  5 + should "populate public institutions with data from SIORG" do
  6 + Institution.destroy_all
  7 +
  8 + InstitutionHelper.mass_update
  9 +
  10 + assert Institution.count != 0
  11 + end
  12 +
  13 + should "receive json data from SIORG" do
  14 + data = InstitutionHelper.get_json(2, 1)
  15 +
  16 + assert data["unidades"].count != 0
  17 + end
  18 +
  19 + should "update Institution's date modification when edit the Institution" do
  20 + institution = Institution.new
  21 + InstitutionHelper.register_institution_modification institution
  22 + date = Time.now.day.to_s + "/" + Time.now.month.to_s + "/" + Time.now.year.to_s
  23 +
  24 + assert_equal date, institution.date_modification
  25 + end
  26 +end
... ...
views/profile/_institution_tab.html.erb
... ... @@ -5,6 +5,7 @@
5 5  
6 6 <%= display_field(_('Type:'), profile.institution, :type, true) %>
7 7 <%= display_field(_('CNPJ:'), profile.institution, :cnpj, true) %>
  8 + <%= display_field(_('Last modification:'), profile.institution, :date_modification, true) %>
8 9 <% if profile.institution.type == "PrivateInstitution"%>
9 10 <%= display_field(_('Fantasy Name:'), profile.institution, :acronym, true) %>
10 11 <% else %>
... ...