From 5c62082bf4c4dbc2a955c8af6a9942b4c46303ad Mon Sep 17 00:00:00 2001 From: Fabio Teixeira Date: Thu, 17 Jul 2014 16:04:02 -0300 Subject: [PATCH] Change mpog_plugin to its own repository --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/update_institutions | 6 ++++++ config/institutions_update.example | 4 ++++ config/siorg.yml | 9 +++++++++ controllers/mpog_software_plugin_controller.rb | 205 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ controllers/mpog_software_plugin_myprofile_controller.rb | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ db/migrate/20140523132016_create_controlled_vocabulary_table.rb | 35 +++++++++++++++++++++++++++++++++++ db/migrate/20140528193816_add_extra_fields_to_user.rb | 17 +++++++++++++++++ db/migrate/20140528193835_create_institutions_table.rb | 13 +++++++++++++ db/migrate/20140528193902_create_license_infos_table.rb | 13 +++++++++++++ db/migrate/20140528193905_create_software_infos_table.rb | 23 +++++++++++++++++++++++ db/migrate/20140528193927_create_libraries_table.rb | 14 ++++++++++++++ db/migrate/20140528193956_create_programming_languages_table.rb | 13 +++++++++++++ db/migrate/20140528194044_create_database_descriptions_table.rb | 13 +++++++++++++ db/migrate/20140528194129_create_software_databases_table.rb | 14 ++++++++++++++ db/migrate/20140528211914_create_software_languages_table.rb | 14 ++++++++++++++ db/migrate/20140617125143_add_new_fields_institution.rb | 27 +++++++++++++++++++++++++++ db/migrate/20140617132133_create_governmental_spheres.rb | 11 +++++++++++ db/migrate/20140617132451_create_governmental_powers.rb | 11 +++++++++++ db/migrate/20140617134556_add_references_to_institution.rb | 15 +++++++++++++++ db/migrate/20140630183326_add_relation_between_community_and_institution.rb | 13 +++++++++++++ db/migrate/20140710185444_create_operating_system_table.rb | 13 +++++++++++++ db/migrate/20140711144012_remove_name_from_software_info.rb | 9 +++++++++ db/migrate/20140714133901_create_operating_name_table.rb | 13 +++++++++++++ db/migrate/20140714135007_change_operating_systems_table.rb | 16 ++++++++++++++++ features/instution_field.feature | 21 +++++++++++++++++++++ features/logic_delete.feature | 44 ++++++++++++++++++++++++++++++++++++++++++++ features/manage_software.feature | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ features/search_people.feature | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ features/software_info_validation.feature | 435 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ features/step_definitions/mpog_steps.rb | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ features/user_registration.feature | 310 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/database_description.rb | 10 ++++++++++ lib/database_helper.rb | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/ext/community.rb | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/ext/controlled_vocabulary.rb | 12 ++++++++++++ lib/ext/person.rb | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/ext/user.rb | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/governmental_power.rb | 10 ++++++++++ lib/governmental_sphere.rb | 7 +++++++ lib/institution.rb | 30 ++++++++++++++++++++++++++++++ lib/institution_helper.rb | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/library.rb | 22 ++++++++++++++++++++++ lib/library_helper.rb | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/license_helper.rb | 7 +++++++ lib/license_info.rb | 8 ++++++++ lib/mpog_software_plugin.rb | 346 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/operating_system.rb | 8 ++++++++ lib/operating_system_helper.rb | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/operating_system_name.rb | 10 ++++++++++ lib/private_institution.rb | 4 ++++ lib/programming_language.rb | 10 ++++++++++ lib/public_institution.rb | 5 +++++ lib/software_database.rb | 9 +++++++++ lib/software_helper.rb | 41 +++++++++++++++++++++++++++++++++++++++++ lib/software_info.rb | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/software_language.rb | 8 ++++++++ lib/software_language_helper.rb | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/mpog-institution-validations.js | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/mpog-software-validations.js | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/mpog-user-validations.js | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/mpog_custom_functions.js | 16 ++++++++++++++++ public/static/databases.txt | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/static/governmental_powers.txt | 3 +++ public/static/governmental_sphere.txt | 1 + public/static/languages.txt | 673 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/static/operating_systems.txt | 9 +++++++++ public/style.css | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ script/schedule_institution_update.sh | 4 ++++ test/functional/account_controller_test.rb | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/functional/mpog_software_plugin_controller_test.rb | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/unit/controlled_vocabulary_test.rb | 47 +++++++++++++++++++++++++++++++++++++++++++++++ test/unit/database_helper_test.rb | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/unit/database_validation_test.rb | 36 ++++++++++++++++++++++++++++++++++++ test/unit/governmental_power_test.rb | 45 +++++++++++++++++++++++++++++++++++++++++++++ test/unit/institution_helper_test.rb | 18 ++++++++++++++++++ test/unit/institution_test.rb | 16 ++++++++++++++++ test/unit/library_helper_test.rb | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ test/unit/library_validation_test.rb | 34 ++++++++++++++++++++++++++++++++++ test/unit/mpog_software_plugin_test.rb | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/unit/mpog_user_test.rb | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/unit/mpog_validation_test.rb | 41 +++++++++++++++++++++++++++++++++++++++++ test/unit/operating_system_helper_test.rb | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/unit/operating_system_validation_test.rb | 26 ++++++++++++++++++++++++++ test/unit/private_institution_test.rb | 25 +++++++++++++++++++++++++ test/unit/public_institution_test.rb | 38 ++++++++++++++++++++++++++++++++++++++ test/unit/search_person_test.rb | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/unit/software_helper_test.rb | 18 ++++++++++++++++++ test/unit/software_info_validation_test.rb | 47 +++++++++++++++++++++++++++++++++++++++++++++++ test/unit/software_language_validation.rb | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ views/institution_editor_extras.html.erb | 31 +++++++++++++++++++++++++++++++ views/mpog_software_plugin/_index_buttons.html.erb | 5 +++++ views/mpog_software_plugin/_software_list.html.erb | 31 +++++++++++++++++++++++++++++++ views/mpog_software_plugin/_softwares_search_form.html.erb | 6 ++++++ views/mpog_software_plugin/archive_software.html.erb | 13 +++++++++++++ views/mpog_software_plugin/create_institution.html.erb | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ views/mpog_software_plugin_myprofile/_database_fields.html.erb | 11 +++++++++++ views/mpog_software_plugin_myprofile/_language_fields.html.erb | 11 +++++++++++ views/mpog_software_plugin_myprofile/_library_fields.html.erb | 11 +++++++++++ views/mpog_software_plugin_myprofile/_operating_system_fields.html.erb | 11 +++++++++++ views/mpog_software_plugin_myprofile/new_software.html.erb | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ views/person_editor_extras.html.erb | 37 +++++++++++++++++++++++++++++++++++++ views/profile/_institution_tab.html.erb | 15 +++++++++++++++ views/profile/_profile_tab.html.erb | 10 ++++++++++ views/profile/_software_tab.html.erb | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ views/software_editor_extras.html.erb | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ views/software_editor_extras.rhtml | 35 +++++++++++++++++++++++++++++++++++ views/user_search/search_filter.html.erb | 35 +++++++++++++++++++++++++++++++++++ 108 files changed, 6300 insertions(+), 0 deletions(-) create mode 100644 README.md create mode 100644 bin/update_institutions create mode 100644 config/institutions_update.example create mode 100644 config/siorg.yml create mode 100644 controllers/mpog_software_plugin_controller.rb create mode 100644 controllers/mpog_software_plugin_myprofile_controller.rb create mode 100644 db/migrate/20140523132016_create_controlled_vocabulary_table.rb create mode 100644 db/migrate/20140528193816_add_extra_fields_to_user.rb create mode 100644 db/migrate/20140528193835_create_institutions_table.rb create mode 100644 db/migrate/20140528193902_create_license_infos_table.rb create mode 100644 db/migrate/20140528193905_create_software_infos_table.rb create mode 100644 db/migrate/20140528193927_create_libraries_table.rb create mode 100644 db/migrate/20140528193956_create_programming_languages_table.rb create mode 100644 db/migrate/20140528194044_create_database_descriptions_table.rb create mode 100644 db/migrate/20140528194129_create_software_databases_table.rb create mode 100644 db/migrate/20140528211914_create_software_languages_table.rb create mode 100644 db/migrate/20140617125143_add_new_fields_institution.rb create mode 100644 db/migrate/20140617132133_create_governmental_spheres.rb create mode 100644 db/migrate/20140617132451_create_governmental_powers.rb create mode 100644 db/migrate/20140617134556_add_references_to_institution.rb create mode 100644 db/migrate/20140630183326_add_relation_between_community_and_institution.rb create mode 100644 db/migrate/20140710185444_create_operating_system_table.rb create mode 100644 db/migrate/20140711144012_remove_name_from_software_info.rb create mode 100644 db/migrate/20140714133901_create_operating_name_table.rb create mode 100644 db/migrate/20140714135007_change_operating_systems_table.rb create mode 100644 features/instution_field.feature create mode 100644 features/logic_delete.feature create mode 100644 features/manage_software.feature create mode 100644 features/search_people.feature create mode 100644 features/software_info_validation.feature create mode 100644 features/step_definitions/mpog_steps.rb create mode 100644 features/user_registration.feature create mode 100644 lib/database_description.rb create mode 100644 lib/database_helper.rb create mode 100644 lib/ext/community.rb create mode 100644 lib/ext/controlled_vocabulary.rb create mode 100644 lib/ext/person.rb create mode 100644 lib/ext/user.rb create mode 100644 lib/governmental_power.rb create mode 100644 lib/governmental_sphere.rb create mode 100644 lib/institution.rb create mode 100644 lib/institution_helper.rb create mode 100644 lib/library.rb create mode 100644 lib/library_helper.rb create mode 100644 lib/license_helper.rb create mode 100644 lib/license_info.rb create mode 100644 lib/mpog_software_plugin.rb create mode 100644 lib/operating_system.rb create mode 100644 lib/operating_system_helper.rb create mode 100644 lib/operating_system_name.rb create mode 100644 lib/private_institution.rb create mode 100644 lib/programming_language.rb create mode 100644 lib/public_institution.rb create mode 100644 lib/software_database.rb create mode 100644 lib/software_helper.rb create mode 100644 lib/software_info.rb create mode 100644 lib/software_language.rb create mode 100644 lib/software_language_helper.rb create mode 100644 public/mpog-institution-validations.js create mode 100644 public/mpog-software-validations.js create mode 100644 public/mpog-user-validations.js create mode 100644 public/mpog_custom_functions.js create mode 100644 public/static/databases.txt create mode 100644 public/static/governmental_powers.txt create mode 100644 public/static/governmental_sphere.txt create mode 100644 public/static/languages.txt create mode 100644 public/static/operating_systems.txt create mode 100644 public/style.css create mode 100755 script/schedule_institution_update.sh create mode 100644 test/functional/account_controller_test.rb create mode 100644 test/functional/mpog_software_plugin_controller_test.rb create mode 100644 test/unit/controlled_vocabulary_test.rb create mode 100644 test/unit/database_helper_test.rb create mode 100644 test/unit/database_validation_test.rb create mode 100644 test/unit/governmental_power_test.rb create mode 100644 test/unit/institution_helper_test.rb create mode 100644 test/unit/institution_test.rb create mode 100644 test/unit/library_helper_test.rb create mode 100644 test/unit/library_validation_test.rb create mode 100644 test/unit/mpog_software_plugin_test.rb create mode 100644 test/unit/mpog_user_test.rb create mode 100644 test/unit/mpog_validation_test.rb create mode 100644 test/unit/operating_system_helper_test.rb create mode 100644 test/unit/operating_system_validation_test.rb create mode 100644 test/unit/private_institution_test.rb create mode 100644 test/unit/public_institution_test.rb create mode 100644 test/unit/search_person_test.rb create mode 100644 test/unit/software_helper_test.rb create mode 100644 test/unit/software_info_validation_test.rb create mode 100644 test/unit/software_language_validation.rb create mode 100644 views/institution_editor_extras.html.erb create mode 100644 views/mpog_software_plugin/_index_buttons.html.erb create mode 100644 views/mpog_software_plugin/_software_list.html.erb create mode 100644 views/mpog_software_plugin/_softwares_search_form.html.erb create mode 100644 views/mpog_software_plugin/archive_software.html.erb create mode 100644 views/mpog_software_plugin/create_institution.html.erb create mode 100644 views/mpog_software_plugin_myprofile/_database_fields.html.erb create mode 100644 views/mpog_software_plugin_myprofile/_language_fields.html.erb create mode 100644 views/mpog_software_plugin_myprofile/_library_fields.html.erb create mode 100644 views/mpog_software_plugin_myprofile/_operating_system_fields.html.erb create mode 100644 views/mpog_software_plugin_myprofile/new_software.html.erb create mode 100644 views/person_editor_extras.html.erb create mode 100644 views/profile/_institution_tab.html.erb create mode 100644 views/profile/_profile_tab.html.erb create mode 100644 views/profile/_software_tab.html.erb create mode 100644 views/software_editor_extras.html.erb create mode 100644 views/software_editor_extras.rhtml create mode 100644 views/user_search/search_filter.html.erb diff --git a/README.md b/README.md new file mode 100644 index 0000000..9aaa510 --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +README - MPOG Software Público Plugin +================================ + +MPOG Software Público Plugin is a plugin that includes features to Novo Portal do Software Público Brasileiro (SPB). + +More information about SPB: https://www.participa.br/softwarepublico + +INSTALL +======= + +Enable Plugin +------------- + +Also, you need to enable MPOG Software Plugin on your Noosfero: + +cd +./script/noosfero-plugins enable mpog_software + +Activate Plugin +--------------- + +As a Noosfero administrator user, go to administrator panel: + +- Click on "Enable/disable plugins" option +- Click on "MPOG Software Plugin" check-box + +Schedule Institutions Update +---------------------------- + +./plugins/mpog_software/script/schedule_institution_update.sh + + +Running MPOG Software tests +-------------------- +$ ruby plugins/mpog_software/test/unit/name_of_file.rb +$ cucumber plugins/mpog_software/features/ + +Get Involved +============ + +If you find any bug and/or want to collaborate, please send an e-mail to arthurmde@gmail.com + +LICENSE +======= + +Copyright (c) The Author developers. + +See Noosfero license. + + +AUTHORS +======= + +Alex Campelo (campelo.al1 at gmail.com) +Arthur de Moura Del Esposte (arthurmde at gmail.com) +Daniel Bucher (daniel.bucher88 at gmail.com) +David Carlos (ddavidcarlos1392 at gmail.com) +Fabio Teixeira (fabio1079 at gmail.com) +Gustavo Jaruga (darksshades at gmail.com) +Luciano Prestes (lucianopcbr at gmail.com) +Matheus Faria (matheus.sousa.faria at gmail.com) + + +ACKNOWLEDGMENTS +=============== + +The authors have been supported by MPOG and UnB diff --git a/bin/update_institutions b/bin/update_institutions new file mode 100644 index 0000000..9cbc71a --- /dev/null +++ b/bin/update_institutions @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +# encoding: utf-8 +require "net/http" +include InstitutionHelper + +InstitutionHelper.mass_update diff --git a/config/institutions_update.example b/config/institutions_update.example new file mode 100644 index 0000000..5f73ecc --- /dev/null +++ b/config/institutions_update.example @@ -0,0 +1,4 @@ +# This file is an example for a crontab file used to update insitutions from +# the web service, SIORG. + +@weekly root cd /usr/share/noosfero && rails runner plugins/mpog_software/bin/update_institutions diff --git a/config/siorg.yml b/config/siorg.yml new file mode 100644 index 0000000..a0b1aad --- /dev/null +++ b/config/siorg.yml @@ -0,0 +1,9 @@ +web_service: + base_url: http://estruturaorganizacional.dados.gov.br/doc/estrutura-organizacional/resumida.json + sphere_codes: + federal: 1 + power_codes: + executive: 1 + legislative: 2 + judiciary: 3 + additional_params: retornarOrgaoEntidadeVinculados=NAO diff --git a/controllers/mpog_software_plugin_controller.rb b/controllers/mpog_software_plugin_controller.rb new file mode 100644 index 0000000..3d61316 --- /dev/null +++ b/controllers/mpog_software_plugin_controller.rb @@ -0,0 +1,205 @@ +require 'csv' +class MpogSoftwarePluginController < ApplicationController + + def archive_software + per_page = 10 + scope = SoftwareInfo + @q = params[:q] + @collection = find_by_contents(:community, scope, @q, {:per_page => per_page, :page => params[:npage]})[:results] + end + + def deactivate + community = SoftwareInfo.find(params[:id]).community_id + Community.find(community).deactivate + if params[:from_profile] + redirect_to :back + else + redirect_to :action => 'archive_software' + end + end + + def activate + community = SoftwareInfo.find(params[:id]).community_id + Community.find(community).activate + redirect_to :action => 'archive_software' + end + + def check_reactivate_account + if request.xhr? and params[:email] + result = "" + user = User.where(:email => params[:email]) + + if user.length == 1 + result = " Reactive account" unless user[0].person.visible + end + + render :json => result.to_json + end + end + + def get_institutions + list = [] + + if request.xhr? and params[:query] + list = Institution.search_institution(params[:query]).map{ |institution| + {:value=>institution.name, :id=>institution.id} + } + end + + render :json => list.to_json + end + + def hide_registration_incomplete_percentage + response = false + + if request.xhr? and params[:hide] + session[:hide_incomplete_percentage] = true + response = session[:hide_incomplete_percentage] + end + + render :json=>response.to_json + end + + def create_institution + if request.xhr? + render :layout=>false + else + redirect_to "/" + end + end + + def new_institution + if request.xhr? and !params[:community].nil? and !params[:institution].nil? and !params[:recaptcha_response_field].nil? + response_message = {} + + institution = create_institution + + response_message = if verify_recaptcha(:model=> institution, :message => _('Please type the word correctly')) + if institution.errors.full_messages.empty? and institution.valid? and institution.save + {:success => true, :message => _("Institution successful created!"), :institution_data=>{:name=>institution.name, :id=>institution.id}} + else + {:success => false, :message => _("Institution could not be created!"), :errors => institution.errors.full_messages} + end + else + {:success => false, :message=>_('Please type the image text correctly'), :errors=>[]} + end + + render :json => response_message.to_json + else + redirect_to "/" + end + end + + def institution_already_exists + if request.xhr? and !params[:name].nil? + already_exists = !Community.where(:name=>params[:name]).empty? + + render :json=>already_exists.to_json + else + redirect_to "/" + end + end + + def download + respond_to do |format| + format.html + format.xml do + softwares = software_list_to_correct_format(SoftwareInfo.all) + send_data softwares.to_xml( + :skip_types => true, + :only => %w[name acronym demonstration_url e_arq e_mag e_ping features icp_brasil objectives operating_platform languages_list database_list]), + :type => 'text/xml', + :disposition => "attachment; filename=softwares.xml" + end + + format.csv do + softwares = software_list_to_correct_format(SoftwareInfo.all) + csv_content = "" + softwares.each { |s| + csv_content << "name;acronym;demonstration_url;e_arq;e_mag;e_ping;features;icp_brasil;objectives;operating_platform\n" + csv_content << CSV.generate_line([s['name'], s['acronym'], s['demonstration_url'], s['e_arq'], s['e_mag'], s['e_ping'], s['features'], s['icp_brasil'], s['objectives'], s['operating_platform']], {:col_sep => ';'}) + + csv_content << "\nlanguage_name;language_version;language_operating_system\n" + s[:languages_list].each { |sl| + csv_content << CSV.generate_line([sl[:name], sl[:version], sl[:operating_system]], {:col_sep => ';'}) + } + + csv_content << "\ndatabase_name;database_version;database_operating_system\n" + s[:database_list].each { |dl| + csv_content << CSV.generate_line([dl[:name], dl[:version], dl[:operating_system]], {:col_sep => ';'}) + } + + csv_content << "\n\n" + } + if csv_content.blank? + csv_content = "name;acronym;demonstration_url;e_arq;e_mag;e_ping;features;icp_brasil;objectives;operating_platform\n" + end + + render :text => csv_content, :content_type => 'text/csv', :layout => false + end + end + end + + + protected + + def create_institution + community = Community.new(params[:community]) + community.environment = environment + + institution = if params[:institution][:type] == "PublicInstitution" + PublicInstitution::new params[:institution] + else + PrivateInstitution::new params[:institution] + end + + institution.name = community[:name] + institution.community = community + + if institution.type == "PublicInstitution" + begin + govPower = GovernmentalPower.find params[:governmental][:power] + govSphere = GovernmentalSphere.find params[:governmental][:sphere] + + institution.governmental_power = govPower + institution.governmental_sphere = govSphere + rescue + institution.errors.add(:governmental_fields, _("Could not find Governmental Power or Governmental Sphere")) + end + end + + if institution.cnpj.nil? or institution.cnpj.blank? + institution.errors.add(:cnpj, _("can't be blank")) + end + + institution + end + + def software_list_to_correct_format software_list=[] + if !software_list.empty? + software_list.each do |software| + software[:name] = Community.find(software.community_id).name + software[:languages_list] = [] + + software.software_languages.each do |sl| + software[:languages_list] << {} + index = software[:languages_list].count - 1 + software[:languages_list][index][:name] = ProgrammingLanguage.find(sl.programming_language_id).name + software[:languages_list][index][:version] = sl.version + software[:languages_list][index][:operating_system] = sl.operating_system + end + + software[:database_list] = [] + software.software_databases.each do |dd| + software[:database_list] << {} + index = software[:database_list].count - 1 + software[:database_list][index][:name] = DatabaseDescription.find(dd.database_description_id).name + software[:database_list][index][:version] = dd.version + software[:database_list][index][:operating_system] = dd.operating_system + end + end + end + software_list + end + +end diff --git a/controllers/mpog_software_plugin_myprofile_controller.rb b/controllers/mpog_software_plugin_myprofile_controller.rb new file mode 100644 index 0000000..e15bb64 --- /dev/null +++ b/controllers/mpog_software_plugin_myprofile_controller.rb @@ -0,0 +1,85 @@ +class MpogSoftwarePluginMyprofileController < MyProfileController + append_view_path File.join(File.dirname(__FILE__) + '/../views') + + def index + end + + def archive_software + puts "="*80 + nil + end + + def new_software + @errors = [] + @community = Community.new(params[:community]) + @community.environment = environment + @software_info = SoftwareInfo.new(params[:software_info]) + @list_libraries = LibraryHelper.list_libraries(params[:library]) + @list_languages = SoftwareLanguageHelper.list_language(params[:language]) + @list_databases = DatabaseHelper.list_database(params[:database]) + @controlled_vocabulary = ControlledVocabulary::new params[:controlled_vocabulary] + @list_operating_systems = OperatingSystemHelper.list_operating_system(params[:operating_system]) + @license_info = if params[:license_info].nil? + LicenseInfo::new + else + LicenseInfo.find(:first, :conditions=>"id = #{params[:license_info][:version]}") + end + + if not @list_libraries.nil? + @list_libraries.each do |library| + @software_info.libraries << library + end + end + + if not @list_languages.nil? + @list_languages.each do |language| + @software_info.software_languages << language + end + end + + if not @list_databases.nil? + @list_databases.each do |database| + @software_info.software_databases << database + end + end + + if not @list_operating_systems.nil? + @list_operating_systems.each do |operating_system| + @software_info.operating_systems << operating_system + end + end + + valid_community = request.post? && @community.valid? + valid_software_info = request.post? && @software_info.valid? + valid_license = (request.post? && @license_info.valid?) + valid_libraries = @list_libraries.empty? || LibraryHelper.valid_list_libraries?(@list_libraries) + valid_database = DatabaseHelper.valid_list_database?(@list_databases) + valid_language = SoftwareLanguageHelper.valid_list_language?(@list_languages) + valid_operating_system = OperatingSystemHelper.valid_list_operating_system?(@list_operating_systems) + + if valid_software_info && valid_community && valid_libraries && valid_license && valid_language && valid_database && valid_operating_system + @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info, @controlled_vocabulary) + redirect_to :controller => 'memberships', :action => 'index' + else + @list_libraries.each do |lib| + @errors |= lib.errors.full_messages + end + + @list_languages.each do |lng| + @errors |= lng.errors.full_messages + end + + @list_databases.each do |db| + @errors |= db.errors.full_messages + end + + @list_operating_systems.each do |os| + @errors |= os.errors.full_messages + end + @errors |= @community.errors.full_messages + @errors |= @software_info.errors.full_messages + @errors |= @license_info.errors.full_messages + end + end + +end diff --git a/db/migrate/20140523132016_create_controlled_vocabulary_table.rb b/db/migrate/20140523132016_create_controlled_vocabulary_table.rb new file mode 100644 index 0000000..c5a8964 --- /dev/null +++ b/db/migrate/20140523132016_create_controlled_vocabulary_table.rb @@ -0,0 +1,35 @@ +class CreateControlledVocabularyTable < ActiveRecord::Migration + def up + create_table :controlled_vocabulary do |t| + t.references :software_info + t.boolean :administration + t.boolean :agriculture + t.boolean :business_and_services + t.boolean :communication + t.boolean :culture + t.boolean :national_defense + t.boolean :economy_and_finances + t.boolean :education + t.boolean :energy + t.boolean :sports + t.boolean :habitation + t.boolean :industry + t.boolean :environment + t.boolean :research_and_development + t.boolean :social_security + t.boolean :social_protection + t.boolean :international_relations + t.boolean :sanitation + t.boolean :health + t.boolean :security_public_order + t.boolean :work + t.boolean :transportation + t.boolean :urbanism + + end + end + + def down + drop_table :controlled_vocabulary + end +end diff --git a/db/migrate/20140528193816_add_extra_fields_to_user.rb b/db/migrate/20140528193816_add_extra_fields_to_user.rb new file mode 100644 index 0000000..087fc62 --- /dev/null +++ b/db/migrate/20140528193816_add_extra_fields_to_user.rb @@ -0,0 +1,17 @@ +class AddExtraFieldsToUser < ActiveRecord::Migration + def self.up + change_table :users do |t| + t.string :secondary_email + t.references :institution + t.string :role + end + end + + def self.down + change_table :users do |t| + t.remove :secondary_email + t.remove_references :institution + t.remove :role + end + end +end diff --git a/db/migrate/20140528193835_create_institutions_table.rb b/db/migrate/20140528193835_create_institutions_table.rb new file mode 100644 index 0000000..294c791 --- /dev/null +++ b/db/migrate/20140528193835_create_institutions_table.rb @@ -0,0 +1,13 @@ +class CreateInstitutionsTable < ActiveRecord::Migration + def self.up + create_table :institutions do |t| + t.string :name + + t.timestamps + end + end + + def self.down + drop_table :institutions + end +end diff --git a/db/migrate/20140528193902_create_license_infos_table.rb b/db/migrate/20140528193902_create_license_infos_table.rb new file mode 100644 index 0000000..89fa231 --- /dev/null +++ b/db/migrate/20140528193902_create_license_infos_table.rb @@ -0,0 +1,13 @@ +class CreateLicenseInfosTable < ActiveRecord::Migration + def self.up + create_table :license_infos do |t| + t.string :version + t.string :link + end + LicenseInfo.create(:version=>"CC-GPL-V2", :link=>"http://creativecommons.org/licenses/GPL/2.0/legalcode.pt") + end + + def self.down + drop_table :license_infos + end +end diff --git a/db/migrate/20140528193905_create_software_infos_table.rb b/db/migrate/20140528193905_create_software_infos_table.rb new file mode 100644 index 0000000..0f21241 --- /dev/null +++ b/db/migrate/20140528193905_create_software_infos_table.rb @@ -0,0 +1,23 @@ +class CreateSoftwareInfosTable < ActiveRecord::Migration + def self.up + create_table :software_infos do |t| + t.references :license_info + t.references :community + t.boolean :e_mag, :default => false + t.boolean :icp_brasil,:default => false + t.boolean :intern, :default => false + t.boolean :e_ping, :default => false + t.boolean :e_arq, :default => false + t.string :name, :default => ' ' + t.string :operating_platform + t.string :demonstration_url + t.string :acronym + t.text :objectives + t.text :features + end + end + + def self.down + drop_table :software_infos + end +end diff --git a/db/migrate/20140528193927_create_libraries_table.rb b/db/migrate/20140528193927_create_libraries_table.rb new file mode 100644 index 0000000..3200454 --- /dev/null +++ b/db/migrate/20140528193927_create_libraries_table.rb @@ -0,0 +1,14 @@ +class CreateLibrariesTable < ActiveRecord::Migration + def self.up + create_table :libraries do |t| + t.string :name + t.string :version + t.string :license + t.references :software_info + end + end + + def self.down + drop_table :libraries + end +end diff --git a/db/migrate/20140528193956_create_programming_languages_table.rb b/db/migrate/20140528193956_create_programming_languages_table.rb new file mode 100644 index 0000000..0413a37 --- /dev/null +++ b/db/migrate/20140528193956_create_programming_languages_table.rb @@ -0,0 +1,13 @@ +class CreateProgrammingLanguagesTable < ActiveRecord::Migration + def self.up + create_table :programming_languages do |t| + t.string :name + end + + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/languages.txt", ProgrammingLanguage) + end + + def self.down + drop_table :programming_languages + end +end diff --git a/db/migrate/20140528194044_create_database_descriptions_table.rb b/db/migrate/20140528194044_create_database_descriptions_table.rb new file mode 100644 index 0000000..e887295 --- /dev/null +++ b/db/migrate/20140528194044_create_database_descriptions_table.rb @@ -0,0 +1,13 @@ +class CreateDatabaseDescriptionsTable < ActiveRecord::Migration + def self.up + create_table :database_descriptions do |t| + t.string :name + end + + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/databases.txt", DatabaseDescription) + end + + def self.down + drop_table :database_descriptions + end +end diff --git a/db/migrate/20140528194129_create_software_databases_table.rb b/db/migrate/20140528194129_create_software_databases_table.rb new file mode 100644 index 0000000..a70c4b7 --- /dev/null +++ b/db/migrate/20140528194129_create_software_databases_table.rb @@ -0,0 +1,14 @@ +class CreateSoftwareDatabasesTable < ActiveRecord::Migration + def self.up + create_table :software_databases do |t| + t.string :version + t.string :operating_system + t.references :database_description + t.references :software_info + end + end + + def self.down + drop_table :software_databases + end +end diff --git a/db/migrate/20140528211914_create_software_languages_table.rb b/db/migrate/20140528211914_create_software_languages_table.rb new file mode 100644 index 0000000..b08a37c --- /dev/null +++ b/db/migrate/20140528211914_create_software_languages_table.rb @@ -0,0 +1,14 @@ +class CreateSoftwareLanguagesTable < ActiveRecord::Migration + def self.up + create_table :software_languages do |t| + t.references :software_info + t.references :programming_language + t.string :version + t.string :operating_system + end + end + + def self.down + drop_table :software_languages + end +end diff --git a/db/migrate/20140617125143_add_new_fields_institution.rb b/db/migrate/20140617125143_add_new_fields_institution.rb new file mode 100644 index 0000000..70ecf88 --- /dev/null +++ b/db/migrate/20140617125143_add_new_fields_institution.rb @@ -0,0 +1,27 @@ +class AddNewFieldsInstitution < ActiveRecord::Migration + def up + add_column :institutions, :acronym, :string + add_column :institutions, :unit_code, :integer + add_column :institutions, :parent_code, :integer + add_column :institutions, :unit_type, :string + add_column :institutions, :juridical_nature, :string + add_column :institutions, :sub_juridical_nature, :string + add_column :institutions, :normalization_level, :string + add_column :institutions, :version, :string + add_column :institutions, :cnpj, :string + add_column :institutions, :type, :string + end + + def down + remove_column :institutions, :acronym + remove_column :institutions, :unit_code + remove_column :institutions, :parent_code + remove_column :institutions, :unit_type + remove_column :institutions, :juridical_nature + remove_column :institutions, :sub_juridical_nature + remove_column :institutions, :normalization_level + remove_column :institutions, :version + remove_column :institutions, :cnpj + remove_column :institutions, :type + end +end diff --git a/db/migrate/20140617132133_create_governmental_spheres.rb b/db/migrate/20140617132133_create_governmental_spheres.rb new file mode 100644 index 0000000..0f0f710 --- /dev/null +++ b/db/migrate/20140617132133_create_governmental_spheres.rb @@ -0,0 +1,11 @@ +class CreateGovernmentalSpheres < ActiveRecord::Migration + def change + create_table :governmental_spheres do |t| + t.string :name + + t.timestamps + end + + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/governmental_sphere.txt", GovernmentalSphere) + end +end diff --git a/db/migrate/20140617132451_create_governmental_powers.rb b/db/migrate/20140617132451_create_governmental_powers.rb new file mode 100644 index 0000000..6d89894 --- /dev/null +++ b/db/migrate/20140617132451_create_governmental_powers.rb @@ -0,0 +1,11 @@ +class CreateGovernmentalPowers < ActiveRecord::Migration + def change + create_table :governmental_powers do |t| + t.string :name + + t.timestamps + end + + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/governmental_powers.txt", GovernmentalPower) + end +end diff --git a/db/migrate/20140617134556_add_references_to_institution.rb b/db/migrate/20140617134556_add_references_to_institution.rb new file mode 100644 index 0000000..e5203e1 --- /dev/null +++ b/db/migrate/20140617134556_add_references_to_institution.rb @@ -0,0 +1,15 @@ +class AddReferencesToInstitution < ActiveRecord::Migration + def up + change_table :institutions do |t| + t.references :governmental_power + t.references :governmental_sphere + end + end + + def down + change_table :institutions do |t| + t.remove_references :governmental_power + t.remove_references :governmental_sphere + end + end +end diff --git a/db/migrate/20140630183326_add_relation_between_community_and_institution.rb b/db/migrate/20140630183326_add_relation_between_community_and_institution.rb new file mode 100644 index 0000000..4dde5a9 --- /dev/null +++ b/db/migrate/20140630183326_add_relation_between_community_and_institution.rb @@ -0,0 +1,13 @@ +class AddRelationBetweenCommunityAndInstitution < ActiveRecord::Migration + def up + change_table :institutions do |t| + t.references :community + end + end + + def down + change_table :institutions do |t| + t.remove_references :community + end + end +end diff --git a/db/migrate/20140710185444_create_operating_system_table.rb b/db/migrate/20140710185444_create_operating_system_table.rb new file mode 100644 index 0000000..1d5bcdc --- /dev/null +++ b/db/migrate/20140710185444_create_operating_system_table.rb @@ -0,0 +1,13 @@ +class CreateOperatingSystemTable < ActiveRecord::Migration + def up + create_table :operating_systems do |t| + t.string :name + t.string :version + t.references :software_info + end + end + + def down + drop_table :operating_systems + end +end diff --git a/db/migrate/20140711144012_remove_name_from_software_info.rb b/db/migrate/20140711144012_remove_name_from_software_info.rb new file mode 100644 index 0000000..4a72d82 --- /dev/null +++ b/db/migrate/20140711144012_remove_name_from_software_info.rb @@ -0,0 +1,9 @@ +class RemoveNameFromSoftwareInfo < ActiveRecord::Migration + def up + remove_column :software_infos, :name + end + + def down + add_column :software_infos, :name, :string + end +end diff --git a/db/migrate/20140714133901_create_operating_name_table.rb b/db/migrate/20140714133901_create_operating_name_table.rb new file mode 100644 index 0000000..0cd23a5 --- /dev/null +++ b/db/migrate/20140714133901_create_operating_name_table.rb @@ -0,0 +1,13 @@ +class CreateOperatingNameTable < ActiveRecord::Migration + def up + create_table :operating_system_names do |t| + t.string :name + end + + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/operating_systems.txt", OperatingSystemName) + end + + def down + drop_table :operating_system_names + end +end diff --git a/db/migrate/20140714135007_change_operating_systems_table.rb b/db/migrate/20140714135007_change_operating_systems_table.rb new file mode 100644 index 0000000..98b843c --- /dev/null +++ b/db/migrate/20140714135007_change_operating_systems_table.rb @@ -0,0 +1,16 @@ +class ChangeOperatingSystemsTable < ActiveRecord::Migration + def up + change_table :operating_systems do |t| + t.remove :name + t.references :operating_system_name + end + + end + + def down + change_table :operating_systems do |t| + t.string :name + t.remove :operating_system_name_id + end + end +end diff --git a/features/instution_field.feature b/features/instution_field.feature new file mode 100644 index 0000000..ef1b22f --- /dev/null +++ b/features/instution_field.feature @@ -0,0 +1,21 @@ +Feature: Institution Field + As a user + I want to sign up resgistring my institution + So others users can use it + + Background: + Given "MpogSoftwarePlugin" plugin is enabled + And I am logged in as admin + And I go to /admin/plugins + And I check "MpogSoftwarePlugin" + And I press "Save changes" + And I go to /account/logout + + @selenium + Scenario: Show new institution field when another institution is selected + Given I go to /account/signup + When I select "Other" from "Institution" + And I should see "New Institution" + And I fill in "institution_name" with "Test Institution" + And I fill in "profile_data_name" with " " + Then I should see "Test Institution" within "#user_institution_id" diff --git a/features/logic_delete.feature b/features/logic_delete.feature new file mode 100644 index 0000000..363dc79 --- /dev/null +++ b/features/logic_delete.feature @@ -0,0 +1,44 @@ +Feature: deactivate user + As a user + I want to deactivate my account + So I can reactivate my account later + + Background: + Given "MpogSoftwarePlugin" plugin is enabled + And I am logged in as admin + And I go to /admin/plugins + And I check "MpogSoftwarePlugin" + And I press "Save changes" + And I go to /account/logout + And the following users + | login | name | email | + | joaosilva | Joao Silva | joaosilva@example.com | + And I am logged in as "joaosilva" + +@selenium + Scenario: successfull deactivation + Given I go to joaosilva's control panel + And I follow "Edit Profile" + And I follow "Delete profile" + And I follow "Yes, I am sure" + Then I am not logged in + When I go to /profile/joaosilva + Then I should see "This profile is inaccessible." + +@selenium + Scenario: successfull reactivation of account + Given I go to joaosilva's control panel + And I follow "Edit Profile" + And I follow "Delete profile" + And I follow "Yes, I am sure" + And I go to the homepage + When I follow "Login" + And I follow "New user" + And I fill in the following within ".no-boxes": + | e-Mail | joaosilva@example.com | + | Full name | 123 | + And I follow "Reactive account" + And I fill in the following within ".no-boxes": + | Username or Email | joaosilva@example.com | + And I press "Send instructions" + Then I should see "An e-mail was just sent to your e-mail address" diff --git a/features/manage_software.feature b/features/manage_software.feature new file mode 100644 index 0000000..06a4544 --- /dev/null +++ b/features/manage_software.feature @@ -0,0 +1,59 @@ +Feature: + As a administrator of a software + I want to manage it + + Background: + Given "MpogSoftwarePlugin" plugin is enabled + And I am logged in as admin + And I go to /admin/plugins + And I check "MpogSoftwarePlugin" + And I press "Save changes" + And SoftwareInfo has initial default values on database + + @selenium + Scenario: Deactivate a software + Given the following software language + | programing_language | version | operating_system | + | Python | 1.0 | Linux | + And the following software databases + | database_name | version | operating_system | + | PostgreSQL | 1.0 | Linux | + And the following softwares + | name | acronym | operating_platform | software_language | software_database | + | teste | ts | I dont know | Python | PostgreSQL | + And I go to /plugin/mpog_software/archive_software + And I should see "teste" + And I follow "Deactivate software" + And I confirm the "Do you want to deactivate this software?" dialog + And I go to /search/communities + And I fill in "search-input" with "teste" + And I press "Search" + Then I should not see "teste" within "search-profile-item" + + @selenium + Scenario: Activate a deactivated software + Given the following software language + | programing_language | version | operating_system | + | Python | 1.0 | Linux | + And the following software databases + | database_name | version | operating_system | + | PostgreSQL | 1.0 | Linux | + And the following softwares + | name | acronym | operating_platform | software_language | software_database | + | teste | ts | I dont know | Python | PostgreSQL | + And I go to /plugin/mpog_software/archive_software + And I should see "teste" + And I follow "Deactivate software" + And I confirm the "Do you want to deactivate this software?" dialog + And I go to /search/communities + And I fill in "search-input" with "teste" + And I press "Search" + And I should not see "Teste" within "search-profile-item" + And I go to /plugin/mpog_software/archive_software + And I should see "teste" + And I follow "Activate Software" + And I confirm the "Do you want to activate this software?" dialog + And I follow "Communities" + And I fill in "search-input" with "teste" + And I press "Search" + Then I should see "teste" within "search-profile-item" diff --git a/features/search_people.feature b/features/search_people.feature new file mode 100644 index 0000000..b26adc7 --- /dev/null +++ b/features/search_people.feature @@ -0,0 +1,62 @@ +Feature: Mpog Search People + As a user + I want to search for people with one or more filter options + So I can find another user + + Background: + Given "MpogSoftwarePlugin" plugin is enabled + And I am logged in as admin + And I go to /admin/plugins + And I check "MpogSoftwarePlugin" + And I press "Save changes" + And I go to /account/logout + And the following users + | login | name | state | city | email | + | josecunha | Jose Cunha | DF | Gama | jose.cunha@gmail.com | + | cunhajose | Cunha Jose | SP | Guarulhos | cunha.jose@gmail.com | + | joaoperera | Joao Perera | NY | New York | joao.perera@gmail.com | + | mariaperera | Maria Perera | NY | New York | maria.perera@gmail.com | + + Scenario: Search a person with name field + Given I go to /search/people + And I fill in "name" with "jo" + And I press "Search" + And I should see "Jose Cunha" + Then I should see "Joao Perera" + + Scenario: Search a person with a state field + Given I go to /search/people + And I fill in "state" with "DF" + And I press "Search" + Then I should see "Jose Cunha" + + Scenario: Search a person with a city field + Given I go to /search/people + And I fill in "city" with "Guarulhos" + And I press "Search" + Then I should see "Cunha Jose" + + Scenario: Search a person with a email field + Given I go to /search/people + And I fill in "email" with "jo" + And I press "Search" + And I should see "Jose Cunha" + And I should see "Cunha Jose" + Then I should see "Joao Perera" + + Scenario: Search a person with name and state fields + Given I go to /search/people + And I fill in "name" with "perera" + And I fill in "state" with "NY" + And I press "Search" + And I should see "Maria Perera" + Then I should see "Joao Perera" + + Scenario: Search a person with all fields + Given I go to /search/people + And I fill in "name" with "perera" + And I fill in "state" with "NY" + And I fill in "city" with "New" + And I fill in "email" with "joao" + And I press "Search" + Then I should see "Joao Perera" \ No newline at end of file diff --git a/features/software_info_validation.feature b/features/software_info_validation.feature new file mode 100644 index 0000000..2c51997 --- /dev/null +++ b/features/software_info_validation.feature @@ -0,0 +1,435 @@ +Feature: + As a user + I want to create a new software + + Background: + Given "MpogSoftwarePlugin" plugin is enabled + And SoftwareInfo has initial default values on database + And I am logged in as admin + And I go to /admin/plugins + And I check "MpogSoftwarePlugin" + And I press "Save changes" + + @selenium + Scenario: Do not show error message if all required fields are correctly filled + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I fill in "community_name" with "test name" + And I fill in "language__version" with "2.0.0" + And I fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I fill in "operating_system__version" with "3.0" + And I fill in "software_info_operating_platform" with "test operating platform" + And fill in "software_info_acronym" with "SFTW" + And I press "Create" + Then I should see "Manage my groups" + + Scenario: Show operating_platform errors if this field is blank + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And fill in "community_name" with "test" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And fill in "software_info_acronym" with "SFTW" + And I press "Create" + Then I should see "Operating platform can't be blank" + + Scenario: Do not show operating_platform errors if this field is not blank + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And fill in "software_info_operating_platform" with "test operating platform" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I press "Create" + Then I should not see "Operating platform can't be blank" + + @selenium + Scenario: Show software_langue errors if this Version is blank + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And fill in "community_name" with "test" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I press "Create" + Then I should see "Software languages is invalid" + + Scenario: Show acronym errors if this field is blank + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And fill in "community_name" with "test" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I press "Create" + Then I should see "Acronym can't be blank" + + @selenium + Scenario: Show database_fields errors version is blank + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And fill in "community_name" with "test" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__operating_system" with "GNU" + And I press "Create" + Then I should see "Software databases is invalid" + + Scenario: Show acronym errors if this field has more than 8 characters + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And fill in "community_name" with "test" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__operating_system" with "GNU" + And I fill in "database__version" with "3.0" + And I press "Create" + And fill in "software_info_acronym" with "123456789" + And I press "Create" + Then I should see "Acronym can't have more than 8 characteres" + + Scenario: Show operating system errors if this field is not filled + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I press "Create" + Then I should see "Operating system : at least one must be filled" + + @selenium + Scenario: Show operating system errors if this field is not filled + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I fill in "operating_system__version" with "3.0" + And I press "Create" + Then I should not see "Operating system : at least one must be filled" + + Scenario: Show library fields when click in New Library + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I follow "New Library" + Then I should see "Name" + Then I should see "Version" + Then I should see "License" + + @selenium + Scenario: Show SoftwareLangue fields when click in New Language + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I follow "New language" + Then I should see "3" of this selector ".software-language-table" + #3 because one is always hidden + + @selenium + Scenario: Show databasefields when click in New database + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I follow "New Database" + Then I should see "3" of this selector ".database-table" + #3 because one is always hidden + + @selenium + Scenario: Create software with libraries + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I follow "New Library" + And I fill in "community_name" with "test123" + And fill in "software_info_acronym" with "SFTW" + And I fill in "software_info_operating_platform" with "test platform" + And I fill in "library__name" with "test library name" + And I fill in "library__version" with "test library version" + And I fill in "library__license" with "test library license" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I fill in "operating_system__version" with "3.0" + And I press "Create" + And I go to /myprofile/test123/profile_editor/edit + And I should see "Libraries" + And selector ".library-table" should have any "test library name" + And selector ".library-table" should have any "test library version" + Then selector ".library-table" should have any "test library license" + + @selenium + Scenario: Delete software libraries + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I follow "New Library" + And I fill in "community_name" with "test123" + And fill in "software_info_acronym" with "SFTW" + And I fill in "software_info_operating_platform" with "test platform" + And I fill in "library__name" with "test name" + And I fill in "library__version" with "test version" + And I fill in "library__license" with "test license" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I fill in "operating_system__version" with "3.0" + And I press "Create" + And I go to /myprofile/test123/profile_editor/edit + And I should see "Libraries" + And selector ".library-table" should have any "test name" + And selector ".library-table" should have any "test version" + And selector ".library-table" should have any "test license" + And I follow "Delete" + And I press "Save" + And I go to /myprofile/test123/profile_editor/edit + And I should not see "test name" within "#library__name" + And I should not see "test version" within "#library__version" + Then I should not see "test license" within "#library__license" + + @selenium + Scenario: Crete software libraries on software edit + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I fill in "community_name" with "test123" + And fill in "software_info_acronym" with "SFTW" + And I fill in "software_info_operating_platform" with "test platform" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I fill in "operating_system__version" with "3.0" + And I press "Create" + And I go to /myprofile/test123/profile_editor/edit + And I follow "New Library" + And I fill in "library__name" with "test name" + And I fill in "library__version" with "test version" + And I fill in "library__license" with "test license" + And I press "Save" + And I go to /myprofile/test123/profile_editor/edit + And I should see "Libraries" + And selector ".library-table" should have any "test name" + And selector ".library-table" should have any "test version" + Then selector ".library-table" should have any "test license" + + @selenium + Scenario: Edit software libraries on software edit + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I follow "New Library" + And I fill in "community_name" with "test123" + And fill in "software_info_acronym" with "SFTW" + And I fill in "software_info_operating_platform" with "test platform" + And I fill in "library__name" with "test name" + And I fill in "library__version" with "test version" + And I fill in "library__license" with "test license" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I fill in "operating_system__version" with "3.0" + And I press "Create" + And I go to /myprofile/test123/profile_editor/edit + And I should see "Libraries" + And selector ".library-table" should have any "test name" + And selector ".library-table" should have any "test version" + And selector ".library-table" should have any "test license" + And I follow "New Library" + And I fill in "library__name" with "new name" + And I fill in "library__version" with "new version" + And I fill in "library__license" with "new license" + And I press "Save" + And I go to /myprofile/test123/profile_editor/edit + And selector ".library-table" should have any "new name" + And selector ".library-table" should have any "new version" + Then selector ".library-table" should have any "new license" + + @selenium + Scenario: change license field + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I fill in "community_name" with "test123" + And fill in "software_info_acronym" with "SFTW" + And I fill in "software_info_operating_platform" with "test platform" + And I select "GPL-2" from "license_info_version" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I fill in "operating_system__version" with "3.0" + And I press "Create" + And I go to /myprofile/test123/profile_editor/edit + And I select "GPL-3" from "version" + And I press "Save" + And I go to /myprofile/test123/profile_editor/edit + Then I should see "GPL-3" + + @selenium + Scenario: license link appears on the create software page + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I fill in "community_name" with "test123" + And I fill in "software_info_operating_platform" with "test platform" + And I select "GPL-2" from "license_info_version" + Then I should see "www.gpl2.com" within "#version_link" + + @selenium + Scenario: license link changes if the user choose a different license + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I fill in "community_name" with "test123" + And I fill in "software_info_operating_platform" with "test platform" + And I select "GPL-2" from "license_info_version" + And I should see "www.gpl2.com" within "#version_link" + And I select "GPL-3" from "license_info_version" + Then I should see "www.gpl3.com" within "#version_link" + + @selenium + Scenario: Crete software with Language + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I fill in "community_name" with "test123" + And fill in "software_info_acronym" with "SFTW" + And I fill in "software_info_operating_platform" with "test platform" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I fill in "operating_system__version" with "3.0" + And I press "Create" + And I go to /myprofile/test123/profile_editor/edit + And I should see "Programming Languages" + And selector ".software-language-table" should have any "2.0.0" + Then selector ".software-language-table" should have any "Linux" + + @selenium + Scenario: Edit softwareLanguage on profile editor + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I fill in "community_name" with "test123" + And fill in "software_info_acronym" with "SFTW" + And I fill in "software_info_operating_platform" with "test platform" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I fill in "operating_system__version" with "3.0" + And I press "Create" + And I go to /myprofile/test123/profile_editor/edit + And I should see "Programming Languages" + And selector ".software-language-table" should have any "2.0.0" + And selector ".software-language-table" should have any "Linux" + And I select "Python" from "language__programming_language_id" + And fill in "language__version" with "3.2" + And fill in "language__operating_system" with "GNU" + And I press "Save" + And I go to /myprofile/test123/profile_editor/edit + And selector ".software-language-table" should have any "Python" + And selector ".software-language-table" should have any "3.2" + Then selector ".software-language-table" should have any "GNU" + + @selenium + Scenario: Adding new softwareLanguage on profile editor + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I fill in "community_name" with "test123" + And fill in "software_info_acronym" with "SFTW" + And I fill in "software_info_operating_platform" with "test platform" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I fill in "operating_system__version" with "3.0" + And I press "Create" + And I go to /myprofile/test123/profile_editor/edit + And I should see "Programming Languages" + And selector ".software-language-table" should have any "2.0.0" + And selector ".software-language-table" should have any "Linux" + And I follow "New language" + And I click on the first button with class ".delete-dynamic-table" + And I click on table number "2" selector ".software-language-table" and select the value "Python" + And I fill with "4.3" in field with name "language[][version]" of table number "2" with class ".software-language-table" + And I fill with "Windows" in field with name "language[][operating_system]" of table number "2" with class ".software-language-table" + And I press "Save" + And I go to /myprofile/test123/profile_editor/edit + And selector ".software-language-table" should have any "Python" + And selector ".software-language-table" should have any "4.3" + Then selector ".software-language-table" should have any "Windows" + + @selenium + Scenario: Edit softwareDatabase on profile editor + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I fill in "community_name" with "test123" + And fill in "software_info_acronym" with "SFTW" + And I fill in "software_info_operating_platform" with "test platform" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.0" + And I fill in "database__operating_system" with "GNU" + And I fill in "operating_system__version" with "3.0" + And I press "Create" + And I go to /myprofile/test123/profile_editor/edit + And I should see "Databases" + And selector ".database-table" should have any "3.0" + And selector ".database-table" should have any "GNU" + And I select "PostgreSQL" from "database__database_description_id" + And fill in "database__version" with "3.2" + And fill in "database__operating_system" with "Linux" + And I press "Save" + And I go to /myprofile/test123/profile_editor/edit + And selector ".database-table" should have any "PostgreSQL" + And selector ".database-table" should have any "3.2" + Then selector ".database-table" should have any "Linux" + + @selenium + Scenario: Delete softwareDatabase on profile editor + Given I go to admin_user's control panel + And I follow "Manage my groups" + And I follow "Create a new software" + And I fill in "community_name" with "test123" + And fill in "software_info_acronym" with "SFTW" + And I fill in "software_info_operating_platform" with "test platform" + And fill in "language__version" with "2.0.0" + And fill in "language__operating_system" with "Linux" + And I fill in "database__version" with "3.5" + And I fill in "database__operating_system" with "Solaris" + And I fill in "operating_system__version" with "3.0" + And I press "Create" + And I go to /myprofile/test123/profile_editor/edit + And I should see "Databases" + And selector ".database-table" should have any "3.5" + And selector ".database-table" should have any "Solaris" + And I follow "New Database" + And I click on table number "2" selector ".database-table" and select the value "MariaDB" + And I fill with "4.3" in field with name "database[][version]" of table number "2" with class ".database-table" + And I fill with "Windows" in field with name "database[][operating_system]" of table number "2" with class ".database-table" + And I click on the first button with class ".database-table .delete-dynamic-table" + And I press "Save" + And I go to /myprofile/test123/profile_editor/edit + And selector ".database-table" should have any "MariaDB" + And selector ".database-table" should have any "4.3" + And selector ".database-table" should have any "Windows" + And I should not see "4th Dimension" + And I should not see "3.5" + And I should not see "Solaris" \ No newline at end of file diff --git a/features/step_definitions/mpog_steps.rb b/features/step_definitions/mpog_steps.rb new file mode 100644 index 0000000..759311c --- /dev/null +++ b/features/step_definitions/mpog_steps.rb @@ -0,0 +1,133 @@ +Given /^SoftwareInfo has initial default values on database$/ do + LicenseInfo.create(:version=>"None", :link=>"") + LicenseInfo.create(:version=>"GPL-2", :link =>"www.gpl2.com") + LicenseInfo.create(:version=>"GPL-3", :link =>"www.gpl3.com") + + ProgrammingLanguage.create(:name=>"C") + ProgrammingLanguage.create(:name=>"C++") + ProgrammingLanguage.create(:name=>"Ruby") + ProgrammingLanguage.create(:name=>"Python") + + DatabaseDescription.create(:name => "Oracle") + DatabaseDescription.create(:name => "MySQL") + DatabaseDescription.create(:name => "Apache") + DatabaseDescription.create(:name => "PostgreSQL") + + OperatingSystemName.create(:name=>"Debina") + OperatingSystemName.create(:name=>"Fedora") + OperatingSystemName.create(:name=>"CentOS") +end + +Given /^Institutions has initial default values on database$/ do + GovernmentalPower.create(:name => "Executivo") + GovernmentalPower.create(:name => "Legislativo") + GovernmentalPower.create(:name => "Judiciario") + + GovernmentalSphere.create(:name => "Federal") +end + +Given /^I type in "([^"]*)" into autocomplete list "([^"]*)" and I choose "([^"]*)"$/ do |typed, input_institution, should_select| + page.driver.browser.execute_script %Q{ jQuery('input[data-autocomplete]').trigger("focus") } + fill_in("#{input_institution}",:with => typed) + page.driver.browser.execute_script %Q{ jQuery('input[data-autocomplete]').trigger("keydown") } + sleep 1 + page.driver.browser.execute_script %Q{ jQuery('.ui-menu-item a:contains("#{should_select}")').trigger("mouseenter").trigger("click"); } +end + +Given /^the following public institutions?$/ do |table| + # table is a Cucumber::Ast::Table + table.hashes.each do |item| + governmental_power = GovernmentalPower.where(:name => item[:governmental_power]).first + governmental_sphere = GovernmentalSphere.where(:name => item[:governmental_sphere]).first + institution = PublicInstitution.create!(:name => item[:name], :type => "PublicInstitution", :acronym => item[:acronym], :cnpj => item[:cnpj], :governmental_power => governmental_power, :governmental_sphere => governmental_sphere) + institution.save! + end +end + +Given /^the following software language$/ do |table| + table.hashes.each do |item| + programming_language = ProgrammingLanguage.where(:name=>item[:programing_language]).first + software_language = SoftwareLanguage::new + + software_language.programming_language = programming_language + software_language.version = item[:version] + software_language.operating_system = item[:operating_system] + + software_language.save! + end +end + +Given /^the following software databases$/ do |table| + table.hashes.each do |item| + database_description = DatabaseDescription.where(:name=>item[:database_name]).first + software_database = SoftwareDatabase::new + + software_database.database_description = database_description + software_database.version = item[:version] + software_database.operating_system = item[:operating_system] + + software_database.save! + end +end + +Given /^the following softwares$/ do |table| + table.hashes.each do |item| + community = Community.create :name=>item[:name] + programming_language = ProgrammingLanguage.where(:name=>item[:software_language]).first + database_description = DatabaseDescription.where(:name=>item[:software_database]).first + + software_language = SoftwareLanguage.where(:programming_language_id=>programming_language).first + software_database = SoftwareDatabase.where(:database_description_id=>database_description).first + + software_info = SoftwareInfo::new(:acronym=>item[:acronym], :operating_platform=>item[:operating_platform]) + software_info.community = community + software_info.software_languages << software_language + software_info.software_databases << software_database + software_info.save! + end +end + +# Dynamic table steps +Given /^I fill in first "([^"]*)" class with "([^"]*)"$/ do |selector, value| + evaluate_script "jQuery('#{selector}').first().attr('value', '#{value}') && true" +end + +Given /^I fill in last "([^"]*)" class with "([^"]*)"$/ do |selector, value| + evaluate_script "jQuery('#{selector}').last().attr('value', '#{value}') && true" +end + +Given /^I click on the first button with class "([^"]*)"$/ do |selector| + evaluate_script "jQuery('#{selector}').first().trigger('click') && true" +end + +Given /^I click on the last button with class "([^"]*)"$/ do |selector| + evaluate_script "jQuery('#{selector}').last().trigger('click') && true" +end + +Given /^the user "([^"]*)" has "([^"]*)" as secondary e\-mail$/ do |login, email| + User[login].update_attributes(:secondary_email => email) +end + +Given /^I click on anything with selector "([^"]*)"$/ do |selector| + evaluate_script "jQuery('#{selector}').trigger('click') && true" +end + +Given /^I should see "([^"]*)" of this selector "([^"]*)"$/ do |quantity, selector| + evaluate_script "jQuery('#{selector}').length == '#{quantity}'" +end + +Given /^selector "([^"]*)" should have any "([^"]*)"$/ do |selector, text| + evaluate_script "jQuery('#{selector}').html().indexOf('#{text}') != -1" +end + +Given /^I click on table number "([^"]*)" selector "([^"]*)" and select the value "([^"]*)"$/ do |number, selector, value| + evaluate_script "jQuery('#{selector}:nth-child(#{number}) select option:contains(\"#{value}\")').selected() && true" +end + +Given /^I fill with "([^"]*)" in field with name "([^"]*)" of table number "([^"]*)" with class "([^"]*)"$/ do |value, name, number, selector| + evaluate_script "jQuery('#{selector}:nth-child(#{number}) input[name=\"#{name}\"]').val('#{value}') && true" +end + +Given /^I sleep for (\d+) seconds$/ do |time| + sleep time.to_i +end \ No newline at end of file diff --git a/features/user_registration.feature b/features/user_registration.feature new file mode 100644 index 0000000..8a3332e --- /dev/null +++ b/features/user_registration.feature @@ -0,0 +1,310 @@ +Feature: User Registration + + Background: + Given "MpogSoftwarePlugin" plugin is enabled + And I am logged in as admin + And I go to /admin/plugins + And I check "MpogSoftwarePlugin" + And I press "Save changes" + And I go to /admin/features/manage_fields + And I check "person_fields_country_active" + And I check "person_fields_country_required" + And I check "person_fields_country_signup" + And I check "person_fields_state_active" + And I check "person_fields_state_required" + And I check "person_fields_state_signup" + And I check "person_fields_city_active" + And I check "person_fields_city_required" + And I check "person_fields_city_signup" + And I press "Save changes" + And the following blocks + | owner | type | + | environment | LoginBlock | + And I go to /account/logout + + @selenium + Scenario: Successfull registration with only required fields + Given I go to /account/signup + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@example.com | + | Username | josesilva | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + | State | Bahia | + | City | Salvador | + And I select "Brazil" from "profile_data[country]" + And wait for the captcha signup time + And I press "Create my account" + When José da Silva's account is activated + And I go to login page + And I fill in "Username" with "josesilva" + And I fill in "Password" with "secret" + And I press "Log in" + Then I should be logged in as "josesilva" + + @selenium + Scenario: Successfull registration with governmental e-mail typing the name of the organization + Given I go to /account/signup + And Institutions has initial default values on database + And the following public institutions + | name | acronym | cnpj | governmental_power | governmental_sphere | + | Ministerio das Cidades | MC | 58.745.189/0001-21 | Executivo | Federal | + | Governo do DF | GDF | 12.645.166/0001-44 | Legislativo | Federal | + | Ministerio do Planejamento | MP | 41.769.591/0001-43 | Judiciario | Federal | + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@serpro.gov.br| + | Username | josesilva | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + | State | Bahia | + | City | Salvador | + | Secondary e-Mail | josesilva@example.com | + | Role | TI analist | + And I select "Brazil" from "profile_data[country]" + And I type in "Minis" into autocomplete list "input_institution" and I choose "Ministerio do Planejamento" + And wait for the captcha signup time + And I press "Create my account" + When José da Silva's account is activated + And I go to login page + And I fill in "Username" with "josesilva" + And I fill in "Password" with "secret" + And I press "Log in" + Then I should be logged in as "josesilva" + + @selenium + Scenario: Successfull registration with governmental e-mail typing the acronym of the organization + Given I go to /account/signup + And Institutions has initial default values on database + And the following public institutions + | name | acronym | cnpj | governmental_power | governmental_sphere | + | Ministerio das Cidades | MC | 58.745.189/0001-21 | Executivo | Federal | + | Governo do DF | GDF | 12.645.166/0001-44 | Legislativo | Federal | + | Ministerio do Planejamento | MP | 41.769.591/0001-43 | Judiciario | Federal | + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@serpro.gov.br| + | Username | josesilva | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + | State | Bahia | + | City | Salvador | + | Secondary e-Mail | josesilva@example.com | + | Role | TI analist | + And I select "Brazil" from "profile_data[country]" + And I type in "MP" into autocomplete list "input_institution" and I choose "Ministerio do Planejamento" + And wait for the captcha signup time + And I press "Create my account" + When José da Silva's account is activated + And I go to login page + And I fill in "Username" with "josesilva" + And I fill in "Password" with "secret" + And I press "Log in" + Then I should be logged in as "josesilva" + + @selenium + Scenario: Unsuccessfull registration due to the existance of e-mail as secondary another user's e-mail + Given the following users + | login | name | email | country | state | city | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | + And the user "maria" has "user@example.com" as secondary e-mail + And I go to /account/signup + And I fill in the following within ".no-boxes": + | e-Mail | user@example.com | + | Username | josesilva | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + | State | Bahia | + | City | Salvador | + And wait for the captcha signup time + And I select "Brazil" from "profile_data[country]" + When I press "Create my account" + Then I should see "E-mail or secondary e-mail already taken." + + @selenium + Scenario: Unsuccessfull registration due to the existance of secondary e-mail as another user's secondary e-mail + Given the following users + | login | name | email | country | state | city | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | + And the user "maria" has "user@example.com" as secondary e-mail + And I go to /account/signup + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@example.com | + | Username | josesilva | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + | State | Bahia | + | City | Salvador | + | Secondary e-Mail | user@example.com | + And I select "Brazil" from "profile_data[country]" + And wait for the captcha signup time + When I press "Create my account" + Then I should see "E-mail or secondary e-mail already taken." + + @selenium + Scenario: Unsuccessfull registration due to the existance of secondary e-mail as another user's e-mail + Given the following users + | login | name | email | country | state | city | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | + And I go to /account/signup + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@example.com | + | Username | josesilva | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + | State | Bahia | + | City | Salvador | + | Secondary e-Mail | user@example.com | + And I select "Brazil" from "profile_data[country]" + And wait for the captcha signup time + When I press "Create my account" + Then I should see "E-mail or secondary e-mail already taken." + + @selenium + Scenario: Unsuccessfull registration due to both primary e-mail and secondary e-mail being equal + Given I go to /account/signup + And I fill in the following within ".no-boxes": + | Username | josesilva | + | e-Mail | josesilva@example.com | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + | State | Bahia | + | City | Salvador | + | Secondary e-Mail | josesilva@example.com | + And I select "Brazil" from "profile_data[country]" + And wait for the captcha signup time + When I press "Create my account" + Then I should see "Email must be different from secondary email." + + @selenium + Scenario: Unsuccessfull registration due to government fields being blank + Given I go to /account/signup + And I fill in the following within ".no-boxes": + | Username | josesilva | + | e-Mail | josesilva@serpro.gov.br| + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + | Secondary e-Mail | josesilva@example.com | + And I select "Brazil" from "profile_data[country]" + And wait for the captcha signup time + When I press "Create my account" + Then I should see "Role can't be blank if e-mail has governamental sulfixes." + And I should see "Institution is obligatory if user has a government email." + And I should see "State can't be blank" + And I should see "City can't be blank" + + @selenium + Scenario: Unsuccessfull registration due to secondary email is governmental and primary is not + Given I go to /account/signup + And I fill in the following within ".no-boxes": + | Username | josesilva | + | e-Mail | josesilva@example.com | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + | State | Bahia | + | City | Salvador | + | Secondary e-Mail | josesilva@serpro.gov.br| + And wait for the captcha signup time + When I press "Create my account" + Then I should see "The governamental email must be the primary one." + + @selenium + Scenario: Show incomplete resgistration percentage + Given I go to /account/signup + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@gmail.com | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + | State | Bahia | + | City | Salvador | + | Secondary e-Mail | josesilva@example.com | + | Role | TI analist | + And I select "Brazil" from "profile_data[country]" + And I fill in "Username" with "josesilva" + And wait for the captcha signup time + And I press "Create my account" + When José da Silva's account is activated + And I go to login page + And I fill in "Username" with "josesilva" + And I fill in "Password" with "secret" + And I press "Log in" + Then I should see "Percentage incomplete: 63 %" + + @selenium + Scenario: Remove the incomplete resgistration percentage message + Given I go to /account/signup + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@gmail.com | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + | State | Bahia | + | City | Salvador | + | Secondary e-Mail | josesilva@example.com | + | Role | TI analist | + And I select "Brazil" from "profile_data[country]" + And I fill in "Username" with "josesilva" + And wait for the captcha signup time + And I press "Create my account" + When José da Silva's account is activated + And I go to login page + And I fill in "Username" with "josesilva" + And I fill in "Password" with "secret" + And I press "Log in" + And I click on anything with selector ".hide-incomplete-percentage" + Then I should not see "Percentage incomplete: 63 %" + + @selenium + Scenario: When the user log out and log in again, the percentage registration message must appear + Given the following users + | login | name | email | country | state | city | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | + When I am logged in as "maria" + And I follow "Logout" + And I am logged in as "maria" + Then I should see "Percentage incomplete:" + + @selenium + Scenario: When the user logged in and hide link of imcomplete percentage and user log out and log in again, the percentage registration link must appear + Given the following users + | login | name | email | country | state | city | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | + When I am logged in as "maria" + And I go to /profile/maria + And I should see "Percentage incomplete:" + And I click on anything with selector ".hide-incomplete-percentage" + And I follow "Logout" + And I am logged in as "maria" + And I go to /profile/maria + Then I should see "Percentage incomplete:" + + @selenium + Scenario: When the user logged in and hide link of imcomplete percentage and user update page, the percentage registration link must not appear + Given the following users + | login | name | email | country | state | city | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | + When I am logged in as "maria" + And I go to /profile/maria + And I should see "Percentage incomplete:" + And I click on anything with selector ".hide-incomplete-percentage" + And I should not see "Percentage incomplete:" + And I go to /myprofile/maria/profile_editor/edit + And I go to /profile/maria + Then I should not see "Percentage incomplete:" + + @selenium + Scenario: When the user press incomplete percentage link,he must be redirect to his edit profile page + Given the following users + | login | name | email | country | state | city | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | + When I am logged in as "maria" + And I follow "Percentage incomplete: 72 %" + Then I should see "Profile settings" diff --git a/lib/database_description.rb b/lib/database_description.rb new file mode 100644 index 0000000..c31dc96 --- /dev/null +++ b/lib/database_description.rb @@ -0,0 +1,10 @@ +class DatabaseDescription < ActiveRecord::Base + attr_accessible :name + + has_many :software_databases + has_many :software_infos, :through => :software_databases + + validates_presence_of :name + validates_uniqueness_of :name + +end diff --git a/lib/database_helper.rb b/lib/database_helper.rb new file mode 100644 index 0000000..42248fa --- /dev/null +++ b/lib/database_helper.rb @@ -0,0 +1,85 @@ +module DatabaseHelper + + def self.list_database new_databases + return [] if new_databases.nil? or new_databases.length == 0 + list_databases = [] + + new_databases.each do |new_database| + unless SoftwareHelper.all_table_is_empty? new_database, ["database_description_id"] + database = SoftwareDatabase.new + database.database_description_id = new_database[:database_description_id] + database.version = new_database[:version] + database.operating_system = new_database[:operating_system] + list_databases << database + end + end + + list_databases + end + + def self.valid_list_database? list_databases + return false if list_databases.nil? or list_databases.length == 0 + + list_databases.each do |database| + return false unless database.valid? + end + + true + end + + def self.database_as_tables(list_databases, have_delete_button = nil) + extend( + ActionView::Helpers::TagHelper, + ActionView::Helpers::FormTagHelper, + ActionView::Helpers::UrlHelper, + ActionView::Helpers::FormOptionsHelper, + ApplicationHelper + ) + + return database_html_structure({:database_description_id => 1, :version => "", :operating_system => ""}, have_delete_button) if list_databases.nil? + + lambdas_list = [] + + list_databases.each do |database| + lambdas_list << database_html_structure(database, have_delete_button) + end + + lambdas_list + end + + def self.database_html_structure(database_data, have_delete_button = nil) + Proc::new do + content_tag('table', + content_tag('tr', + content_tag('td', label_tag(_("database Name: ")))+ + content_tag('td', select_tag("database[][database_description_id]", SoftwareHelper.select_options(DatabaseDescription.all, database_data[:database_description_id]) ))+ + content_tag('td') + )+ + + content_tag('tr', + content_tag('td', label_tag(_("Version")))+ + content_tag('td', text_field_tag("database[][version]", database_data[:version]))+ + content_tag('td') + )+ + + content_tag('tr', + content_tag('td', label_tag(_("Operating System")))+ + content_tag('td', text_field_tag("database[][operating_system]", database_data[:operating_system]))+ + + if have_delete_button.nil? + content_tag('td', + button_without_text(:delete, _('Delete'), "#" , :class=>"delete-dynamic-table"), + :align => 'right' + ) + else + content_tag('td') + end + ), :class => 'dynamic-table database-table' + ) + end + end + + def self.add_dynamic_table + database_as_tables(nil).call + end +end diff --git a/lib/ext/community.rb b/lib/ext/community.rb new file mode 100644 index 0000000..7594568 --- /dev/null +++ b/lib/ext/community.rb @@ -0,0 +1,51 @@ +require_dependency 'community' + +class Community + + attr_accessible :visible + + has_one :software_info, :dependent=>:delete + has_one :institution, :dependent=>:delete + + def self.create_after_moderation(requestor, attributes = {}, software_info = nil, license_info = nil, controlled_vocabulary = nil) + community = Community.new(attributes) + if community.environment.enabled?('admin_must_approve_new_communities') + CreateCommunity.create(attributes.merge(:requestor => requestor)) + else + community = Community.create(attributes) + + if not software_info.nil? + if not license_info.nil? + software_info.license_info = license_info + end + + if not controlled_vocabulary.nil? + software_info.controlled_vocabulary = controlled_vocabulary + end + + community.software_info = software_info + end + + community.add_admin(requestor) + end + community + end + + def software? + return !software_info.nil? + end + + def institution? + return !institution.nil? + end + + def deactivate + self.visible = false + self.save! + end + + def activate + self.visible = true + self.save! + end +end diff --git a/lib/ext/controlled_vocabulary.rb b/lib/ext/controlled_vocabulary.rb new file mode 100644 index 0000000..3afc6f8 --- /dev/null +++ b/lib/ext/controlled_vocabulary.rb @@ -0,0 +1,12 @@ +class ControlledVocabulary < ActiveRecord::Base + self.table_name = "controlled_vocabulary" + + attr_accessible :administration , :agriculture , :business_and_services , :communication , + :culture , :national_defense , :economy_and_finances , :education , + :energy , :sports , :habitation , :industry , :environment , + :research_and_development , :social_security , :social_protection , + :international_relations , :sanitation , :health , + :security_public_order , :work , :transportation , :urbanism + + belongs_to :software_info +end \ No newline at end of file diff --git a/lib/ext/person.rb b/lib/ext/person.rb new file mode 100644 index 0000000..58c1d0b --- /dev/null +++ b/lib/ext/person.rb @@ -0,0 +1,77 @@ +require_dependency 'person' + +class Person + + settings_items :area_interest, :type => :string, :default => "" + settings_items :percentage_incomplete, :type => :string, :default => "" + + attr_accessible :area_interest + attr_accessible :percentage_incomplete + + scope :search, lambda { |name="", state="", city="", email=""| + like_sql = "" + values = [] + + unless name.nil? and name.blank? + like_sql << "name ILIKE ? AND " + values << "%#{name}%" + end + + unless state.nil? and state.blank? + like_sql << "data ILIKE ? AND " + values << "%:state: %#{state}%" + end + + unless city.nil? and city.blank? + like_sql << "data ILIKE ? AND " + values << "%:city: %#{city}%" + end + + unless email.nil? and email.blank? + like_sql << "email ILIKE ? AND " + values << "%#{email}%" + end + like_sql = like_sql[0..like_sql.length-5] + + { + :joins => :user, + :conditions=>[like_sql, *values] + } + } + + def secondary_email + self.user.secondary_email unless self.user.nil? + end + + def secondary_email= value + self.user.secondary_email = value unless self.user.nil? + end + + def institution + self.user.institution.name if self.user and self.user.institution + end + + def institution_id + self.user.institution.id unless self.user.institution.nil? + end + + def institution_id= value + institution = Institution.find(:first, :conditions=>"id = #{value}") + + unless institution.nil? + self.user.institution = institution + end + end + + def role + self.user.role unless self.user.nil? + end + + def role= value + self.user.role = value unless self.user.nil? + end + + def software? + false + end +end diff --git a/lib/ext/user.rb b/lib/ext/user.rb new file mode 100644 index 0000000..d0659e6 --- /dev/null +++ b/lib/ext/user.rb @@ -0,0 +1,67 @@ +require_dependency 'user' + +class User + + belongs_to :institution + + validate :email_different_secondary?, :email_has_already_been_used?, + :secondary_email_format, :email_suffix_is_gov?, :validate_role? + + scope :primary_or_secondary_email_already_used?, lambda { |email| + where("email=? OR secondary_email=?", email, email) + } + + def email_different_secondary? + self.errors.add(:base, _("Email must be different from secondary email.")) if self.email == self.secondary_email + end + + def email_has_already_been_used? + user_already_saved = User.find(:first, :conditions=>["email = ?", self.email]) + + if user_already_saved.nil? + primary_email_hasnt_been_used = User.primary_or_secondary_email_already_used?(self.email).empty? + secondary_email_hasnt_been_used = User.primary_or_secondary_email_already_used?(self.secondary_email).empty? + + if !primary_email_hasnt_been_used or !secondary_email_hasnt_been_used + self.errors.add(:base, _("E-mail or secondary e-mail already taken.")) + end + end + end + + def secondary_email_format + if !self.secondary_email.nil? and self.secondary_email.length > 0 + test = /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/ + self.errors.add(:base, _("Invalid secondary email format.")) unless test.match(self.secondary_email) + end + end + + def email_suffix_is_gov? + test = /^.*@[gov.br|jus.br|leg.br|mp.br]+$/ + primary_email_has_gov_suffix = false + secondary_email_has_gov_suffix = false + + if !self.email.nil? and self.email.length > 0 + primary_email_has_gov_suffix = true if test.match(self.email) + end + + unless primary_email_has_gov_suffix + if !self.secondary_email.nil? and self.secondary_email.length > 0 + secondary_email_has_gov_suffix = true if test.match(self.secondary_email) + end + self.errors.add(:base, _("The governamental email must be the primary one.")) if secondary_email_has_gov_suffix + end + + self.errors.add(:base, _("Institution is obligatory if user has a government email.")) if primary_email_has_gov_suffix and self.institution.nil? + end + + def validate_role? + valid_sufix = ['gov.br','jus.br','leg.br','mp.br'] + valid_sufix.each do |sufix| + if (self.secondary_email =~ /#{sufix}(.*)/ || self.email =~ /#{sufix}(.*)/) and self.role.blank? + errors.add(:role, _("can't be blank if e-mail has governamental sulfixes.")) + break + end + end + end + +end diff --git a/lib/governmental_power.rb b/lib/governmental_power.rb new file mode 100644 index 0000000..992fa7f --- /dev/null +++ b/lib/governmental_power.rb @@ -0,0 +1,10 @@ +class GovernmentalPower < ActiveRecord::Base + attr_accessible :name + + validates :name, :presence=>true, :uniqueness=>true + has_many :institutions + + def public_institutions + Institution.where(:type=>"PublicInstitution", :governmental_power_id=>self.id) + end +end diff --git a/lib/governmental_sphere.rb b/lib/governmental_sphere.rb new file mode 100644 index 0000000..aef8f8f --- /dev/null +++ b/lib/governmental_sphere.rb @@ -0,0 +1,7 @@ +class GovernmentalSphere < ActiveRecord::Base + attr_accessible :name + + validates :name, :presence=>true, :uniqueness=>true + + has_many :institutions +end diff --git a/lib/institution.rb b/lib/institution.rb new file mode 100644 index 0000000..930cd3a --- /dev/null +++ b/lib/institution.rb @@ -0,0 +1,30 @@ +class Institution < ActiveRecord::Base + belongs_to :governmental_power + belongs_to :governmental_sphere + + attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type, + :juridical_nature, :sub_juridical_nature, :normalization_level, + :version, :cnpj, :type, :governmental_power, :governmental_sphere + has_many :users + + validates :name, :presence=>true, :uniqueness=>true + + before_save :verify_institution_type + + belongs_to :community + + scope :search_institution, lambda{ |value| + where("name ilike ? OR acronym ilike ?", "%#{value}%", "%#{value}%" ) + } + + protected + + def verify_institution_type + valid_institutions_type = ["PublicInstitution", "PrivateInstitution"] + + unless valid_institutions_type.include? self.type + self.errors.add(:type, _("invalid, only public and private institutions are allowed.")) + false + end + end +end diff --git a/lib/institution_helper.rb b/lib/institution_helper.rb new file mode 100644 index 0000000..d76f5cc --- /dev/null +++ b/lib/institution_helper.rb @@ -0,0 +1,76 @@ +require "net/http" +require "yaml" + +module InstitutionHelper + + SPHERES = ['federal'] + POWERS = ['executive', 'legislative', 'judiciary'] + + def self.mass_update + @web_service_info = self.web_service_info + + POWERS.each do |power| + SPHERES.each do |sphere| + json = self.get_json power, sphere + + units = json["unidades"] + + units.each do |unit| + institution = Institution.where(:name=>unit["nome"]) + + institution = if institution.count == 0 + Institution::new + else + institution.first + end + + institution = self.set_institution_data institution, unit + institution.save + end + end + end + end + + protected + + def self.web_service_info + YAML.load_file(File.dirname(__FILE__) + '/../config/siorg.yml')['web_service'] + end + + def self.service_url power, sphere + base_url = @web_service_info['base_url'] + power_code = @web_service_info['power_codes'][power].to_s + sphere_code = @web_service_info['sphere_codes'][sphere].to_s + additional_params = @web_service_info['additional_params'] + + return URI("#{base_url}?codigoPoder=#{power_code}&codigoEsfera=#{sphere_code}&#{additional_params}") + end + + def self.get_json power, sphere + uri = self.service_url power, sphere #URI(BASE_URL+"codigoPoder=#{power_code}&codigoEsfera=#{sphere_code}&retornarOrgaoEntidadeVinculados=NAO") + data = Net::HTTP.get(uri) + ActiveSupport::JSON.decode(data) + end + + def self.retrieve_code unit, field + data = unit[field] + return data.split("/").last unless (data.blank? || data.nil?) + return nil + end + + def self.set_institution_data institution, unit + institution.name = unit["nome"] + institution.acronym = unit["sigla"] + institution.unit_code = self.retrieve_code(unit,"codigoUnidade") + institution.parent_code = self.retrieve_code(unit,"codigoUnidadePai") + institution.unit_type = self.retrieve_code(unit,"codigoTipoUnidade") + institution.juridical_nature = self.retrieve_code(unit,"codigoNaturezaJuridica") + institution.sub_juridical_nature = self.retrieve_code(unit,"codigoSubNaturezaJuridica") + institution.normalization_level = unit["nivelNormatizacao"] + institution.version = unit["versaoConsulta"] + institution.type = "PublicInstitution" + institution.governmental_power = GovernmentalPower.where(:name=>self.retrieve_code(unit,"codigoPoder")).first + institution.governmental_sphere = GovernmentalSphere.where(:name=>self.retrieve_code(unit,"codigoEsfera")).first + institution + end +end diff --git a/lib/library.rb b/lib/library.rb new file mode 100644 index 0000000..de05804 --- /dev/null +++ b/lib/library.rb @@ -0,0 +1,22 @@ +class Library < ActiveRecord::Base + + #TODO missing relations? + + attr_accessible :name, :version, :license, :software_info_id + + #TODO: review validations + validate :validate_name, :validate_version, :validate_license + + def validate_name + self.errors.add(:name, _("can't be blank")) if self.name.blank? && self.errors[:name].blank? + end + + def validate_version + self.errors.add(:version, _("can't be blank")) if self.version.blank? && self.errors[:version].blank? + end + + def validate_license + self.errors.add(:license, _("can't be blank")) if self.license.blank? && self.errors[:license].blank? + end + +end diff --git a/lib/library_helper.rb b/lib/library_helper.rb new file mode 100644 index 0000000..0db27eb --- /dev/null +++ b/lib/library_helper.rb @@ -0,0 +1,78 @@ +module LibraryHelper + def self.list_libraries new_libraries + return [] if new_libraries.nil? or new_libraries.length == 0 + list_libraries = [] + + new_libraries.each do |new_library| + unless SoftwareHelper.all_table_is_empty? new_library + library = Library.new + library.name = new_library[:name] + library.version = new_library[:version] + library.license = new_library[:license] + list_libraries << library + end + end + + list_libraries + end + + def self.valid_list_libraries? list_libraries + return true if list_libraries.nil? or list_libraries.length == 0 + + list_libraries.each do |library| + return false unless library.valid? + end + + true + end + + def self.library_as_tables list_libraries + extend( + ActionView::Helpers::TagHelper, + ActionView::Helpers::FormTagHelper, + ActionView::Helpers::UrlHelper, + ApplicationHelper + ) + + return library_html_structure({:name=>"", :version=>"", :license=>""}) if list_libraries.nil? + + lambdas_list = [] + + list_libraries.each do |library| + lambdas_list << library_html_structure(library) + end + + lambdas_list + end + + def self.library_html_structure library_data + Proc::new do + content_tag('table', + content_tag('tr', + content_tag('td', label_tag(_("Name")))+ + content_tag('td', text_field_tag("library[][name]", library_data[:name]))+ + content_tag('td') + )+ + + content_tag('tr', + content_tag('td', label_tag(_("Version")))+ + content_tag('td', text_field_tag("library[][version]", library_data[:version]))+ + content_tag('td') + )+ + + content_tag('tr', + content_tag('td', label_tag(_("License")))+ + content_tag('td', text_field_tag("library[][license]", library_data[:license])) + + content_tag('td', + button_without_text(:delete, _('Delete'), "#" , :class=>"delete-dynamic-table"), + :align => 'right' + ) + ), :class => 'dynamic-table library-table' + ) + end + end + + def self.add_dynamic_table + library_as_tables(nil).call + end +end diff --git a/lib/license_helper.rb b/lib/license_helper.rb new file mode 100644 index 0000000..46e0b84 --- /dev/null +++ b/lib/license_helper.rb @@ -0,0 +1,7 @@ +module LicenseHelper + + def self.getListLicenses + LicenseInfo.all + end + +end diff --git a/lib/license_info.rb b/lib/license_info.rb new file mode 100644 index 0000000..6f9bfe7 --- /dev/null +++ b/lib/license_info.rb @@ -0,0 +1,8 @@ +class LicenseInfo < ActiveRecord::Base + attr_accessible :version, :link + + validates_presence_of :version + + has_many :software_info + +end diff --git a/lib/mpog_software_plugin.rb b/lib/mpog_software_plugin.rb new file mode 100644 index 0000000..544d2ce --- /dev/null +++ b/lib/mpog_software_plugin.rb @@ -0,0 +1,346 @@ +class MpogSoftwarePlugin < Noosfero::Plugin + include ActionView::Helpers::TagHelper + include ActionView::Helpers::FormTagHelper + include ActionView::Helpers::FormOptionsHelper + include ActionView::Helpers::JavaScriptHelper + include ActionView::Helpers::AssetTagHelper + include FormsHelper + include LibraryHelper + + def self.plugin_name + "MpogSoftwarePlugin" + end + + def self.plugin_description + _("Add Public Software and MPOG features.") + end + + def signup_extra_contents + institutions = Institution.all + + Proc::new do + content_tag(:div, + required(labelled_form_field( + _('Secondary e-Mail'), + text_field(:user, :secondary_email, :id => 'secondary_email_field') + + content_tag( + :small, _("If you have a gov email, don't forget to use this email on the primary email") ,:class => 'signup-form',:id =>'secondary-email-balloon') + )), + :id => 'signup-secondary-email') + + + content_tag(:div, + labelled_form_field( + _('Role'), text_field(:user, :role, :id => 'role_field') + + content_tag( + :small,_('If your primary email has one of those sufix: gov.br, jus.br, leg.br or mp.br, dont forget to fill your role in the organization'),:class => 'signup-form',:id =>'role-balloon')), + :id => 'signup-role' + ) + + + content_tag(:div, + labelled_form_field( + _('Areas of Interest'), + text_field(:profile_data, :area_interest, :id => 'area_interest_field')+ + content_tag( + :small,_('Fill with your interest areas'),:class => 'signup-form',:id =>'area-interest-balloon')), + :id => 'signup-area-interest' + ) + + + content_tag(:div, + labelled_form_field( + _('Institution'), + text_field(:institution, :name, :id => 'input_institution')+ + content_tag( + :small, _('Fill with your institution') ,:class => 'signup-form', :id =>'institution-balloon' + ) + + content_tag(:div, _("The searched institution does not exist"), :id=>"institution_empty_ajax_message", :class=>"errorExplanation hide-field") + + link_to(_("Add new institution"), "#", :id=>"create_institution_link", :class=>'button with-text icon-add')+ + hidden_field_tag("user[institution_id]", "", :id => 'user_institution_id')+ + content_tag(:div, "", :id=>"institution_dialog") + ), + :id => 'signup-institution' + ) + end + end + + def profile_editor_extras + if context.profile.person? + expanded_template('person_editor_extras.html.erb') + elsif context.profile.respond_to? :software_info and !context.profile.software_info.nil? + expanded_template('software_editor_extras.html.erb') + elsif context.profile.respond_to? :institution and !context.profile.institution.nil? + expanded_template('institution_editor_extras.html.erb') + end + end + + def profile_editor_transaction_extras + if context.profile.respond_to?(:software_info) + if context.params.has_key?(:software_info) + software_info_transaction + end + + if context.params.has_key?(:library) + libraries_transaction + end + + if context.params.has_key?(:version) + license_transaction + end + + if context.params.has_key?(:language) + language_transaction + end + + if context.params.has_key?(:database) + databases_transaction + end + + if context.params.has_key?(:operating_system) + operating_system_transaction + end + if context.params.has_key?(:institution) || context.params.has_key?(:governmental_power) || context.params.has_key?(:governmental_sphere) + institution_transaction + end + + if context.params.has_key?(:controlled_vocabulary) + controlled_vocabulary_transaction + end + elsif context.profile.respond_to?(:user) + if context.params.has_key?(:user) + user_transaction + end + end + end + + def profile_tabs + if context.profile.person? + { :title => _("Mpog"), + :id => 'mpog-fields', + :content => Proc::new do render :partial => 'profile_tab' end, + :start => true } + elsif context.profile.software? + { :title => _("Software"), + :id => 'mpog-fields', + :content => Proc::new do render :partial => 'software_tab' end, + :start => true } + elsif context.profile.institution? + { :title => _("Institution"), + :id => 'mpog-fields', + :content => Proc::new do render :partial => 'institution_tab' end, + :start => true + } + end + end + + def stylesheet? + true + end + + def js_files + ["mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js"] + end + + def alternative_exclusion + if context.profile.person? + if context.profile.disable + context.session[:notice] = _('The profile was deactivated.') + context.profile.user.forget_me + context.session.delete(:user) + + true + end + elsif context.profile.community? + context.profile.software_info.software_languages.delete_all + context.profile.destroy + + mensage = context.profile.software_info.nil? ? "community" : "software" + context.session[:notice] = _("The #{mensage} was deleted.") + else + false + end + end + + def add_new_organization_button + Proc::new do + button(:add, _('Create a new software'), :controller => 'mpog_software_plugin_myprofile', :action => 'new_software') + end + end + + def alternative_reactive_account(person) + person.visible = true + person.save + true + end + + # FIXME - if in error log apears has_permission?, try to use this method + def has_permission?(person, permission, target) + person.has_permission_without_plugins?(permission, target) + end + + def incomplete_registration params + person = User.find(params[:user]).person + percentege = calc_percentage_registration(person) + if percentege >= 0 and percentege <= 100 + return _("Registration "+percentege.to_s+"% incomplete ") + end + end + + def calc_percentage_registration person + empty_fields = 0 + required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","role","area_interest","image"] + required_list.each do |field| + if person.send(field).blank? + empty_fields = empty_fields + 1 + end + end + percentege = (empty_fields*100)/required_list.count + person.percentage_incomplete = percentege + person.save(validate: false) + percentege + end + + def add_link_to_complete_registration person + #find a better way to do it + if context.session[:hide_incomplete_percentage] != true + new_url = person.public_profile_url + new_url[:controller] = 'profile_editor' + new_url[:action] = 'edit' + + Proc::new do + content_tag(:div, + link_to( _("Percentage incomplete: #{person.percentage_incomplete.to_s} %" ), new_url) + + link_to(image_tag("/images/icon_filter_exclude.png"), "#", :class => "hide-incomplete-percentage", :alt => "Hide Incomplete Percentage"), :class=>"mpog-incomplete-percentage" + ) + end + end + end + + def manage_software + [{:title => _('Manage Software'), :url => {:controller => 'mpog_software_plugin', :action => 'archive_software'}}] + end + + protected + + def operating_system_transaction + OperatingSystem.transaction do + list_operating = OperatingSystemHelper.list_operating_system(context.params[:operating_system]) + + if OperatingSystemHelper.valid_list_operating_system?(list_operating) + OperatingSystem.where(:software_info_id => context.profile.software_info.id).destroy_all + list_operating.each do |operating_system| + operating_system.software_info = context.profile.software_info + operating_system.save! + end + else + raise 'Invalid Operating System fields' + end + end + end + + def user_transaction + User.transaction do + context.profile.user.update_attributes!(context.params[:user]) + end + end + + def institution_transaction + if context.params.has_key?(:governmental_power) + context.profile.institution.governmental_power_id = context.params[:governmental_power] + context.profile.institution.save! + end + + if context.params.has_key?(:governmental_sphere) + context.profile.institution.governmental_sphere_id = context.params[:governmental_sphere] + context.profile.institution.save! + end + + if context.params.has_key?(:institution) + Institution.transaction do + context.profile.institution.update_attributes!(context.params[:institution]) + end + end + end + + def software_info_transaction + SoftwareInfo.transaction do + context.profile.software_info.update_attributes!(context.params[:software_info]) + end + end + + def libraries_transaction + Library.transaction do + list_libraries = LibraryHelper.list_libraries(context.params[:library]) + + if LibraryHelper.valid_list_libraries?(list_libraries) + Library.where(:software_info_id=> context.profile.software_info.id).destroy_all + + list_libraries.each do |library| + library.software_info_id = context.profile.software_info.id + library.save! + end + else + raise 'Invalid Library fields' + end + end + end + + def databases_transaction + SoftwareDatabase.transaction do + list_databases = DatabaseHelper.list_database(context.params[:database]) + + if DatabaseHelper.valid_list_database?(list_databases) + SoftwareDatabase.where(:software_info_id => context.profile.software_info.id).destroy_all + list_databases.each do |database| + database.software_info = context.profile.software_info + database.save! + end + else + raise 'Invalid Database fields' + end + end + end + + def license_transaction + license = LicenseInfo.find(context.params[:version]) + context.profile.software_info.license_info = license + context.profile.software_info.save! + end + + def manage_software + [{:title => _('Manage Software'), :url => {:controller => 'mpog_software_plugin_myprofile', :action => 'new_software'}}] + end + + def language_transaction + SoftwareLanguage.transaction do + list_language = SoftwareLanguageHelper.list_language(context.params[:language]) + + if SoftwareLanguageHelper.valid_list_language?(list_language) + SoftwareLanguage.where(:software_info_id => context.profile.software_info.id).destroy_all + + list_language.each do |language| + language.software_info = context.profile.software_info + language.save! + end + else + raise 'Invalid Software Language fields' + end + end + end + + def add_new_user_search_filter + expanded_template('user_search/search_filter.html.erb') + end + + def custom_people_search params + Person.search(params[:name], + params[:state], + params[:city], + params[:email] + ) + end + + def controlled_vocabulary_transaction + ControlledVocabulary.transaction do + context.profile.software_info.controlled_vocabulary.update_attributes!(context.params[:controlled_vocabulary]) + end + end +end diff --git a/lib/operating_system.rb b/lib/operating_system.rb new file mode 100644 index 0000000..33d70c8 --- /dev/null +++ b/lib/operating_system.rb @@ -0,0 +1,8 @@ +class OperatingSystem < ActiveRecord::Base + attr_accessible :version + + belongs_to :software_info + belongs_to :operating_system_name + + validates :version, :operating_system_name, :presence=>true +end \ No newline at end of file diff --git a/lib/operating_system_helper.rb b/lib/operating_system_helper.rb new file mode 100644 index 0000000..8340c81 --- /dev/null +++ b/lib/operating_system_helper.rb @@ -0,0 +1,80 @@ +module OperatingSystemHelper + def self.list_operating_system new_operating_systems + return [] if new_operating_systems.nil? or new_operating_systems.length == 0 + list_operating_system = [] + + new_operating_systems.each do |new_operating_system| + unless SoftwareHelper.all_table_is_empty? new_operating_system, ["operating_system_name_id"] + operating_system = OperatingSystem.new + operating_system.operating_system_name = OperatingSystemName.find(new_operating_system[:operating_system_name_id]) + operating_system.version = new_operating_system[:version] + list_operating_system << operating_system + end + end + list_operating_system + end + + def self.valid_list_operating_system? list_operating_system + return false if list_operating_system.nil? or list_operating_system.length == 0 + + list_operating_system.each do |operating_system| + return false unless operating_system.valid? + end + true + end + + def self.operating_system_as_tables (list_operating_system, have_delete_button = true, show_information = false) + extend( + ActionView::Helpers::TagHelper, + ActionView::Helpers::FormTagHelper, + ActionView::Helpers::UrlHelper, + ActionView::Helpers::FormOptionsHelper, + ApplicationHelper + ) + + lambdas_list = [] + + if not show_information + return operating_system_html_structure({:operating_system_name_id => "", :version => ""}, have_delete_button) if list_operating_system.nil? + + list_operating_system.each do |operating_system| + lambdas_list << operating_system_html_structure(operating_system,have_delete_button) + end + else + list_operating_system.each do |operating_system| + lambdas_list << operating_system_html_structure(operating_system) + end + end + + lambdas_list + end + + def self.operating_system_html_structure (operating_system_data,have_delete_button = true) + Proc::new do + content_tag('table', + content_tag('tr', + content_tag('td', label_tag(_("Name")))+ + content_tag('td', select_tag("operating_system[][operating_system_name_id]", SoftwareHelper.select_options(OperatingSystemName.all, operating_system_data[:operating_system_name_id]) ))+ + content_tag('td') + )+ + + content_tag('tr', + content_tag('td', label_tag(_("Version")))+ + content_tag('td', text_field_tag("operating_system[][version]", operating_system_data[:version]))+ + if have_delete_button + content_tag('td', + button_without_text(:delete, _('Delete'), "#" , :class=>"delete-dynamic-table"), + :align => 'right' + ) + else + content_tag('td', "") + end + ),:class => 'dynamic-table library-table' + ) + end + end + + def self.add_dynamic_table + operating_system_as_tables(nil).call + end +end diff --git a/lib/operating_system_name.rb b/lib/operating_system_name.rb new file mode 100644 index 0000000..cc59602 --- /dev/null +++ b/lib/operating_system_name.rb @@ -0,0 +1,10 @@ +class OperatingSystemName < ActiveRecord::Base + attr_accessible :name + + validates_presence_of :name + validates_uniqueness_of :name + + has_many :operating_systems + has_many :software_infos, :through => :operating_systems + +end diff --git a/lib/private_institution.rb b/lib/private_institution.rb new file mode 100644 index 0000000..075b966 --- /dev/null +++ b/lib/private_institution.rb @@ -0,0 +1,4 @@ +class PrivateInstitution < Institution + validates :cnpj, :presence=>true, :uniqueness=>true + validates_format_of :cnpj, :with => /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/ +end \ No newline at end of file diff --git a/lib/programming_language.rb b/lib/programming_language.rb new file mode 100644 index 0000000..d871fe2 --- /dev/null +++ b/lib/programming_language.rb @@ -0,0 +1,10 @@ +class ProgrammingLanguage < ActiveRecord::Base + attr_accessible :name + + validates_presence_of :name + validates_uniqueness_of :name + + has_many :software_languages + has_many :software_infos, :through => :software_languages + +end diff --git a/lib/public_institution.rb b/lib/public_institution.rb new file mode 100644 index 0000000..1964cb1 --- /dev/null +++ b/lib/public_institution.rb @@ -0,0 +1,5 @@ +class PublicInstitution < Institution + validates :acronym, :governmental_power, :governmental_sphere, :presence=>true + validates_uniqueness_of :cnpj, :unit_code, :allow_nil => true, :allow_blank => true + validates_format_of :cnpj, :with => /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/, :allow_nil => true, :allow_blank => true +end \ No newline at end of file diff --git a/lib/software_database.rb b/lib/software_database.rb new file mode 100644 index 0000000..3ba3481 --- /dev/null +++ b/lib/software_database.rb @@ -0,0 +1,9 @@ +class SoftwareDatabase < ActiveRecord::Base + attr_accessible :version, :operating_system + + belongs_to :software_info + belongs_to :database_description + + validates_presence_of :database_description_id, :version, :operating_system + +end diff --git a/lib/software_helper.rb b/lib/software_helper.rb new file mode 100644 index 0000000..29290fa --- /dev/null +++ b/lib/software_helper.rb @@ -0,0 +1,41 @@ +module SoftwareHelper + def self.select_options programming_languages, selected=0 + value = "" + + programming_languages.each do |language| + value += "" + end + + value + end + + def self.create_list_with_file file_name, model + list_file = File.open file_name, "r" + + list_file.each_line do |line| + model.create(:name=>line.strip) + end + + list_file.close + end + + def self.all_table_is_empty? table, ignored_fields=[] + filled_fields = [] + + table.each do |key, value| + unless ignored_fields.include? key + filled_fields << if value.empty? + false + else + true + end + end + end + + if filled_fields.include? true + false + else + true + end + end +end diff --git a/lib/software_info.rb b/lib/software_info.rb new file mode 100644 index 0000000..4d00dd8 --- /dev/null +++ b/lib/software_info.rb @@ -0,0 +1,63 @@ +class SoftwareInfo < ActiveRecord::Base + attr_accessible :e_mag, :icp_brasil, :intern, :e_ping, :e_arq, :operating_platform, :demonstration_url, :acronym, :objectives, :features, :license_infos_id, :community_id + + has_many :libraries, :dependent => :destroy + has_many :software_databases + has_many :database_descriptions, :through => :software_databases + has_many :software_languages + has_many :operating_systems + has_many :programming_languages, :through => :software_languages + has_many :operating_system_names, :through => :operating_systems + + belongs_to :community + belongs_to :license_info + + has_one :controlled_vocabulary + + validate :validate_operating_platform, :validate_acronym, :valid_software_info, :valid_databases, :valid_operating_systems + + # used on find_by_contents + scope :like_search, lambda{ |name| + joins(:community).where("name ilike ?", "%#{name}%") + } + + def validate_operating_platform + self.errors.add(:operating_platform, _("can't be blank")) if self.operating_platform.blank? && self.errors.messages[:operating_platform].nil? + end + + def validate_acronym + if self.acronym.blank? && self.errors.messages[:acronym].nil? + self.errors.add(:acronym, _("can't be blank")) + elsif self.acronym.length > 8 && self.errors.messages[:acronym].nil? + self.errors.add(:acronym, _("can't have more than 8 characteres")) + end + end + + def valid_operating_systems + self.errors.add(:operating_system, _(": at least one must be filled")) if self.operating_systems.empty? + end + + def valid_software_info + self.errors.add(:software_languages, _(": at least one must be filled")) if self.software_languages.empty? + end + + def valid_databases + self.errors.add(:software_databases, _(": at least one must be filled")) if self.software_databases.empty? + end + + def visible? + self.community.visible? + end + + def name + self.community.name + end + + def short_name + self.community.short_name + end + + def identifier + self.community.identifier + end +end diff --git a/lib/software_language.rb b/lib/software_language.rb new file mode 100644 index 0000000..1b86529 --- /dev/null +++ b/lib/software_language.rb @@ -0,0 +1,8 @@ +class SoftwareLanguage < ActiveRecord::Base + attr_accessible :version, :operating_system + + belongs_to :software_info + belongs_to :programming_language + + validates_presence_of :version,:programming_language,:operating_system +end diff --git a/lib/software_language_helper.rb b/lib/software_language_helper.rb new file mode 100644 index 0000000..8ec6c47 --- /dev/null +++ b/lib/software_language_helper.rb @@ -0,0 +1,118 @@ +module SoftwareLanguageHelper + + def self.list_language new_languages + return [] if new_languages.nil? or new_languages.length == 0 + list_languages = [] + + new_languages.each do |new_language| + unless SoftwareHelper.all_table_is_empty? new_language, ["programming_language_id"] + language = SoftwareLanguage.new + language.programming_language = ProgrammingLanguage.find(new_language[:programming_language_id]) + language.version = new_language[:version] + language.operating_system = new_language[:operating_system] + list_languages << language + end + end + + list_languages + end + + def self.valid_list_language? list_languages + return false if list_languages.nil? or list_languages.length == 0 + + list_languages.each do |language| + return false unless language.valid? + end + + true + end + + def self.language_as_tables(list_languages, have_delete_button = true, show_information = false) + extend( + ActionView::Helpers::TagHelper, + ActionView::Helpers::FormTagHelper, + ActionView::Helpers::UrlHelper, + ActionView::Helpers::FormOptionsHelper, + ApplicationHelper + ) + + lambdas_list = [] + + if not show_information + return language_html_structure({:programming_language_id => 1, :version => "", :operating_system => ""}, have_delete_button) if list_languages.nil? + + list_languages.each do |language| + lambdas_list << language_html_structure(language, have_delete_button) + end + + else + list_languages.each do |language| + lambdas_list << language_html_show_structure(language) + end + + end + + + lambdas_list + end + + def self.language_html_structure(language_data, have_delete_button = true) + Proc::new do + content_tag('table', + content_tag('tr', + content_tag('td', label_tag(_("Language Name: ")))+ + content_tag('td', select_tag("language[][programming_language_id]", SoftwareHelper.select_options(ProgrammingLanguage.all, language_data[:programming_language_id]) ))+ + content_tag('td') + )+ + + content_tag('tr', + content_tag('td', label_tag(_("Version")))+ + content_tag('td', text_field_tag("language[][version]", language_data[:version]))+ + content_tag('td') + )+ + + content_tag('tr', + content_tag('td', label_tag(_("Operating System")))+ + content_tag('td', text_field_tag("language[][operating_system]", language_data[:operating_system]))+ + + if have_delete_button + content_tag('td', + button_without_text(:delete, _('Delete'), "#" , :class=>"delete-dynamic-table"), + :align => 'right' + ) + else + content_tag('td', "") + end + ), :class => 'dynamic-table software-language-table' + ) + end + end + + def self.language_html_show_structure(language) + Proc::new do + content_tag('table', + content_tag('tr', + content_tag('td', label_tag(_("Language Name: ")))+ + content_tag('td', ProgrammingLanguage.where(:id => language[:programming_language_id])[0].name)+ + content_tag('td') + )+ + + content_tag('tr', + content_tag('td', label_tag(_("Version")))+ + content_tag('td', language[:version])+ + content_tag('td') + )+ + + content_tag('tr', + content_tag('td', label_tag(_("Operating System")))+ + content_tag('td', language[:operating_system])+ + content_tag('td', "") + ), :class => 'dynamic-table software-language-table' + ) + end + end + + def self.add_dynamic_table + language_as_tables(nil).call + end +end diff --git a/public/mpog-institution-validations.js b/public/mpog-institution-validations.js new file mode 100644 index 0000000..6d4ce3f --- /dev/null +++ b/public/mpog-institution-validations.js @@ -0,0 +1,129 @@ +(function(){ + function open_create_institution_modal(evt) { + evt.preventDefault(); + + jQuery.get("/plugin/mpog_software/create_institution", function(response){ + jQuery("#institution_dialog").html(response); + set_events(); + + jQuery("#institution_dialog").dialog({ + modal: true, + width: 500, + height: 530, + position: 'center', + close: function() { + jQuery("#institution_dialog").html(""); + jQuery('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); + } + }); + }); + } + + function show_public_institutions_fields() { + jQuery(".public-institutions-fields").show(); + jQuery("label[for='institutions_acronym']").html(jQuery("#acronym_translate").val()); + } + + function show_private_institutions_fields() { + jQuery(".public-institutions-fields").hide(); + jQuery("label[for='institutions_acronym']").html(jQuery("#fantasy_name_translate").val()); + + jQuery("#institutions_governmental_power option").selected(0); + jQuery("#institutions_governmental_sphere option").selected(0); + } + + function get_selected_institution_type() { + var radio_buttons = jQuery("input[type='radio'][name='type']"); + var type = ""; + + for( var i = 0; i < radio_buttons.length; i++ ) { + if( radio_buttons[i].checked ) { + type = radio_buttons[i].value; + break; + } + } + + return type; + } + + function get_post_data() { + return { + community : { name : jQuery("#community_name").val()}, + governmental : { + power : jQuery("#institutions_governmental_power").selected().val(), + sphere : jQuery("#institutions_governmental_sphere").selected().val() + } , + institution : { + cnpj: jQuery("#institutions_cnpj").val(), + type: get_selected_institution_type(), + acronym : jQuery("#institutions_acronym").val() + }, + authenticity_token : jQuery("input[name='authenticity_token']").val(), + recaptcha_response_field : jQuery('#recaptcha_response_field').val(), + recaptcha_challenge_field : jQuery('#recaptcha_challenge_field').val() + } + } + + function success_ajax_response(response) { + close_loading(); + if(response.success){ + jQuery("#institution_dialog").html("

