Code

Removed generation of change note from "sendmessage" in roundupdb.py.
[roundup.git] / roundup / templates / extended / dbinit.py
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: dbinit.py,v 1.17 2001-12-02 05:06:16 richard Exp $
20 import os
22 import instance_config
23 from roundup import roundupdb
24 import select_db
26 from roundup.roundupdb import Class, FileClass
28 class Database(roundupdb.Database, select_db.Database):
29     ''' Creates a hybrid database from: 
30          . the selected database back-end from select_db
31          . the roundup extensions from roundupdb 
32     ''' 
33     pass 
35 class IssueClass(roundupdb.IssueClass):
36     ''' issues need the email information
37     '''
38     INSTANCE_NAME = instance_config.INSTANCE_NAME
39     ISSUE_TRACKER_WEB = instance_config.ISSUE_TRACKER_WEB
40     ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
41     ADMIN_EMAIL = instance_config.ADMIN_EMAIL
42     MAILHOST = instance_config.MAILHOST
43     MESSAGES_TO_AUTHOR = instance_config.MESSAGES_TO_AUTHOR
44     EMAIL_SIGNATURE_POSITION = instance_config.EMAIL_SIGNATURE_POSITION
46  
47 def open(name=None):
48     ''' as from the roundupdb method openDB 
49  
50     ''' 
51     from roundup.hyperdb import String, Password, Date, Link, Multilink
53     # open the database
54     db = Database(instance_config.DATABASE, name)
56     # Now initialise the schema. Must do this each time.
57     pri = Class(db, "priority", 
58                     name=String(), order=String())
59     pri.setkey("name")
61     stat = Class(db, "status", 
62                     name=String(), order=String())
63     stat.setkey("name")
65     keywords = Class(db, "keyword", 
66                     name=String())
67     keywords.setkey("name")
69     user = Class(db, "user", 
70                     username=String(),   password=Password(),
71                     address=String(),    realname=String(), 
72                     phone=String(),      organisation=String())
73     user.setkey("username")
75     msg = FileClass(db, "msg", 
76                     author=Link("user"), recipients=Multilink("user"), 
77                     date=Date(),         summary=String(), 
78                     files=Multilink("file"))
80     file = FileClass(db, "file", 
81                     name=String(),       type=String())
83     # bugs and support calls etc
84     rate = Class(db, "rate", 
85                     name=String(),       order=String())
86     rate.setkey("name")
88     source = Class(db, "source", 
89                     name=String(),       order=String())
90     source.setkey("name")
92     platform = Class(db, "platform", 
93                     name=String(),       order=String())
94     platform.setkey("name")
96     product = Class(db, "product", 
97                     name=String(),       order=String())
98     product.setkey("name")
100     timelog = Class(db, "timelog", 
101                     date=Date(),         time=String(),
102                     performedby=Link("user"), description=String())
104     support = IssueClass(db, "support", 
105                     assignedto=Link("user"), status=Link("status"),
106                     rate=Link("rate"), source=Link("source"),
107                     product=Link("product"), platform=Multilink("platform"),
108                     version=String(), timelog=Multilink("timelog"),
109                     customername=String())
111     issue = IssueClass(db, "issue", 
112                     assignedto=Link("user"), priority=Link("priority"), 
113                     status=Link("status"), product=Link("product"), 
114                     platform=Multilink("platform"), version=String(),
115                     targetversion=String(), supportcall=Multilink("support"))
117     import detectors
118     detectors.init(db)
120     return db
121  
122 def init(adminpw): 
123     ''' as from the roundupdb method initDB 
124  
125     Open the new database, and set up a bunch of attributes.
127     ''' 
128     dbdir = os.path.join(instance_config.DATABASE, 'files')
129     if not os.path.isdir(dbdir):
130         os.makedirs(dbdir)
132     db = open("admin")
133     db.clear()
135     pri = db.getclass('priority')
136     pri.create(name="fatal-bug", order="1")
137     pri.create(name="bug", order="2")
138     pri.create(name="usability", order="3")
139     pri.create(name="feature", order="4")
141     stat = db.getclass('status')
142     stat.create(name="unread", order="1")
143     stat.create(name="deferred", order="2")
144     stat.create(name="chatting", order="3")
145     stat.create(name="need-eg", order="4")
146     stat.create(name="in-progress", order="5")
147     stat.create(name="testing", order="6")
148     stat.create(name="done-cbb", order="7")
149     stat.create(name="resolved", order="8")
151     rate = db.getclass("rate")
152     rate.create(name='basic', order="1")
153     rate.create(name='premium', order="2")
154     rate.create(name='internal', order="3")
156     source = db.getclass("source")
157     source.create(name='phone', order="1")
158     source.create(name='e-mail', order="2")
159     source.create(name='internal', order="3")
160     source.create(name='internal-qa', order="4")
162     platform = db.getclass("platform")
163     platform.create(name='linux', order="1")
164     platform.create(name='windows', order="2")
165     platform.create(name='mac', order="3")
167     product = db.getclass("product")
168     product.create(name='Bizar Shop', order="1")
169     product.create(name='Bizar Shop Developer', order="2")
170     product.create(name='Bizar Shop Manual', order="3")
171     product.create(name='Bizar Shop Developer Manual', order="4")
173     user = db.getclass('user')
174     user.create(username="admin", password=adminpw, 
175                                   address=instance_config.ADMIN_EMAIL)
177     db.commit()
180 # $Log: not supported by cvs2svn $
181 # Revision 1.16  2001/12/01 07:17:50  richard
182 # . We now have basic transaction support! Information is only written to
183 #   the database when the commit() method is called. Only the anydbm
184 #   backend is modified in this way - neither of the bsddb backends have been.
185 #   The mail, admin and cgi interfaces all use commit (except the admin tool
186 #   doesn't have a commit command, so interactive users can't commit...)
187 # . Fixed login/registration forwarding the user to the right page (or not,
188 #   on a failure)
190 # Revision 1.15  2001/11/26 22:55:56  richard
191 # Feature:
192 #  . Added INSTANCE_NAME to configuration - used in web and email to identify
193 #    the instance.
194 #  . Added EMAIL_SIGNATURE_POSITION to indicate where to place the roundup
195 #    signature info in e-mails.
196 #  . Some more flexibility in the mail gateway and more error handling.
197 #  . Login now takes you to the page you back to the were denied access to.
199 # Fixed:
200 #  . Lots of bugs, thanks Roché and others on the devel mailing list!
202 # Revision 1.14  2001/11/21 02:34:18  richard
203 # Added a target version field to the extended issue schema
205 # Revision 1.13  2001/10/30 00:54:45  richard
206 # Features:
207 #  . #467129 ] Lossage when username=e-mail-address
208 #  . #473123 ] Change message generation for author
209 #  . MailGW now moves 'resolved' to 'chatting' on receiving e-mail for an issue.
211 # Revision 1.12  2001/10/09 07:25:59  richard
212 # Added the Password property type. See "pydoc roundup.password" for
213 # implementation details. Have updated some of the documentation too.
215 # Revision 1.11  2001/08/07 00:24:43  richard
216 # stupid typo
218 # Revision 1.10  2001/08/07 00:15:51  richard
219 # Added the copyright/license notice to (nearly) all files at request of
220 # Bizar Software.
222 # Revision 1.9  2001/08/02 06:38:17  richard
223 # Roundupdb now appends "mailing list" information to its messages which
224 # include the e-mail address and web interface address. Templates may
225 # override this in their db classes to include specific information (support
226 # instructions, etc).
228 # Revision 1.8  2001/07/30 01:26:59  richard
229 # Big changes:
230 #  . split off the support priority into its own class
231 #  . added "new support, new user" to the page head
232 #  . fixed the display options for the heading links
234 # Revision 1.7  2001/07/29 07:01:39  richard
235 # Added vim command to all source so that we don't get no steenkin' tabs :)
237 # Revision 1.6  2001/07/25 01:23:07  richard
238 # Added the Roundup spec to the new documentation directory.
240 # Revision 1.5  2001/07/23 23:20:35  richard
241 # forgot to remove the interfaces from the dbinit module ;)
243 # Revision 1.4  2001/07/23 08:45:28  richard
244 # ok, so now "./roundup-admin init" will ask questions in an attempt to get a
245 # workable instance_home set up :)
246 # _and_ anydbm has had its first test :)
248 # Revision 1.3  2001/07/23 07:14:41  richard
249 # Moved the database backends off into backends.
251 # Revision 1.2  2001/07/23 06:25:50  richard
252 # relfected the move to roundup/backends
254 # Revision 1.1  2001/07/23 04:33:21  anthonybaxter
255 # split __init__.py into 2. dbinit and instance_config.
257 # Revision 1.1  2001/07/23 03:50:46  anthonybaxter
258 # moved templates to proper location
260 # Revision 1.2  2001/07/22 12:09:32  richard
261 # Final commit of Grande Splite
264 # vim: set filetype=python ts=4 sw=4 et si