Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added mytickets view

  • Loading branch information...
commit 8509ee90b57771a431efa0cc821505d541628b45 1 parent 409ab82
@gborelli gborelli authored
View
1  docs/HISTORY.txt
@@ -4,6 +4,7 @@ Changelog
1.0 (unreleased)
----------------
+- added mytickets view [gborelli]
- added project dashboard view [gborelli]
- added IMyStoriesLIsting adapter [gborelli]
- changed dashboard view [gborelli]
View
26 src/collective/simplemanagement/browser/dashboard.py
@@ -1,8 +1,10 @@
from plone.memoize.instance import memoize
-
from Products.CMFCore.utils import getToolByName
from Products.Five.browser import BrowserView
+
from ..interfaces import IMyStoriesListing
+from ..interfaces import IProject
+from ..utils import get_project
class DashboardMixin(BrowserView):
@@ -41,7 +43,27 @@ def _query(self):
def tickets(self):
pc = self.tools()['portal_catalog']
- return pc.searchResults(self._query)
+ tickets = pc.searchResults(self._query)
+ return tickets
+
+ def get_project(self, brain):
+ context = brain.getObject()
+ prj = None
+ while context is not None:
+ if IProject.providedBy(context):
+ prj = context
+ break
+ try:
+ context = context.__parent__
+ except AttributeError:
+ break
+
+ if prj:
+ return {
+ 'title': prj.Title(),
+ 'description': prj.Description(),
+ 'url': prj.absolute_url(),
+ }
class MyStories(DashboardMixin):
View
126 src/collective/simplemanagement/browser/templates/mytickets.pt
@@ -5,19 +5,121 @@
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="collective.simplemanagement">
- <body>
+<head>
+ <metal:block fill-slot="top_slot"
+ tal:define="dummy python:request.set('disable_border',1);
+ disable_column_one python:request.set('disable_plone.leftcolumn',1);
+ disable_column_two python:request.set('disable_plone.rightcolumn',1);" />
+</head>
+<body metal:use-macro="content">
- <metal:title fill-slot="content-title">
- <h1 i18n:translate="">My tickets</h1>
- </metal:title>
+ <metal:bodytext fill-slot="main">
+ <metal:main define-macro="main"
+ tal:define="results view/tickets;
+ Batch python:modules['Products.CMFPlone'].Batch;
+ b_start python:request.get('b_start', 0);
+ batch python:Batch(results, 1, int(b_start), orphan=0)">
- <metal:content-core fill-slot="content-core">
- <metal:block define-macro="content-core"
- tal:define="tickets view/tickets">
- <metal:stories
- use-macro="context/simpemanagement-macros/tickets-shortlist" />
- </metal:block>
- </metal:content-core>
+ <div tal:replace="structure provider:plone.abovecontenttitle" />
+ <h1 class="documentFirstHeading">My tickets</h1>
+ <div 18n:translate="">
+ Found
+ <span 18n:name="n_ticket"
+ tal:content="python:len(results)"></span>
+ tickets
+ </div>
+ <!-- <div tal:replace="structure provider:plone.belowcontenttitle" /> -->
- </body>
+ <div tal:replace="structure provider:plone.abovecontentbody" />
+ <div id="content-core"
+ metal:define-macro="content-core">
+
+ <table id="tickets"
+ class="listing"
+ tal:condition="batch">
+ <thead>
+ <tr>
+ <th 18n:translate="">Title</th>
+ <th 18n:translate="">Project</th>
+ <th 18n:translate="">Created</th>
+ <th 18n:translate="">Modified</th>
+ <th 18n:translate="">Severity</th>
+ <th 18n:translate="">Status</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr tal:repeat="ticket batch">
+ <td>
+ <a href=""
+ title=""
+ tal:attributes="href ticket/getURL;
+ title ticket/Title">
+ <span tal:content="ticket/Title"></span>
+ (# <span tal:content="ticket/getId"></span>)
+ </a>
+ </td>
+ <td tal:define="project python:view.get_project(ticket)">
+ <a tal:condition="project"
+ tal:attributes="href project/url;
+ title project/description"
+ tal:content="project/title" />
+ </td>
+ <td tal:content="ticket/created"></td>
+ <td tal:content="ticket/modified"></td>
+ <td tal:content="ticket/getSeverity"></td>
+ <td tal:content="ticket/review_state"
+ tal:attributes="class ticket/review_state"></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <div id="tickets-navigation"
+ class="see-more"
+ metal:define-macro="navigation"
+ tal:define="request request|context/request|container/request|nothing;
+ batch batch|nothing;
+ batchformkeys batchformkeys|nothing;
+ batchlinkparams python:batchformkeys and dict([(key, request.form[key]) for key in batchformkeys if key in request]) or request.form;
+ mq python:modules['ZTUtils'].make_query;
+ url batch_base_url | request/ACTUAL_URL;
+ currentpage batch/pagenumber;"
+ tal:condition="python: batch.next">
+
+ <tal:block tal:define="n batch/next | nothing"
+ tal:condition="n">
+ <a href=""
+ class="infinite-scroller"
+ tal:attributes="href python: '%s?%s' % (url , mq( batchlinkparams, {batch.b_start_str:n.first} ))"
+ i18n:translate="next_items">
+ Next items
+ </a>
+ </tal:block>
+ </div>
+
+ </div>
+ <script type="text/javascript">
+ $('.infinite-scroller').click(function (event) {
+ var container = $('#tickets tbody'),
+ link = $(this),
+ els, new_link, elements;
+ event.preventDefault();
+ $.get(link.attr('href'), function (data) {
+ data = $(data);
+ elements = data.find('#tickets tbody tr');
+ container.append(elements);
+ new_link = data.find('.infinite-scroller');
+ if (new_link.length > 0) {
+ link.attr('href') = new_link.attr('href');
+ } else {
+ link.hide();
+ }
+
+ });
+ return False
+ });
+ </script>
+ </metal:main>
+ </metal:bodytext>
+
+</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.