"+response.message+"

"); + jQuery("#input_institution").val(response.institution_data.name); + jQuery("#user_institution_id").val(response.institution_data.id); + jQuery("#create_institution_errors").switchClass("show-field", "hide-field"); + } else { + var errors = ""; + + jQuery("#create_institution_errors").switchClass("hide-field", "show-field").html("

"+response.message+"

"+errors); + } + } + + function save_institution(evt) { + evt.preventDefault(); + var form_data = jQuery("#institution_form").serialize(); + + open_loading(jQuery("#loading_message").val()); + jQuery.ajax({ + url: "/plugin/mpog_software/new_institution", + data : get_post_data(), + type: "POST", + success: success_ajax_response, + error: function() { + close_loading(); + var error_message = jQuery("#institution_error_message").val(); + jQuery("#create_institution_errors").switchClass("hide-field", "show-field").html("

"+error_message+"

"); + } + }); + } + + function institution_already_exists(){ + if( this.value.length >= 3 ) { + jQuery.get("/plugin/mpog_software/institution_already_exists", {name:this.value}, function(response){ + if( response == true ) { + jQuery("#already_exists_text").switchClass("hide-field", "show-field"); + } else { + jQuery("#already_exists_text").switchClass("show-field", "hide-field"); + } + }); + } + } + + function set_events() { + jQuery("#create_institution_link").click(open_create_institution_modal); + + jQuery("#type_PrivateInstitution").click(show_private_institutions_fields); + + jQuery("#type_PublicInstitution").click(show_public_institutions_fields); + + jQuery('#save_institution_button').click(save_institution); + + jQuery("#community_name").keyup(institution_already_exists); + } + + jQuery(document).ready(set_events); +})(); \ No newline at end of file diff --git a/public/mpog-software-validations.js b/public/mpog-software-validations.js new file mode 100644 index 0000000..9d89d63 --- /dev/null +++ b/public/mpog-software-validations.js @@ -0,0 +1,159 @@ +function delete_dynamic_table() { + var button = jQuery(".delete-dynamic-table"); + + button.each(function(){ + var table = jQuery(this).parent().parent().parent().parent(); + var color = table.css("background-color"); + + jQuery(this).click(function(){ + if( table.hasClass("software-language-table") && has_more_than_one("software-language-table")) + table.remove(); + + if( table.hasClass("database-table") && has_more_than_one("database-table")) + table.remove(); + + if( !table.hasClass("software-language-table") && !table.hasClass("database-table") ) + table.remove(); + + return false; + }).mouseover(function(){ + table.css("background-color", "#eee"); + }).mouseout(function(){ + table.css("background-color", color); + }); + }); +} + +function has_more_than_one(table_class) { + return (jQuery("."+table_class).length > 2); // One is always added by defaul and its hidden +} + +function add_dynamic_table(element_id, content) { + Element.insert(element_id, {bottom: content}); +} + +function get_license_link(select_id){ + var selected = jQuery('#'+select_id).selected().val(); + var link = jQuery("#version_" + selected).val(); + + jQuery("#version_link") + .attr("href", link) + .text(link); +} + +function hide_infos(){ + jQuery(".language-info").hide(); + jQuery(".database-info").hide(); + jQuery(".libraries-info").hide(); + jQuery(".operating-system-info").hide(); + jQuery(".language-button-hide").hide(); + jQuery(".database-button-hide").hide(); + jQuery(".libraries-button-hide").hide(); + jQuery(".operating-system-button-hide").hide(); + + +} + +function animate_fields() { + jQuery(".expand-field").focus(function(){ + jQuery(this).switchClass("expand-field", "expand-field-focus", 700, "easeInOutQuad"); + }).blur(function(){ + jQuery(this).switchClass("expand-field-focus", "expand-field", 700, "easeInOutQuad"); + }); +} + + +jQuery(document).ready(function(){ + var dynamic_tables = ["dynamic-databases", "dynamic-languages", "dynamic-libraries","dynamic-operating_systems"]; + + delete_dynamic_table(); + + jQuery(".new-dynamic-table").click(function(){ + var link = jQuery(this); + + dynamic_tables.each(function(value){ + if( link.hasClass(value) ) { + var table_id = value.split("-")[1]; + + var table_html = jQuery("#table_structure_"+table_id).html(); + add_dynamic_table(table_id, table_html); + } + }); + + delete_dynamic_table(); + return false; + }); + + hide_infos(); + + jQuery(".language-button-hide").click(function(event){ + event.preventDefault(); + jQuery(".language-info").hide(); + jQuery(".language-button-show").show(); + jQuery(".language-button-hide").hide(); + }); + + jQuery(".language-button-show").click(function(event){ + event.preventDefault(); + jQuery(".language-info").show(); + jQuery(".language-button-show").hide(); + jQuery(".language-button-hide").show(); + }); + + jQuery(".operating-system-button-hide").click(function(event){ + event.preventDefault(); + jQuery(".operating-system-info").hide(); + jQuery(".operating-system-button-show").show(); + jQuery(".operating-system-button-hide").hide(); + }); + + jQuery(".operating-system-button-show").click(function(event){ + event.preventDefault(); + jQuery(".operating-system-info").show(); + jQuery(".operating-system-button-show").hide(); + jQuery(".operating-system-button-hide").show(); + }); + + jQuery(".database-button-hide").click(function(event){ + event.preventDefault(); + jQuery(".database-info").hide(); + jQuery(".database-button-show").show(); + jQuery(".database-button-hide").hide(); + }); + + jQuery(".database-button-show").click(function(event){ + event.preventDefault(); + jQuery(".database-info").show(); + jQuery(".database-button-show").hide(); + jQuery(".database-button-hide").show(); + }); + + jQuery(".libraries-button-hide").click(function(event){ + event.preventDefault(); + jQuery(".libraries-info").hide(); + jQuery(".libraries-button-show").show(); + jQuery(".libraries-button-hide").hide(); + }); + + jQuery(".libraries-button-show").click(function(event){ + event.preventDefault(); + jQuery(".libraries-info").show(); + jQuery(".libraries-button-show").hide(); + jQuery(".libraries-button-hide").show(); + }); + + jQuery(".operating_systems-button-hide").click(function(event){ + event.preventDefault(); + jQuery(".operating_systems-info").hide(); + jQuery(".operating_systems-button-show").show(); + jQuery(".operating_systems-button-hide").hide(); + }); + + jQuery(".operating_systems-button-show").click(function(event){ + event.preventDefault(); + jQuery(".operating_systems-info").show(); + jQuery(".operating_systems-button-show").hide(); + jQuery(".operating_systems-button-hide").show(); + }); + animate_fields(); +}); diff --git a/public/mpog-user-validations.js b/public/mpog-user-validations.js new file mode 100644 index 0000000..4fddbc4 --- /dev/null +++ b/public/mpog-user-validations.js @@ -0,0 +1,112 @@ +function check_reactivate_account(value, input_object){ + jQuery.ajax({ + url : "/plugin/mpog_software/check_reactivate_account", + type: "GET", + data: { "email": value }, + success: function(response) { + if( jQuery("#forgot_link").length == 0 ) + jQuery(input_object).parent().append(response); + else + jQuery("#forgot_link").html(response); + }, + error: function(type, err, message) { + console.log(type+" -- "+err+" -- "+message); + } + }); +} + +function put_brazil_based_on_email(){ + var suffixes = ['gov.br', 'jus.br', 'leg.br', 'mp.br']; + var value = this.value; + var input_object = this; + + suffixes.each(function(suffix){ + var has_suffix = new RegExp("(.*)"+suffix+"$", "i"); + + if( has_suffix.test(value) ) + jQuery("#profile_data_country").val("BR"); + }); + + check_reactivate_account(value, input_object) +} + +function validate_email_format(){ + var correct_format_regex = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/; + + if( this.value.length > 0 ) { + if(correct_format_regex.test(this.value)) + this.className = "validated"; + else + this.className = "invalid"; + } else + this.className = ""; +} + +function institution_autocomplete() { + jQuery("#input_institution").autocomplete({ + source : function(request, response){ + jQuery.ajax({ + type: "GET", + url: "/plugin/mpog_software/get_institutions", + data: {query: request.term}, + success: function(result){ + response(result); + + if( result.length == 0 ) { + jQuery('#institution_empty_ajax_message').switchClass("hide-field", "show-field"); + } else { + jQuery('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); + } + }, + error: function(ajax, stat, errorThrown) { + console.log('Link not found : ' + errorThrown); + } + }); + }, + + minLength: 2, + + select : function (event, selected) { + jQuery("#user_institution_id").val(selected.item.id); + } + }); +} + + +function hide_incomplete_percentage(evt) { + evt.preventDefault(); + var link_div = jQuery(this).parent(); + + jQuery.get("/plugin/mpog_software/hide_registration_incomplete_percentage", {hide:true}, function(response){ + if( response == true ) + link_div.hide(); + }); +} + +jQuery(document).ready(function(){ + jQuery('#secondary_email_field').blur( + validate_email_format + ); + + jQuery("#user_email").blur( + put_brazil_based_on_email + ); + + jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage); + + jQuery('#secondary_email_field').focus(function() { jQuery('#secondary-email-balloon').fadeIn('slow'); }); + jQuery('#secondary_email_field').blur(function() { jQuery('#secondary-email-balloon').fadeOut('slow'); }); + + jQuery('#role_field').focus(function() { jQuery('#role-balloon').fadeIn('slow'); }); + jQuery('#role_field').blur(function() { jQuery('#role-balloon').fadeOut('slow'); }); + + jQuery('#area_interest_field').focus(function() { jQuery('#area-interest-balloon').fadeIn('slow'); }); + jQuery('#area_interest_field').blur(function() { jQuery('#area-interest-balloon').fadeOut('slow'); }); + + institution_autocomplete(); + + jQuery("#input_institution").blur(function(){ + if( this.value == "" ) + jQuery("#user_institution_id").val(""); + }); +}); diff --git a/public/mpog_custom_functions.js b/public/mpog_custom_functions.js new file mode 100644 index 0000000..c0c5ecc --- /dev/null +++ b/public/mpog_custom_functions.js @@ -0,0 +1,16 @@ +Array.prototype.removeValue = function(value) { + for (var i = 0; i < this.length; i++) { + if (this[i] === value) { + this.splice(i, 1); + i--; + } + } + + return this; +} + +Array.prototype.removeIndex = function(index) { + this.splice(index, 1); + + return this; +} diff --git a/public/static/databases.txt b/public/static/databases.txt new file mode 100644 index 0000000..f997988 --- /dev/null +++ b/public/static/databases.txt @@ -0,0 +1,176 @@ +4th Dimension +Adabas D +Aerospike +AllegroGraph +Alpha Five +Altibase +Amazon DynamoDB +Apache Accumulo +Apache Cassandra +Apache CouchDB +Apache Derby +Apache Hbase +Apache JENA +Apache River +Aster Data +BaseX +Berkeley DB +BigTable +BlackRay +CA-Datacom +CDB +CSQL +CUBRID +Clarion +Cloudant +Cloudant Data Layer (CouchDB) +Clusterpoint +Clusterpoint XML database +Clustrix +Coherence +CoreFoundation Property list +Couchbase Server +D3 Pick database +DEX/Sparksee +Daffodil database +DataEase +Database Management Library +Dataphor +Datastore on Google Appengine +Derby aka Java DB +Dynamo +EXASolution +ElasticSearch +Empress Embedded Database +EnterpriseDB +Extensible Storage Engine (ESE/NT) +FileMaker Pro +Firebird +FlockDB +FoundationDB +Freebase +GT.M +GemStone/S +GigaSpaces +Greenplum +GroveSite +H2 +HSQLDB +Hazelcast +Helix database +Hibari +Hypertable +IBM DB2 +IBM DB2 Express-C +IBM Informix C-ISAM +IBM Lotus Approach +IBM Notes and IBM Domino +InfiniteGraph +InfinityDB +Infobright +Informix +Ingres +InterBase +InterSystems Caché +JADE +Jackrabbit +Keyspace +LevelDB +Linter +MariaDB +MarkLogic +MarkLogic Server +MaxDB +MemSQL +MemcacheDB +Microsoft Access +Microsoft Jet Database Engine +Microsoft SQL Server +Microsoft SQL Server Express +Microsoft Visual FoxPro +Mimer SQL +Mnesia +MonetDB +MongoDB +MySQL +NDBM +Neo4j +NeoDatis ODB +Netezza +NexusDB +NonStop SQL +ODABA +OWLIM +Object database +ObjectDB +ObjectDatabase++ +ObjectStore +Objectivity/DB +Ontotext-OWLIM +OpenLink Virtuoso +OpenLink Virtuoso Universal Server +OpenOffice.org Base +OpenQM +Openbase +Oracle +Oracle NoSQL Database +Oracle Rdb for OpenVMS +OrientDB +Panorama +Perst +Pervasive PSQL +Polyhedra +PostgreSQL +Postgres Plus Advanced Server +Progress Software +R:Base +RDM Embedded +RDM Server +Revelation Software's OpenInsight +Riak +Rocket U2 +SAND CDBMS +SAP HANA +SAP Sybase Adaptive Server Enterprise +SAP Sybase IQ +SQL Anywhere +SQLBase +SQLite +ScimoreDB +Sedna +SimpleDB +SmallSQL +Solr +Sones GraphDB +SparkleDB +Sqrrl Enterprise +Sybase Advantage Database Server +Tarantool +Teradata +The SAS system +TimesTen +TokuMX +Tokyo Cabinet +Tuple space +UniData +UniVerse +Unisys RDMS 2200 +VMDS +Vectorwise +Versant Object Database +Vertica +Virtuoso Universal Server +WakandaDB +XAP +ZODB +dBase +db4o +djondb +eXist +eXtremeDB +mSQL +memcached +mizanSQL +redis +solidDB +txtSQL diff --git a/public/static/governmental_powers.txt b/public/static/governmental_powers.txt new file mode 100644 index 0000000..f8bc341 --- /dev/null +++ b/public/static/governmental_powers.txt @@ -0,0 +1,3 @@ +executivo +legislativo +judiciario \ No newline at end of file diff --git a/public/static/governmental_sphere.txt b/public/static/governmental_sphere.txt new file mode 100644 index 0000000..4833200 --- /dev/null +++ b/public/static/governmental_sphere.txt @@ -0,0 +1 @@ +federal \ No newline at end of file diff --git a/public/static/languages.txt b/public/static/languages.txt new file mode 100644 index 0000000..2ff05cb --- /dev/null +++ b/public/static/languages.txt @@ -0,0 +1,673 @@ +A# +A-0 System +A+ +A++ +ABAP +ABC +ABC ALGOL +ABLE +ABSET +ABSYS +ACC +Accent +Ace DASL +ACL2 +ACT-III +Action! +ActionScript +Ada +Adenine +Agda +Agilent VEE +Agora +AIMMS +Alef +ALF +ALGOL 58 +ALGOL 60 +ALGOL 68 +ALGOL W +Alice +Alma-0 +AmbientTalk +Amiga E +AMOS +AMPL +APL +AppleScript +Arc +ARexx +Argus +AspectJ +Assembly language +ATS +Ateji PX +AutoHotkey +Autocoder +AutoIt +AutoLISP / Visual LISP +Averest +AWK +Axum +B +Babbage +BAIL +Bash +BASIC +bc +BCPL +BeanShell +Batch +Bertrand +BETA +Bigwig +Bistro +BitC +BLISS +Blue +Bon +Boo +Boomerang +Bourne shell +BREW +BPEL +BuildProfessional +C +C-- +C++ +C# +C/AL +Caché ObjectScript +C Shell +Caml +Candle +Cayenne +CDuce +Cecil +Cel +Cesil +Ceylon +CFML +Cg +Ch +Chapel +CHAIN +Charity +Charm +Chef +CHILL +CHIP-8 +chomski +ChucK +CICS +Cilk +CL (IBM) +Claire +Clarion +Clean +Clipper +CLIST +Clojure +CLU +CMS-2 +COBOL +Cobra +CODE +CoffeeScript +Cola +ColdC +ColdFusion +Cool +COMAL +Combined Programming Language +Common Intermediate Language +Common Lisp +COMPASS +Component Pascal +COMIT +Constraint Handling Rules +Converge +Coral 66 +Corn +CorVision +Coq +COWSEL +CPL +csh +CSP +Csound +Curl +Curry +Cyclone +Cython +D +DASL +Dart +DataFlex +Datalog +DATATRIEVE +dBase +dc +Deesel +Delphi +DCL +DinkC +DIBOL +Dog +Draco +DRAKON +Dylan +DYNAMO +E +E# +Ease +Easy PL/I +EASYTRIEVE PLUS +ECMAScript +Edinburgh IMP +EGL +Eiffel +ELAN +Elixir +Elm +Emacs Lisp +Emerald +Epigram +Erlang +es +Escapade +Escher +ESPOL +Esterel +Etoys +Euclid +Euler +Euphoria +EusLisp +CMS EXEC +EXEC 2 +Executable UML +F +F# +Factor +Falcon +Fancy +Fantom +FAUST +Felix +Ferite +FFP +Fjölnir +FL +Flavors +Flex +FLOW-MATIC +FOCAL +FOCUS +FOIL +FORMAC +@Formula +Forth +Fortran +Fortress +FoxBase +FoxPro +FP +FPr +Franz Lisp +F-Script +FSProg +G +Game Maker Language +GameMonkey Script +GAMS +GAP +G-code +Genie +GDL +Gibiane +GJ +GEORGE +GLSL +GNU E +GM +Go +Go! +GOAL +Gödel +Godiva +GOM +Goo +Gosu +GOTRAN +GPSS +GraphTalk +GRASS +Groovy +Hack +HAL/S +Hamilton C shell +Harbour +Hartmann pipelines +Haskell +Haxe +High Level Assembly +HLSL +Hop +Hope +Hugo +Hume +HyperTalk +IBM Basic assembly language +IBM HAScript +IBM Informix-4GL +IBM RPG +ICI +Icon +Id +IDL +Idris +IMP +Inform +Io +Ioke +IPL +IPTSCRAE +ISLISP +ISPF +ISWIM +J +J# +J++ +JADE +Jako +JAL +Janus +JASS +Java +JavaScript +JCL +JEAN +Join Java +JOSS +Joule +JOVIAL +Joy +JScript +JavaFX Script +Julia +K +Kaleidoscope +Karel +Karel++ +KEE +KIF +Kojo +Kotlin +KRC +KRL +KRYPTON +ksh +L +L# +LabVIEW +Ladder +Lagoona +LANSA +Lasso +LaTeX +Lava +LC-3 +Leadwerks Script +Leda +Legoscript +LIL +LilyPond +Limbo +Limnor +LINC +Lingo +Linoleum +LIS +LISA +Lisaac +Lisp +Lite-C +Lithe +Little b +Logo +Logtalk +LPC +LSE +LSL +LiveCode +LiveScript +Lua +Lucid +Lustre +LYaPAS +Lynx +M +M2001 +M4 +Machine code +MAD +MAD/I +Magik +Magma +make +Maple +MAPPER +MARK-IV +Mary +MASM +Mathematica +MATLAB +Maxima +Max +MaxScript +Maya +MDL +Mercury +Mesa +Metacard +Metafont +MetaL +Microcode +MicroScript +MIIS +MillScript +MIMIC +Mirah +Miranda +MIVA Script +ML +Moby +Model 204 +Modelica +Modula +Modula-2 +Modula-3 +Mohol +MOO +Mortran +Mouse +MPD +MSIL +MSL +MUMPS +NASM +NATURAL +Napier88 +Neko +Nemerle +nesC +NESL +Net.Data +NetLogo +NetRexx +NewLISP +NEWP +Newspeak +NewtonScript +NGL +Nial +Nice +Nickle +NPL +Not eXactly C +Not Quite C +NSIS +Nu +NWScript +o:XML +Oak +Oberon +Obix +OBJ2 +Object Lisp +ObjectLOGO +Object REXX +Object Pascal +Objective-C +Objective-J +Obliq +Obol +OCaml +occam +occam-π +Octave +OmniMark +Onyx +Opa +Opal +OpenEdge ABL +OPL +OPS5 +OptimJ +Orc +ORCA/Modula-2 +Oriel +Orwell +Oxygene +Oz +P# +PARI/GP +Pascal +Pawn +PCASTL +PCF +PEARL +PeopleCode +Perl +PDL +PHP +Phrogram +Pico +Pict +Pike +PIKT +PILOT +Pipelines +Pizza +PL-11 +PL/0 +PL/B +PL/C +PL/I +PL/M +PL/P +PL/SQL +PL360 +PLANC +Plankalkül +PLEX +PLEXIL +Plus +POP-11 +PostScript +PortablE +Powerhouse +PowerBuilder +PowerShell +PPL +Processing +Processing.js +Prograph +PROIV +Prolog +Visual Prolog +Promela +PROSE modeling language +PROTEL +ProvideX +Pro*C +Pure +Python +Q +Qalb +Qi +QtScript +QuakeC +QPL +R +R++ +Racket +RAPID +Rapira +Ratfiv +Ratfor +rc +REBOL +Red +Redcode +REFAL +Reia +Revolution +rex +REXX +Rlab +RobotC +ROOP +RPG +RPL +RSL +RTL/2 +Ruby +Rust +S +S2 +S3 +S-Lang +S-PLUS +SA-C +SabreTalk +SAIL +SALSA +SAM76 +SAS +SASL +Sather +Sawzall +SBL +Scala +Scheme +Scilab +Scratch +Script.NET +Sed +Seed7 +Self +SenseTalk +SequenceL +SETL +Shift Script +SIMPOL +SIMSCRIPT +Simula +Simulink +SISAL +SLIP +SMALL +Smalltalk +Small Basic +SML +SNOBOL +Snowball +SOL +Span +SPARK +SPIN +SP/k +SPS +Squeak +Squirrel +SR +S/SL +Starlogo +Strand +Stata +Stateflow +Subtext +SuperCollider +SuperTalk +SYMPL +SyncCharts +SystemVerilog +T +TACL +TACPOL +TADS +TAL +Tcl +Tea +TECO +TELCOMP +TeX +TEX +TIE +Timber +TMG, compiler-compiler +Tom +TOM +Topspeed +TPU +Trac +TTM +T-SQL +TTCN +Turing +TUTOR +TXL +TypeScript +Turbo C++ +Ubercode +UCSD Pascal +Umple +Unicon +Uniface +UNITY +Unix shell +UnrealScript +Vala +VBA +VBScript +Verilog +VHDL +Visual Basic +Visual Basic .NET +Microsoft Visual C++ +Visual C# +Visual DataFlex +Visual DialogScript +Visual Fortran +Visual FoxPro +Visual J++ +Visual J# +Visual Objects +VSXu +Vvvv +WATFIV, WATFOR +WebDNA +WebQL +Windows PowerShell +Winbatch +X++ +X# +X10 +XBL +XC +xHarbour +XL +XOTcl +XPL +XPL0 +XQuery +XSB +XSLT +Yorick +YQL +Z notation +Zeno +ZOPL +ZPL \ No newline at end of file diff --git a/public/static/operating_systems.txt b/public/static/operating_systems.txt new file mode 100644 index 0000000..445ec6e --- /dev/null +++ b/public/static/operating_systems.txt @@ -0,0 +1,9 @@ +Debian +Ubuntu +Windows +CentOS +RedHat +Mint +MacOS +Fedora +Arch \ No newline at end of file diff --git a/public/style.css b/public/style.css new file mode 100644 index 0000000..0075970 --- /dev/null +++ b/public/style.css @@ -0,0 +1,115 @@ +.mpog_hidden_field{ + display: none; +} + +#signup-form small#secondary-email-balloon , +#signup-form small#role-balloon, +#signup-form small#area-interest-balloon +{ + display: none; + width: 142px; + height: 69px; + color: #FFFFFF; + font-weight: bold; + font-size: 11px; + padding: 5px 10px 45px 10px; + margin: 0; + line-height: 1.5em; + background: transparent url(/images/gray-balloon.png) bottom center no-repeat; + position: absolute; + z-index: 2; + right: -150px; +} + +#signup-form #signup-secondary-email, +#signup-form #signup-role, +#signup-form #signup-area-interest +{ + position: relative; +} + +#signup-form small#secondary-email-balloon, +#signup-form small#role-balloon, +#signup-form small#area-interest-balloon +{ + top: -80px; +} + +.dynamic-table { + border: solid 1px #000; + margin-top: 5px; + margin-bottom: 15px; +} +.dynamic-table td, .dynamic-table tr { + border: none; +} + +.expand-field { + height: 80px; +} + +.expand-field-focus { + height: 300px; +} + +.mpog-incomplete-percentage img { + margin-left: 5px; +} + +.mpog-incomplete-percentage img:hover { + cursor: pointer; +} + +#institution_dialog { + display: none; +} + +.errorExplanation { + color: red; + margin-left: 10px; +} + +.hide-field { + display: none !important; +} + +.show-field { + display: block !important; +} + +#user_filter_content { + display: block; + width: 100%; + height: auto; +} + +.user_filter_options { + width: 80%; + height: auto; + position: relative; + float: left; +} + +.user_filter_options input[type='text'] { + width: 78%; + +} + +.user_filter_actions { + width: 18 %; + height: auto; + position: relative; + float: right; + text-align: right; +} + +.search-table tr td:first-child { + width: 40px; +} + +.formfieldline { + margin-top: 10px; +} +.formfieldline input[type="text"] { + width: 180px; +} \ No newline at end of file diff --git a/script/schedule_institution_update.sh b/script/schedule_institution_update.sh new file mode 100755 index 0000000..a6d0d0a --- /dev/null +++ b/script/schedule_institution_update.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cp plugins/mpog_software/config/institutions_update.example /etc/cron.d/institutions_update +echo "Created crontab file in /etc/cron.d/institution_update..." diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb new file mode 100644 index 0000000..06706d3 --- /dev/null +++ b/test/functional/account_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../../controllers/mpog_software_plugin_controller' + +class AccountController; def rescue_action(e) raise e end; end + +class AccountControllerTest < ActionController::TestCase + + def setup + @response = ActionController::TestResponse.new + @institution_list = [] + @institution_list << create_institution("Ministerio Publico da Uniao", "MPU") + @institution_list << create_institution("Tribunal Regional da Uniao", "TRU") + + @user_info = { + :login=>"novo_usuario", + :password=>"nova_senha", + :password_confirmation=>"nova_senha", + :email=>"um@novo.usuario", + :secondary_email=>"outro@email.com", + :role=>"um role ai", + :institution_id=>@institution_list.last.id + } + + @profile_data_info = { + :name=>"Um novo usuario", + :area_interest=>"uma area ai" + } + end + + should "Create a user without gov email and institution" do + @user_info[:institution_id] = nil + + post :signup, :user => @user_info, :profile_data => @profile_data_info + + assert_equal assigns(:user).login, @user_info[:login] + assert assigns(:user).save + end + + should "Create a user with gov email and institution" do + @user_info[:email] = "email@gov.br" + + post :signup, :user => @user_info, :profile_data => @profile_data_info + + assert_equal assigns(:user).login, @user_info[:login] + assert assigns(:user).save + end + + should "Do not create a user with gov email without institution" do + @user_info[:email] = "email@gov.br" + @user_info[:institution_id] = nil + + post :signup, :user => @user_info, :profile_data => @profile_data_info + + assert_equal assigns(:user).login, @user_info[:login] + assert !assigns(:user).save + end + + private + + def create_institution name, acronym + institution = Institution.new + institution.name = name + institution.acronym = acronym + institution.type = "PublicInstitution" + institution.save + institution + end + + def form_params + user = { + :login=>"novo_usuario", + :password=>"nova_senha", + :password_confirmation=>"nova_senha", + :email=>"um@novo.usuario", + :secondary_email=>"outro@email.com", + :role=>"um role ai", + :institution_id=>@institution_list.last.id + } + + profile_data = { + :name=>"Um novo usuario", + :area_interest=>"uma area ai" + } + + user["profile_data"] = profile_data + user + end +end \ No newline at end of file diff --git a/test/functional/mpog_software_plugin_controller_test.rb b/test/functional/mpog_software_plugin_controller_test.rb new file mode 100644 index 0000000..5d847e0 --- /dev/null +++ b/test/functional/mpog_software_plugin_controller_test.rb @@ -0,0 +1,112 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../../controllers/mpog_software_plugin_controller' + +class MpogSoftwarePluginController; def rescue_action(e) raise e end; end + + +class MpogSoftwarePluginControllerTest < ActionController::TestCase + + def setup + @govPower = GovernmentalPower.create(:name=>"Some Gov Power") + @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") + @response = ActionController::TestResponse.new + @institution_list = [] + @institution_list << create_public_institution("Ministerio Publico da Uniao", "MPU", @govPower, @govSphere) + @institution_list << create_public_institution("Tribunal Regional da Uniao", "TRU", @govPower, @govSphere) + end + + should "Search for institution with acronym" do + xhr :get, :get_institutions, :query=>"TRU" + + json_response = ActiveSupport::JSON.decode(@response.body) + + assert_equal "Tribunal Regional da Uniao", json_response[0]["value"] + end + + should "Search for institution with name" do + xhr :get, :get_institutions, :query=>"Minis" + + json_response = ActiveSupport::JSON.decode(@response.body) + + assert_equal "Ministerio Publico da Uniao", json_response[0]["value"] + end + + should "search with name or acronym and return a list with institutions" do + xhr :get, :get_institutions, :query=>"uni" + + json_response = ActiveSupport::JSON.decode(@response.body) + + assert_equal "Ministerio Publico da Uniao", json_response[0]["value"] + assert_equal "Tribunal Regional da Uniao", json_response[1]["value"] + end + + should "method create_institution return the html for modal" do + xhr :get, :create_institution + assert_template 'create_institution' + end + + should "create new institution with ajax" do + @controller.stubs(:verify_recaptcha).returns(true) + + xhr :get, :new_institution, + :authenticity_token=>"dsa45a6das52sd", + :community=>{:name=>"foo bar"}, + :institution => {:cnpj=>"12.234.567/8900-10", :acronym=>"fb", :type=>"PublicInstitution"}, + :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id}, + :recaptcha_response_field=>'' + + json_response = ActiveSupport::JSON.decode(@response.body) + + assert json_response["success"] + end + + should "not create a institution that already exists" do + @controller.stubs(:verify_recaptcha).returns(true) + + xhr :get, :new_institution, + :authenticity_token=>"dsa45a6das52sd", + :community=>{:name=>"Ministerio Publico da Uniao"}, + :institution => {:cnpj=>"12.234.567/8900-10", :acronym=>"fb", :type=>"PublicInstitution"}, + :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id}, + :recaptcha_response_field=>'' + + json_response = ActiveSupport::JSON.decode(@response.body) + + assert !json_response["success"] + end + + should "verify if institution name already exists" do + xhr :get, :institution_already_exists, :name=>"Ministerio Publico da Uniao" + assert_equal "true", @response.body + + xhr :get, :institution_already_exists, :name=>"Another name here" + assert_equal "false", @response.body + end + + + should "response as XML to export softwares" do + get :download, :format => 'xml' + assert_equal 'text/xml', @response.content_type + end + + should "response as CSV to export softwares" do + get :download, :format => 'csv' + assert_equal 'text/csv', @response.content_type + assert_equal "name;acronym;demonstration_url;e_arq;e_mag;e_ping;features;icp_brasil;objectives;operating_platform\n", @response.body + end + + + private + + def create_public_institution name, acronym, gov_p, gov_s + institution_community = Community::new :name=>name + institution = PublicInstitution.new + institution.community = institution_community + institution.name = name + institution.acronym = acronym + institution.governmental_power = gov_p + institution.governmental_sphere = gov_s + institution.save + institution + end +end diff --git a/test/unit/controlled_vocabulary_test.rb b/test/unit/controlled_vocabulary_test.rb new file mode 100644 index 0000000..4c5de0d --- /dev/null +++ b/test/unit/controlled_vocabulary_test.rb @@ -0,0 +1,47 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class ControlledVocabularyTest < ActiveSupport::TestCase + + def setup + @community = fast_create(Community) + @language = ProgrammingLanguage.new(:name => 'C++') + @language.save + @software_language = SoftwareLanguage.new(:version => '1', :operating_system => 'os') + @software_language.programming_language = @language + @software_language.save + @database = DatabaseDescription.new(:name => 'Oracle') + @database.save + @software_database = SoftwareDatabase.new(:version => '2', :operating_system => 'os2') + @software_database.database_description = @database + @software_database.save + @software_info = SoftwareInfo.new(:community_id=>1, :acronym => "SFTW", :e_mag => true,:icp_brasil => true,:intern => true,:e_ping => true, + :e_arq => true,:name => true,:operating_platform => true,:objectives => "",:features => "") + @controlled_language = ControlledVocabulary.new() + @controlled_vocabulary = ControlledVocabulary.new(:administration => true, :agriculture => true, :business_and_services => true, :communication => true, + :culture => true, :national_defense => true, :economy_and_finances => true, :education => true, + :energy => true, :sports => false , :habitation => true, :industry => true, :environment => true, + :research_and_development => true, :social_security => false , :social_protection => true, + :international_relations => true, :sanitation => true, :health => false, + :security_public_order => true, :work => true, :transportation => true, :urbanism => true) + @software_info.software_languages << @software_language + @software_info.software_databases << @software_database + @software_info.controlled_vocabulary = @controlled_vocabulary + end + + should "save software correctly with ControlledVocabulary filds" do + assert @software_info.save + end + + should "set in software_info a reference to controlled_vocabulary" do + @software_info.save + @controlled_vocabulary.save + assert_equal SoftwareInfo.last.controlled_vocabulary, ControlledVocabulary.last + end + + should "return a valid value from database" do + @software_info.save + @controlled_vocabulary.save + controlled_vocabulary = ControlledVocabulary.find(SoftwareInfo.last.controlled_vocabulary) + assert_equal true, controlled_vocabulary.education + end +end diff --git a/test/unit/database_helper_test.rb b/test/unit/database_helper_test.rb new file mode 100644 index 0000000..8afe4cf --- /dev/null +++ b/test/unit/database_helper_test.rb @@ -0,0 +1,58 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class DatabaseHelperTest < ActiveSupport::TestCase + + include DatabaseHelper + + def setup + @database_objects = [{"database_description_id" => "1" ,"version" => "2.0", "operating_system" => "debian"}, + {"database_description_id" => "2" ,"version" => "2.1", "operating_system" => "debian"}, + {"database_description_id" => "3" ,"version" => "2.2", "operating_system" => "debian"}] + @database_objects + end + + def teardown + @database_objects = nil + end + + should "return an empty list" do + empty_list = [] + assert_equal [],DatabaseHelper.list_database(empty_list) + end + + should "return a list with current database objects" do + list_compare = [] + assert_equal list_compare.class, DatabaseHelper.list_database(@database_objects).class + end + + should "have same information from the list passed as parameter" do + list_compare = DatabaseHelper.list_database(@database_objects) + assert_equal @database_objects.first[:database_description_id], list_compare.first.database_description_id + end + + should "return a list with the same size of the parameter" do + list_compare = DatabaseHelper.list_database(@database_objects) + assert_equal @database_objects.count, list_compare.count + end + + should "return false if list_database are empty or null" do + list_compare = [] + assert_equal false,DatabaseHelper.valid_list_database?(list_compare) + end + + should "return a html text with operating system equals to linux" do + databases = [] + + database_description = DatabaseDescription.new + database_description.name = "teste" + + software_database = SoftwareDatabase.new + software_database.version = 2 + software_database.operating_system = "linux" + software_database.database_description = database_description + + databases << software_database + + assert_not_nil DatabaseHelper.database_as_tables(databases).first.call.index("linux") + end + end diff --git a/test/unit/database_validation_test.rb b/test/unit/database_validation_test.rb new file mode 100644 index 0000000..b1502e5 --- /dev/null +++ b/test/unit/database_validation_test.rb @@ -0,0 +1,36 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class DatabaseValidationTest < ActiveSupport::TestCase + + def setup + @database_desc = DatabaseDescription.create(:name => "ABC") + @database = SoftwareDatabase.new + @database.database_description = @database_desc + @database.version = "MYSQL" + @database.operating_system = "debian" + @database + end + + def teardown + @database = nil + end + + should "Save database if all fields are filled" do + assert_equal true, @database.save + end + + should "Don't save database if database_description database_description is empty" do + @database.database_description = nil + assert_equal true, !@database.save + end + + should "Don't save database if operating system are empty" do + @database.operating_system = " " + assert_equal true, !@database.save + end + + should "Don't save database if version are empty" do + @database.version = " " + assert_equal true, !@database.save + end +end diff --git a/test/unit/governmental_power_test.rb b/test/unit/governmental_power_test.rb new file mode 100644 index 0000000..cd2e2e6 --- /dev/null +++ b/test/unit/governmental_power_test.rb @@ -0,0 +1,45 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class GovernmentalPowerTest < ActiveSupport::TestCase + def teardown + Institution.destroy_all + end + + should "get public institutions" do + gov_power = GovernmentalPower::new :name=>"Some gov power" + + assert build_institution("one").save + assert build_institution("two").save + assert build_institution("three").save + + assert gov_power.public_institutions.count == PublicInstitution.count + end + + should "not get private institutions" do + gov_power = GovernmentalPower::new :name=>"Some gov power" + + assert build_institution("one", "PrivateInstitution", "00.000.000/0000-00").save + assert build_institution("two","PrivateInstitution", "00.000.000/0000-01").save + assert build_institution("three","PrivateInstitution", "00.000.000/0000-02").save + + assert gov_power.public_institutions.count == 0 + assert gov_power.public_institutions.count == PublicInstitution.count + assert gov_power.public_institutions.count != PrivateInstitution.count + end + + private + + def build_institution name, type="PublicInstitution", cnpj=nil + institution = Institution::new + institution.name = name + institution.type = type + institution.cnpj = cnpj + + if type == "PublicInstitution" + institution.governmental_power = GovernmentalPower.first + institution.governmental_sphere = GovernmentalSphere.first + end + + institution + end +end \ No newline at end of file diff --git a/test/unit/institution_helper_test.rb b/test/unit/institution_helper_test.rb new file mode 100644 index 0000000..e1ef948 --- /dev/null +++ b/test/unit/institution_helper_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class InstitutionHelperTest < ActiveSupport::TestCase + + should "populate public institutions with data from SIORG" do + Institution.destroy_all + + InstitutionHelper.mass_update + + assert Institution.count != 0 + end + + should "receive json data from SIORG" do + data = InstitutionHelper.get_json(2, 1) + + assert data["unidades"].count != 0 + end +end diff --git a/test/unit/institution_test.rb b/test/unit/institution_test.rb new file mode 100644 index 0000000..2a35215 --- /dev/null +++ b/test/unit/institution_test.rb @@ -0,0 +1,16 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class InstitutionTest < ActiveSupport::TestCase + + should "save public institutions without name" do + institution = Institution::new + assert !institution.save + assert institution.errors.full_messages.include? "Name can't be blank" + end + + should "not save if institution has invalid type" do + institution = Institution::new :name => "teste", :type => "Other type" + assert !institution.save + assert institution.errors.full_messages.include? "Type invalid, only public and private institutions are allowed." + end +end \ No newline at end of file diff --git a/test/unit/library_helper_test.rb b/test/unit/library_helper_test.rb new file mode 100644 index 0000000..ec9c0f7 --- /dev/null +++ b/test/unit/library_helper_test.rb @@ -0,0 +1,52 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class LibraryHelperTest < ActiveSupport::TestCase + + include LibraryHelper + + def setup + @license_objects = [{"name" => "license1" ,"version" => "2.0", "license" => "debian", "software_id" => "1"}, + {"name" => "license2" ,"version" => "2.1", "license" => "debian", "software_id" => "1"}, + {"name" => "license3" ,"version" => "2.2", "license" => "debian", "software_id" => "1"}] + end + + def teardown + @license_objects = nil + end + + should "return an empty list" do + empty_list = [] + assert_equal [],LibraryHelper.list_libraries(empty_list) + end + + should "return a list with current library objects" do + list_compare = [] + assert_equal list_compare.class, LibraryHelper.list_libraries(@license_objects).class + end + + should "have same information from the list passed as parameter" do + list_compare = LibraryHelper.list_libraries(@license_objects) + assert_equal @license_objects.first[:name], list_compare.first.name + end + + should "return a list with the same size of the parameter" do + list_compare = LibraryHelper.list_libraries(@license_objects) + assert_equal @license_objects.count, list_compare.count + end + + should "return false if list_database are empty or null" do + list_compare = [] + assert_equal true, LibraryHelper.valid_list_libraries?(list_compare) + end + + should "return a html text with license name equals to linux" do + libraries = [] + + library_description = Library.new + library_description.name = "Lib" + + libraries << library_description + + assert_not_nil LibraryHelper.library_as_tables(libraries).first.call.index("lib") + end +end diff --git a/test/unit/library_validation_test.rb b/test/unit/library_validation_test.rb new file mode 100644 index 0000000..01e789a --- /dev/null +++ b/test/unit/library_validation_test.rb @@ -0,0 +1,34 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class LibraryValidationTest < ActiveSupport::TestCase + + def setup + @library = Library.new + @library.name = "name" + @library.version = "version" + @library.license = "license" + end + + def teardown + @Libray = nil + end + + should "Save Libray if all fields are filled" do + assert @library.save + end + + should "Don't save Library of name are not filed" do + @library.name = "" + assert !@library.save + end + + should "Don't save Library of version are not filed" do + @library.version = "" + assert !@library.save + end + + should "Don't save Library of license are not filed" do + @library.license = "" + assert !@library.save + end +end diff --git a/test/unit/mpog_software_plugin_test.rb b/test/unit/mpog_software_plugin_test.rb new file mode 100644 index 0000000..1cf5aaf --- /dev/null +++ b/test/unit/mpog_software_plugin_test.rb @@ -0,0 +1,60 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class MpogSoftwarePluginTest < ActiveSupport::TestCase + + def setup + @plugin = MpogSoftwarePlugin.new + @user = create_user + @person = @user.person + end + + def teardown + @user.person.destroy + @user.destroy + end + + + should 'be a noosfero plugin' do + assert_kind_of Noosfero::Plugin, @plugin + end + + should 'calculate the percentege of person incomplete fields' do + @person.name = "Person Name" + @person.cell_phone = "76888919" + + required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","role","area_interest","image"] + + empty_fields = required_list.count - 1 + test_percentege = (empty_fields * 100) / required_list.count + + plugin_percentege = @plugin.calc_percentage_registration(@person) + + assert_equal(test_percentege, plugin_percentege) + end + + should 'return message with percentege of incomplete registration' do + @user.person.name = "Person Name" + @user.person.cell_phone = "76888919" + + plugin_percentege = @plugin.calc_percentage_registration(@user.person) + + expected_result = "Registration " + plugin_percentege.to_s + "% incomplete "; + plugin_result = @plugin.incomplete_registration({:user => @user}) + + assert_equal(expected_result, plugin_result) + end + + private + + def create_user + user = User.new + user.login = "login" + user.email = "user@email.com" + user.password = "123456" + user.password_confirmation = "123456" + user.secondary_email = "user@secondary_email.com" + user.save + user.person.save + user + end +end diff --git a/test/unit/mpog_user_test.rb b/test/unit/mpog_user_test.rb new file mode 100644 index 0000000..a075f26 --- /dev/null +++ b/test/unit/mpog_user_test.rb @@ -0,0 +1,121 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class MpogSoftwarePluginUserTest < ActiveSupport::TestCase + + should 'not save user whose both email and secondary email are the same' do + + user = fast_create(User) + user.email = "test@email.com" + user.secondary_email = "test@email.com" + + assert !user.save + end + + should 'not save user whose both email and secondary email have already been used' do + user1 = create_default_user + user2 = fast_create(User) + + user2.email = "primary@email.com" + user2.secondary_email = "secondary@email.com" + assert !user2.save + end + + should 'not save user whose email has already been used' do + user1 = create_default_user + user2 = fast_create(User) + + user2.email = "primary@email.com" + user2.secondary_email = "noosfero@email.com" + assert !user2.save + end + + should 'not save user whose email has already been used in another users secondary email' do + user1 = create_default_user + user2 = fast_create(User) + + user2.login = "another-login" + user2.email = "secondary@email.com" + user2.secondary_email = "noosfero@email.com" + assert !user2.save + end + + should 'not save user whose secondary email has already been used in another users email' do + user1 = create_default_user + user2 = fast_create(User) + + user2.login = "another-login" + user2.email = "noosfero@email.com" + user2.secondary_email = "primary@email.com" + assert !user2.save + end + + should 'not save user whose secondary email has already been used in another users secondary email' do + user1 = create_default_user + user2 = fast_create(User) + + user2.login = "another-login" + user2.email = "noosfero@email.com" + user2.secondary_email = "secondary@email.com" + assert !user2.save + end + + should 'not save user whose secondary email is in the wrong format' do + user = fast_create(User) + user.email = "test@email.com" + user.secondary_email = "notarightformat.com" + + assert !user.save + + user.secondary_email = "not@arightformatcom" + + assert !user.save + end + + should 'return an error if secondary email is governmental and primary is not' do + user = fast_create(User) + + user.email = "test@email.com" + user.secondary_email = "test@gov.br" + + assert !user.save + assert user.errors.full_messages.include?("The governamental email must be the primary one.") + end + + should 'have institution if email is governmental' do + user = fast_create(User) + + user.email = "test@gov.br" + user.role = "Developer" + + user.institution = nil + assert !user.save + + user.institution = Institution::new(:name=>"Test Other institution") + assert user.save + end + + should 'have role if email is governmental' do + user = fast_create(User) + + user.email = "test@gov.br" + user.institution = Institution::new(:name=>"Test Other institution") + + user.role = nil + assert !user.save + + user.role = "Developer" + assert user.save + end + + private + + def create_default_user + user = fast_create(User) + user.login = "a-login" + user.email = "primary@email.com" + user.secondary_email = "secondary@email.com" + user.save + + return user + end +end diff --git a/test/unit/mpog_validation_test.rb b/test/unit/mpog_validation_test.rb new file mode 100644 index 0000000..6f598ad --- /dev/null +++ b/test/unit/mpog_validation_test.rb @@ -0,0 +1,41 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class MpogSoftwarePluginValidationTest < ActiveSupport::TestCase + def setup + @plugin = MpogSoftwarePlugin.new + institution = Institution::new(:name => "Test institution") + institution.save + @user = fast_create(User) + @user.institution = institution + end + + def teardown + @plugin = nil + @user = nil + end + + should 'be a noosfero plugin' do + assert_kind_of Noosfero::Plugin, @plugin + end + + should 'return true when the email has gov.br,jus.br,leg.br or mp.br as sufix and role its not empty' do + @user.secondary_email = "test_email2@net.br" + @user.email = "test_email@jus.br" + @user.role = "Team" + assert @user.save + end + + should 'return false when the email has gov.br,jus.br,leg.br or mp.br as sufix and role its empty' do + @user.role = "" + @user.secondary_email = "test_email@leg.br" + @user.email = "test_email@mp.br" + assert !@user.save + end + + should 'return true when the email has not gov.br,jus.br,leg.br or mp.br' do + @user.role = "" + @user.secondary_email = "test_email@com.br" + @user.email = "test_email@net.br" + assert @user.save + end +end diff --git a/test/unit/operating_system_helper_test.rb b/test/unit/operating_system_helper_test.rb new file mode 100644 index 0000000..c34b279 --- /dev/null +++ b/test/unit/operating_system_helper_test.rb @@ -0,0 +1,61 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +OperatingSystemName.create(:name=>"Debina") +OperatingSystemName.create(:name=>"Fedora") +OperatingSystemName.create(:name=>"CentOS") + +class OperatingSystemHelperTest < ActiveSupport::TestCase + + include OperatingSystemHelper + + def setup + @operating_system_objects = [{:operating_system_name_id => "1" ,:version => "2.0"}, + {:operating_system_name_id => "2" ,"version" => "2.1"}, + {:operating_system_name_id => "3" ,"version" => "2.2"}] + @operating_system_objects + end + + def teardown + @database_objects = nil + end + + should "return an empty list" do + empty_list = [] + assert_equal [],OperatingSystemHelper.list_operating_system(empty_list) + end + + should "return a list with current OperatingSystems" do + list_compare = [] + assert_equal list_compare.class, OperatingSystemHelper.list_operating_system(@operating_system_objects).class + end + + should "have same information from the list passed as parameter" do + list_compare = OperatingSystemHelper.list_operating_system(@operating_system_objects) + assert_equal @operating_system_objects.first[:operating_system_name_id], list_compare.first.operating_system_name_id.to_s + end + + should "return a list with the same size of the parameter" do + list_compare = OperatingSystemHelper.list_operating_system(@operating_system_objects) + assert_equal @operating_system_objects.count, list_compare.count + end + + should "return false if list_operating_system are empty or null" do + list_compare = [] + assert_equal false,OperatingSystemHelper.valid_list_operating_system?(list_compare) + end + + should "return a html text with operating system" do + operating_systems = [] + + operating_system = OperatingSystemName.new + operating_system.name = "teste" + + software_operating_system = OperatingSystem.new + software_operating_system.version = 2 + software_operating_system.operating_system_name = operating_system + + operating_systems << software_operating_system + + assert_not_nil OperatingSystemHelper.operating_system_as_tables(operating_systems).first.call.index(OperatingSystemName.first.name) + end +end diff --git a/test/unit/operating_system_validation_test.rb b/test/unit/operating_system_validation_test.rb new file mode 100644 index 0000000..217f7c9 --- /dev/null +++ b/test/unit/operating_system_validation_test.rb @@ -0,0 +1,26 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class OperatingSystemValidationTest < ActiveSupport::TestCase + + def setup + operating_system_name = OperatingSystemName::new :name=>"Linux" + @operating_system = OperatingSystem::new :version=>"3.0" + @operating_system.operating_system_name = operating_system_name + @operating_system + end + + should "save OperatingSystem if all fields are filled" do + assert @operating_system.save + end + + should "not save if OperatingSystem does not have version" do + @operating_system.version = " " + assert !@operating_system.save + end + + should "not save if OperatingSystem does not have operating_system_name" do + @operating_system.operating_system_name = nil + assert !@operating_system.save + end + +end diff --git a/test/unit/private_institution_test.rb b/test/unit/private_institution_test.rb new file mode 100644 index 0000000..95760ee --- /dev/null +++ b/test/unit/private_institution_test.rb @@ -0,0 +1,25 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class PrivateInstitutionTest < ActiveSupport::TestCase + def setup + @institution = PrivateInstitution::new :name=>"Simple Private Institution", + :cnpj=>"00.000.000/0001-00" + end + + should "not save without a cnpj" do + @institution.cnpj = nil + + assert !@institution.save + assert @institution.errors.full_messages.include? "Cnpj can't be blank" + end + + should "not save with a repeated cnpj" do + assert @institution.save + + sec_institution = PrivateInstitution::new :name=>"Another Private Institution", + :cnpj=>"00.000.000/0001-00" + + assert !sec_institution.save + assert sec_institution.errors.full_messages.include? "Cnpj has already been taken" + end +end \ No newline at end of file diff --git a/test/unit/public_institution_test.rb b/test/unit/public_institution_test.rb new file mode 100644 index 0000000..ebfdbf3 --- /dev/null +++ b/test/unit/public_institution_test.rb @@ -0,0 +1,38 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class PublicInstitutionTest < ActiveSupport::TestCase + def setup + govPower = GovernmentalPower.create(:name=>"Some Gov Power") + govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") + + @institution = PublicInstitution::new :name=>"Simple Public Institution", :acronym=>"SPI", + :governmental_power=>govPower, :governmental_sphere=>govSphere + end + + should "save without a cnpj" do + @institution.cnpj = nil + + assert @institution.save + end + + should "Not save institution without an acronym" do + @institution.acronym = nil + + assert !@institution.save + assert @institution.errors.full_messages.include? "Acronym can't be blank" + end + + should "Not save institution without a governmental_power" do + @institution.governmental_power = nil + + assert !@institution.save + assert @institution.errors.full_messages.include? "Governmental power can't be blank" + end + + should "Not save institution without a governmental_sphere" do + @institution.governmental_sphere = nil + + assert !@institution.save + assert @institution.errors.full_messages.include? "Governmental sphere can't be blank" + end +end \ No newline at end of file diff --git a/test/unit/search_person_test.rb b/test/unit/search_person_test.rb new file mode 100644 index 0000000..0a69074 --- /dev/null +++ b/test/unit/search_person_test.rb @@ -0,0 +1,64 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class SearchPersonTest < ActiveSupport::TestCase + + def setup + create_person("Jose_Augusto", "DF", "Gama", "jose_augusto@email.com") + create_person("Maria_cunha", "RJ", "Rio de Janeiro", "maria_cunha@email.com") + create_person("Joao_da_silva_costa_cunha", "RJ", "Rio de Janeiro", "joao_da_silva_costa_cunha@gemail.com") + end + + should "Find people with Jo in name" do + people_list = Person.search("Jo") + + assert_equal 2, people_list.count + end + + should "Find people with RJ in state" do + people_list = Person.search("", "RJ") + + assert_equal 2, people_list.count + end + + should "Find people with Gama in city" do + people_list = Person.search("", "", "Gama") + + assert_equal 1, people_list.count + end + + should "Find people with jose in email" do + people_list = Person.search("", "", "", "jose") + + assert_equal 1, people_list.count + end + + should "Find people with Jo in name and j in email" do + people_list = Person.search("Jo", "", "", "j") + + assert_equal 2, people_list.count + end + + should "Find people with Ma in name and RJ in state and Rio in city and ma in email" do + people_list = Person.search("Ma", "RJ", "Rio", "ma") + + assert_equal 1, people_list.count + end + + def create_person name, state, city, email + user = User::new + user.login = name.downcase + user.email = email + user.secondary_email = "#{name}_secondary@email2.com" + user.password = "adlasdasd" + user.password_confirmation = "adlasdasd" + user.save! + + user.person.name = name + user.person.state = state + user.person.city = city + user.person.save! + + user.save! + end + +end \ No newline at end of file diff --git a/test/unit/software_helper_test.rb b/test/unit/software_helper_test.rb new file mode 100644 index 0000000..d29e924 --- /dev/null +++ b/test/unit/software_helper_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class SoftwareHelperTest < ActiveSupport::TestCase + + include SoftwareHelper + + should "Create ProgrammingLanguages based on file with languages names" do + ProgrammingLanguage.delete_all + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/languages.txt", ProgrammingLanguage) + + list = File.open("plugins/mpog_software/public/static/languages.txt", "r") + count = list.readlines.count + list.close + + assert(ProgrammingLanguage.count == count) + end + +end diff --git a/test/unit/software_info_validation_test.rb b/test/unit/software_info_validation_test.rb new file mode 100644 index 0000000..55999a9 --- /dev/null +++ b/test/unit/software_info_validation_test.rb @@ -0,0 +1,47 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class SoftwareInfoValidationTest < ActiveSupport::TestCase + + def setup + @community = fast_create(Community) + @language = ProgrammingLanguage.new(:name => 'C++') + @language.save + @software_language = SoftwareLanguage.new(:version => '1', :operating_system => 'os') + @software_language.programming_language = @language + @software_language.save + + @database = DatabaseDescription.new(:name => 'Oracle') + @database.save + @software_database = SoftwareDatabase.new(:version => '2', :operating_system => 'os2') + @software_database.database_description = @database + @software_database.save + @software_info = SoftwareInfo.new(:community_id=>1, :acronym => "SFTW", :e_mag => true,:icp_brasil => true,:intern => true,:e_ping => true, + :e_arq => true,:name => true,:operating_platform => true,:objectives => "",:features => "") + @software_info.software_languages << @software_language + @software_info.software_databases << @software_database + end + + should 'Save SoftwareInfo if all fields are filled' do + assert_equal true, @software_info.save + end + + should 'Not save SoftwareInfo if operating_platform is blank' do + @software_info.operating_platform = '' + assert_equal false, @software_info.save + end + + should 'Save SoftwareInfo without demonstration_url be filled' do + @software_info.demonstration_url = '' + assert_equal true, @software_info.save + end + + should "Not save SoftwareInfo if acronym is blank" do + @software_info.acronym = "" + assert_equal false, @software_info.save + end + + should "Not save SoftwareInfo if acronym has more than 8 characters" do + @software_info.acronym = "123456789" + assert_equal false, @software_info.save + end +end diff --git a/test/unit/software_language_validation.rb b/test/unit/software_language_validation.rb new file mode 100644 index 0000000..34762fc --- /dev/null +++ b/test/unit/software_language_validation.rb @@ -0,0 +1,63 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class SoftwareLanguageValidationTest < ActiveSupport::TestCase + def setup + create_programming_language + @software_info = create_software_info + @software_info.save + end + + should "Save SoftwareLanguage if version and programming_language are filled" do + @software_language = create_software_language + assert_equal true, @software_language.save + end + + should "Don't save SoftwareLanguage if programming_language is not filed" do + @software_language = create_software_language + @software_language.programming_language = nil + assert_equal true, !@software_language.save + end + + should "Don't save SoftwareLanguage if version is not filed" do + @software_language = create_software_language + @software_language.version = "" + assert_equal true, !@software_language.save + end + + should "Save SoftwareLanguage if operating_system is not filed" do + @software_language = create_software_language + @software_language.operating_system = "" + assert_equal false, @software_language.save + end + + private + + def create_software_language + software_language = SoftwareLanguage.new + software_language.software_info = @software_info + software_language.programming_language = ProgrammingLanguage.last + software_language.version = "version" + software_language.operating_system = "GNU/Linux" + software_language + end + + def create_software_info + software_info = SoftwareInfo.new + software_info.community_id = fast_create(Community).id + software_info.e_mag = true + software_info.icp_brasil = true + software_info.intern = true + software_info.e_ping = true + software_info.e_arq = true + software_info.name = true + software_info.operating_platform = true + software_info + end + + def create_programming_language + ProgrammingLanguage.create(:name=>"C") + ProgrammingLanguage.create(:name=>"C++") + ProgrammingLanguage.create(:name=>"Ruby") + ProgrammingLanguage.create(:name=>"Python") + end +end \ No newline at end of file diff --git a/views/institution_editor_extras.html.erb b/views/institution_editor_extras.html.erb new file mode 100644 index 0000000..bd6fbc7 --- /dev/null +++ b/views/institution_editor_extras.html.erb @@ -0,0 +1,31 @@ +

