diff --git a/app/assets/images/orcid.png b/app/assets/images/orcid.png
new file mode 100644
index 0000000..2db382d
--- /dev/null
+++ b/app/assets/images/orcid.png
Binary files differ
diff --git a/app/assets/stylesheets/admin.css.less b/app/assets/stylesheets/admin.css.less
index 132e00e..00ea783 100644
--- a/app/assets/stylesheets/admin.css.less
+++ b/app/assets/stylesheets/admin.css.less
@@ -567,7 +567,6 @@
}
-
/***********************************
Home page
************************************/
diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less
index f0b730b..e71ec49 100644
--- a/app/assets/stylesheets/bootstrap_and_overrides.css.less
+++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less
@@ -576,7 +576,21 @@
-moz-border-radius: 3px;
}
-
+/***********************************
+ User Profile Page
+************************************/
+td.force-left .select2-container {
+ position: relative;
+ float: left;
+ clear: left;
+}
+.user-identifier {
+ background-repeat: no-repeat;
+ background-size: 25px;
+ background-position: 6px 50%;
+ margin-left: -7px;
+ padding: 3px 0 3px 35px;
+}
/***********************************
Home page
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb
index 3394ba2..27ebbd2 100644
--- a/app/controllers/registrations_controller.rb
+++ b/app/controllers/registrations_controller.rb
@@ -2,7 +2,8 @@
class RegistrationsController < Devise::RegistrationsController
def edit
- @languages = Language.all.order("name")
+ @languages = Language.order("name")
+ @identifier_schemes = IdentifierScheme.order(:name)
end
# POST /resource
diff --git a/app/models/identifier_scheme.rb b/app/models/identifier_scheme.rb
new file mode 100644
index 0000000..79a89ad
--- /dev/null
+++ b/app/models/identifier_scheme.rb
@@ -0,0 +1,3 @@
+class IdentifierScheme < ActiveRecord::Base
+ has_many :user_identifiers
+end
\ No newline at end of file
diff --git a/app/models/user.rb b/app/models/user.rb
index d3bec38..ab016a7 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -15,6 +15,7 @@
has_many :project_groups, :dependent => :destroy
#has_many :organisations , through: :user_org_roles
has_many :user_role_types, through: :user_org_roles
+ has_many :user_identifiers
has_one :language
belongs_to :organisation
@@ -70,6 +71,11 @@
end
end
+ def identifier_for(scheme)
+ user_identifier = user_identifiers.where(identifier_scheme: scheme).first
+ (user_identifier.nil? ? '' : user_identifier.identifier)
+ end
+
##
# sets a new organisation id for the user
# if the user has any roles such as org_admin or admin, those are removed
diff --git a/app/models/user_identifier.rb b/app/models/user_identifier.rb
new file mode 100644
index 0000000..cf0c188
--- /dev/null
+++ b/app/models/user_identifier.rb
@@ -0,0 +1,4 @@
+class UserIdentifier < ActiveRecord::Base
+ belongs_to :user
+ belongs_to :identifier_scheme
+end
\ No newline at end of file
diff --git a/app/views/devise/registrations/_external_identifier.html.erb b/app/views/devise/registrations/_external_identifier.html.erb
new file mode 100644
index 0000000..cac7b72
--- /dev/null
+++ b/app/views/devise/registrations/_external_identifier.html.erb
@@ -0,0 +1,25 @@
+
)">
+
+ <% if id.nil? || id == '' %>
+
+ <%= link_to "#{constant("identifier_schemes.#{scheme.name}.connect")}",
+ "#{scheme.auth_uri}",
+ title: constant("identifier_schemes.#{scheme.name}.tooltip") %>
+
+ <% else %>
+ <% uri = "#{scheme.user_uri.gsub(/\{id\}/, id)}" %>
+ <%= link_to uri, uri, target: '_blank',
+ title: constant("identifier_schemes.#{scheme.name}.tooltip") %>
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb
index 7357115..9e8ad73 100644
--- a/app/views/devise/registrations/edit.html.erb
+++ b/app/views/devise/registrations/edit.html.erb
@@ -36,7 +36,7 @@
<%= t("helpers.org_type.organisation") %>
- <%= collection_select(:user,
+ <%= collection_select(:user,
:organisation_id, Organisation.where("parent_id IS NULL").order("name"),
:id, :name, {include_blank: constant("organisation_types.organisation")},
{ :class => "typeahead org_sign_up" }) %>
@@ -53,7 +53,7 @@
<%= t('helpers.user_details_language') %>
-
+
<%= @languages.each do |l| %>
@@ -63,13 +63,19 @@
-
- <%= t("helpers.orcid_id") %>
- <%= f.text_field :orcid_id ,
- :as => :string,
- :autocomplete => "off" ,
- :class => "text_field has-tooltip", "data-toggle" => "tooltip", "data-html" => "true", "title" => t("helpers.orcid_html") %>
-
+
+ <% @identifier_schemes.each do |scheme| %>
+
+ <%= scheme.name %>
+
+ <%= render partial: 'external_identifier',
+ locals: {scheme: scheme,
+ id: current_user.identifier_for(scheme)} %>
+
+
+ <% end %>
+
+
<% unless @user.api_token.blank? %>
<%= t("helpers.api_token") %>
diff --git a/config/initializers/devise_example.rb b/config/initializers/devise_example.rb
index 17b481e..af16333 100644
--- a/config/initializers/devise_example.rb
+++ b/config/initializers/devise_example.rb
@@ -247,7 +247,7 @@
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
-
+
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
# change the failure app, you can configure them inside the config.warden block.
@@ -269,7 +269,7 @@
#
# When using omniauth, Devise cannot automatically set Omniauth path,
# so you need to do it manually. For the users scope, it would be:
- # config.omniauth_path_prefix = "/my_engine/users/auth"
+ #config.omniauth_path_prefix = "/my_engine/users/auth"
config.warden do |manager|
manager.failure_app = CustomFailure
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 6649b1f..05939aa 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -885,4 +885,8 @@
plans: 'plans'
templates: 'templates'
statistics: 'statistics'
+ identifier_schemes:
+ ORCID:
+ connect_icon: '/assets/orcid.png'
+ tooltip: 'ORCID bietet eine persistente digitale Kennung, die Sie von anderen Forschern unterscheidet.'
languages:
diff --git a/config/locales/en-UK.yml b/config/locales/en-UK.yml
index 55158f9..7acf644 100644
--- a/config/locales/en-UK.yml
+++ b/config/locales/en-UK.yml
@@ -980,4 +980,8 @@
plans: 'plans'
templates: 'templates'
statistics: 'statistics'
+ identifier_schemes:
+ ORCID:
+ connect_icon: '/assets/orcid.png'
+ tooltip: 'ORCID provides a persistent digital identifier that distinguishes you from other researchers.'
languages:
diff --git a/config/locales/en-US.yml b/config/locales/en-US.yml
index 91b09d9..8254981 100644
--- a/config/locales/en-US.yml
+++ b/config/locales/en-US.yml
@@ -970,4 +970,9 @@
plans: 'plans'
templates: 'templates'
statistics: 'statistics'
+ identifier_schemes:
+ ORCID:
+ connect_icon: '/assets/orcid.png'
+ connect: 'Connect your ORCID'
+ tooltip: 'ORCID provides a persistent digital identifier that distinguishes you from other researchers.'
languages:
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 4570d10..edd1a51 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -868,4 +868,8 @@
plans: 'plans'
templates: 'templates'
statistics: 'statistics'
+ identifier_schemes:
+ ORCID:
+ connect_icon: '/assets/orcid.png'
+ tooltip: 'ORCID fournit un identifiant numérique persistant qui vous distingue des autres chercheurs.'
languages:
diff --git a/db/migrate/20161024163546_create_user_identifier_scheme.rb b/db/migrate/20161024163546_create_user_identifier_scheme.rb
new file mode 100644
index 0000000..3883c3c
--- /dev/null
+++ b/db/migrate/20161024163546_create_user_identifier_scheme.rb
@@ -0,0 +1,11 @@
+class CreateUserIdentifierScheme < ActiveRecord::Migration
+ def change
+ create_table :identifier_schemes do |t|
+ t.string :name
+ t.string :auth_uri
+ t.string :user_uri
+
+ t.timestamps
+ end
+ end
+end
\ No newline at end of file
diff --git a/db/migrate/20161024163920_create_user_identifiers.rb b/db/migrate/20161024163920_create_user_identifiers.rb
new file mode 100644
index 0000000..9a86e89
--- /dev/null
+++ b/db/migrate/20161024163920_create_user_identifiers.rb
@@ -0,0 +1,11 @@
+class CreateUserIdentifiers < ActiveRecord::Migration
+ def change
+ create_table :user_identifiers do |t|
+ t.string :identifier
+ t.timestamps
+ end
+
+ add_reference :user_identifiers, :user, foreign_key: true
+ add_reference :user_identifiers, :identifier_scheme, foreign_key: true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 4c22ef6..cc4fde9 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,14 +10,16 @@
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20160822130701) do
+
+ActiveRecord::Schema.define(version: 20161024163920) do
+
create_table "answers", force: :cascade do |t|
t.text "text", limit: 65535
t.integer "plan_id", limit: 4
t.integer "user_id", limit: 4
t.integer "question_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "answers_options", id: false, force: :cascade do |t|
@@ -31,8 +33,8 @@
t.integer "user_id", limit: 4
t.integer "question_id", limit: 4
t.text "text", limit: 65535
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.boolean "archived"
t.integer "plan_id", limit: 4
t.integer "archived_by", limit: 4
@@ -44,8 +46,8 @@
t.boolean "published"
t.integer "user_id", limit: 4
t.integer "organisation_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.string "locale", limit: 255
t.boolean "is_default"
end
@@ -59,8 +61,8 @@
t.integer "plan_id", limit: 4
t.integer "user_id", limit: 4
t.string "format", limit: 255
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "file_types", force: :cascade do |t|
@@ -68,8 +70,8 @@
t.string "icon_name", limit: 255
t.integer "icon_size", limit: 4
t.string "icon_location", limit: 255
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "file_uploads", force: :cascade do |t|
@@ -80,12 +82,12 @@
t.boolean "published"
t.string "location", limit: 255
t.integer "file_type_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "friendly_id_slugs", force: :cascade do |t|
- t.string "slug", limit: 255, null: false
+ t.string "slug", limit: 191, null: false
t.integer "sluggable_id", limit: 4, null: false
t.string "sluggable_type", limit: 40
t.datetime "created_at"
@@ -98,8 +100,8 @@
create_table "guidance_groups", force: :cascade do |t|
t.string "name", limit: 255
t.integer "organisation_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.boolean "optional_subset"
t.boolean "published"
end
@@ -114,17 +116,25 @@
create_table "guidances", force: :cascade do |t|
t.text "text", limit: 65535
t.integer "guidance_group_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.integer "question_id", limit: 4
t.boolean "published"
end
+ create_table "identifier_schemes", force: :cascade do |t|
+ t.string "name", limit: 255
+ t.string "auth_uri", limit: 255
+ t.string "user_uri", limit: 255
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "languages", force: :cascade do |t|
t.string "abbreviation", limit: 255
t.string "description", limit: 255
t.string "name", limit: 255
- t.boolean "default_language", limit: 1
+ t.boolean "default_language"
end
create_table "option_warnings", force: :cascade do |t|
@@ -140,8 +150,8 @@
t.string "text", limit: 255
t.integer "number", limit: 4
t.boolean "is_default"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "org_token_permissions", force: :cascade do |t|
@@ -154,8 +164,8 @@
create_table "organisation_types", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "organisations", force: :cascade do |t|
@@ -166,8 +176,8 @@
t.string "domain", limit: 255
t.string "wayfless_entity", limit: 255
t.integer "stylesheet_file_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.integer "parent_id", limit: 4
t.boolean "is_other"
t.string "sort_name", limit: 255
@@ -187,7 +197,7 @@
t.integer "dmptemplate_id", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
- t.string "slug", limit: 255
+ t.string "slug", limit: 191
end
add_index "phases", ["dmptemplate_id"], name: "index_phases_on_dmptemplate_id", using: :btree
@@ -197,8 +207,8 @@
t.integer "user_id", limit: 4
t.integer "section_id", limit: 4
t.integer "plan_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.datetime "release_time"
end
@@ -206,8 +216,8 @@
t.boolean "locked"
t.integer "project_id", limit: 4
t.integer "version_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "project_groups", force: :cascade do |t|
@@ -215,8 +225,8 @@
t.boolean "project_editor"
t.integer "user_id", limit: 4
t.integer "project_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.boolean "project_administrator"
end
@@ -232,7 +242,7 @@
t.integer "dmptemplate_id", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
- t.string "slug", limit: 255
+ t.string "slug", limit: 191
t.integer "organisation_id", limit: 4
t.string "grant_number", limit: 255
t.string "identifier", limit: 255
@@ -248,8 +258,8 @@
create_table "question_formats", force: :cascade do |t|
t.string "title", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "questions", force: :cascade do |t|
@@ -261,8 +271,8 @@
t.integer "dependency_id", limit: 4
t.text "dependency_text", limit: 65535
t.integer "section_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.integer "question_format_id", limit: 4
t.boolean "option_comment_display", default: true
end
@@ -286,10 +296,10 @@
end
create_table "roles", force: :cascade do |t|
- t.string "name", limit: 255
+ t.string "name", limit: 191
t.datetime "created_at"
t.datetime "updated_at"
- t.boolean "role_in_plans", limit: 1
+ t.boolean "role_in_plans"
t.integer "resource_id", limit: 4
t.string "resource_type", limit: 255
end
@@ -303,16 +313,16 @@
t.integer "number", limit: 4
t.integer "version_id", limit: 4
t.integer "organisation_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.boolean "published"
end
create_table "settings", force: :cascade do |t|
- t.string "var", limit: 255, null: false
+ t.string "var", limit: 191, null: false
t.text "value", limit: 65535
t.integer "target_id", limit: 4, null: false
- t.string "target_type", limit: 255, null: false
+ t.string "target_type", limit: 191, null: false
t.datetime "created_at"
t.datetime "updated_at"
end
@@ -321,24 +331,24 @@
create_table "splash_logs", force: :cascade do |t|
t.string "destination", limit: 255
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "suggested_answers", force: :cascade do |t|
t.integer "question_id", limit: 4
t.integer "organisation_id", limit: 4
t.text "text", limit: 65535
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.boolean "is_example"
end
create_table "themes", force: :cascade do |t|
t.string "title", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.string "locale", limit: 255
end
@@ -354,6 +364,17 @@
t.datetime "updated_at"
end
+ create_table "user_identifiers", force: :cascade do |t|
+ t.string "identifier", limit: 255
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "user_id", limit: 4
+ t.integer "identifier_scheme_id", limit: 4
+ end
+
+ add_index "user_identifiers", ["identifier_scheme_id"], name: "fk_rails_fe95df7db0", using: :btree
+ add_index "user_identifiers", ["user_id"], name: "fk_rails_65c9a98cdb", using: :btree
+
create_table "user_org_roles", force: :cascade do |t|
t.integer "user_id", limit: 4
t.integer "organisation_id", limit: 4
@@ -365,28 +386,28 @@
create_table "user_role_types", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "user_statuses", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "user_types", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "users", force: :cascade do |t|
t.string "firstname", limit: 255
t.string "surname", limit: 255
- t.string "email", limit: 255, default: "", null: false
+ t.string "email", limit: 191, default: "", null: false
t.string "orcid_id", limit: 255
t.string "shibboleth_id", limit: 255
t.integer "user_type_id", limit: 4
@@ -394,7 +415,7 @@
t.datetime "created_at"
t.datetime "updated_at"
t.string "encrypted_password", limit: 255, default: ""
- t.string "reset_password_token", limit: 255
+ t.string "reset_password_token", limit: 191
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", limit: 4, default: 0
@@ -402,14 +423,15 @@
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip", limit: 255
t.string "last_sign_in_ip", limit: 255
- t.string "confirmation_token", limit: 255
+ t.string "confirmation_token", limit: 191
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
- t.string "invitation_token", limit: 255
+ t.string "invitation_token", limit: 191
t.datetime "invitation_created_at"
t.datetime "invitation_sent_at"
t.datetime "invitation_accepted_at"
t.string "other_organisation", limit: 255
+ t.boolean "dmponline3"
t.boolean "accept_terms"
t.integer "organisation_id", limit: 4
t.string "api_token", limit: 255
@@ -436,10 +458,12 @@
t.boolean "published"
t.integer "number", limit: 4
t.integer "phase_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
add_index "versions", ["phase_id"], name: "index_versions_on_phase_id", using: :btree
+ add_foreign_key "user_identifiers", "identifier_schemes"
+ add_foreign_key "user_identifiers", "users"
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 3be10f2..665366c 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -86,6 +86,25 @@
end
end
+identifier_schemes = {
+ 'orcid' => {
+ name: 'ORCID',
+ auth_uri: '/roadmap/auth/orcid?resource_id=123',
+ user_uri: 'https://sandbox.orcid.org/{id}/'
+ }
+}
+
+identifier_schemes.each do |l, details|
+ if IdentifierScheme.where(name: details[:name]).empty?
+ scheme = IdentifierScheme.new({
+ name: details[:name],
+ auth_uri: details[:auth_uri],
+ user_uri: details[:user_uri]
+ })
+ scheme.save!
+ end
+end
+
organisation_types = {
'Organisation' => {
name: "Organisation"