keithsalisbury-subtrac 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/bin/subtrac +2 -0
- data/lib/subtrac.rb +85 -50
- data/lib/subtrac/config/config.yml +22 -19
- data/lib/subtrac/templates/location.erb +2 -2
- data/lib/subtrac/templates/projects/blank/trac/wiki/WikiStart +1 -1
- data/lib/subtrac/templates/trac.erb +1 -1
- data/lib/subtrac/templates/vhost.erb +6 -6
- metadata +1 -105
- data/lib/subtrac/trac-plugins/advancedticketworkflowplugin/advancedworkflow/__init__.py +0 -0
- data/lib/subtrac/trac-plugins/advancedticketworkflowplugin/advancedworkflow/controller.py +0 -419
- data/lib/subtrac/trac-plugins/advancedticketworkflowplugin/setup.cfg +0 -3
- data/lib/subtrac/trac-plugins/advancedticketworkflowplugin/setup.py +0 -20
- data/lib/subtrac/trac-plugins/clientsplugin/clients/__init__.py +0 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/action.py +0 -28
- data/lib/subtrac/trac-plugins/clientsplugin/clients/action_email.py +0 -168
- data/lib/subtrac/trac-plugins/clientsplugin/clients/action_zendesk_forum.py +0 -137
- data/lib/subtrac/trac-plugins/clientsplugin/clients/admin.py +0 -91
- data/lib/subtrac/trac-plugins/clientsplugin/clients/api.py +0 -199
- data/lib/subtrac/trac-plugins/clientsplugin/clients/client.py +0 -105
- data/lib/subtrac/trac-plugins/clientsplugin/clients/events.py +0 -287
- data/lib/subtrac/trac-plugins/clientsplugin/clients/eventsadmin.py +0 -71
- data/lib/subtrac/trac-plugins/clientsplugin/clients/htdocs/clients.css +0 -4
- data/lib/subtrac/trac-plugins/clientsplugin/clients/model.py +0 -135
- data/lib/subtrac/trac-plugins/clientsplugin/clients/processor.py +0 -70
- data/lib/subtrac/trac-plugins/clientsplugin/clients/reportmanager.py +0 -142
- data/lib/subtrac/trac-plugins/clientsplugin/clients/reports.py +0 -231
- data/lib/subtrac/trac-plugins/clientsplugin/clients/summary.py +0 -27
- data/lib/subtrac/trac-plugins/clientsplugin/clients/summary_milestone.py +0 -152
- data/lib/subtrac/trac-plugins/clientsplugin/clients/summary_ticketchanges.py +0 -160
- data/lib/subtrac/trac-plugins/clientsplugin/clients/templates/admin_client_events.html +0 -124
- data/lib/subtrac/trac-plugins/clientsplugin/clients/templates/admin_clients.html +0 -134
- data/lib/subtrac/trac-plugins/clientsplugin/cron/changes.xslt +0 -132
- data/lib/subtrac/trac-plugins/clientsplugin/cron/run-client-event +0 -97
- data/lib/subtrac/trac-plugins/clientsplugin/cron/summary.xslt +0 -161
- data/lib/subtrac/trac-plugins/clientsplugin/setup.py +0 -43
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/__init__.py +0 -4
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/burndownchart.py +0 -273
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/hoursinplaceeditor.py +0 -44
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/hoursremaining.py +0 -36
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/htdocs/jquery-1.2.3.min.js +0 -32
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/htdocs/jquery.jeditable.js +0 -409
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/htdocs/jquery.jeditable.mini.js +0 -30
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/templates/edithours.html +0 -53
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/tests/burndownchart.py +0 -181
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/tests/hoursremaining.py +0 -66
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/tests/workloadchart.py +0 -47
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/utils.py +0 -93
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/workloadchart.py +0 -86
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/setup.py +0 -20
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/SumRollups.js +0 -23
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/adw_tracdb.py +0 -128
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/git-post-receive +0 -40
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/trac-post-commit.py +0 -285
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/trac_billing.py +0 -173
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/utils/__init__.py +0 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/utils/mail.py +0 -164
- data/lib/subtrac/trac-plugins/timingandestimationplugin/setup.py +0 -69
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/__init__.py +0 -1
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/api.py +0 -292
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/blackmagic.py +0 -172
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/dbhelper.py +0 -178
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/billingplugin.css +0 -25
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/field_disabler.js +0 -6
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/formatDate.js +0 -356
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/js/tip_centerwindow.js +0 -100
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/js/tip_followscroll.js +0 -84
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/js/wz_tooltip.js +0 -1149
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/linkifyer.js +0 -119
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/query.js +0 -73
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/ticket.js +0 -165
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/query_webui.py +0 -28
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/reportmanager.py +0 -221
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/reports.py +0 -675
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/reports_filter.py +0 -150
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/statuses.py +0 -25
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/tande_filters.py +0 -131
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/templates/billing.cs +0 -84
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/templates/billing.html +0 -104
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/ticket_daemon.py +0 -194
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/ticket_policy.py +0 -62
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/ticket_webui.py +0 -28
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/usermanual.py +0 -127
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/webui.py +0 -129
- data/lib/subtrac/trac-plugins/worklogplugin/setup.py +0 -29
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/__init__.py +0 -1
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/api.py +0 -187
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/jqModal.css +0 -40
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/jqModal.js +0 -67
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/jquery.mousewheel.pack.js +0 -12
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/jquery.timeentry.pack.js +0 -7
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/tracWorklog.js +0 -40
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/ui.datepicker.css +0 -208
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/ui.datepicker.js +0 -1439
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/work.png +0 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/work.xcf +0 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/worklogplugin.css +0 -80
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/workstart.png +0 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/workstop.png +0 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/manager.py +0 -336
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/reports.py +0 -598
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/templates/worklog.html +0 -45
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/templates/worklog_stop.html +0 -70
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/templates/worklog_user.html +0 -40
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/templates/worklog_webadminui.html +0 -59
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/ticket_daemon.py +0 -33
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/ticket_filter.py +0 -153
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/timeline_hook.py +0 -96
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/usermanual.py +0 -29
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/util.py +0 -31
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/webadminui.py +0 -47
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/webui.py +0 -174
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/xmlrpc.py +0 -73
@@ -1,135 +0,0 @@
|
|
1
|
-
import re
|
2
|
-
import sys
|
3
|
-
import time
|
4
|
-
from datetime import date, datetime
|
5
|
-
|
6
|
-
from trac.attachment import Attachment
|
7
|
-
from trac.core import TracError
|
8
|
-
from trac.ticket.api import TicketSystem
|
9
|
-
from trac.util import sorted, embedded_numbers
|
10
|
-
from trac.util.datefmt import utc, utcmax, to_timestamp
|
11
|
-
|
12
|
-
__all__ = ['Client']
|
13
|
-
|
14
|
-
def simplify_whitespace(name):
|
15
|
-
"""Strip spaces and remove duplicate spaces within names"""
|
16
|
-
return ' '.join(name.split())
|
17
|
-
|
18
|
-
class Client(object):
|
19
|
-
|
20
|
-
def __init__(self, env, name=None, db=None):
|
21
|
-
self.env = env
|
22
|
-
if name:
|
23
|
-
name = simplify_whitespace(name)
|
24
|
-
if name:
|
25
|
-
if not db:
|
26
|
-
db = self.env.get_db_cnx()
|
27
|
-
cursor = db.cursor()
|
28
|
-
cursor.execute("SELECT description,"
|
29
|
-
"default_rate, currency "
|
30
|
-
"FROM client "
|
31
|
-
"WHERE name=%s", (name,))
|
32
|
-
row = cursor.fetchone()
|
33
|
-
if not row:
|
34
|
-
raise TracError('Client %s does not exist.' % name)
|
35
|
-
self.name = self._old_name = name
|
36
|
-
self.description = row[0] or ''
|
37
|
-
self.default_rate = row[1] or ''
|
38
|
-
self.currency = row[2] or ''
|
39
|
-
else:
|
40
|
-
self.name = self._old_name = None
|
41
|
-
self.description = None
|
42
|
-
self.default_rate = ''
|
43
|
-
self.currency = ''
|
44
|
-
|
45
|
-
exists = property(fget=lambda self: self._old_name is not None)
|
46
|
-
|
47
|
-
def delete(self, db=None):
|
48
|
-
assert self.exists, 'Cannot deleting non-existent client'
|
49
|
-
if not db:
|
50
|
-
db = self.env.get_db_cnx()
|
51
|
-
handle_ta = True
|
52
|
-
else:
|
53
|
-
handle_ta = False
|
54
|
-
|
55
|
-
cursor = db.cursor()
|
56
|
-
self.env.log.info('Deleting client %s' % self.name)
|
57
|
-
cursor.execute("DELETE FROM client WHERE name=%s", (self.name,))
|
58
|
-
|
59
|
-
self.name = self._old_name = None
|
60
|
-
|
61
|
-
if handle_ta:
|
62
|
-
db.commit()
|
63
|
-
|
64
|
-
def insert(self, db=None):
|
65
|
-
assert not self.exists, 'Cannot insert existing client'
|
66
|
-
self.name = simplify_whitespace(self.name)
|
67
|
-
assert self.name, 'Cannot create client with no name'
|
68
|
-
if not db:
|
69
|
-
db = self.env.get_db_cnx()
|
70
|
-
handle_ta = True
|
71
|
-
else:
|
72
|
-
handle_ta = False
|
73
|
-
|
74
|
-
cursor = db.cursor()
|
75
|
-
self.env.log.debug("Creating new client '%s'" % self.name)
|
76
|
-
cursor.execute("INSERT INTO client (name, description,"
|
77
|
-
" default_rate, currency) "
|
78
|
-
"VALUES (%s,%s, %s,%s)",
|
79
|
-
(self.name, self.description,
|
80
|
-
self.default_rate, self.currency))
|
81
|
-
|
82
|
-
if handle_ta:
|
83
|
-
db.commit()
|
84
|
-
|
85
|
-
def update(self, db=None):
|
86
|
-
assert self.exists, 'Cannot update non-existent client'
|
87
|
-
self.name = simplify_whitespace(self.name)
|
88
|
-
assert self.name, 'Cannot update client with no name'
|
89
|
-
if not db:
|
90
|
-
db = self.env.get_db_cnx()
|
91
|
-
handle_ta = True
|
92
|
-
else:
|
93
|
-
handle_ta = False
|
94
|
-
|
95
|
-
cursor = db.cursor()
|
96
|
-
self.env.log.info('Updating client "%s"' % self.name)
|
97
|
-
cursor.execute("UPDATE client SET name=%s,description=%s,"
|
98
|
-
" default_rate=%s, currency=%s "
|
99
|
-
"WHERE name=%s",
|
100
|
-
(self.name, self.description,
|
101
|
-
self.default_rate, self.currency,
|
102
|
-
self._old_name))
|
103
|
-
if self.name != self._old_name:
|
104
|
-
# Update tickets
|
105
|
-
cursor.execute("UPDATE ticket_custom SET value=%s "
|
106
|
-
"WHERE name=%s AND value=%s",
|
107
|
-
(self.name, 'client', self._old_name))
|
108
|
-
# Update event options
|
109
|
-
cursor.execute("UPDATE client_event_summary_options SET client=%s "
|
110
|
-
"WHERE client=%s",
|
111
|
-
(self.name, self._old_name))
|
112
|
-
cursor.execute("UPDATE client_event_action_options SET client=%s "
|
113
|
-
"WHERE client=%s",
|
114
|
-
(self.name, self._old_name))
|
115
|
-
self._old_name = self.name
|
116
|
-
|
117
|
-
if handle_ta:
|
118
|
-
db.commit()
|
119
|
-
|
120
|
-
def select(cls, env, db=None):
|
121
|
-
if not db:
|
122
|
-
db = env.get_db_cnx()
|
123
|
-
cursor = db.cursor()
|
124
|
-
cursor.execute("SELECT name,description,"
|
125
|
-
" default_rate, currency "
|
126
|
-
"FROM client "
|
127
|
-
"ORDER BY name")
|
128
|
-
for name, description, default_rate, currency in cursor:
|
129
|
-
client = cls(env)
|
130
|
-
client.name = client._old_name = name
|
131
|
-
client.description = description or ''
|
132
|
-
client.default_rate = default_rate or ''
|
133
|
-
client.currency = currency or ''
|
134
|
-
yield client
|
135
|
-
select = classmethod(select)
|
@@ -1,70 +0,0 @@
|
|
1
|
-
from trac.core import *
|
2
|
-
from trac.wiki.api import IWikiMacroProvider, WikiSystem, parse_args
|
3
|
-
from trac.wiki import wiki_to_html
|
4
|
-
from trac.wiki.macros import WikiMacroBase
|
5
|
-
from trac.env import IEnvironmentSetupParticipant
|
6
|
-
from trac.wiki.parser import WikiParser
|
7
|
-
from StringIO import StringIO
|
8
|
-
|
9
|
-
class ClientWikiProcessor(Component):
|
10
|
-
implements(IWikiMacroProvider)
|
11
|
-
|
12
|
-
def __init__(self):
|
13
|
-
pass
|
14
|
-
|
15
|
-
def get_macros(self):
|
16
|
-
return ['client']
|
17
|
-
|
18
|
-
def get_macro_description(self, name):
|
19
|
-
return 'No real formatting but allows for easy extraction of specific text blocks designed to be displayed to the client'
|
20
|
-
|
21
|
-
def expand_macro(self, formatter, name, content):
|
22
|
-
return '<fieldset class="client"><legend>Comments to Client</legend>%s</fieldset>' % \
|
23
|
-
wiki_to_html(content, self.env, formatter.req)
|
24
|
-
|
25
|
-
|
26
|
-
def extract_client_text(text, sep="----\n"):
|
27
|
-
buf = StringIO()
|
28
|
-
stack = 0
|
29
|
-
gotblock = False
|
30
|
-
realsep = ''
|
31
|
-
for line in text.splitlines():
|
32
|
-
if stack:
|
33
|
-
realsep = sep
|
34
|
-
if line.strip() == WikiParser.ENDBLOCK:
|
35
|
-
stack = stack - 1
|
36
|
-
if stack:
|
37
|
-
buf.write(line + "\n")
|
38
|
-
realsep = ''
|
39
|
-
if gotblock:
|
40
|
-
if line.strip() == '#!client':
|
41
|
-
stack = stack + 1
|
42
|
-
if stack == 1:
|
43
|
-
buf.write(realsep)
|
44
|
-
else:
|
45
|
-
gotblock = False
|
46
|
-
elif line.strip() == WikiParser.STARTBLOCK:
|
47
|
-
gotblock = True
|
48
|
-
return buf.getvalue()
|
49
|
-
|
50
|
-
class TestProcessor(Component):
|
51
|
-
implements(IWikiMacroProvider)
|
52
|
-
|
53
|
-
def __init__(self):
|
54
|
-
pass
|
55
|
-
|
56
|
-
def get_macros(self):
|
57
|
-
return ['clientx']
|
58
|
-
|
59
|
-
def get_macro_description(self, name):
|
60
|
-
return 'Just a test'
|
61
|
-
|
62
|
-
def expand_macro(self, formatter, name, content):
|
63
|
-
db = self.env.get_db_cnx()
|
64
|
-
cursor = db.cursor()
|
65
|
-
cursor.execute("SELECT text FROM wiki WHERE name=%s ORDER BY version DESC LIMIT 1", ("WikiStart",))
|
66
|
-
try:
|
67
|
-
text = extract_client_text(cursor.fetchone()[0])
|
68
|
-
return wiki_to_html(text, self.env, formatter.req)
|
69
|
-
except:
|
70
|
-
return 'B0rken'
|
@@ -1,142 +0,0 @@
|
|
1
|
-
from trac.core import *
|
2
|
-
|
3
|
-
|
4
|
-
class CustomReportManager:
|
5
|
-
"""A Class to manage custom reports"""
|
6
|
-
version = 1
|
7
|
-
name = "custom_report_manager_version"
|
8
|
-
env = None
|
9
|
-
log = None
|
10
|
-
|
11
|
-
def __init__(self, env, log):
|
12
|
-
self.env = env
|
13
|
-
self.log = log
|
14
|
-
self.upgrade()
|
15
|
-
|
16
|
-
def upgrade(self):
|
17
|
-
# Check to see what version we have
|
18
|
-
db = self.env.get_db_cnx()
|
19
|
-
cursor = db.cursor()
|
20
|
-
cursor.execute("SELECT value FROM system WHERE name=%s", (self.name,))
|
21
|
-
try:
|
22
|
-
version = int(cursor.fetchone()[0])
|
23
|
-
except:
|
24
|
-
version = 0
|
25
|
-
cursor.execute("INSERT INTO system (name,value) VALUES(%s,%s)",
|
26
|
-
(self.name, version))
|
27
|
-
|
28
|
-
if version > self.version:
|
29
|
-
raise TracError("Fatal Error: You appear to be running two plugins with conflicting versions "
|
30
|
-
"of the CustomReportManager class. Please ensure that '%s' is updated to "
|
31
|
-
"version %s of the file reportmanager.py (currently using version %s)."
|
32
|
-
% (__name__, str(version), str(self.version)))
|
33
|
-
|
34
|
-
# Do the staged updates
|
35
|
-
try:
|
36
|
-
if version < 1:
|
37
|
-
cursor.execute("CREATE TABLE custom_report ("
|
38
|
-
"id INTEGER,"
|
39
|
-
"uuid VARCHAR(64),"
|
40
|
-
"maingroup VARCHAR(255),"
|
41
|
-
"subgroup VARCHAR(255),"
|
42
|
-
"version INTEGER,"
|
43
|
-
"ordering INTEGER)")
|
44
|
-
|
45
|
-
#if version < 2:
|
46
|
-
# cursor.execute("...")
|
47
|
-
|
48
|
-
# Updates complete, set the version
|
49
|
-
cursor.execute("UPDATE system SET value=%s WHERE name=%s",
|
50
|
-
(self.version, self.name))
|
51
|
-
db.commit()
|
52
|
-
db.close()
|
53
|
-
|
54
|
-
except Exception, e:
|
55
|
-
self.log.error("CustomReportManager Exception: %s" % (e,));
|
56
|
-
db.rollback()
|
57
|
-
|
58
|
-
def add_report(self, title, author, description, query, uuid, version, maingroup, subgroup=""):
|
59
|
-
# First check to see if we can load an existing version of this report
|
60
|
-
db = self.env.get_db_cnx()
|
61
|
-
cursor = db.cursor()
|
62
|
-
try:
|
63
|
-
cursor.execute("SELECT id, version FROM custom_report "
|
64
|
-
"WHERE uuid=%s", (uuid,))
|
65
|
-
(id, currentversion) = cursor.fetchone()
|
66
|
-
except:
|
67
|
-
id = None
|
68
|
-
currentversion = 0
|
69
|
-
|
70
|
-
try:
|
71
|
-
if not id:
|
72
|
-
cursor.execute("SELECT MAX(id) FROM report")
|
73
|
-
next_id = int(cursor.fetchone()[0]) + 1
|
74
|
-
self.log.debug("Inserting new report with uuid '%s'" % (uuid,));
|
75
|
-
|
76
|
-
# Get the ordering of any current reports in this group/subgroup.
|
77
|
-
try:
|
78
|
-
cursor.execute("SELECT MAX(ordering) FROM custom_report "
|
79
|
-
"WHERE maingroup=%s AND subgroup=%s", (maingroup, subgroup))
|
80
|
-
ordering = int(cursor.fetchone()[0]) + 1
|
81
|
-
except:
|
82
|
-
ordering = 0
|
83
|
-
|
84
|
-
cursor.execute("INSERT INTO report (id, title, author, description, query) "
|
85
|
-
"VALUES (%s, %s, %s, %s, %s)",
|
86
|
-
(next_id, title, author, description, query))
|
87
|
-
cursor.execute("INSERT INTO custom_report (id, uuid, maingroup, subgroup, version, ordering) "
|
88
|
-
"VALUES (%s, %s, %s, %s, %s, %s)",
|
89
|
-
(next_id, uuid, maingroup, subgroup, version, ordering))
|
90
|
-
db.commit()
|
91
|
-
db.close()
|
92
|
-
return True
|
93
|
-
if currentversion < version:
|
94
|
-
self.log.debug("Updating report with uuid '%s' to version %s" % (uuid,version));
|
95
|
-
cursor.execute("UPDATE report SET title=%s, author=%s, description=%s, query=%s "
|
96
|
-
"WHERE id=%s", (title, author, description, query, id))
|
97
|
-
cursor.execute("UPDATE custom_report SET version=%s, maingroup=%s, subgroup=%s "
|
98
|
-
"WHERE id=%s", (version, maingroup, subgroup, id))
|
99
|
-
db.commit()
|
100
|
-
db.close()
|
101
|
-
return True
|
102
|
-
except Exception, e:
|
103
|
-
self.log.error("CustomReportManager Exception: %s" % (e,));
|
104
|
-
db.rollback()
|
105
|
-
|
106
|
-
return False
|
107
|
-
|
108
|
-
def get_report_by_uuid(self, uuid):
|
109
|
-
db = self.env.get_db_cnx()
|
110
|
-
cursor = db.cursor()
|
111
|
-
rv = None
|
112
|
-
try:
|
113
|
-
cursor.execute("SELECT report.id,report.title FROM custom_report "
|
114
|
-
"LEFT JOIN report ON custom_report.id=report.id "
|
115
|
-
"WHERE custom_report.uuid=%s", (uuid,))
|
116
|
-
row = cursor.fetchone()
|
117
|
-
rv = (row[0], row[1])
|
118
|
-
except:
|
119
|
-
pass
|
120
|
-
|
121
|
-
return rv
|
122
|
-
|
123
|
-
def get_reports_by_group(self, group):
|
124
|
-
db = self.env.get_db_cnx()
|
125
|
-
cursor = db.cursor()
|
126
|
-
rv = {}
|
127
|
-
try:
|
128
|
-
cursor.execute("SELECT custom_report.subgroup,report.id,report.title "
|
129
|
-
"FROM custom_report "
|
130
|
-
"LEFT JOIN report ON custom_report.id=report.id "
|
131
|
-
"WHERE custom_report.maingroup=%s "
|
132
|
-
"ORDER BY custom_report.subgroup,custom_report.ordering", (group,))
|
133
|
-
for subgroup,id,title in cursor:
|
134
|
-
if not rv.has_key(subgroup):
|
135
|
-
rv[subgroup] = { "title": subgroup,
|
136
|
-
"reports": [] }
|
137
|
-
rv[subgroup]["reports"].append( { "id": int(id), "title": title } )
|
138
|
-
except:
|
139
|
-
pass
|
140
|
-
|
141
|
-
return rv
|
142
|
-
|
@@ -1,231 +0,0 @@
|
|
1
|
-
# IF YOU ADD A NEW SECTION OF REPORTS, You will need to make
|
2
|
-
# sure that section is also added to the reports hashtable
|
3
|
-
# near the bottom
|
4
|
-
|
5
|
-
# Please try to keep this clean
|
6
|
-
|
7
|
-
billing_reports = [{
|
8
|
-
'uuid': 'cd175fb0-0c74-48e4-816f-d72b4ba98fc1',
|
9
|
-
'title': 'Client Work Summary',
|
10
|
-
'description': '',
|
11
|
-
'version': 1,
|
12
|
-
'sql': """
|
13
|
-
SELECT
|
14
|
-
__group__, __style__, ticket, summary, newvalue as Work_added,
|
15
|
-
time, _ord
|
16
|
-
FROM(
|
17
|
-
SELECT '' as __style__, t.id as ticket,
|
18
|
-
SUM(CAST(newvalue as DECIMAL)) as newvalue, t.summary as summary,
|
19
|
-
MAX(ticket_change.time) as time, client.value as __group__, 0 as _ord
|
20
|
-
FROM ticket_change
|
21
|
-
JOIN ticket t on t.id = ticket_change.ticket
|
22
|
-
LEFT JOIN ticket_custom as billable on billable.ticket = t.id
|
23
|
-
and billable.name = 'billable'
|
24
|
-
LEFT JOIN ticket_custom as client on client.ticket = t.id
|
25
|
-
and client.name = 'client'
|
26
|
-
WHERE field = 'hours' and
|
27
|
-
t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED)
|
28
|
-
AND billable.value in ($BILLABLE, $UNBILLABLE)
|
29
|
-
AND ticket_change.time >= $STARTDATE
|
30
|
-
AND ticket_change.time < $ENDDATE
|
31
|
-
GROUP BY client.value, t.id, t.summary
|
32
|
-
|
33
|
-
UNION
|
34
|
-
|
35
|
-
SELECT 'background-color:#DFE;' as __style__, NULL as ticket,
|
36
|
-
sum(CAST(newvalue as DECIMAL)) as newvalue, 'Total work done' as summary,
|
37
|
-
NULL as time, client.value as __group__, 1 as _ord
|
38
|
-
FROM ticket_change
|
39
|
-
JOIN ticket t on t.id = ticket_change.ticket
|
40
|
-
LEFT JOIN ticket_custom as billable on billable.ticket = t.id
|
41
|
-
and billable.name = 'billable'
|
42
|
-
LEFT JOIN ticket_custom as client on client.ticket = t.id
|
43
|
-
and client.name = 'client'
|
44
|
-
WHERE field = 'hours' and
|
45
|
-
t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED)
|
46
|
-
AND billable.value in ($BILLABLE, $UNBILLABLE)
|
47
|
-
AND ticket_change.time >= $STARTDATE
|
48
|
-
AND ticket_change.time < $ENDDATE
|
49
|
-
GROUP By client.value
|
50
|
-
) as tbl
|
51
|
-
ORDER BY __group__, _ord ASC, ticket, time
|
52
|
-
"""
|
53
|
-
}]
|
54
|
-
|
55
|
-
ticket_hours_reports = [{
|
56
|
-
'uuid': 'e2ab8124-9309-4d1c-9cec-f8c7b11bf579',
|
57
|
-
'title': 'Ticket Hours Grouped By Client',
|
58
|
-
'description': '',
|
59
|
-
'version': 1,
|
60
|
-
'sql': """
|
61
|
-
SELECT __color__, __group__, __style__, ticket, summary, __component__ ,version,
|
62
|
-
severity, milestone, status, owner, estimate_work, total_work, billable,
|
63
|
-
_ord
|
64
|
-
|
65
|
-
FROM (
|
66
|
-
SELECT p.value AS __color__,
|
67
|
-
client.value AS __group__,
|
68
|
-
'' as __style__,
|
69
|
-
t.id AS ticket, summary AS summary, -- ## Break line here
|
70
|
-
component as __component__,version, severity, milestone, status, owner,
|
71
|
-
CAST(estimatedhours.value as DECIMAL) as estimate_work,
|
72
|
-
CAST(totalhours.value as DECIMAL) as Total_work,
|
73
|
-
CASE WHEN billable.value = 1 THEN 'Y'
|
74
|
-
else 'N'
|
75
|
-
END as billable,
|
76
|
-
time AS created, changetime AS modified, -- ## Dates are formatted
|
77
|
-
description AS _description_, -- ## Uses a full row
|
78
|
-
changetime AS _changetime,
|
79
|
-
reporter AS _reporter
|
80
|
-
,0 as _ord
|
81
|
-
|
82
|
-
FROM ticket as t
|
83
|
-
JOIN enum as p ON p.name=t.priority AND p.type='priority'
|
84
|
-
|
85
|
-
LEFT JOIN ticket_custom as estimatedhours ON estimatedhours.name='estimatedhours'
|
86
|
-
AND estimatedhours.ticket = t.id
|
87
|
-
LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
|
88
|
-
AND totalhours.ticket = t.id
|
89
|
-
LEFT JOIN ticket_custom as billable ON billable.name='billable'
|
90
|
-
AND billable.ticket = t.id
|
91
|
-
LEFT JOIN ticket_custom as client ON client.name='client'
|
92
|
-
AND client.ticket = t.id
|
93
|
-
|
94
|
-
WHERE t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED)
|
95
|
-
AND billable.value in ($BILLABLE, $UNBILLABLE)
|
96
|
-
|
97
|
-
|
98
|
-
UNION
|
99
|
-
|
100
|
-
SELECT '1' AS __color__,
|
101
|
-
client.value AS __group__,
|
102
|
-
'background-color:#DFE;' as __style__,
|
103
|
-
NULL as ticket, 'Total work' AS summary,
|
104
|
-
t.component as __component__, NULL as version, NULL as severity,
|
105
|
-
NULL as milestone, NULL as status,
|
106
|
-
NULL as owner,
|
107
|
-
SUM(CAST(estimatedhours.value as DECIMAL)) as estimate_work,
|
108
|
-
SUM(CAST(totalhours.value as DECIMAL)) as Total_work,
|
109
|
-
NULL as billable,
|
110
|
-
NULL as created,
|
111
|
-
NULL as modified, -- ## Dates are formatted
|
112
|
-
|
113
|
-
NULL AS _description_,
|
114
|
-
NULL AS _changetime,
|
115
|
-
NULL AS _reporter
|
116
|
-
,1 as _ord
|
117
|
-
FROM ticket as t
|
118
|
-
JOIN enum as p ON p.name=t.priority AND p.type='priority'
|
119
|
-
|
120
|
-
LEFT JOIN ticket_custom as estimatedhours ON estimatedhours.name='estimatedhours'
|
121
|
-
AND estimatedhours.ticket = t.id
|
122
|
-
|
123
|
-
LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
|
124
|
-
AND totalhours.ticket = t.id
|
125
|
-
|
126
|
-
LEFT JOIN ticket_custom as billable ON billable.name='billable'
|
127
|
-
AND billable.ticket = t.id
|
128
|
-
|
129
|
-
LEFT JOIN ticket_custom as client ON client.name='client'
|
130
|
-
AND client.ticket = t.id
|
131
|
-
|
132
|
-
WHERE t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED)
|
133
|
-
AND billable.value in ($BILLABLE, $UNBILLABLE)
|
134
|
-
GROUP BY client.value
|
135
|
-
) as tbl
|
136
|
-
ORDER BY __group__, _ord ASC,ticket
|
137
|
-
"""
|
138
|
-
},{
|
139
|
-
'uuid': '9194d297-bd5a-4225-a28c-e981525b20e1',
|
140
|
-
'title': 'Ticket Hours Grouped By Client with Description',
|
141
|
-
'description': '',
|
142
|
-
'version': 1,
|
143
|
-
'sql': """
|
144
|
-
SELECT __color__, __group__, __style__, ticket, summary, __component__ ,version,
|
145
|
-
severity, milestone, status, owner, estimate_work, total_work, billable,
|
146
|
-
_description_, _ord
|
147
|
-
|
148
|
-
FROM (
|
149
|
-
SELECT p.value AS __color__,
|
150
|
-
client.value AS __group__,
|
151
|
-
'' as __style__,
|
152
|
-
t.id AS ticket, summary AS summary, -- ## Break line here
|
153
|
-
component as __component__,version, severity, milestone, status, owner,
|
154
|
-
CAST(estimatedhours.value as DECIMAL) as estimate_work,
|
155
|
-
CAST(totalhours.value as DECIMAL) as Total_work,
|
156
|
-
CASE WHEN billable.value = 1 THEN 'Y'
|
157
|
-
else 'N'
|
158
|
-
END as billable,
|
159
|
-
time AS created, changetime AS modified, -- ## Dates are formatted
|
160
|
-
description AS _description_, -- ## Uses a full row
|
161
|
-
changetime AS _changetime,
|
162
|
-
reporter AS _reporter
|
163
|
-
,0 as _ord
|
164
|
-
|
165
|
-
FROM ticket as t
|
166
|
-
JOIN enum as p ON p.name=t.priority AND p.type='priority'
|
167
|
-
|
168
|
-
LEFT JOIN ticket_custom as estimatedhours ON estimatedhours.name='estimatedhours'
|
169
|
-
AND estimatedhours.ticket = t.id
|
170
|
-
LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
|
171
|
-
AND totalhours.ticket = t.id
|
172
|
-
LEFT JOIN ticket_custom as billable ON billable.name='billable'
|
173
|
-
AND billable.ticket = t.id
|
174
|
-
LEFT JOIN ticket_custom as client ON client.name='client'
|
175
|
-
AND client.ticket = t.id
|
176
|
-
|
177
|
-
WHERE t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED)
|
178
|
-
AND billable.value in ($BILLABLE, $UNBILLABLE)
|
179
|
-
|
180
|
-
|
181
|
-
UNION
|
182
|
-
|
183
|
-
SELECT '1' AS __color__,
|
184
|
-
client.value AS __group__,
|
185
|
-
'background-color:#DFE;' as __style__,
|
186
|
-
NULL as ticket, 'Total work' AS summary,
|
187
|
-
t.component as __component__, NULL as version, NULL as severity,
|
188
|
-
NULL as milestone, NULL as status,
|
189
|
-
NULL as owner,
|
190
|
-
SUM(CAST(estimatedhours.value as DECIMAL)) as estimate_work,
|
191
|
-
SUM(CAST(totalhours.value as DECIMAL)) as Total_work,
|
192
|
-
NULL as billable,
|
193
|
-
NULL as created,
|
194
|
-
NULL as modified, -- ## Dates are formatted
|
195
|
-
|
196
|
-
NULL AS _description_,
|
197
|
-
NULL AS _changetime,
|
198
|
-
NULL AS _reporter
|
199
|
-
,1 as _ord
|
200
|
-
FROM ticket as t
|
201
|
-
JOIN enum as p ON p.name=t.priority AND p.type='priority'
|
202
|
-
|
203
|
-
LEFT JOIN ticket_custom as estimatedhours ON estimatedhours.name='estimatedhours'
|
204
|
-
AND estimatedhours.ticket = t.id
|
205
|
-
|
206
|
-
LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
|
207
|
-
AND totalhours.ticket = t.id
|
208
|
-
|
209
|
-
LEFT JOIN ticket_custom as billable ON billable.name='billable'
|
210
|
-
AND billable.ticket = t.id
|
211
|
-
|
212
|
-
LEFT JOIN ticket_custom as client ON client.name='client'
|
213
|
-
AND client.ticket = t.id
|
214
|
-
|
215
|
-
WHERE t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED)
|
216
|
-
AND billable.value in ($BILLABLE, $UNBILLABLE)
|
217
|
-
GROUP BY client.value
|
218
|
-
) as tbl
|
219
|
-
ORDER BY __group__, _ord ASC,ticket
|
220
|
-
"""
|
221
|
-
}]
|
222
|
-
|
223
|
-
|
224
|
-
reports = [{
|
225
|
-
'title': 'Billing Reports',
|
226
|
-
'reports': billing_reports
|
227
|
-
},{
|
228
|
-
'title': 'Ticket/Hour Reports',
|
229
|
-
'reports': ticket_hours_reports
|
230
|
-
}]
|
231
|
-
|