Code

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