]> source.dussan.org Git - gitblit.git/commitdiff
Include all users with RW access in New Ticket responsible choices 70/170/1
authorJames Moger <james.moger@gitblit.com>
Mon, 8 Sep 2014 19:25:47 +0000 (15:25 -0400)
committerJames Moger <james.moger@gitblit.com>
Mon, 8 Sep 2014 19:25:47 +0000 (15:25 -0400)
src/main/java/com/gitblit/wicket/pages/NewTicketPage.java

index 7a68febb5d78ad7cec2e851804fe4263bc1e4756..21a2af1035d33ba9c30fdf8afbd95156f6cf8df3 100644 (file)
@@ -19,6 +19,8 @@ import java.util.ArrayList;
 import java.util.Arrays;\r
 import java.util.Collections;\r
 import java.util.List;\r
+import java.util.Set;\r
+import java.util.TreeSet;\r
 \r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.ajax.AjaxRequestTarget;\r
@@ -35,6 +37,7 @@ import org.eclipse.jgit.lib.Repository;
 \r
 import com.gitblit.Constants;\r
 import com.gitblit.Constants.AccessPermission;\r
+import com.gitblit.Constants.AuthorizationControl;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
 import com.gitblit.models.TicketModel;\r
 import com.gitblit.models.TicketModel.Change;\r
@@ -117,25 +120,29 @@ public class NewTicketPage extends RepositoryPage {
 \r
                if (currentUser.canAdmin(null, getRepositoryModel())) {\r
                        // responsible\r
-                       List<TicketResponsible> responsibles = new ArrayList<TicketResponsible>();\r
-                       if (UserModel.ANONYMOUS.canPush(getRepositoryModel())) {\r
-                               // anonymous push allowed\r
-                               for (UserModel user : app().users().getAllUsers()) {\r
-                                       if (!user.disabled) {\r
-                                               responsibles.add(new TicketResponsible(user));\r
-                                       }\r
-                               }\r
+                       Set<String> userlist = new TreeSet<String>();\r
+\r
+                       if (UserModel.ANONYMOUS.canPush(getRepositoryModel())\r
+                                       || AuthorizationControl.AUTHENTICATED == getRepositoryModel().authorizationControl) {\r
+                               //      authorization is ANONYMOUS or AUTHENTICATED (i.e. all users can be set responsible)\r
+                               userlist.addAll(app().users().getAllUsernames());\r
                        } else {\r
-                               // authenticated push\r
+                               // authorization is by NAMED users (users with PUSH permission can be set responsible)\r
                                for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) {\r
-                                       if (rp.permission.atLeast(AccessPermission.PUSH) && !rp.isTeam()) {\r
-                                               UserModel user = app().users().getUserModel(rp.registrant);\r
-                                               if (user != null && !user.disabled) {\r
-                                                       responsibles.add(new TicketResponsible(user));\r
-                                               }\r
+                                       if (rp.permission.atLeast(AccessPermission.PUSH)) {\r
+                                               userlist.add(rp.registrant);\r
                                        }\r
                                }\r
                        }\r
+\r
+                       List<TicketResponsible> responsibles = new ArrayList<TicketResponsible>();\r
+                       for (String username : userlist) {\r
+                               UserModel user = app().users().getUserModel(username);\r
+                               if (user != null && !user.disabled) {\r
+                                       TicketResponsible responsible = new TicketResponsible(user);\r
+                                       responsibles.add(responsible);\r
+                               }\r
+                       }\r
                        Collections.sort(responsibles);\r
                        Fragment responsible = new Fragment("responsible", "responsibleFragment", this);\r
                        responsible.add(new DropDownChoice<TicketResponsible>("responsible", responsibleModel, responsibles));\r