<%= _('Institution Information') %>

+ +
+ <%= labelled_text_field(_("CNPJ"), 'institution[cnpj]', context.profile.institution.cnpj, :class=>"formlabel") %> +
+ + +
+ <% if context.profile.institution.type == "PublicInstitution" %> + <%= labelled_text_field(_("Acronym"), "institution[acronym]", context.profile.institution.acronym, :class=>"formlabel") %> + <% else %> + <%= labelled_text_field(_("Fantasy name"), "institution[acronym]", context.profile.institution.acronym, :class=>"formlabel") %> + <% end %> +
+
+ +<% if context.profile.institution.type == "PublicInstitution" %> + +
+ <%= label_tag('governmental_power', _("Governmental Power")) %> + <%= select_tag(:governmental_power, options_for_select(GovernmentalPower.all.map {|g| [g.name, g.id]}, :selected => context.profile.institution.governmental_power_id), :class=>"formlabel") %> +
+
+ + +
+ <%= label_tag('governmental_sphere', _("Governmental Sphere")) %> + <%= select_tag(:governmental_sphere, options_for_select(GovernmentalSphere.all.map {|s| [s.name, s.id]}, :selected => context.profile.institution.governmental_sphere_id), :class=>"formlabel") %> +
+
+<% end %> \ No newline at end of file diff --git a/views/mpog_software_plugin/_index_buttons.html.erb b/views/mpog_software_plugin/_index_buttons.html.erb new file mode 100644 index 0000000..899cdf7 --- /dev/null +++ b/views/mpog_software_plugin/_index_buttons.html.erb @@ -0,0 +1,5 @@ +<% button_bar do %> + <%= button :'text-plain', _('Software list as [CSV]'), :action => 'download.csv' %> + <%= button :'text-html', _('Software list as [XML]'), :action => 'download.xml' %> + <%= button :back, _('Back'), :controller => 'admin_panel' %> +<% end %> \ No newline at end of file diff --git a/views/mpog_software_plugin/_software_list.html.erb b/views/mpog_software_plugin/_software_list.html.erb new file mode 100644 index 0000000..6bfa0c7 --- /dev/null +++ b/views/mpog_software_plugin/_software_list.html.erb @@ -0,0 +1,31 @@ +
+
+
+ + + + + + + + + + + <% @collection.each do |s| %> + + + + + <% end %> +
<%= _('Software') %><%= _('Actions') %>
<%= link_to_profile s.short_name, s.identifier, :title => s.name %> +
+ <% if !s.visible? %> + <%= button_without_text :'activate-user', _('Activate Software'), {:action => 'activate', :id => s, :q => @q}, :filter => @filter, :confirm => _("Do you want to activate this software?") %> + <% else %> + <%= button_without_text :'deactivate-user', _('Deactivate software'), {:action => 'deactivate', :id => s, :q => @q,:from_profile => false}, :filter => @filter, :confirm => _("Do you want to deactivate this software?") %> + <% end %> + <%= button_without_text :'delete', _('Remove'), {:action => :destroy_user, :id => s, :q => @q}, :method => :post, :filter => @filter, :confirm => _("Do you want to remove this software?") %> +
+
+ +<%= pagination_links @collection, {:param_name => 'npage', :page_links => true} %> diff --git a/views/mpog_software_plugin/_softwares_search_form.html.erb b/views/mpog_software_plugin/_softwares_search_form.html.erb new file mode 100644 index 0000000..be5d8ec --- /dev/null +++ b/views/mpog_software_plugin/_softwares_search_form.html.erb @@ -0,0 +1,6 @@ +
+ + <%= text_field_tag 'q', @q, :title => _("Find software") %> + +<%= submit_button(:search, _('Search')) %> +
\ No newline at end of file diff --git a/views/mpog_software_plugin/archive_software.html.erb b/views/mpog_software_plugin/archive_software.html.erb new file mode 100644 index 0000000..324e31c --- /dev/null +++ b/views/mpog_software_plugin/archive_software.html.erb @@ -0,0 +1,13 @@ +

