kjkmadness 2014-04-14
pullrequest: remove forking project limit
- now user can fork two or more times from one original project.
@a0c4d26ca4546928e2c4bd91de364afa118fab57
app/controllers/PullRequestApp.java
--- app/controllers/PullRequestApp.java
+++ app/controllers/PullRequestApp.java
@@ -82,13 +82,8 @@
         Project project = Project.findByOwnerAndProjectName(userName, projectName);
         List<OrganizationUser> orgUserList = OrganizationUser.findByAdmin(UserApp.currentUser().id);
         Project forkedProject = Project.findByOwnerAndOriginalProject(destination, project);
-
-        if (forkedProject != null) {
-            return ok(fork.render("fork", project, forkedProject, false, new Form<>(Project.class), orgUserList));
-        } else {
-            Project forkProject = Project.copy(project, destination);
-            return ok(fork.render("fork", project, forkProject, true, new Form<>(Project.class), orgUserList));
-        }
+        Project forkProject = Project.copy(project, destination);
+        return ok(fork.render("fork", project, forkProject, forkedProject, new Form<>(Project.class), orgUserList));
     }
 
     private static String findDestination(String forkOwner) {
@@ -118,13 +113,6 @@
         Project projectForm = forkProjectForm.get();
         String destination = findDestination(projectForm.owner);
         Project originalProject = Project.findByOwnerAndProjectName(userName, projectName);
-
-        // 이미 포크한 프로젝트가 있다면 그 프로젝트로 이동.
-        Project forkedProject = Project.findByOwnerAndOriginalProject(destination, originalProject);
-        if(forkedProject != null) {
-            flash(Constants.WARNING, "fork.redirect.exist");
-            return redirect(routes.ProjectApp.project(forkedProject.owner, forkedProject.name));
-        }
 
         // 포크 프로젝트 이름 중복 검사
         if (Project.exists(destination, projectForm.name)) {
app/views/git/fork.scala.html
--- app/views/git/fork.scala.html
+++ app/views/git/fork.scala.html
@@ -1,4 +1,4 @@
-@(title:String, project: Project, forkProject: Project, isNew: Boolean, form: Form[Project], orgUserList:List[OrganizationUser])
+@(title:String, project: Project, forkProject: Project, forkedProject: Project, form: Form[Project], orgUserList:List[OrganizationUser])
 
 @import utils.TemplateHelper._
 @import controllers.UserApp
@@ -18,9 +18,9 @@
                             @project.owner / @project.name @Messages("fork")
                         </h4>
                     </legend>
-                    @if(isNew){
                     <div id="helpMessage" class="well">
                         <div class="row-fluid">
+                        @if(forkedProject == null){
                             <div class="pull-left">
                                 <img class="img-polaroid" src="@routes.Assets.at("images/fork-pull/fork.jpg")"><br>
                             </div>
@@ -29,9 +29,19 @@
                                 <p>@Messages("fork.help.message.1")</p>
                                 <p>@Messages("fork.help.message.2")</p>
                             </div>
+                        } else {
+                            <div class="help-messages center-txt">
+                                <i class="ico ico-err2"></i>
+                                <p>@Messages("fork.already.exist")</p>
+                                <p>
+                                    <strong class="vmiddle">@project.owner / @project.name</strong>
+                                    <i class="yobicon-right vmiddle"></i>
+                                    <a href="@routes.ProjectApp.project(forkedProject.owner, forkedProject.name)" class="vmiddle primary-txt">@forkedProject.owner / @forkedProject.name</a>
+                                </p>
+                            </div>
+                        }
                         </div>
                     </div>
-
                     <div class="control-group">
                         <label class="control-label" for="inputOwner">@Messages("project.owner")</label>
                         <div class="controls">
@@ -70,21 +80,6 @@
                             <a href="@routes.PullRequestApp.pullRequests(project.owner, project.name)" class="ybtn">@Messages("button.cancel")</a>
                         </div>
                     </div>
-                    } else {
-                    <div class="error-wrap">
-                        <i class="ico ico-err2"></i>
-                        <p>@Messages("fork.already.exist")</p>
-                        <p>
-                            <strong class="vmiddle">@project.owner / @project.name</strong>
-                            <i class="yobicon-right vmiddle"></i>
-                            <a href="@routes.ProjectApp.project(forkProject.owner, forkProject.name)" class="vmiddle primary-txt">@forkProject.owner / @forkProject.name</a>
-                        </p>
-                    </div>
-                    <div class="center-txt">
-                        <a href="@routes.ProjectApp.project(forkProject.owner, forkProject.name)" class="ybtn ybtn-info">@Messages("fork.go")</a>
-                        <a href="@routes.PullRequestApp.pullRequests(project.owner, project.name)" class="ybtn">@Messages("button.cancel")</a>
-                    </div>
-                    }
                 </fieldset>
             </form>
         </div>
public/javascripts/service/yobi.project.Fork.js
--- public/javascripts/service/yobi.project.Fork.js
+++ public/javascripts/service/yobi.project.Fork.js
@@ -38,8 +38,6 @@
          * initialize element variables
          */
         function _initElement(htOptions){
-            htElement.welHelpMessage = $("#helpMessage");
-            htElement.welHelpButton = $("#helpBtn");
             htElement.welInputProjectOwner = $("#project-owner");
         }
 
@@ -47,13 +45,7 @@
          * attach event handlers
          */
         function _attachEvent() {
-            htElement.welHelpButton.on("click", _onHelpButtonClick);
             htElement.welInputProjectOwner.on("change", _onChangeProjectOwner);
-        }
-
-        function _onHelpButtonClick(weEvt) {
-            weEvt.preventDefault();
-            htElement.welHelpMessage.toggle();
         }
 
         function _onChangeProjectOwner() {
test/controllers/PullRequestAppTest.java
--- test/controllers/PullRequestAppTest.java
+++ test/controllers/PullRequestAppTest.java
@@ -248,7 +248,9 @@
         User currentUser = User.findByLoginId("yobi");
 
         Map<String,String> data = new HashMap<>();
+        data.put("owner", "yobi");
         data.put("name", "projectYobi-2");
+        data.put("projectScope", "PUBLIC");
 
         Result result = callAction(
                 controllers.routes.ref.PullRequestApp.fork(ownerLoginId, projectName),
@@ -257,7 +259,7 @@
                 .withFormUrlEncodedBody(data)
               );
 
-        assertThat(status(result)).isEqualTo(SEE_OTHER);
+        assertThat(status(result)).isEqualTo(OK);
     }
 
     @Test
Add a comment
List