Commit 5d10ae37a668232a782c7fc62f16e9e735e8310b
0 parents
Exists in
master
initial coomit
Showing
8 changed files
with
147 additions
and
0 deletions
Show diff stats
No preview for this file type
controllers/myprofile/dialoga_plugin_myprofile_controller.rb
0 → 100644
| 1 | +++ a/controllers/myprofile/dialoga_plugin_myprofile_controller.rb | |
| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | +class DialogaPluginMyprofileController < MyProfileController | |
| 2 | + | |
| 3 | +# before_filter :check_permission | |
| 4 | + | |
| 5 | + def sent_report | |
| 6 | + report = params[:report] || | |
| 7 | +# @article.comment_paragraph_plugin_activate = !@article.comment_paragraph_plugin_activate | |
| 8 | +# @article.save! | |
| 9 | +# redirect_to @article.view_url | |
| 10 | + end | |
| 11 | + | |
| 12 | + protected | |
| 13 | + | |
| 14 | + def check_permission | |
| 15 | +# @article = profile.articles.find(params[:id]) | |
| 16 | +# render_access_denied unless @article.comment_paragraph_plugin_enabled? && @article.allow_edit?(user) | |
| 17 | + end | |
| 18 | + | |
| 19 | +end | ... | ... |
| 1 | +++ a/lib/dialoga_plugin.rb | |
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +class DialogaPlugin < Noosfero::Plugin | |
| 2 | + | |
| 3 | + def self.plugin_name | |
| 4 | + _('Dialoga custom plugin') | |
| 5 | + end | |
| 6 | + | |
| 7 | + def self.plugin_description | |
| 8 | + _("Provide a plugin to dialoga environment.") | |
| 9 | + end | |
| 10 | + | |
| 11 | +# def self.api_mount_points | |
| 12 | +# [JuventudePlugin::API] | |
| 13 | +# end | |
| 14 | + | |
| 15 | +end | ... | ... |
| 1 | +++ a/lib/dialoga_plugin/api.rb | |
| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | +class DialogaPlugin::API < Grape::API | |
| 2 | + | |
| 3 | +# resource :states do | |
| 4 | +# | |
| 5 | +# get do | |
| 6 | +# states = State.select([:id, :name]).order(:name) | |
| 7 | +# present states | |
| 8 | +# end | |
| 9 | +# | |
| 10 | +# get ':id/cities' do | |
| 11 | +# state = State.find(params[:id]) | |
| 12 | +# cities = City.where(:parent_id => state.id).select([:id, :name]).order(:name) | |
| 13 | +# present cities | |
| 14 | +# end | |
| 15 | +# | |
| 16 | +# end | |
| 17 | +end | ... | ... |
| 1 | +++ a/script/sent_event_report | |
| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | +#!/usr/bin/env ruby | |
| 2 | +require_relative '../../../config/environment' | |
| 3 | +require 'net/smtp' | |
| 4 | + | |
| 5 | +puts 'Iniciando script' | |
| 6 | + | |
| 7 | +file = File.open('event.csv', 'w+') | |
| 8 | + | |
| 9 | +events = Event.all | |
| 10 | +events.map do |event| | |
| 11 | + file.write(event.name+ "\n") | |
| 12 | + header = "'Nome';'Email'\n" | |
| 13 | + file.write(header) | |
| 14 | + count = 0 | |
| 15 | + event.person_followers.map do |person| | |
| 16 | + count += 1 | |
| 17 | + puts "%s de %s: adicionando evento: %s" % [count, event.person_followers.count, event.id ] | |
| 18 | + info = [] | |
| 19 | + info.push(person.name) | |
| 20 | + info.push(person.email) | |
| 21 | + file.write(info.map{|i| "'" + i.to_s + "'"}.join(";")) | |
| 22 | + file.write("\n") | |
| 23 | + end | |
| 24 | +end | |
| 25 | + | |
| 26 | +file.close | |
| 27 | + | ... | ... |
| 1 | +++ a/script/sent_proposal_report | |
| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | +#!/usr/bin/env ruby | |
| 2 | +require_relative '../../../config/environment' | |
| 3 | +require 'net/smtp' | |
| 4 | + | |
| 5 | +mails = ['leandronunes@gmail.com', 'leandro.santos@serpro.gov.br'] | |
| 6 | + | |
| 7 | +puts 'Iniciando script' | |
| 8 | + | |
| 9 | +file = File.open('data.csv', 'w+') | |
| 10 | + | |
| 11 | +#articles = ProposalsDiscussionPlugin::Proposal.all | |
| 12 | +tasks = ProposalsDiscussionPlugin::ProposalTask.all | |
| 13 | +count = 0 | |
| 14 | +header = "'Origem';'Status';'Criada em';'Moderado por';'Data de Moderado';'Validado por';'Data de Validado';'Autor';'Proposta'\n" | |
| 15 | +file.write(header) | |
| 16 | +STATUS_TRANSLATION = { | |
| 17 | + 1 => 'Pendente de Moderacao', | |
| 18 | + 2 => 'Rejeitada', | |
| 19 | + 3 => 'Aprovada', | |
| 20 | + 5 => 'Pre Aprovada', | |
| 21 | + 6 => 'Pre Rejeitada', | |
| 22 | +} | |
| 23 | +tasks.map do |task| | |
| 24 | + count += 1 | |
| 25 | + puts "%s de %s: adicionando task: %s" % [count, tasks.count, task.id ] | |
| 26 | + info = [] | |
| 27 | + info.push(task.proposal_source) | |
| 28 | + info.push(STATUS_TRANSLATION[task.status]) | |
| 29 | + info.push(task.created_at.strftime("%d/%m/%y %H:%M")) | |
| 30 | + info.push(task.proposal_evaluation.present? ? task.proposal_evaluation.evaluated_by.name : '') | |
| 31 | + info.push(task.proposal_evaluation.present? ? task.proposal_evaluation.created_at.strftime("%d/%m/%y %H:%M") : '') | |
| 32 | + info.push(task.closed_by.present? ? task.closed_by.name : '') | |
| 33 | + info.push(task.closed_by.present? ? task.end_date.strftime("%d/%m/%y %H:%M") : '') | |
| 34 | + info.push(task.requestor.present? ? task.requestor.name : '') | |
| 35 | + info.push(task.abstract.present? ? task.abstract.gsub(/\s+/, ' ').strip : '') | |
| 36 | + file.write(info.map{|i| "'" + i.to_s + "'"}.join(";")) | |
| 37 | + file.write("\n") | |
| 38 | +end | |
| 39 | + | |
| 40 | +file.close | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | +message = <<MESSAGE_END | |
| 45 | +From: Relatorio Dialoga <relatorio@dialoga.gov.br> | |
| 46 | +To: Leandro <leandronunes@gmail.com> | |
| 47 | +Subject: Relatorio do Dialoga | |
| 48 | + | |
| 49 | +Segue em anexo o relatorio do Dialoga. | |
| 50 | +MESSAGE_END | |
| 51 | + | |
| 52 | +Net::SMTP.start('localhost') do |smtp| | |
| 53 | + smtp.send_message message, 'leandronunes@gmail.com', | |
| 54 | + 'leandro.santos@serpro.gov.br' | |
| 55 | +end | ... | ... |
| 1 | +++ a/test/unit/api_test.rb | |
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +require_relative '../test_helper' | |
| 2 | +require_relative '../../../../test/unit/api/test_helper' | |
| 3 | + | |
| 4 | +class APITest < ActiveSupport::TestCase | |
| 5 | + | |
| 6 | + def setup | |
| 7 | + login_api | |
| 8 | + end | |
| 9 | + | |
| 10 | + should 'return something' do | |
| 11 | + end | |
| 12 | + | |
| 13 | +end | ... | ... |