Commit e34ffc64349091f9c78d595f66ad15faef95fdd6
Exists in
staging
and in
15 other branches
Merge branch 'master' of gitlab.com:noosfero/noosfero
Showing
11 changed files
with
94 additions
and
9 deletions
Show diff stats
plugins/oauth_client/Gemfile
1 | gem 'omniauth', '~> 1.2.2' | 1 | gem 'omniauth', '~> 1.2.2' |
2 | gem 'omniauth-facebook', '~> 2.0.0' | 2 | gem 'omniauth-facebook', '~> 2.0.0' |
3 | +gem 'omniauth-twitter', '~> 1.0.1' | ||
3 | gem "omniauth-google-oauth2", '~> 0.2.6' | 4 | gem "omniauth-google-oauth2", '~> 0.2.6' |
4 | gem "omniauth-oauth2", '~> 1.3.1' | 5 | gem "omniauth-oauth2", '~> 1.3.1' |
6 | +gem "omniauth-github", '~> 1.1.2' |
plugins/oauth_client/README.md
@@ -33,6 +33,20 @@ Facebook | @@ -33,6 +33,20 @@ Facebook | ||
33 | 33 | ||
34 | [Create Facebook application](https://developers.facebook.com/docs/facebook-login/v2.1) | 34 | [Create Facebook application](https://developers.facebook.com/docs/facebook-login/v2.1) |
35 | 35 | ||
36 | +Github | ||
37 | +-------- | ||
38 | + | ||
39 | +[Create Github application](https://github.com/settings/developers) | ||
40 | + | ||
41 | |||
42 | +-------- | ||
43 | + | ||
44 | +- Specially on twitter you need to request user's email address, see more | ||
45 | +in https://dev.twitter.com/rest/reference/get/account/verify_credentials | ||
46 | + | ||
47 | +[Create Twitter application](https://apps.twitter.com/) | ||
48 | + | ||
49 | + | ||
36 | Callback | 50 | Callback |
37 | ======== | 51 | ======== |
38 | 52 |
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +Feature: Create Twitter provider | ||
2 | + As a environment admin | ||
3 | + I want to be able to create a new twitter provider | ||
4 | + So that users can login wth different strategies | ||
5 | + | ||
6 | +Background: | ||
7 | + Given "OauthProvider" plugin is enabled | ||
8 | + And I am logged in as admin | ||
9 | + And I go to /admin/plugins | ||
10 | + And I check "Oauth Client Plugin" | ||
11 | + And I press "Save changes" | ||
12 | + | ||
13 | +Scenario: Create a twitter provider | ||
14 | + Given I go to /admin/plugin/oauth_client/new | ||
15 | + And I fill in "oauth_client_plugin_provider_name" with "myid" | ||
16 | + And I fill in "oauth_client_plugin_provider[name]" with "google" | ||
17 | + And I fill in "oauth_client_plugin_provider_client_secret" with "mysecret" | ||
18 | + And I check "oauth_client_plugin_provider[enabled]" | ||
19 | + And I select "twitter" from "oauth_client_plugin_provider_strategy" | ||
20 | + Then I should see "To use this provider you need to request the user email in your app" |
plugins/oauth_client/lib/oauth_client_plugin.rb
@@ -31,13 +31,20 @@ class OauthClientPlugin < Noosfero::Plugin | @@ -31,13 +31,20 @@ class OauthClientPlugin < Noosfero::Plugin | ||
31 | 31 | ||
32 | PROVIDERS = { | 32 | PROVIDERS = { |
33 | :facebook => { | 33 | :facebook => { |
34 | - :name => 'Facebook' | 34 | + :name => 'Facebook', |
35 | + :info_fields => 'name,email' | ||
35 | }, | 36 | }, |
36 | :google_oauth2 => { | 37 | :google_oauth2 => { |
37 | :name => 'Google' | 38 | :name => 'Google' |
38 | }, | 39 | }, |
39 | :noosfero_oauth2 => { | 40 | :noosfero_oauth2 => { |
40 | :name => 'Noosfero' | 41 | :name => 'Noosfero' |
42 | + }, | ||
43 | + :github => { | ||
44 | + :name => 'Github' | ||
45 | + }, | ||
46 | + :twitter => { | ||
47 | + :name => 'Twitter' | ||
41 | } | 48 | } |
42 | } | 49 | } |
43 | 50 | ||
@@ -62,8 +69,9 @@ class OauthClientPlugin < Noosfero::Plugin | @@ -62,8 +69,9 @@ class OauthClientPlugin < Noosfero::Plugin | ||
62 | provider_id = request.params['id'] | 69 | provider_id = request.params['id'] |
63 | provider_id ||= request.session['omniauth.params']['id'] if request.session['omniauth.params'] | 70 | provider_id ||= request.session['omniauth.params']['id'] if request.session['omniauth.params'] |
64 | provider = environment.oauth_providers.find(provider_id) | 71 | provider = environment.oauth_providers.find(provider_id) |
72 | + strategy.options.merge! consumer_key: provider.client_id, consumer_secret: provider.client_secret | ||
65 | strategy.options.merge! client_id: provider.client_id, client_secret: provider.client_secret | 73 | strategy.options.merge! client_id: provider.client_id, client_secret: provider.client_secret |
66 | - strategy.options.merge! provider.options.symbolize_keys | 74 | + strategy.options.merge! options |
67 | 75 | ||
68 | request.session[:provider_id] = provider_id | 76 | request.session[:provider_id] = provider_id |
69 | } | 77 | } |
@@ -95,4 +103,8 @@ class OauthClientPlugin < Noosfero::Plugin | @@ -95,4 +103,8 @@ class OauthClientPlugin < Noosfero::Plugin | ||
95 | } | 103 | } |
96 | end | 104 | end |
97 | 105 | ||
106 | + def js_files | ||
107 | + ["script.js"] | ||
108 | + end | ||
109 | + | ||
98 | end | 110 | end |
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +$(document).ready(function(){ | ||
2 | + select_box_event(); | ||
3 | +}); | ||
4 | + | ||
5 | +var toggle_info_message = function(){ | ||
6 | + var selected_option = $("#oauth_client_plugin_provider_strategy option:selected"); | ||
7 | + if (selected_option.length){ | ||
8 | + if (selected_option.val() === "twitter"){ | ||
9 | + $(".remember-enable-email").removeClass("hidden"); | ||
10 | + } else { | ||
11 | + $(".remember-enable-email").addClass("hidden"); | ||
12 | + } | ||
13 | + } | ||
14 | +}; | ||
15 | + | ||
16 | +var select_box_event = function(){ | ||
17 | + var select_box = $("#oauth_client_plugin_provider_strategy"); | ||
18 | + select_box.on("change",function(){ | ||
19 | + toggle_info_message(); | ||
20 | + }); | ||
21 | +}; |
plugins/oauth_client/public/style.css
plugins/oauth_client/views/oauth_client_plugin_admin/edit.html.erb
@@ -15,6 +15,10 @@ | @@ -15,6 +15,10 @@ | ||
15 | <%= labelled_form_field _('Strategy'), f.select(:strategy, OauthClientPlugin::PROVIDERS) %> | 15 | <%= labelled_form_field _('Strategy'), f.select(:strategy, OauthClientPlugin::PROVIDERS) %> |
16 | </div> | 16 | </div> |
17 | 17 | ||
18 | + <div class="remember-enable-email hidden"> | ||
19 | + <span class="error"><%=_('To use this provider you need to request the user email in your app')%></span> | ||
20 | + </div> | ||
21 | + | ||
18 | <div class="client-id"> | 22 | <div class="client-id"> |
19 | <%= labelled_form_field _('Client Id'), f.text_field(:client_id) %> | 23 | <%= labelled_form_field _('Client Id'), f.text_field(:client_id) %> |
20 | </div> | 24 | </div> |
plugins/work_assignment/lib/work_assignment_plugin/email_contact.rb
@@ -50,13 +50,13 @@ class WorkAssignmentPlugin::EmailContact | @@ -50,13 +50,13 @@ class WorkAssignmentPlugin::EmailContact | ||
50 | mail(options) | 50 | mail(options) |
51 | end | 51 | end |
52 | 52 | ||
53 | - def build_mail_message(email_contact, uploaded_files) | 53 | + def self.build_mail_message(email_contact, uploaded_files) |
54 | message = "" | 54 | message = "" |
55 | if uploaded_files && uploaded_files.first && uploaded_files.first.parent && uploaded_files.first.parent.parent | 55 | if uploaded_files && uploaded_files.first && uploaded_files.first.parent && uploaded_files.first.parent.parent |
56 | article = uploaded_files.first.parent.parent | 56 | article = uploaded_files.first.parent.parent |
57 | message = article.default_email + "<br>" | 57 | message = article.default_email + "<br>" |
58 | uploaded_files.each do |file| | 58 | uploaded_files.each do |file| |
59 | - url = url_for(file.url) | 59 | + url = Rails.application.routes.url_helpers.url_for(file.url) |
60 | message += "<br><a href='#{url}'>#{url}</a>" | 60 | message += "<br><a href='#{url}'>#{url}</a>" |
61 | end | 61 | end |
62 | end | 62 | end |
plugins/work_assignment/lib/work_assignment_plugin/helper.rb
@@ -16,7 +16,7 @@ module WorkAssignmentPlugin::Helper | @@ -16,7 +16,7 @@ module WorkAssignmentPlugin::Helper | ||
16 | end | 16 | end |
17 | 17 | ||
18 | def display_author_folder(author_folder, user) | 18 | def display_author_folder(author_folder, user) |
19 | - return if author_folder.children.empty? | 19 | + return if author_folder.children(true).empty? |
20 | content_tag('tr', | 20 | content_tag('tr', |
21 | content_tag('td', link_to_last_submission(author_folder, user)) + | 21 | content_tag('td', link_to_last_submission(author_folder, user)) + |
22 | content_tag('td', time_format(author_folder.children.last.created_at)) + | 22 | content_tag('td', time_format(author_folder.children.last.created_at)) + |
plugins/work_assignment/test/functional/content_viewer_controller_test.rb
@@ -35,6 +35,14 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -35,6 +35,14 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
35 | assert_response :success | 35 | assert_response :success |
36 | end | 36 | end |
37 | 37 | ||
38 | + should 'display users submissions' do | ||
39 | + folder = work_assignment.find_or_create_author_folder(@person) | ||
40 | + submission = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => organization, :parent => folder) | ||
41 | + get :view_page, :profile => @organization.identifier, :page => work_assignment.path | ||
42 | + assert_response :success | ||
43 | + assert_match /rails.png/, @response.body | ||
44 | + end | ||
45 | + | ||
38 | should "display 'Upload files' when create children of image gallery" do | 46 | should "display 'Upload files' when create children of image gallery" do |
39 | login_as(profile.identifier) | 47 | login_as(profile.identifier) |
40 | f = Gallery.create!(:name => 'gallery', :profile => profile) | 48 | f = Gallery.create!(:name => 'gallery', :profile => profile) |
po/pt/noosfero.po
@@ -13,8 +13,8 @@ msgid "" | @@ -13,8 +13,8 @@ msgid "" | ||
13 | msgstr "" | 13 | msgstr "" |
14 | "Project-Id-Version: 1.3~rc2-8-g01ea9f7\n" | 14 | "Project-Id-Version: 1.3~rc2-8-g01ea9f7\n" |
15 | "POT-Creation-Date: 2015-11-04 12:36-0300\n" | 15 | "POT-Creation-Date: 2015-11-04 12:36-0300\n" |
16 | -"PO-Revision-Date: 2016-03-14 15:58+0000\n" | ||
17 | -"Last-Translator: Eduardo Vital <vitaldu@gmail.com>\n" | 16 | +"PO-Revision-Date: 2016-06-20 20:14+0000\n" |
17 | +"Last-Translator: Gabriel Silva <gabriel93.silva@gmail.com>\n" | ||
18 | "Language-Team: Portuguese " | 18 | "Language-Team: Portuguese " |
19 | "<https://hosted.weblate.org/projects/noosfero/noosfero/pt/>\n" | 19 | "<https://hosted.weblate.org/projects/noosfero/noosfero/pt/>\n" |
20 | "Language: pt\n" | 20 | "Language: pt\n" |
@@ -22,7 +22,7 @@ msgstr "" | @@ -22,7 +22,7 @@ msgstr "" | ||
22 | "Content-Type: text/plain; charset=UTF-8\n" | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | "Content-Transfer-Encoding: 8bit\n" | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" | 24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" |
25 | -"X-Generator: Weblate 2.5\n" | 25 | +"X-Generator: Weblate 2.7-dev\n" |
26 | 26 | ||
27 | #: app/models/approve_comment.rb:17 | 27 | #: app/models/approve_comment.rb:17 |
28 | msgid "Anonymous" | 28 | msgid "Anonymous" |
@@ -4141,7 +4141,7 @@ msgstr "%s não pôde ser desabilitado" | @@ -4141,7 +4141,7 @@ msgstr "%s não pôde ser desabilitado" | ||
4141 | 4141 | ||
4142 | #: app/controllers/admin/organizations_controller.rb:52 | 4142 | #: app/controllers/admin/organizations_controller.rb:52 |
4143 | msgid "%s removed" | 4143 | msgid "%s removed" |
4144 | -msgstr "% foi removido" | 4144 | +msgstr "%s foi removido" |
4145 | 4145 | ||
4146 | #: app/controllers/admin/organizations_controller.rb:54 | 4146 | #: app/controllers/admin/organizations_controller.rb:54 |
4147 | msgid "%s could not be removed" | 4147 | msgid "%s could not be removed" |