1 #
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3 # This module is free software, and you may redistribute it and/or modify
4 # under the same terms as Python, so long as this copyright message and
5 # disclaimer are retained in their original form.
6 #
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10 # POSSIBILITY OF SUCH DAMAGE.
11 #
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 #
18 # $Id: interfaces.py,v 1.10 2001-10-05 02:23:24 richard Exp $
20 import instance_config, urlparse, os
21 from roundup import cgi_client, mailgw
23 class Client(cgi_client.Client):
24 ''' derives basic mail gateway implementation from the standard module,
25 with any specific extensions
26 '''
27 TEMPLATES = instance_config.TEMPLATES
28 showsupport = cgi_client.Client.shownode
29 showtimelog = cgi_client.Client.shownode
30 newsupport = cgi_client.Client.newnode
31 newtimelog = cgi_client.Client.newnode
33 default_index_sort = ['-activity']
34 default_index_group = ['priority']
35 default_index_filter = []
36 default_index_columns = ['activity','status','title','assignedto']
37 default_index_filterspec = {'status': ['1', '2', '3', '4', '5', '6', '7']}
39 def pagehead(self, title, message=None):
40 url = self.env['SCRIPT_NAME'] + '/' #self.env.get('PATH_INFO', '/')
41 machine = self.env['SERVER_NAME']
42 port = self.env['SERVER_PORT']
43 if port != '80': machine = machine + ':' + port
44 base = urlparse.urlunparse(('http', machine, url, None, None, None))
45 if message is not None:
46 message = '<div class="system-msg">%s</div>'%message
47 else:
48 message = ''
49 style = open(os.path.join(self.TEMPLATES, 'style.css')).read()
50 user_name = self.user or ''
51 if self.user == 'admin':
52 admin_links = ' | <a href="list_classes">Class List</a>'
53 else:
54 admin_links = ''
55 if self.user not in (None, 'anonymous'):
56 userid = self.db.user.lookup(self.user)
57 user_info = '''
58 <a href="issue?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">My Issues</a> |
59 <a href="support?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">My Support</a> |
60 <a href="user%s">My Details</a> | <a href="logout">Logout</a>
61 '''%(userid, userid, userid)
62 else:
63 user_info = '<a href="login">Login</a>'
64 if self.user is not None:
65 add_links = '''
66 | Add
67 <a href="newissue">Issue</a>,
68 <a href="newsupport">Support</a>,
69 <a href="newuser">User</a>
70 '''
71 else:
72 add_links = ''
73 self.write('''<html><head>
74 <title>%s</title>
75 <style type="text/css">%s</style>
76 </head>
77 <body bgcolor=#ffffff>
78 %s
79 <table width=100%% border=0 cellspacing=0 cellpadding=2>
80 <tr class="location-bar"><td><big><strong>%s</strong></big></td>
81 <td align=right valign=bottom>%s</td></tr>
82 <tr class="location-bar">
83 <td align=left>All
84 <a href="issue?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">Issues</a>,
85 <a href="support?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">Support</a>
86 | Unassigned
87 <a href="issue?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">Issues</a>,
88 <a href="support?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">Support</a>
89 %s
90 %s</td>
91 <td align=right>%s</td>
92 </table>
93 '''%(title, style, message, title, user_name, add_links, admin_links,
94 user_info))
96 class MailGW(mailgw.MailGW):
97 ''' derives basic mail gateway implementation from the standard module,
98 with any specific extensions
99 '''
100 ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
101 ADMIN_EMAIL = instance_config.ADMIN_EMAIL
102 MAILHOST = instance_config.MAILHOST
104 #
105 # $Log: not supported by cvs2svn $
106 # Revision 1.9 2001/08/07 00:24:43 richard
107 # stupid typo
108 #
109 # Revision 1.8 2001/08/07 00:15:51 richard
110 # Added the copyright/license notice to (nearly) all files at request of
111 # Bizar Software.
112 #
113 # Revision 1.7 2001/08/02 00:43:06 richard
114 # Even better (more useful) headings
115 #
116 # Revision 1.6 2001/08/02 00:36:42 richard
117 # Made all the user-specific link names the same (My Foo)
118 #
119 # Revision 1.5 2001/08/01 05:15:09 richard
120 # Added "My Issues" and "My Support" to extended template.
121 #
122 # Revision 1.4 2001/07/30 08:12:17 richard
123 # Added time logging and file uploading to the templates.
124 #
125 # Revision 1.3 2001/07/30 01:26:59 richard
126 # Big changes:
127 # . split off the support priority into its own class
128 # . added "new support, new user" to the page head
129 # . fixed the display options for the heading links
130 #
131 # Revision 1.2 2001/07/29 07:01:39 richard
132 # Added vim command to all source so that we don't get no steenkin' tabs :)
133 #
134 # Revision 1.1 2001/07/23 23:16:01 richard
135 # Split off the interfaces (CGI, mailgw) into a separate file from the DB stuff.
136 #
137 #
138 # vim: set filetype=python ts=4 sw=4 et si