<%= _('Manage softwares') %>

+ +<%= form_tag( { :action => 'archive_software' }, :method => 'get', :class => 'users-search' ) do %> + +
+ <%= render :partial => 'softwares_search_form' %> +
+
+ <%= render :partial => 'software_list' %> +
+<% end %> + +<%= render :partial => 'index_buttons' %> \ No newline at end of file diff --git a/views/mpog_software_plugin/create_institution.html.erb b/views/mpog_software_plugin/create_institution.html.erb new file mode 100644 index 0000000..c13c320 --- /dev/null +++ b/views/mpog_software_plugin/create_institution.html.erb @@ -0,0 +1,79 @@ +

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

+ +<% if environment.enabled?('admin_must_approve_new_communities') %> +
+ <%= _("Note that the creation of communities in this environment is restricted. Your request to create this new community will be sent to %{environment} administrators and will be approved or rejected according to their methods and criteria.") % { :environment => environment.name }%> +
+<%end %> + +<% unless @errors.blank? %> +
+

<%= _("Can`t create new Institution: #{@errors.length} errors") %>

+
    + <% @errors.each do |error| %> +
  • <%= error %>
  • + <% end %> +
+
+<% end %> + +
+ +
+ <%= labelled_form_for :community, :html => { :multipart => true, :id=>"institution_form" } do |f| %> + <%= required f.text_field(:name) %> + <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %> + + <%= fields_for :institutions do |inst| %> + + +
+ <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %> + <%= required inst.text_field(:cnpj) %> +
+
+ + +
+ <%= label_tag("type_PublicInstitution", _("Public Institution")) %> + <%= radio_button_tag(:type,"PublicInstitution", true)%> + <%= label_tag("type_PrivateInstitution", _("Private Institution")) %> + <%= radio_button_tag(:type,"PrivateInstitution")%> +
+
+ + +
+ <%= hidden_field_tag "acronym_translate", _("Acronym") %> + <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %> + <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %> + <%= required inst.text_field(:acronym) %> +
+
+ + +
+ <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %> + <%= inst.select(:governmental_power, [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}, {:selected=>0})%> +
+
+ + +
+ <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %> + <%= inst.select(:governmental_sphere, [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}, {:selected=>0})%> +
+
+ +
+ +
+

