Code

Added the Password property type. See "pydoc roundup.password" for
[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.12 2001-10-09 07:25:59 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     ISSUE_TRACKER_WEB = instance_config.ISSUE_TRACKER_WEB
39     ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
40     ADMIN_EMAIL = instance_config.ADMIN_EMAIL
41     MAILHOST = instance_config.MAILHOST
43  
44 def open(name=None):
45     ''' as from the roundupdb method openDB 
46  
47     ''' 
48     from roundup.hyperdb import String, Password, Date, Link, Multilink
50     # open the database
51     db = Database(instance_config.DATABASE, name)
53     # Now initialise the schema. Must do this each time.
54     pri = Class(db, "priority", 
55                     name=String(), order=String())
56     pri.setkey("name")
58     stat = Class(db, "status", 
59                     name=String(), order=String())
60     stat.setkey("name")
62     keywords = Class(db, "keyword", 
63                     name=String())
64     keywords.setkey("name")
66     user = Class(db, "user", 
67                     username=String(),   password=Password(),
68                     address=String(),    realname=String(), 
69                     phone=String(),      organisation=String())
70     user.setkey("username")
72     msg = FileClass(db, "msg", 
73                     author=Link("user"), recipients=Multilink("user"), 
74                     date=Date(),         summary=String(), 
75                     files=Multilink("file"))
77     file = FileClass(db, "file", 
78                     name=String(),       type=String())
80     # bugs and support calls etc
81     rate = Class(db, "rate", 
82                     name=String(),       order=String())
83     rate.setkey("name")
85     source = Class(db, "source", 
86                     name=String(),       order=String())
87     source.setkey("name")
89     platform = Class(db, "platform", 
90                     name=String(),       order=String())
91     platform.setkey("name")
93     product = Class(db, "product", 
94                     name=String(),       order=String())
95     product.setkey("name")
97     timelog = Class(db, "timelog", 
98                     date=Date(),         time=String(),
99                     performedby=Link("user"), description=String())
101     support = IssueClass(db, "support", 
102                     assignedto=Link("user"), status=Link("status"),
103                     rate=Link("rate"), source=Link("source"),
104                     product=Link("product"), platform=Multilink("platform"),
105                     version=String(), timelog=Multilink("timelog"),
106                     customername=String())
108     issue = IssueClass(db, "issue", 
109                     assignedto=Link("user"), priority=Link("priority"), 
110                     status=Link("status"), product=Link("product"), 
111                     platform=Multilink("platform"), version=String(),
112                     supportcall=Multilink("support"))
114     import detectors
115     detectors.init(db)
117     return db
118  
119 def init(adminpw): 
120     ''' as from the roundupdb method initDB 
121  
122     Open the new database, and set up a bunch of attributes.
124     ''' 
125     dbdir = os.path.join(instance_config.DATABASE, 'files')
126     if not os.path.isdir(dbdir):
127         os.makedirs(dbdir)
129     db = open("admin")
130     db.clear()
132     pri = db.getclass('priority')
133     pri.create(name="fatal-bug", order="1")
134     pri.create(name="bug", order="2")
135     pri.create(name="usability", order="3")
136     pri.create(name="feature", order="4")
138     stat = db.getclass('status')
139     stat.create(name="unread", order="1")
140     stat.create(name="deferred", order="2")
141     stat.create(name="chatting", order="3")
142     stat.create(name="need-eg", order="4")
143     stat.create(name="in-progress", order="5")
144     stat.create(name="testing", order="6")
145     stat.create(name="done-cbb", order="7")
146     stat.create(name="resolved", order="8")
148     rate = db.getclass("rate")
149     rate.create(name='basic', order="1")
150     rate.create(name='premium', order="2")
151     rate.create(name='internal', order="3")
153     source = db.getclass("source")
154     source.create(name='phone', order="1")
155     source.create(name='e-mail', order="2")
156     source.create(name='internal', order="3")
157     source.create(name='internal-qa', order="4")
159     platform = db.getclass("platform")
160     platform.create(name='linux', order="1")
161     platform.create(name='windows', order="2")
162     platform.create(name='mac', order="3")
164     product = db.getclass("product")
165     product.create(name='Bizar Shop', order="1")
166     product.create(name='Bizar Shop Developer', order="2")
167     product.create(name='Bizar Shop Manual', order="3")
168     product.create(name='Bizar Shop Developer Manual', order="4")
170     user = db.getclass('user')
171     user.create(username="admin", password=adminpw, 
172                                   address=instance_config.ADMIN_EMAIL)
174     db.close()
177 # $Log: not supported by cvs2svn $
178 # Revision 1.11  2001/08/07 00:24:43  richard
179 # stupid typo
181 # Revision 1.10  2001/08/07 00:15:51  richard
182 # Added the copyright/license notice to (nearly) all files at request of
183 # Bizar Software.
185 # Revision 1.9  2001/08/02 06:38:17  richard
186 # Roundupdb now appends "mailing list" information to its messages which
187 # include the e-mail address and web interface address. Templates may
188 # override this in their db classes to include specific information (support
189 # instructions, etc).
191 # Revision 1.8  2001/07/30 01:26:59  richard
192 # Big changes:
193 #  . split off the support priority into its own class
194 #  . added "new support, new user" to the page head
195 #  . fixed the display options for the heading links
197 # Revision 1.7  2001/07/29 07:01:39  richard
198 # Added vim command to all source so that we don't get no steenkin' tabs :)
200 # Revision 1.6  2001/07/25 01:23:07  richard
201 # Added the Roundup spec to the new documentation directory.
203 # Revision 1.5  2001/07/23 23:20:35  richard
204 # forgot to remove the interfaces from the dbinit module ;)
206 # Revision 1.4  2001/07/23 08:45:28  richard
207 # ok, so now "./roundup-admin init" will ask questions in an attempt to get a
208 # workable instance_home set up :)
209 # _and_ anydbm has had its first test :)
211 # Revision 1.3  2001/07/23 07:14:41  richard
212 # Moved the database backends off into backends.
214 # Revision 1.2  2001/07/23 06:25:50  richard
215 # relfected the move to roundup/backends
217 # Revision 1.1  2001/07/23 04:33:21  anthonybaxter
218 # split __init__.py into 2. dbinit and instance_config.
220 # Revision 1.1  2001/07/23 03:50:46  anthonybaxter
221 # moved templates to proper location
223 # Revision 1.2  2001/07/22 12:09:32  richard
224 # Final commit of Grande Splite
227 # vim: set filetype=python ts=4 sw=4 et si