# Produces:
# -----------------------------
#  cc_super
#  cc_admin
#
#  funder_admin
#
#  complete_admin
#  complete_user
#
#  institution_[1..2]_admin
#  institution_[1..2]_user
#
#  school_[1..2]_admin
#  school_[1..2]_user
#
#  project_[1..2]_admin
#  project_[1..2]_user
#

# Import organisation_types.yml and roles.yml
<% organisation_types = YAML::load(ERB.new(File.read('./test/fixtures/organisation_types.yml')).result) %>
cc_super:
  firstname: 'Curation Centre'
  surname: 'Super Admin'
  email: 'super-admin@example-cc.org'
  encrypted_password: <%= User.new.send(:password_digest, 'password123') %>
  accept_terms: true
  organisation: curation_center
  roles: [add_organisations, change_org_affiliation, grant_api_to_orgs, grant_permissions, modify_templates, modify_guidance, change_org_details, use_api]
  api_token: "ABCD1234ZYX987supercc"
  language: en-UK
  confirmed_at: '2016-09-09 10:10:10'

cc_admin:
  firstname: 'Curation Centre'
  surname: 'Administrator'
  email: 'admin@example-cc.org'
  encrypted_password: <%= User.new.send(:password_digest, 'password123') %>
  accept_terms: true
  organisation: curation_center
  roles: [grant_permissions, modify_templates, modify_guidance, change_org_details, use_api]
  api_token: "ABCD1234ZYX987admincc"
  language: en-UK
  confirmed_at: '2016-09-09 10:10:10'

funder_admin:
  firstname: 'Funder'
  surname: 'Administrator'
  email: 'admin@example-funder.org'
  encrypted_password: <%= User.new.send(:password_digest, 'password123') %>
  accept_terms: true
  organisation: funder
  roles: [grant_permissions, modify_templates, modify_guidance, change_org_details, use_api]
  api_token: "ABCD1234ZYX987adminfunder"
  language: en-UK
  confirmed_at: '2016-09-09 10:10:10'

# We unfortunatley cannot tab this out nicely because YAML is expecting the values in 
# the first column
<% organisation_types.each do |lbl, obj| %>
  <% unless ['funder', 'organisation'].include?(lbl) %>
    <% 2.times do |x| %>

<%= lbl %>_<%= x + 1 %>_admin:
  firstname: <%= "#{obj['name']} #{x + 1}" %>
  surname: "Admin"
  email: <%= "admin@example-#{lbl}-#{x + 1}.org" %>
  encrypted_password: <%= User.new.send(:password_digest, 'password123') %>
  orcid_id: <%= "orcid-#{lbl}-#{x + 1}-admin12345" %>
  shibboleth_id: <%= "shib-#{lbl}-#{x + 1}-admin12345" %>
  accept_terms: true
  organisation: <%= lbl %>_<%= x + 1 %>
  roles: [grant_permissions, modify_templates, modify_guidance, change_org_details, use_api]
  api_token: "ABCD1234ZYX987admin#{lbl}#{x + 1}"
  language: en-UK
  confirmed_at: '2016-09-09 10:10:10'

<%= lbl %>_<%= x + 1 %>_user:
  firstname: <%= "#{obj['name']} #{x + 1}" %>
  surname: "User"
  email: <%= "user@example-#{lbl}-#{x + 1}.org" %>
  encrypted_password: <%= User.new.send(:password_digest, 'password123') %>
  orcid_id: <%= "orcid-#{lbl}-#{x + 1}-user12345" %>
  shibboleth_id: <%= "shib-#{lbl}-#{x + 1}-user12345" %>
  accept_terms: true
  organisation: <%= lbl %>_<%= x + 1 %>
  api_token: "ABCD1234ZYX987user#{lbl}#{x + 1}"
  language: en-UK
  confirmed_at: '2016-09-09 10:10:10'

    <% end %>
  <% end %>
<% end %>

complete_admin:
  firstname: "Complete"
  surname: "Admin"
  email: <%= "admin@example-complete.org" %>
  encrypted_password: <%= User.new.send(:password_digest, 'password123') %>
  orcid_id: <%= "orcid-complete-admin12345" %>
  shibboleth_id: <%= "shib-complete-admin12345" %>
  accept_terms: true
  organisation: complete
  roles: [grant_permissions, modify_templates, modify_guidance, change_org_details, use_api]
  api_token: "ABCD1234ZYX987admincomplete"
  language: en-UK
  confirmed_at: '2016-09-09 10:10:10'

complete_user:
  firstname: "Complete"
  surname: "User"
  email: <%= "user@example-complete.org" %>
  encrypted_password: <%= User.new.send(:password_digest, 'password123') %>
  orcid_id: <%= "orcid-complete-user12345" %>
  shibboleth_id: <%= "shib-complete-user12345" %>
  accept_terms: true
  organisation: complete
  api_token: "ABCD1234ZYX987usercomplete"
  language: en-UK
  confirmed_at: '2016-09-09 10:10:10'