Example #1
0
    def _render_editor(self, req, milestone):
        # Suggest a default due time of 18:00 in the user's timezone
        now = datetime.now(req.tz)
        default_due = datetime(now.year, now.month, now.day, 18)
        if now.hour > 18:
            default_due += timedelta(days=1)
        default_due = to_datetime(default_due, req.tz)

        data = {
            "milestone": milestone,
            "datetime_hint": get_datetime_format_hint(req.lc_time),
            "default_due": default_due,
            "milestone_groups": [],
        }

        if milestone.exists:
            req.perm(milestone.resource).require("MILESTONE_MODIFY")
            milestones = [
                m
                for m in Milestone.select(self.env)
                if m.name != milestone.name and "MILESTONE_VIEW" in req.perm(m.resource)
            ]
            data["milestone_groups"] = group_milestones(milestones, "TICKET_ADMIN" in req.perm)
        else:
            req.perm(milestone.resource).require("MILESTONE_CREATE")

        chrome = Chrome(self.env)
        chrome.add_jquery_ui(req)
        chrome.add_wiki_toolbars(req)
        return "milestone_edit.html", data, None
Example #2
0
    def _render_confirm(self, req, milestone):
        req.perm(milestone.resource).require("MILESTONE_DELETE")

        milestones = [
            m
            for m in Milestone.select(self.env)
            if m.name != milestone.name and "MILESTONE_VIEW" in req.perm(m.resource)
        ]
        data = {"milestone": milestone, "milestone_groups": group_milestones(milestones, "TICKET_ADMIN" in req.perm)}
        return "milestone_delete.html", data, None