currentUser = UserModel.ANONYMOUS;\r
}\r
\r
- if (!currentUser.isAuthenticated || !app().tickets().isAcceptingTicketUpdates(getRepositoryModel())) {\r
- // tickets prohibited\r
- setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));\r
- }\r
-\r
long ticketId = 0L;\r
try {\r
String h = WicketUtils.getObject(params);\r
}\r
\r
TicketModel ticket = app().tickets().getTicket(getRepositoryModel(), ticketId);\r
- if (ticket == null) {\r
- setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));\r
+ if (ticket == null\r
+ || !currentUser.canEdit(ticket, getRepositoryModel())\r
+ || !app().tickets().isAcceptingTicketUpdates(getRepositoryModel())) {\r
+ setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(repositoryName, "" + ticketId));\r
}\r
\r
typeModel = Model.of(ticket.type);\r
}\r
form.add(new DropDownChoice<TicketModel.Type>("type", typeModel, typeChoices));\r
\r
- List<Status> statusChoices;\r
- if (ticket.isClosed()) {\r
- statusChoices = Arrays.asList(ticket.status, Status.Open);\r
- } else if (ticket.isProposal()) {\r
- statusChoices = Arrays.asList(TicketModel.Status.proposalWorkflow);\r
- } else if (ticket.isBug()) {\r
- statusChoices = Arrays.asList(TicketModel.Status.bugWorkflow);\r
- } else {\r
- statusChoices = Arrays.asList(TicketModel.Status.requestWorkflow);\r
- }\r
- form.add(new DropDownChoice<TicketModel.Status>("status", statusModel, statusChoices));\r
-\r
form.add(new TextField<String>("title", titleModel));\r
form.add(new TextField<String>("topic", topicModel));\r
\r
descriptionEditor.setText(ticket.body);\r
form.add(descriptionEditor);\r
\r
- if (currentUser != null && currentUser.isAuthenticated && currentUser.canPush(getRepositoryModel())) {\r
- // responsible\r
- Set<String> userlist = new TreeSet<String>(ticket.getParticipants());\r
+ // status\r
+ List<Status> statusChoices;\r
+ if (ticket.isClosed()) {\r
+ statusChoices = Arrays.asList(ticket.status, Status.Open);\r
+ } else if (ticket.isProposal()) {\r
+ statusChoices = Arrays.asList(TicketModel.Status.proposalWorkflow);\r
+ } else if (ticket.isBug()) {\r
+ statusChoices = Arrays.asList(TicketModel.Status.bugWorkflow);\r
+ } else {\r
+ statusChoices = Arrays.asList(TicketModel.Status.requestWorkflow);\r
+ }\r
+ Fragment status = new Fragment("status", "statusFragment", this);\r
+ status.add(new DropDownChoice<TicketModel.Status>("status", statusModel, statusChoices));\r
+ form.add(status);\r
\r
- for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) {\r
- if (rp.permission.atLeast(AccessPermission.PUSH) && !rp.isTeam()) {\r
- userlist.add(rp.registrant);\r
- }\r
- }\r
+ // responsible\r
+ Set<String> userlist = new TreeSet<String>(ticket.getParticipants());\r
\r
- List<TicketResponsible> responsibles = new ArrayList<TicketResponsible>();\r
- for (String username : userlist) {\r
- UserModel user = app().users().getUserModel(username);\r
- if (user != null) {\r
- TicketResponsible responsible = new TicketResponsible(user);\r
- responsibles.add(responsible);\r
- if (user.username.equals(ticket.responsible)) {\r
- responsibleModel.setObject(responsible);\r
- }\r
- }\r
+ for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) {\r
+ if (rp.permission.atLeast(AccessPermission.PUSH) && !rp.isTeam()) {\r
+ userlist.add(rp.registrant);\r
}\r
- Collections.sort(responsibles);\r
- responsibles.add(new TicketResponsible(NIL, "", ""));\r
- Fragment responsible = new Fragment("responsible", "responsibleFragment", this);\r
- responsible.add(new DropDownChoice<TicketResponsible>("responsible", responsibleModel, responsibles));\r
- form.add(responsible.setVisible(!responsibles.isEmpty()));\r
-\r
- // milestone\r
- List<TicketMilestone> milestones = app().tickets().getMilestones(getRepositoryModel(), Status.Open);\r
- for (TicketMilestone milestone : milestones) {\r
- if (milestone.name.equals(ticket.milestone)) {\r
- milestoneModel.setObject(milestone);\r
- break;\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) {\r
+ TicketResponsible responsible = new TicketResponsible(user);\r
+ responsibles.add(responsible);\r
+ if (user.username.equals(ticket.responsible)) {\r
+ responsibleModel.setObject(responsible);\r
}\r
}\r
- if (milestoneModel.getObject() == null && !StringUtils.isEmpty(ticket.milestone)) {\r
- // ensure that this unrecognized milestone is listed\r
- // so that we get the <nil> selection.\r
- TicketMilestone tms = new TicketMilestone(ticket.milestone);\r
- milestones.add(tms);\r
- milestoneModel.setObject(tms);\r
- }\r
- if (!milestones.isEmpty()) {\r
- milestones.add(new TicketMilestone(NIL));\r
+ }\r
+ Collections.sort(responsibles);\r
+ responsibles.add(new TicketResponsible(NIL, "", ""));\r
+ Fragment responsible = new Fragment("responsible", "responsibleFragment", this);\r
+ responsible.add(new DropDownChoice<TicketResponsible>("responsible", responsibleModel, responsibles));\r
+ form.add(responsible.setVisible(!responsibles.isEmpty()));\r
+\r
+ // milestone\r
+ List<TicketMilestone> milestones = app().tickets().getMilestones(getRepositoryModel(), Status.Open);\r
+ for (TicketMilestone milestone : milestones) {\r
+ if (milestone.name.equals(ticket.milestone)) {\r
+ milestoneModel.setObject(milestone);\r
+ break;\r
}\r
+ }\r
+ if (milestoneModel.getObject() == null && !StringUtils.isEmpty(ticket.milestone)) {\r
+ // ensure that this unrecognized milestone is listed\r
+ // so that we get the <nil> selection.\r
+ TicketMilestone tms = new TicketMilestone(ticket.milestone);\r
+ milestones.add(tms);\r
+ milestoneModel.setObject(tms);\r
+ }\r
+ if (!milestones.isEmpty()) {\r
+ milestones.add(new TicketMilestone(NIL));\r
+ }\r
\r
- Fragment milestone = new Fragment("milestone", "milestoneFragment", this);\r
+ Fragment milestone = new Fragment("milestone", "milestoneFragment", this);\r
\r
- milestone.add(new DropDownChoice<TicketMilestone>("milestone", milestoneModel, milestones));\r
- form.add(milestone.setVisible(!milestones.isEmpty()));\r
+ milestone.add(new DropDownChoice<TicketMilestone>("milestone", milestoneModel, milestones));\r
+ form.add(milestone.setVisible(!milestones.isEmpty()));\r
\r
- // mergeTo (integration branch)\r
- List<String> branches = new ArrayList<String>();\r
- for (String branch : getRepositoryModel().getLocalBranches()) {\r
- // exclude ticket branches\r
- if (!branch.startsWith(Constants.R_TICKET)) {\r
- branches.add(Repository.shortenRefName(branch));\r
- }\r
+ // mergeTo (integration branch)\r
+ List<String> branches = new ArrayList<String>();\r
+ for (String branch : getRepositoryModel().getLocalBranches()) {\r
+ // exclude ticket branches\r
+ if (!branch.startsWith(Constants.R_TICKET)) {\r
+ branches.add(Repository.shortenRefName(branch));\r
}\r
- branches.remove(Repository.shortenRefName(getRepositoryModel().HEAD));\r
- branches.add(0, Repository.shortenRefName(getRepositoryModel().HEAD));\r
-\r
- Fragment mergeto = new Fragment("mergeto", "mergeToFragment", this);\r
- mergeto.add(new DropDownChoice<String>("mergeto", mergeToModel, branches));\r
- form.add(mergeto.setVisible(!branches.isEmpty()));\r
-\r
- } else {\r
- // user does not have permission to assign milestone or responsible\r
- form.add(new Label("responsible").setVisible(false));\r
- form.add(new Label("milestone").setVisible(false));\r
- form.add(new Label("mergeto").setVisible(false));\r
}\r
+ branches.remove(Repository.shortenRefName(getRepositoryModel().HEAD));\r
+ branches.add(0, Repository.shortenRefName(getRepositoryModel().HEAD));\r
+\r
+ Fragment mergeto = new Fragment("mergeto", "mergeToFragment", this);\r
+ mergeto.add(new DropDownChoice<String>("mergeto", mergeToModel, branches));\r
+ form.add(mergeto.setVisible(!branches.isEmpty()));\r
\r
form.add(new Button("update"));\r
Button cancel = new Button("cancel") {\r