Commit 52bcd04df83a895b4ad2da3c31b30aaa55559518

Authored by Victor Costa
1 parent 439fe345

fix gitlab integration

plugins/community_track/public/public 0 → 120000
... ... @@ -0,0 +1 @@
  1 +/root/noosfero/config/plugins/community_track/public
0 2 \ No newline at end of file
... ...
plugins/serpro_integration/lib/ext/community.rb
... ... @@ -12,7 +12,7 @@ class Community
12 12  
13 13 attr_accessible :allow_unauthenticated_comments, :allow_gitlab_integration, :allow_sonar_integration, :allow_jenkins_integration, :serpro_integration_plugin_gitlab, :serpro_integration_plugin_jenkins, :serpro_integration_plugin_sonar
14 14  
15   - after_update :create_integration_projects
  15 + before_update :create_integration_projects
16 16  
17 17 def create_integration_projects
18 18 return unless setting_changed?(:serpro_integration_plugin_gitlab)
... ... @@ -20,6 +20,7 @@ class Community
20 20 if allow_gitlab_integration
21 21 gitlab_integration = SerproIntegrationPlugin::GitlabIntegration.new(gitlab_host, gitlab_private_token)
22 22 gitlab_project = gitlab_integration.create_gitlab_project(self)
  23 + serpro_integration_plugin_gitlab[:project_id] = gitlab_project.id
23 24  
24 25 if allow_jenkins_integration
25 26 jenkins_integration = SerproIntegrationPlugin::JenkinsIntegration.new(jenkins_host, jenkins_private_token, jenkins_user)
... ...
plugins/serpro_integration/lib/serpro_integration_plugin.rb
... ... @@ -11,8 +11,8 @@ class SerproIntegrationPlugin < Noosfero::Plugin
11 11 #FIXME make this test
12 12 # User could not have this block
13 13 def self.extra_blocks
14   - { SonarPlugin::SonarWidgetBlock => {:type => [Community] },
15   - SonarPlugin::SmileBlock => {:type => [Community] }
  14 + { SerproIntegrationPlugin::SonarWidgetBlock => {:type => [Community] },
  15 + SerproIntegrationPlugin::SmileBlock => {:type => [Community] },
16 16 }
17 17 end
18 18  
... ...
plugins/serpro_integration/lib/serpro_integration_plugin/gitlab_integration.rb
... ... @@ -15,7 +15,7 @@ class SerproIntegrationPlugin::GitlabIntegration
15 15 def create_project(project_name, group)
16 16 path_with_namespace = "#{group.name}/#{project_name}"
17 17 #FIXME find project by namespace
18   - project = @client.projects(:scope => :all).select do |project|
  18 + project = @client.get("/projects/search/#{project_name}").select do |project|
19 19 project.path_with_namespace == path_with_namespace
20 20 end.first
21 21  
... ...
plugins/serpro_integration/lib/serpro_integration_plugin/gitlab_issues_block.rb 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +require 'open-uri'
  2 +require 'json'
  3 +
  4 +class SerproIntegrationPlugin::GitlabIssuesBlock < Block
  5 +
  6 + def self.description
  7 + _('Gitlab Issues')
  8 + end
  9 +
  10 + def help
  11 + _('This block list gitlab issues')
  12 + end
  13 +
  14 + #FIXME make this test
  15 + def content(args={})
  16 + gitlab_integration = SerproIntegrationPlugin::GitlabIntegration.new(owner.gitlab_host, owner.gitlab_private_token)
  17 + issues = gitlab_integration.issues(owner)
  18 + block = self
  19 + proc do
  20 + render :file => 'blocks/gitlab_issues', :locals => {:issues => issues, :block => block}
  21 + end
  22 + #content_tag(:div,
  23 + # content_tag(:canvas, '', :id => smile_face_id, :width => '95%', :height => '95%' ) +
  24 + # "<script type='text/javascript'>drawFace('#{smile_face_id}', '#{self.smile_factor}')</script>",
  25 + # :class => 'smile'
  26 + #)
  27 + end
  28 +
  29 + def cacheable?
  30 + false
  31 + end
  32 +
  33 +end
... ...
plugins/serpro_integration/lib/serpro_integration_plugin/smile_block.rb
1 1 require 'open-uri'
2 2 require 'json'
3 3  
4   -class SonarPlugin::SmileBlock < Block
  4 +class SerproIntegrationPlugin::SmileBlock < Block
5 5  
6 6  
7 7 METRIC_SUCCESS_DENSITY = 'test_success_density'
... ...
plugins/serpro_integration/lib/serpro_integration_plugin/sonar_widget_block.rb
1   -class SerproIntegrationrPlugin::SonarWidgetBlock < Block
  1 +class SerproIntegrationPlugin::SonarWidgetBlock < Block
2 2  
3 3 #FIXME make this test
4 4 AVAILABLE_WIDGETS = {
... ...
plugins/serpro_integration/views/blocks/_gitlab_issue.html.erb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<li>
  2 + <span><%= gitlab_issue.id %></span>
  3 + <span><%= gitlab_issue.title %></span>
  4 + <span><%= gitlab_url gitlab_issue %></span>
  5 + <%= gitlab_issue.inspect %>
  6 +</li>
... ...
plugins/serpro_integration/views/blocks/gitlab_issues.html.erb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +
  2 +<%= block_title(block.title) %>
  3 +
  4 +<ul>
  5 + <%= render :partial => 'blocks/gitlab_issue', :collection => issues %>
  6 +</ul>
... ...