Commit b7149266 authored by James Lopez's avatar James Lopez

WIP project members - json not quite right yet

parent c2304141
...@@ -3,7 +3,7 @@ module Projects ...@@ -3,7 +3,7 @@ module Projects
module ProjectFactory module ProjectFactory
extend self extend self
def create(project_params:, user:, members:) def create(project_params:, user:, members_map:)
project = Project.new(project_params.except('id')) project = Project.new(project_params.except('id'))
project.creator = user project.creator = user
check_namespace(project_params['namespace_id'], project, user) check_namespace(project_params['namespace_id'], project, user)
......
...@@ -16,7 +16,7 @@ module Projects ...@@ -16,7 +16,7 @@ module Projects
private private
def members def members_map
@members ||= Projects::ImportExport::MembersMapper.map(exported_members: @tree_hash.delete('project_members')) @members ||= Projects::ImportExport::MembersMapper.map(exported_members: @tree_hash.delete('project_members'))
end end
...@@ -35,7 +35,7 @@ module Projects ...@@ -35,7 +35,7 @@ module Projects
def create_project def create_project
project_params = @tree_hash.reject { |_key, value| value.is_a?(Array) } project_params = @tree_hash.reject { |_key, value| value.is_a?(Array) }
project = Projects::ImportExport::ProjectFactory.create( project = Projects::ImportExport::ProjectFactory.create(
project_params: project_params, user: @user, members: members) project_params: project_params, user: @user, members_map: members_map)
project.save project.save
project project
end end
...@@ -43,7 +43,7 @@ module Projects ...@@ -43,7 +43,7 @@ module Projects
def create_relation(relation, relation_hash_list) def create_relation(relation, relation_hash_list)
relation_hash_list.map do |relation_hash| relation_hash_list.map do |relation_hash|
Projects::ImportExport::RelationFactory.create( Projects::ImportExport::RelationFactory.create(
relation_sym: relation, relation_hash: relation_hash.merge(project_id: project.id), members: members) relation_sym: relation, relation_hash: relation_hash.merge(project_id: project.id), members_map: members_map)
end end
end end
end end
......
...@@ -5,7 +5,7 @@ module Projects ...@@ -5,7 +5,7 @@ module Projects
OVERRIDES = { snippets: :project_snippets } OVERRIDES = { snippets: :project_snippets }
def create(relation_sym:, relation_hash:) def create(relation_sym:, relation_hash:, members_map:)
relation_sym = parse_relation_sym(relation_sym) relation_sym = parse_relation_sym(relation_sym)
klass = relation_class(relation_sym) klass = relation_class(relation_sym)
relation_hash.delete('id') #screw IDs for now relation_hash.delete('id') #screw IDs for now
......
{"name":"searchable_project","path":"gitlabhq","description":null,"issues_enabled":true,"wall_enabled":false,"merge_requests_enabled":true,"wiki_enabled":true,"snippets_enabled":true,"visibility_level":20,"archived":false,"issues":[{"id":2,"title":"Culpa dolores et nostrum magni quo.","assignee_id":19,"author_id":20,"project_id":14,"created_at":"2016-03-10T15:54:30.960Z","updated_at":"2016-03-10T15:54:36.624Z","position":0,"branch_name":null,"description":null,"milestone_id":null,"state":"opened","iid":1,"updated_by_id":null}],"merge_requests":[{"id":2,"target_branch":"feature","source_branch":"master","source_project_id":9,"author_id":23,"assignee_id":null,"title":"Distinctio voluptas qui suscipit asperiores.","created_at":"2016-03-10T15:54:31.921Z","updated_at":"2016-03-10T15:54:31.921Z","milestone_id":null,"state":"opened","merge_status":"can_be_merged","target_project_id":14,"iid":1,"description":null,"position":0,"locked_at":null,"updated_by_id":null,"merge_error":null,"merge_params":{},"merge_when_build_succeeds":false,"merge_user_id":null,"merge_commit_sha":null}],"labels":[{"id":2,"title":"Bug","color":"#990000","project_id":14,"created_at":"2016-03-10T15:54:33.128Z","updated_at":"2016-03-10T15:54:36.645Z","template":false,"description":null}],"milestones":[{"id":2,"title":"Milestone v1.2","project_id":14,"description":null,"due_date":null,"created_at":"2016-03-10T15:54:36.756Z","updated_at":"2016-03-10T15:54:36.756Z","state":"active","iid":1}],"snippets":[{"id":2,"title":"In voluptatibus possimus fugiat qui.","content":"Qui exercitationem culpa in dolore ab.","author_id":30,"project_id":14,"created_at":"2016-03-10T15:54:34.253Z","updated_at":"2016-03-10T15:54:36.658Z","file_name":"patrick","expires_at":null,"visibility_level":0}],"releases":[{"id":2,"tag":"v1.1.0","description":"Awesome release","project_id":14,"created_at":"2016-03-10T15:54:35.211Z","updated_at":"2016-03-10T15:54:36.671Z"}],"events":[{"id":2,"target_type":null,"target_id":null,"title":null,"data":null,"project_id":14,"created_at":"2016-03-10T15:54:36.906Z","updated_at":"2016-03-10T15:54:36.906Z","action":8,"author_id":19}],"commit_statuses":[{"id":2,"project_id":null,"status":"success","finished_at":"2016-01-26T07:23:42.000Z","trace":null,"created_at":"2016-03-10T15:54:35.937Z","updated_at":"2016-03-10T15:54:36.699Z","started_at":"2016-01-26T07:21:42.000Z","runner_id":null,"coverage":null,"commit_id":2,"commands":null,"job_id":null,"name":"default","deploy":false,"options":null,"allow_failure":false,"stage":null,"trigger_request_id":null,"stage_idx":null,"tag":null,"ref":null,"user_id":null,"target_url":null,"description":"commit status","artifacts_file":null,"gl_project_id":14,"artifacts_metadata":null,"erased_by_id":null,"erased_at":null}]} {"name":"searchable_project","path":"gitlabhq","description":null,"issues_enabled":true,"wall_enabled":false,"merge_requests_enabled":true,"wiki_enabled":true,"snippets_enabled":true,"visibility_level":20,"archived":false,"project_members":[{"id":11,"access_level":40,"source_id":77,"source_type":"Project","user_id":181,"notification_level":3,"created_at":"2016-03-11T09:02:34.007Z","updated_at":"2016-03-11T09:02:34.007Z","created_by_id":null,"invite_email":null,"invite_token":null,"invite_accepted_at":null}],"issues":[{"id":11,"title":"Voluptatibus eius eaque qui officiis fugit.","assignee_id":181,"author_id":182,"project_id":77,"created_at":"2016-03-11T09:02:27.677Z","updated_at":"2016-03-11T09:02:33.728Z","position":0,"branch_name":null,"description":null,"milestone_id":null,"state":"opened","iid":1,"updated_by_id":null}],"merge_requests":[{"id":11,"target_branch":"feature","source_branch":"master","source_project_id":72,"author_id":185,"assignee_id":null,"title":"Dolorum similique voluptate odio id unde a maxime officiis.","created_at":"2016-03-11T09:02:28.616Z","updated_at":"2016-03-11T09:02:28.616Z","milestone_id":null,"state":"opened","merge_status":"can_be_merged","target_project_id":77,"iid":1,"description":null,"position":0,"locked_at":null,"updated_by_id":null,"merge_error":null,"merge_params":{},"merge_when_build_succeeds":false,"merge_user_id":null,"merge_commit_sha":null}],"labels":[{"id":11,"title":"Bug","color":"#990000","project_id":77,"created_at":"2016-03-11T09:02:29.974Z","updated_at":"2016-03-11T09:02:33.752Z","template":false,"description":null}],"milestones":[{"id":11,"title":"Milestone v1.2","project_id":77,"description":null,"due_date":null,"created_at":"2016-03-11T09:02:33.882Z","updated_at":"2016-03-11T09:02:33.882Z","state":"active","iid":1}],"snippets":[{"id":11,"title":"Voluptas et expedita autem quia totam voluptate culpa quis.","content":"Veritatis esse fugiat sint eos.","author_id":192,"project_id":77,"created_at":"2016-03-11T09:02:31.022Z","updated_at":"2016-03-11T09:02:33.768Z","file_name":"dexter.hessel","expires_at":null,"visibility_level":0}],"releases":[{"id":11,"tag":"v1.1.0","description":"Awesome release","project_id":77,"created_at":"2016-03-11T09:02:32.099Z","updated_at":"2016-03-11T09:02:33.787Z"}],"events":[{"id":11,"target_type":null,"target_id":null,"title":null,"data":null,"project_id":77,"created_at":"2016-03-11T09:02:34.069Z","updated_at":"2016-03-11T09:02:34.069Z","action":8,"author_id":181}],"commit_statuses":[{"id":11,"project_id":null,"status":"success","finished_at":"2016-01-26T07:23:42.000Z","trace":null,"created_at":"2016-03-11T09:02:32.916Z","updated_at":"2016-03-11T09:02:33.825Z","started_at":"2016-01-26T07:21:42.000Z","runner_id":null,"coverage":null,"commit_id":11,"commands":null,"job_id":null,"name":"default","deploy":false,"options":null,"allow_failure":false,"stage":null,"trigger_request_id":null,"stage_idx":null,"tag":null,"ref":null,"user_id":null,"target_url":null,"description":"commit status","artifacts_file":null,"gl_project_id":77,"artifacts_metadata":null,"erased_by_id":null,"erased_at":null}]}
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment