<commit_before># This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed.

# Please keep the seeding idempotent, as it may be used as a migration if upgrading a production
# instance is necessary and the target version has introduced any new types requiring seeds.
def should_seed? model
  empty = model.all.empty?
  puts(empty ? "Seeding #{model}." : "Not seeding #{model}. Already populated.")
  empty
end

if should_seed? User
  registration_worker = Role.create!(:name => "registration worker", :permissions => [Permission::CHILDREN[:view_and_search], Permission::CHILDREN[:register], Permission::CHILDREN[:edit]])
  registration_officer = Role.create!(:name => "registration officer", :permissions => [Permission::CHILDREN[:view_and_search], Permission::CHILDREN[:register], Permission::CHILDREN[:edit], Permission::CHILDREN[:export], Permission::REPORTS[:view]])
  child_protection_specialist = Role.create!(:name => "child protection specialist", :permissions => [Permission::CHILDREN[:view_and_search], Permission::CHILDREN[:register], Permission::CHILDREN[:edit], Permission::CHILDREN[:export], Permission::REPORTS[:view], Permission::USERS[:view]])
  senior_official = Role.create!(:name => "senior official", :permissions => [Permission::REPORTS[:view]])
  field_level_admin = Role.create!(:name => "field level admin", :permissions => [Permission::USERS[:create_and_edit], Permission::USERS[:view], Permission::USERS[:destroy], Permission::USERS[:disable], Permission::ROLES[:view], Permission::CHILDREN[:view_and_search], Permission::CHILDREN[:export], Permission::REPORTS[:view]])
  system_admin = Role.create!(:name => "system admin", :permissions => [Permission::USERS[:create_and_edit], Permission::USERS[:view], Permission::USERS[:destroy], Permission::USERS[:disable], Permission::ROLES[:create_and_edit], Permission::ROLES[:view], Permission::REPORTS[:view], Permission::FORMS[:manage], Permission::SYSTEM[:highlight_fields], Permission::SYSTEM[:contact_information], Permission::SYSTEM[:system_users], Permission::DEVICES[:blacklist], Permission::DEVICES[:replications]])

  User.create!("user_name" => "rapidftr",
              "password" => "<PASSWORD>",
              "password_confirmation" => "<PASSWORD>",
              "full_name" => "System Administrator",
              "email" => "<EMAIL>",
              "disabled" => "false",
              "organisation" => "N/A",
              "role_ids" => [system_admin.id])

  User.create!("user_name" => "field_worker",
              "password" => "<PASSWORD>",
              "password_confirmation" => "<PASSWORD>",
              "full_name" => "Field Worker",
              "email" => "<EMAIL>",
              "disabled" => "false",
              "organisation" => "N/A",
              "role_ids" => [registration_worker.id])

  User.create!("user_name" => "field_admin",
              "password" => "<PASSWORD>",
              "password_confirmation" => "<PASSWORD>",
              "full_name" => "Field Administrator",
              "email" => "<EMAIL>",
              "disabled" => "false",
              "organisation" => "N/A",
              "role_ids" => [field_level_admin.id])
end

if should_seed? FormSection
  RapidFTR::FormSectionSetup.reset_definitions
  RapidFTR::I18nSetup.reset_definitions
end

if should_seed? SuggestedField
  RapidFTR::SuggestedFieldsSetup.reset_definitions
end

if should_seed? ContactInformation
  ContactInformation.create(:id=>"administrator")
end
<commit_msg>Added a user admin to run android tests<commit_after># This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed.

# Please keep the seeding idempotent, as it may be used as a migration if upgrading a production
# instance is necessary and the target version has introduced any new types requiring seeds.
def should_seed? model
  empty = model.all.empty?
  puts(empty ? "Seeding #{model}." : "Not seeding #{model}. Already populated.")
  empty
end

if should_seed? User
  registration_worker = Role.create!(:name => "registration worker", :permissions => [Permission::CHILDREN[:view_and_search], Permission::CHILDREN[:register], Permission::CHILDREN[:edit]])
  registration_officer = Role.create!(:name => "registration officer", :permissions => [Permission::CHILDREN[:view_and_search], Permission::CHILDREN[:register], Permission::CHILDREN[:edit], Permission::CHILDREN[:export], Permission::REPORTS[:view]])
  child_protection_specialist = Role.create!(:name => "child protection specialist", :permissions => [Permission::CHILDREN[:view_and_search], Permission::CHILDREN[:register], Permission::CHILDREN[:edit], Permission::CHILDREN[:export], Permission::REPORTS[:view], Permission::USERS[:view]])
  senior_official = Role.create!(:name => "senior official", :permissions => [Permission::REPORTS[:view]])
  field_level_admin = Role.create!(:name => "field level admin", :permissions => [Permission::USERS[:create_and_edit], Permission::USERS[:view], Permission::USERS[:destroy], Permission::USERS[:disable], Permission::ROLES[:view], Permission::CHILDREN[:view_and_search], Permission::CHILDREN[:export], Permission::REPORTS[:view]])
  system_admin = Role.create!(:name => "system admin", :permissions => [Permission::USERS[:create_and_edit], Permission::USERS[:view], Permission::USERS[:destroy], Permission::USERS[:disable], Permission::ROLES[:create_and_edit], Permission::ROLES[:view], Permission::REPORTS[:view], Permission::FORMS[:manage], Permission::SYSTEM[:highlight_fields], Permission::SYSTEM[:contact_information], Permission::SYSTEM[:system_users], Permission::DEVICES[:blacklist], Permission::DEVICES[:replications]])

  User.create!("user_name" => "rapidftr",
              "password" => "<PASSWORD>",
              "password_confirmation" => "<PASSWORD>",
              "full_name" => "System Administrator",
              "email" => "<EMAIL>",
              "disabled" => "false",
              "organisation" => "N/A",
              "role_ids" => [system_admin.id])

  User.create!("user_name" => "field_worker",
              "password" => "<PASSWORD>",
              "password_confirmation" => "<PASSWORD>",
              "full_name" => "<NAME>",
              "email" => "<EMAIL>",
              "disabled" => "false",
              "organisation" => "N/A",
              "role_ids" => [registration_worker.id])

  User.create!("user_name" => "field_admin",
              "password" => "<PASSWORD>",
              "password_confirmation" => "<PASSWORD>",
              "full_name" => "<NAME>",
              "email" => "<EMAIL>",
              "disabled" => "false",
              "organisation" => "N/A",
              "role_ids" => [field_level_admin.id])

  if Rails.env.android?
    User.create!("user_name" => "admin",
                 "password" => "<PASSWORD>" ,
                 "password_confirmation" => "<PASSWORD>",
                 "full_name" => "admin user",
                 "email" => "<EMAIL>",
                 "disabled" => "false",
                 "organisation" => "Unicef",
                "role_ids"=>[registration_worker.id,system_admin.id,field_level_admin.id])
  end
end

if should_seed? FormSection
  RapidFTR::FormSectionSetup.reset_definitions
  RapidFTR::I18nSetup.reset_definitions
end

if should_seed? SuggestedField
  RapidFTR::SuggestedFieldsSetup.reset_definitions
end

if should_seed? ContactInformation
  ContactInformation.create(:id=>"administrator")
end

{'fraction_non_alphanumeric': 0.1583597046413502, 'fraction_numerical': 0.0005274261603375527, 'mean_word_length': 4.379432624113475, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 108, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7264647', 'n_tokens_mistral': 2204, 'n_tokens_neox': 2131, 'n_words': 450}