<%= recaptcha_tags :ajax => true, :display => {:theme => 'clean'} %>

+ <%= link_to(_('Save'), '#', :id=>'save_institution_button', :class=>'button with-text icon-add') %> +
+ <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %> + <% end %> + + <% end %> +
+<%= hidden_field_tag :loading_message, _("Creating institution") %> \ No newline at end of file diff --git a/views/mpog_software_plugin_myprofile/_database_fields.html.erb b/views/mpog_software_plugin_myprofile/_database_fields.html.erb new file mode 100644 index 0000000..2c33490 --- /dev/null +++ b/views/mpog_software_plugin_myprofile/_database_fields.html.erb @@ -0,0 +1,11 @@ +<%= fields_for :database_description, @database_description do |db| %> + +
+ <% DatabaseHelper.database_as_tables(database).each do |tab| %> + <%= tab.call %> + <%end%> +
+ + +<%= link_to _('New Database'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-databases"%> +<% end %> diff --git a/views/mpog_software_plugin_myprofile/_language_fields.html.erb b/views/mpog_software_plugin_myprofile/_language_fields.html.erb new file mode 100644 index 0000000..0ab7ab8 --- /dev/null +++ b/views/mpog_software_plugin_myprofile/_language_fields.html.erb @@ -0,0 +1,11 @@ +<%= fields_for :software_language, @software_language do |lng| %> + +
+ <% SoftwareLanguageHelper.language_as_tables(languages).each do |tab| %> + <%= tab.call %> + <%end%> +
+ + +<%= link_to _('New language'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-languages"%> +<% end %> \ No newline at end of file diff --git a/views/mpog_software_plugin_myprofile/_library_fields.html.erb b/views/mpog_software_plugin_myprofile/_library_fields.html.erb new file mode 100644 index 0000000..da365c6 --- /dev/null +++ b/views/mpog_software_plugin_myprofile/_library_fields.html.erb @@ -0,0 +1,11 @@ +<%= fields_for :library ,@library do |lib| %> + +
+ <% LibraryHelper.library_as_tables(libraries).each do |tab| %> + <%= tab.call %> + <% end %> +
+ + +<%= link_to _('New Library'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-libraries"%> +<% end %> diff --git a/views/mpog_software_plugin_myprofile/_operating_system_fields.html.erb b/views/mpog_software_plugin_myprofile/_operating_system_fields.html.erb new file mode 100644 index 0000000..c712eee --- /dev/null +++ b/views/mpog_software_plugin_myprofile/_operating_system_fields.html.erb @@ -0,0 +1,11 @@ +<%= fields_for :operating_systems ,@operating_systems do |lib| %> + +
+ <% OperatingSystemHelper.operating_system_as_tables(operating_systems_fields).each do |tab| %> + <%= tab.call %> + <% end %> +
+ + +<%= link_to _('New Operating System'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-operating_systems"%> +<% end %> diff --git a/views/mpog_software_plugin_myprofile/new_software.html.erb b/views/mpog_software_plugin_myprofile/new_software.html.erb new file mode 100644 index 0000000..eeb48a4 --- /dev/null +++ b/views/mpog_software_plugin_myprofile/new_software.html.erb @@ -0,0 +1,254 @@ +<%= javascript_include_tag "mpog-validations" %> + +

<%= _('Creating new software') %>

+ +<% if environment.enabled?('admin_must_approve_new_communities') %> +
+ <%= _("Note that the creation of communities in this environment is restricted. Your request to create this new community will be sent to %{environment} administrators and will be approved or rejected according to their methods and criteria.") % { :environment => environment.name }%> +
+<%end %> + +<% unless @errors.blank? %> +
+

<%= _("Can`t create new software: #{@errors.length} errors") %>

+
    + <% @errors.each do |error| %> +
  • <%= error %>
  • + <% end %> +
+
+<% end %> + +
+ <%= labelled_form_for :community, :html => { :multipart => true } do |f| %> + + <%= required_fields_message %> + + <%= required f.text_field(:name) %> + + <%= fields_for @software_info do |swf| %> + +
+ <%= swf.label("acronym" ,_("Acronym"), :class=>"formlabel") %> + <%= required swf.text_field(:acronym) %> +
+
+ +
+ <%= swf.label _("Adherent to e-PING ?") %> + + <%= swf.label "e_ping_true", "Yes" %> + <%= swf.radio_button(:e_ping,true)%> + <%= swf.label "e_ping_false", "No"%> + <%= swf.radio_button(:e_ping,false)%> +
+ +
+ <%= swf.label _("Adherent to e-MAG ?") %> + + <%= swf.label "e_mag_true", "Yes"%> + <%= swf.radio_button(:e_mag,true)%> + <%= swf.label "e_mag_false", "No"%> + <%= swf.radio_button(:e_mag,false)%> +
+ +
+ <%= swf.label _("Adherent to ICP-Brasil ?") %> + + <%= swf.label "icp_brasil_true", "Yes"%> + <%= swf.radio_button(:icp_brasil,true)%> + <%= swf.label "icp_brasil_false", "No"%> + <%= swf.radio_button(:icp_brasil,false)%> +
+ +
+ <%= swf.label _("Adherent to e-ARQ ?") %> + + <%= swf.label "e_arq_true", "Yes"%> + <%= swf.radio_button(:e_arq,true)%> + <%= swf.label "e_arq_false", "No"%> + <%= swf.radio_button(:e_arq,false)%> +
+ +
+ <%= swf.label _("Internacionalizable ?") %> + + <%= swf.label "intern_true", "Yes" %> + <%= swf.radio_button(:intern,true)%> + <%= swf.label "intern_false", "No"%> + <%= swf.radio_button(:intern,false)%> +
+ <%= swf.label "operating_platform", _("Operating Platform: ") %>
+ <%= swf.text_area(:operating_platform, :class=>"expand-field") %> +
+ +
+ <%= swf.label "objectives", _("Objectives: ")%>
+ <%= swf.text_area(:objectives, :class=>"expand-field") %> +
+ +
+ <%= swf.label "features", _("Features: ")%>
+ <%= swf.text_area(:features, :class=>"expand-field") %> +
+ +
+ <%= swf.label "demonstration_url", _("Demonstration URL: ") %> + <%= swf.text_field(:demonstration_url) %> +
+ <% end %> + +
+

<%= _("Libraries") %>

+ <%= render :partial => 'library_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :libraries => @list_libraries } %> +
+
+ +
+

<%= _("Operating Systems") %>

+ <% if @list_operating_systems.blank? %> + <%= OperatingSystemHelper.operating_system_as_tables(nil, false).call %> + <% end %> + <%= render :partial => 'operating_system_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :operating_systems_fields => @list_operating_systems} %> +
+
+ + <%= fields_for @license_info do |lcv| %> +
+

<%= lcv.label _("License Version: ") %> + <%= lcv.select(:version, LicenseInfo.all.map {|l| [l.version, l.id]}, {:selected=>1}, :onchange => "get_license_link('license_info_version')") %> +

+

<%= _("License link") %>

+ <% LicenseHelper.getListLicenses.each do | license | %> + + <% end %> + <%=LicenseInfo.first.link %> + +
+ <% end %> + +
+
+

<%= _("Programming languages") %>

+ <% if @list_languages.blank? %> + <%= SoftwareLanguageHelper.language_as_tables(nil, false).call %> + <% end %> + + <%= render :partial => 'language_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :languages => @list_languages } %> +
+ +
+
+

<%= _("Databases") %>

+ <% if @list_databases.blank? %> + <%= DatabaseHelper.database_as_tables(nil, true).call %> + <% end %> + + <%= render :partial => 'database_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :database => @list_databases } %> +
+ + <%= fields_for @controlled_vocabulary do |cv| %> +
+

<%= _("Controlled Vocabulary of E-government") %>

+ + <%= cv.check_box :administration %> + <%= cv.label :administration, _("Administration") %>
+ + <%= cv.check_box :agriculture %> + <%= cv.label :agriculture, _("Agriculture") %>
+ + <%= cv.check_box :business_and_services %> + <%= cv.label :business_and_services, _("Business_and Services") %>
+ + <%= cv.check_box :communication %> + <%= cv.label :communication, _("Communication") %>
+ + <%= cv.check_box :culture %> + <%= cv.label :culture, _("Culture") %>
+ + <%= cv.check_box :national_defense %> + <%= cv.label :national_defense, _("National Defense") %>
+ + <%= cv.check_box :economy_and_finances %> + <%= cv.label :economy_and_finances, _("Economy and Finances") %>
+ + <%= cv.check_box :education %> + <%= cv.label :education, _("Education") %>
+ + <%= cv.check_box :energy %> + <%= cv.label :energy, _("Energy") %>
+ + <%= cv.check_box :sports %> + <%= cv.label :sports, _("Sports") %>
+ + <%= cv.check_box :habitation %> + <%= cv.label :habitation, _("Habitation") %>
+ + <%= cv.check_box :industry %> + <%= cv.label :industry, _("Industry") %>
+ + <%= cv.check_box :environment %> + <%= cv.label :environment, _("Environment") %>
+ + <%= cv.check_box :research_and_development %> + <%= cv.label :research_and_development, _("Research and Development") %>
+ + <%= cv.check_box :social_security %> + <%= cv.label :social_security, _("Social Security") %>
+ + <%= cv.check_box :social_protection %> + <%= cv.label :social_protection, _("Social Protection") %>
+ + <%= cv.check_box :sanitation %> + <%= cv.label :sanitation, _("Sanitation") %>
+ + <%= cv.check_box :health %> + <%= cv.label :health, _("Health") %>
+ + <%= cv.check_box :security_public_order %> + <%= cv.label :security_public_order, _("Security and Public Order") %>
+ + <%= cv.check_box :work %> + <%= cv.label :work, _("Work") %>
+ + <%= cv.check_box :transportation %> + <%= cv.label :transportation, _("Transportation") %>
+ + <%= cv.check_box :urbanism %> + <%= cv.label :urbanism, _("Urbanism") %>
+
+ <% end %> + <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => 'community', :profile => @community } %> + + <%= f.fields_for :image_builder, @community.image do |i| %> + <%= file_field_or_thumbnail(_('Image:'), @community.image, i) %> + <% end %> + +
+ <%= _('New members must be approved:')%> +
+
+ <%= radio_button 'community', 'closed', 'true', :style => 'float: left' %> +
+ <%= _('Before joining this group (a moderator has to accept the member in pending request before member can access the intranet and/or the website).') %> +
+
+
+ <%= radio_button 'community', 'closed', 'false', :style => 'float: left' %> +
+ <%= _('After joining this group (a moderator can always desactivate access for users later).') %> +
+
+ + <%= template_options(:communities, 'community')%> + + <%= hidden_field_tag('back_to', @back_to) %> + + <% button_bar do %> + <%= submit_button(:save, _('Create')) %> + <%= button(:cancel, _('Cancel'), @back_to ) %> + <% end %> + + <% end %> + +
diff --git a/views/person_editor_extras.html.erb b/views/person_editor_extras.html.erb new file mode 100644 index 0000000..d739111 --- /dev/null +++ b/views/person_editor_extras.html.erb @@ -0,0 +1,37 @@ +
+ <%= label_tag "user[secondary_email]", _('Secondary e-mail')+":", :class=>"formlabel" %> + +
+ <%= text_field_tag "user[secondary_email]", context.profile.user.secondary_email %> +
+
+ +
+ <%= label_tag 'user[role]', _('Your role in the organization'), :class=>"formlabel" %> + +
+ <%= text_field_tag 'user[role]', context.profile.user.role %> +
+
+ +
+ <%= label_tag 'profile_data[area_interest]', _('Areas of Interest'), :class=>"formlabel" %> + +
+ <%= text_field_tag 'profile_data[area_interest]', context.profile.area_interest %> +
+
+ +
+ <%= label_tag "user[institution_id]", _('Institution'), :class=>"formlabel" %> + +
+ <%= select_tag "user[institution_id]", options_for_select(Institution.all.map {|i| [i.name, i.id]}, context.profile.institution_id) %> +
+ +
\ No newline at end of file diff --git a/views/profile/_institution_tab.html.erb b/views/profile/_institution_tab.html.erb new file mode 100644 index 0000000..c2183a0 --- /dev/null +++ b/views/profile/_institution_tab.html.erb @@ -0,0 +1,15 @@ + + + + + + <%= display_field(_('Type:'), profile.institution, :type, true) %> + <%= display_field(_('CNPJ:'), profile.institution, :cnpj, true) %> + <% if profile.institution.type == "PrivateInstitution"%> + <%= display_field(_('Fantasy Name:'), profile.institution, :acronym, true) %> + <% else %> + <%= display_field(_('Acronym:'), profile.institution, :acronym, true) %> + <%= display_field(_('Governmental Power:'), profile.institution.governmental_power, :name, true) %> + <%= display_field(_('Governmental Sphere:'), profile.institution.governmental_sphere, :name, true) %> + <% end %> +
<%= _('Institution Information')%>
\ No newline at end of file diff --git a/views/profile/_profile_tab.html.erb b/views/profile/_profile_tab.html.erb new file mode 100644 index 0000000..5fb4da4 --- /dev/null +++ b/views/profile/_profile_tab.html.erb @@ -0,0 +1,10 @@ + + + + + + <%= display_field(_('Secondary E-mail:'), profile, :secondary_email, true) %> + <%= display_field(_('Role:'), profile, :role, true) %> + <%= display_field(_('Areas of Interest:'), profile, :area_interest, true) %> + <%= display_field(_('Institution:'), profile, :institution, true) %> +
<%= _('Mpog Profile Information')%>
diff --git a/views/profile/_software_tab.html.erb b/views/profile/_software_tab.html.erb new file mode 100644 index 0000000..8765657 --- /dev/null +++ b/views/profile/_software_tab.html.erb @@ -0,0 +1,106 @@ +<%= javascript_include_tag "mpog-validations" %> + + + + + + <%= display_field(_('Name:'), profile, :name, true) %> + <%= content_tag('tr', content_tag('td', _("Adherent to e_mag:")) + content_tag('td', profile.software_info.e_mag ? _("Yes") : _("No"))) %> + <%= content_tag('tr', content_tag('td', _("Adherent to icp_brasil:")) + content_tag('td', profile.software_info.icp_brasil ? _("Yes") : _("No"))) %> + <%= content_tag('tr', content_tag('td', _("Adherent to e_ping:")) + content_tag('td', profile.software_info.e_ping ? _("Yes") : _("No"))) %> + <%= content_tag('tr', content_tag('td', _("Adherent to e_arq:")) + content_tag('td', profile.software_info.e_arq ? _("Yes") : _("No"))) %> + <%= content_tag('tr', content_tag('td', _("Internacionalizable:")) + content_tag('td', profile.software_info.intern ? _("Yes") : _("No"))) %> + <%= display_field(_('Operating Platform:'), profile.software_info, :operating_platform, true) %> + <%= display_field(_('Demonstration URL:'), profile.software_info, :demonstration_url, true) %> + <%= display_field(_('Acronym:'), profile.software_info, :acronym, true) %> + <%= display_field(_('Objectives:'), profile.software_info, :objectives, true) %> + <%= display_field(_('Features:'), profile.software_info, :features, true) %> + + <%= content_tag('tr', content_tag('td', _("License"))) %> + <%= display_field(_('Version:'), profile.software_info.license_info, :version, true) %> + <%= display_field(_('Link:'), profile.software_info.license_info, :link, true) %> +
<%= _('Software Information')%>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%= _('Show Libraries') %> + <%= _('Hide Libraries') %> +
+ + <%= content_tag('tr', content_tag('td', _("Libraries")) + content_tag('td', '')) %> + <% profile.software_info.libraries.each do |library| %> + <%= display_field(_('Name:'), library, :name, true) %> + <%= display_field(_('Version:'), library, :version, true) %> + <%= display_field(_('License:'), library, :license, true) %> + <% end %> +
+
<%= _('Show Database') %> + <%= _('Hide Database') %> +
+ + <%= content_tag('tr', content_tag('td', _("Program Database")) + content_tag('td', '')) %> + <% profile.software_info.software_databases.each do |database| %> + <%= display_field(_('Name:'), DatabaseDescription.find(database.database_description_id), :name, true) %> + <%= display_field(_('Version:'), database, :version, true) %> + <%= display_field(_('Operating System:'), database, :operating_system, true) %> + <% end %> +
+
<%= _('Show Languages') %> + <%= _('Hide Languages') %> +
+ + <%= content_tag('tr', content_tag('td', _("Programming Language")) + content_tag('td', '')) %> + <% profile.software_info.software_languages.each do |language| %> + <%= display_field(_('Name:'), language.programming_language , :name, true) %> + <%= display_field(_('Version:'), language, :version, true) %> + <%= display_field(_('Operating System:'), language, :operating_system, true) %> + <% end %> +
+
<%= _('Show Operating Systems') %> + <%= _('Hide Operating Systems') %> +
+ + <%= content_tag('tr', content_tag('td', _("Operating System")) + content_tag('td', '')) %> + <% profile.software_info.operating_systems.each do |operating_system| %> + <%= display_field(_('Name:'), operating_system.operating_system_name , :name, true) %> + <%= display_field(_('Version:'), operating_system, :version, true) %> + <% end %> +
+
+ +<% if profile.admins.include? current_person %> + <%= label_tag _("Deactivate Software: ") %> + <%= button_without_text :'deactivate-user', _('Deactivate software'), {:controller => "mpog_software_plugin", :action => 'deactivate', :id => profile.software_info.id, :q => @q, :from_profile => true}, :filter => @filter, :confirm => _("Do you want to deactivate this software?") %> +<% end %> + diff --git a/views/software_editor_extras.html.erb b/views/software_editor_extras.html.erb new file mode 100644 index 0000000..fd43f15 --- /dev/null +++ b/views/software_editor_extras.html.erb @@ -0,0 +1,153 @@ +

<%= _('Software Information') %>

+ +
+ <%= labelled_text_field(_("Acronym"), 'software_info[acronym]', context.profile.software_info.acronym) %> +
+ +
+ <%= _("Adherent to e-PING?") %> + <%= labelled_radio_button(_('Yes'), 'software_info[e_ping]', 'true', context.profile.software_info.e_ping)%> + <%= labelled_radio_button(_('No'), 'software_info[e_ping]', 'false', !context.profile.software_info.e_ping)%> +
+
+ <%= _("Adherent to e-MAG?") %> + <%= labelled_radio_button(_('Yes'), 'software_info[e_mag]', 'true', context.profile.software_info.e_mag)%> + <%= labelled_radio_button(_('No'), 'software_info[e_mag]', 'false', !context.profile.software_info.e_mag)%> +
+
+ <%= _("Adherent to ICP-Brasil?") %> + <%= labelled_radio_button(_('Yes'), 'software_info[icp_brasil]', 'true', context.profile.software_info.icp_brasil)%> + <%= labelled_radio_button(_('No'), 'software_info[icp_brasil]', 'false', !context.profile.software_info.icp_brasil)%> +
+
+ <%= _("Adherent to e-ARQ?") %> + <%= labelled_radio_button(_('Yes'), 'software_info[e_arq]', 'true', context.profile.software_info.e_arq)%> + <%= labelled_radio_button(_('No'), 'software_info[e_arq]', 'false', !context.profile.software_info.e_arq)%> +
+
+ <%= _("Internacionalizable") %> + <%= labelled_radio_button(_('Yes'), 'software_info[intern]', 'true', context.profile.software_info.intern)%> + <%= labelled_radio_button(_('No'), 'software_info[intern]', 'false', !context.profile.software_info.intern)%> +
+ +
+ <%= label_tag('software_info[operating_platform]', 'Operating Platform:') %> +
+ <%= text_area_tag('software_info[operating_platform]', context.profile.software_info.operating_platform, :size => '40x20', :class=>"expand-field") %> +
+ +
+ <%= label_tag('software_info[objectives]', 'Objectives:') %> +
+ <%= text_area_tag('software_info[objectives]', context.profile.software_info.objectives, :size => '40x20', :class=>"expand-field") %> +
+ +
+ <%= label_tag('software_info[features]', 'Features:') %> +
+ <%= text_area_tag('software_info[features]', context.profile.software_info.features, :size => '40x20', :class=>"expand-field") %> +
+ +
+ <%= labelled_text_field('Demonstration URL', 'software_info[demonstration_url]', context.profile.software_info.demonstration_url) %> +
+ +

<%= _("Licenses") %>

+
+ <%= select_tag(:version, options_for_select(LicenseHelper.getListLicenses.collect{|l| [l.version, l.id]}, :selected => context.profile.software_info.license_info.id), :onchange => "get_license_link('version')") %> +
+ +

<%= _("License link") %>

+ <% LicenseHelper.getListLicenses.each do | license | %> + + <% end %> + + <%= context.profile.software_info.license_info.link %> +
+ +

<%= _("Libraries") %>

+
+ <% LibraryHelper.library_as_tables(context.profile.software_info.libraries).each do |tab| %> + <%= tab.call %> + <%end%> +
+ + +<%= link_to _('New Library'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-libraries"%> + +

<%= _("Programming Languages") %>

+
+ <% SoftwareLanguageHelper.language_as_tables(context.profile.software_info.software_languages).each do |tab| %> + <%= tab.call %> + <%end%> +
+ + +<%= link_to _('New language'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-languages"%> + +

<%= _("Databases") %>

+
+ <% DatabaseHelper.database_as_tables(context.profile.software_info.software_databases).each do |tab| %> + <%= tab.call %> + <%end%> +
+ + +<%= link_to _('New Database'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-databases"%> + +
+

<%= _("Controlled Vocabulary of E-government") %>

+ + <%= labelled_check_box _("Administration"), "controlled_vocabulary[administration]", "1", context.profile.software_info.controlled_vocabulary.administration %>
+ + <%= labelled_check_box _("Agriculture"), "controlled_vocabulary[agriculture]", "1", context.profile.software_info.controlled_vocabulary.agriculture %>
+ + <%= labelled_check_box _("Business_and Services"), "controlled_vocabulary[business_and_services]", "1", context.profile.software_info.controlled_vocabulary.business_and_services %>
+ + <%= labelled_check_box _("Communication"), "controlled_vocabulary[communication]", "1", context.profile.software_info.controlled_vocabulary.communication %>
+ + <%= labelled_check_box _("Culture"), "controlled_vocabulary[culture]", "1", context.profile.software_info.controlled_vocabulary.culture %>
+ + <%= labelled_check_box _("National Defense"), "controlled_vocabulary[national_defense]", "1", context.profile.software_info.controlled_vocabulary.national_defense %>
+ + <%= labelled_check_box _("Economy and Finances"), "controlled_vocabulary[economy_and_finances]", "1", context.profile.software_info.controlled_vocabulary.economy_and_finances %>
+ + <%= labelled_check_box _("Education"), "controlled_vocabulary[education]", "1", context.profile.software_info.controlled_vocabulary.education %>
+ + <%= labelled_check_box _("Energy"), "controlled_vocabulary[energy]", "1", context.profile.software_info.controlled_vocabulary.energy %>
+ + <%= labelled_check_box _("Sports"), "controlled_vocabulary[sports]", "1", context.profile.software_info.controlled_vocabulary.sports %>
+ + <%= labelled_check_box _("Habitation"), "controlled_vocabulary[habitation]", "1", context.profile.software_info.controlled_vocabulary.habitation %>
+ + <%= labelled_check_box _("Industry"), "controlled_vocabulary[industry]", "1", context.profile.software_info.controlled_vocabulary.industry %>
+ + <%= labelled_check_box _("Environment"), "controlled_vocabulary[environment]", "1", context.profile.software_info.controlled_vocabulary.environment %>
+ + <%= labelled_check_box _("Research and Development"), "controlled_vocabulary[research_and_development]", "1", context.profile.software_info.controlled_vocabulary.research_and_development %>
+ + <%= labelled_check_box _("Social Security"), "controlled_vocabulary[social_security]", "1", context.profile.software_info.controlled_vocabulary.social_security %>
+ + <%= labelled_check_box _("Social Protection"), "controlled_vocabulary[social_protection]", "1", context.profile.software_info.controlled_vocabulary.social_protection %>
+ + <%= labelled_check_box _("Sanitation"), "controlled_vocabulary[sanitation]", "1", context.profile.software_info.controlled_vocabulary.sanitation %>
+ + <%= labelled_check_box _("Health"), "controlled_vocabulary[health]", "1", context.profile.software_info.controlled_vocabulary.health %>
+ + <%= labelled_check_box _("Security and Public Order"), "controlled_vocabulary[security_public_order]", "1", context.profile.software_info.controlled_vocabulary.security_public_order %>
+ + <%= labelled_check_box _("Work"), "controlled_vocabulary[work]", "1", context.profile.software_info.controlled_vocabulary.work %>
+ + <%= labelled_check_box _("Transportation"), "controlled_vocabulary[transportation]", "1", context.profile.software_info.controlled_vocabulary.transportation %>
+ + <%= labelled_check_box _("Urbanism"), "controlled_vocabulary[urbanism]", "1", context.profile.software_info.controlled_vocabulary.urbanism %>
+
+ +

<%= _("Operating System") %>

+
+ <% OperatingSystemHelper.operating_system_as_tables(context.profile.software_info.operating_systems).each do |tab| %> + <%= tab.call %> + <%end%> +
+ +<%= link_to _('New Operating System'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-operating_system"%> diff --git a/views/software_editor_extras.rhtml b/views/software_editor_extras.rhtml new file mode 100644 index 0000000..c4a119e --- /dev/null +++ b/views/software_editor_extras.rhtml @@ -0,0 +1,35 @@ +

<%= _('Software Information') %>

+ +
+ <%= _("Adherent to e-PING?") %> + <%= labelled_radio_button(_('Sim'), 'software_info[e_ping]', 'sim', context.profile.software_info.e_ping == 'sim')%> + <%= labelled_radio_button(_('Não'), 'software_info[e_ping]', 'nao', context.profile.software_info.e_ping == 'nao')%> +
+
+ <%= _("Adherent to e-MAG?") %> + <%= labelled_radio_button(_('Sim'), 'software_info[e_mag]', 'sim', context.profile.software_info.e_mag == 'sim')%> + <%= labelled_radio_button(_('Não'), 'software_info[e_mag]', 'nao', context.profile.software_info.e_mag == 'nao')%> +
+
+ <%= _("Adherent to ICP-Brasil?") %> + <%= labelled_radio_button(_('Sim'), 'software_info[icp_brasil]', 'sim', context.profile.software_info.icp_brasil == 'sim')%> + <%= labelled_radio_button(_('Não'), 'software_info[icp_brasil]', 'nao', context.profile.software_info.icp_brasil == 'nao')%> +
+
+ <%= _("Adherent to e-ARQ?") %> + <%= labelled_radio_button(_('Sim'), 'software_info[e_arq]', 'sim', context.profile.software_info.e_arq == 'sim')%> + <%= labelled_radio_button(_('Não'), 'software_info[e_arq]', 'nao', context.profile.software_info.e_arq == 'nao')%> +
+
+ <%= _("Internacionalizable") %> + <%= labelled_radio_button(_('Sim'), 'software_info[intern]', 'sim', context.profile.software_info.intern == 'sim')%> + <%= labelled_radio_button(_('Não'), 'software_info[intern]', 'nao', context.profile.software_info.intern == 'nao')%> +
+ +
+ <%= label_tag('software_info[operating_platform]', 'Operating Platform:') %> + <%= text_area_tag('software_info[operating_platform]', context.profile.software_info.operating_platform, :size => '40x20') %> +
+
+ <%= labelled_text_field('Demonstration URL', 'software_info[demonstration_url]', context.profile.software_info.demonstration_url) %> +
diff --git a/views/user_search/search_filter.html.erb b/views/user_search/search_filter.html.erb new file mode 100644 index 0000000..5ca0e16 --- /dev/null +++ b/views/user_search/search_filter.html.erb @@ -0,0 +1,35 @@ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
<%= label_tag :name, _("Name") %> <%= text_field_tag :name %>
<%= label_tag :state, _("State") %> <%= text_field_tag :state %>
<%= label_tag :city, _("City") %> <%= text_field_tag :city %>
<%= label_tag :email, _("Email") %> <%= text_field_tag :email %>
<%= submit_button(:search, _('Search')) %>
+
+ +
+ +
+ +
+
+
\ No newline at end of file -- libgit2 0.21.2