Commit 9b9dd3f9bf62e8b116213012b766abcaef3e641e
1 parent
4bd30245
Exists in
master
and in
4 other branches
Unnecessary code removed
Showing
1 changed file
with
9 additions
and
11 deletions
Show diff stats
lib/api/projects.rb
| ... | ... | @@ -38,17 +38,15 @@ module Gitlab |
| 38 | 38 | # Example Request |
| 39 | 39 | # POST /projects |
| 40 | 40 | post do |
| 41 | - @project = Project.create_by_user({ | |
| 42 | - name: params[:name], | |
| 43 | - code: (params[:code] || params[:name]), | |
| 44 | - path: (params[:path] || params[:name]), | |
| 45 | - description: (params[:description] || Project.columns_hash["description"].default), | |
| 46 | - default_branch: (params[:default_branch] || Project.columns_hash["default_branch"].default), | |
| 47 | - issues_enabled: (params[:issues_enabled] || Project.columns_hash["issues_enabled"].default), | |
| 48 | - wall_enabled: (params[:wall_enabled] || Project.columns_hash["wall_enabled"].default), | |
| 49 | - merge_requests_enabled: (params[:merge_requests_enabled] || Project.columns_hash["merge_requests_enabled"].default), | |
| 50 | - wiki_enabled: (params[:wiki_enabled] || Project.columns_hash["wiki_enabled"].default) | |
| 51 | - }, current_user) | |
| 41 | + params[:code] ||= params[:name] | |
| 42 | + params[:path] ||= params[:name] | |
| 43 | + project_attrs = {} | |
| 44 | + params.each_pair do |k ,v| | |
| 45 | + if Project.attribute_names.include? k | |
| 46 | + project_attrs[k] = v | |
| 47 | + end | |
| 48 | + end | |
| 49 | + @project = Project.create_by_user(project_attrs, current_user) | |
| 52 | 50 | if @project.saved? |
| 53 | 51 | present @project, with: Entities::Project |
| 54 | 52 | else | ... | ... |