Permalink
Browse files

split tickets in projects in dashboard view

  • Loading branch information...
1 parent 23081f4 commit b4cd0b7ae3b7b4911b0fc0960242eda2e31dc087 @gborelli gborelli committed Apr 8, 2013
@@ -13,6 +13,7 @@
from plone.memoize.view import memoize as view_memoize
from plone.z3cform import z2
from plone.z3cform.layout import wrap_form
+from plone.uuid.interfaces import IUUID
from plone.dexterity.utils import createContentInContainer
from Products.CMFCore.utils import getToolByName
@@ -130,6 +131,8 @@ def get_project_details(self, brain):
if prj:
return {
+ 'UID': IUUID(prj),
+ 'priority': prj.priority,
'title': prj.Title(),
'description': prj.Description(),
'url': prj.absolute_url(),
@@ -189,19 +192,30 @@ def _get_tickets(self):
return results
def _format_ticket(self, item):
+
return {
'url': item.getURL(),
'title': item.Title,
'id': item.getId,
- 'created': item.created,
'modified': item.modified,
'severity': item.getSeverity,
'review_state': get_wf_state_info(item, self.context),
'project': self.get_project_details(item)
}
def tickets(self):
- return [self._format_ticket(item) for item in self._get_tickets()]
+ projects = {}
+ for item in self._get_tickets():
+ ticket = self._format_ticket(item)
+ prj = ticket.pop('project')
+ if not projects.get(prj['UID']):
+ projects[prj['UID']] = prj
+ projects[prj['UID']]['tickets'] = []
+ projects[prj['UID']]['tickets'].append(ticket)
+ projects = [p[1] for p in projects.items()]
+ projects.sort(key=lambda x: x['priority'])
+
+ return projects
def timeago(self, timestamp):
return timeago(timestamp.utcdatetime())
@@ -277,12 +291,13 @@ def bookings(self):
project=project,
from_date=from_date
)
+ results = []
for booking in _bookings:
story = booking.getObject().__parent__
if not is_project_context:
project = get_project(story)
- yield {
+ results.append({
'date': self.context.toLocalizedTime(booking.date.isoformat()),
'date2': timeago(booking.date),
'time': booking.time,
@@ -297,7 +312,8 @@ def bookings(self):
'url': story.absolute_url()
},
- }
+ })
+ return results
def booking_holes(self):
userid = self.user.getId()
@@ -49,7 +49,8 @@
<!-- Stories pane -->
<div id="stories-wrapper"
class="pane"
- tal:define="booking_holes view/booking_holes;">
+ tal:define="booking_holes view/booking_holes;
+ projects view/projects">
<div id="missed-bookings"
class="pat-expose alert alert-top alert-booking"
data-expose-triggers="hover"
@@ -103,13 +104,30 @@
</div>
</div>
- <div id="projects">
- <div class="project" tal:repeat="project view/projects">
+ <div id="projects"
+ tal:condition="not: projects">
+ <span class="label"
+ i18n:translate=""
+ tal:condition="employee_details">
+ There are not stories assigned to
+ <span tal:replace="employee_details/fullname"
+ i18n:name="username" />
+ </span>
+ <span class="label"
+ i18n:translate=""
+ tal:condition="not: employee_details">
+ There are not stories assigned to you.</span>
+ </div>
+
+ <div id="projects"
+ tal:condition="projects">
+ <div class="project" tal:repeat="project projects">
<h2>
<span>
- <a tal:attributes="href project/url"
- tal:content="project/priority"></a></span>
+ <a tal:attributes="href project/url">
+ <span tal:content="project/priority"></span>
<span tal:replace="project/title">Project #1</span>
+ </a>
</h2>
<table class="listing stories">
<thead>
@@ -155,7 +173,7 @@
<!-- Tickets pane -->
<div id="tickets-wrapper" class="pane"
- tal:define="tickets view/tickets">
+ tal:define="results view/tickets">
<p class="label" i18n:translate="">
Found
@@ -164,14 +182,43 @@
ticket/s
</p>
- <metal:tickets
- use-macro="context/simpemanagement-ticketsmacros/tickets" />
+ <div class="project" tal:repeat="project results">
+ <h2>
+ <span>
+ <a tal:attributes="href project/url">
+ <span tal:content="project/priority"></span>
+ <span tal:replace="project/title">Project #1</span>
+ </a>
+ </h2>
+ <div class="tickets-wrapper"
+ tal:define="tickets project/tickets">
+ <metal:tickets
+ use-macro="context/simpemanagement-ticketsmacros/tickets" />
+ </div>
+ </div>
</div>
<!-- Booking History pane -->
- <div id="booking-wrapper" class="pane">
+ <div id="booking-wrapper" class="pane"
+ tal:define="bookings view/bookings">
+
+ <div tal:condition="not: bookings">
+ <span class="label"
+ i18n:translate=""
+ tal:condition="employee_details">
+ <span tal:replace="employee_details/fullname"
+ i18n:name="username" />
+ have no bookings yet
+ </span>
+
+ <span class="label"
+ i18n:translate=""
+ tal:condition="not: employee_details">
+ You have no bookings yet</span>
+ </div>
- <table class="listing">
+ <table class="listing"
+ tal:condition="bookings">
<thead>
<tr>
<th i18n:translate="">Date</th>
@@ -182,7 +229,7 @@
</tr>
</thead>
<tbody>
- <tr tal:repeat="book view/bookings">
+ <tr tal:repeat="book bookings">
<td><span
tal:content="book/date">today</span>
(<span class="discreet"
@@ -6,51 +6,37 @@
i18n:domain="collective.simplemanagement">
<metal:tickets define-macro="tickets">
-
- <div id="tickets-wrapper">
-
- <table id="tickets-listing"
- class="listing"
- tal:condition="tickets">
- <thead>
- <tr>
- <th i18n:translate="">Title</th>
- <th i18n:translate="">Project</th>
- <th i18n:translate="">Created</th>
- <th i18n:translate="">Modified</th>
- <th i18n:translate="">Severity</th>
- <th i18n:translate="">Status</th>
- </tr>
- </thead>
- <tbody>
- <tr tal:repeat="item tickets"
- class="ticket">
- <td
- tal:attributes="class string:severity-${item/severity}">
- <a href=""
- title=""
- tal:attributes="href item/url">
- <span tal:content="item/title"></span>
- (# <span tal:content="item/id"></span>)
- </a>
- </td>
- <td>
- <a tal:condition="item/project"
- tal:attributes="href item/project/url;
- title item/project/description"
- tal:content="item/project/title" />
- </td>
- <td tal:content="python: view.timeago(item['created'])"></td>
- <td tal:content="python: view.timeago(item['modified'])"></td>
- <td tal:content="item/severity"></td>
- <td>
- <span class="state-published"
- tal:content="item/review_state/title"
- tal:attributes="class string:state-${item/review_state/state}">Pubblicato</span></td>
- </tr>
- </tbody>
- </table>
- </div>
+ <table class="tickets-listing listing"
+ tal:condition="tickets">
+ <thead>
+ <tr>
+ <th i18n:translate="">Title</th>
+ <th i18n:translate="">Modified</th>
+ <th i18n:translate="">Severity</th>
+ <th i18n:translate="">Status</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr tal:repeat="item tickets"
+ class="ticket">
+ <td
+ tal:attributes="class string:severity-${item/severity}">
+ <a href=""
+ title=""
+ tal:attributes="href item/url">
+ <span tal:content="item/title"></span>
+ (# <span tal:content="item/id"></span>)
+ </a>
+ </td>
+ <td tal:content="python: view.timeago(item['modified'])"></td>
+ <td tal:content="item/severity"></td>
+ <td>
+ <span class="state-published"
+ tal:content="item/review_state/title"
+ tal:attributes="class string:state-${item/review_state/state}">Pubblicato</span></td>
+ </tr>
+ </tbody>
+ </table>
</metal:tickets>

0 comments on commit b4cd0b7

Please sign in to comment.