Code

93389261b80d377ecc0013ae6caee6ad39eec661
[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.11 2001-08-07 00:24:43 richard Exp $
20 import os
22 import instance_config
23 from roundup import roundupdb
24 import select_db
25 from roundup.roundupdb import Class, FileClass
27 class Database(roundupdb.Database, select_db.Database):
28     ''' Creates a hybrid database from: 
29          . the selected database back-end from select_db
30          . the roundup extensions from roundupdb 
31     ''' 
32     pass 
34 class IssueClass(roundupdb.IssueClass):
35     ''' issues need the email information
36     '''
37     ISSUE_TRACKER_WEB = instance_config.ISSUE_TRACKER_WEB
38     ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
39     ADMIN_EMAIL = instance_config.ADMIN_EMAIL
40     MAILHOST = instance_config.MAILHOST
42  
43 def open(name=None):
44     ''' as from the roundupdb method openDB 
45  
46     ''' 
47     from roundup.hyperdb import String, Date, Link, Multilink
49     # open the database
50     db = Database(instance_config.DATABASE, name)
52     # Now initialise the schema. Must do this each time.
53     pri = Class(db, "priority", 
54                     name=String(), order=String())
55     pri.setkey("name")
57     stat = Class(db, "status", 
58                     name=String(), order=String())
59     stat.setkey("name")
61     keywords = Class(db, "keyword", 
62                     name=String())
64     user = Class(db, "user", 
65                     username=String(),   password=String(),
66                     address=String(),    realname=String(), 
67                     phone=String(),      organisation=String())
68     user.setkey("username")
70     msg = FileClass(db, "msg", 
71                     author=Link("user"), recipients=Multilink("user"), 
72                     date=Date(),         summary=String(), 
73                     files=Multilink("file"))
75     file = FileClass(db, "file", 
76                     name=String(),       type=String())
78     # bugs and support calls etc
79     rate = Class(db, "rate", 
80                     name=String(),       order=String())
81     rate.setkey("name")
83     source = Class(db, "source", 
84                     name=String(),       order=String())
85     source.setkey("name")
87     platform = Class(db, "platform", 
88                     name=String(),       order=String())
89     platform.setkey("name")
91     product = Class(db, "product", 
92                     name=String(),       order=String())
93     product.setkey("name")
95     timelog = Class(db, "timelog", 
96                     date=Date(),         time=String(),
97                     performedby=Link("user"), description=String())
99     support = IssueClass(db, "support", 
100                     assignedto=Link("user"), status=Link("status"),
101                     rate=Link("rate"), source=Link("source"),
102                     product=Link("product"), platform=Multilink("platform"),
103                     version=String(), timelog=Multilink("timelog"),
104                     customername=String())
106     issue = IssueClass(db, "issue", 
107                     assignedto=Link("user"), priority=Link("priority"), 
108                     status=Link("status"), product=Link("product"), 
109                     platform=Multilink("platform"), version=String(),
110                     supportcall=Multilink("support"))
112     import detectors
113     detectors.init(db)
115     return db
116  
117 def init(adminpw): 
118     ''' as from the roundupdb method initDB 
119  
120     Open the new database, and set up a bunch of attributes.
122     ''' 
123     dbdir = os.path.join(instance_config.DATABASE, 'files')
124     if not os.path.isdir(dbdir):
125         os.makedirs(dbdir)
127     db = open("admin")
128     db.clear()
130     pri = db.getclass('priority')
131     pri.create(name="fatal-bug", order="1")
132     pri.create(name="bug", order="2")
133     pri.create(name="usability", order="3")
134     pri.create(name="feature", order="4")
136     stat = db.getclass('status')
137     stat.create(name="unread", order="1")
138     stat.create(name="deferred", order="2")
139     stat.create(name="chatting", order="3")
140     stat.create(name="need-eg", order="4")
141     stat.create(name="in-progress", order="5")
142     stat.create(name="testing", order="6")
143     stat.create(name="done-cbb", order="7")
144     stat.create(name="resolved", order="8")
146     rate = db.getclass("rate")
147     rate.create(name='basic', order="1")
148     rate.create(name='premium', order="2")
149     rate.create(name='internal', order="3")
151     source = db.getclass("source")
152     source.create(name='phone', order="1")
153     source.create(name='e-mail', order="2")
154     source.create(name='internal', order="3")
155     source.create(name='internal-qa', order="4")
157     platform = db.getclass("platform")
158     platform.create(name='linux', order="1")
159     platform.create(name='windows', order="2")
160     platform.create(name='mac', order="3")
162     product = db.getclass("product")
163     product.create(name='Bizar Shop', order="1")
164     product.create(name='Bizar Shop Developer', order="2")
165     product.create(name='Bizar Shop Manual', order="3")
166     product.create(name='Bizar Shop Developer Manual', order="4")
168     user = db.getclass('user')
169     user.create(username="admin", password=adminpw, 
170                                   address=instance_config.ADMIN_EMAIL)
172     db.close()
175 # $Log: not supported by cvs2svn $
176 # Revision 1.10  2001/08/07 00:15:51  richard
177 # Added the copyright/license notice to (nearly) all files at request of
178 # Bizar Software.
180 # Revision 1.9  2001/08/02 06:38:17  richard
181 # Roundupdb now appends "mailing list" information to its messages which
182 # include the e-mail address and web interface address. Templates may
183 # override this in their db classes to include specific information (support
184 # instructions, etc).
186 # Revision 1.8  2001/07/30 01:26:59  richard
187 # Big changes:
188 #  . split off the support priority into its own class
189 #  . added "new support, new user" to the page head
190 #  . fixed the display options for the heading links
192 # Revision 1.7  2001/07/29 07:01:39  richard
193 # Added vim command to all source so that we don't get no steenkin' tabs :)
195 # Revision 1.6  2001/07/25 01:23:07  richard
196 # Added the Roundup spec to the new documentation directory.
198 # Revision 1.5  2001/07/23 23:20:35  richard
199 # forgot to remove the interfaces from the dbinit module ;)
201 # Revision 1.4  2001/07/23 08:45:28  richard
202 # ok, so now "./roundup-admin init" will ask questions in an attempt to get a
203 # workable instance_home set up :)
204 # _and_ anydbm has had its first test :)
206 # Revision 1.3  2001/07/23 07:14:41  richard
207 # Moved the database backends off into backends.
209 # Revision 1.2  2001/07/23 06:25:50  richard
210 # relfected the move to roundup/backends
212 # Revision 1.1  2001/07/23 04:33:21  anthonybaxter
213 # split __init__.py into 2. dbinit and instance_config.
215 # Revision 1.1  2001/07/23 03:50:46  anthonybaxter
216 # moved templates to proper location
218 # Revision 1.2  2001/07/22 12:09:32  richard
219 # Final commit of Grande Splite
222 # vim: set filetype=python ts=4 sw=4 et si