f870b490e70821bc53c9c23fb44ab41b3234f7c4
1 # $Id: dbinit.py,v 1.8 2001-07-30 01:26:59 richard Exp $
3 import os
5 import instance_config
6 from roundup import roundupdb
7 import select_db
8 from roundup.roundupdb import Class, FileClass
10 class Database(roundupdb.Database, select_db.Database):
11 ''' Creates a hybrid database from:
12 . the selected database back-end from select_db
13 . the roundup extensions from roundupdb
14 '''
15 pass
17 class IssueClass(roundupdb.IssueClass):
18 ''' issues need the email information
19 '''
20 ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
21 ADMIN_EMAIL = instance_config.ADMIN_EMAIL
22 MAILHOST = instance_config.MAILHOST
25 def open(name=None):
26 ''' as from the roundupdb method openDB
28 '''
29 from roundup.hyperdb import String, Date, Link, Multilink
31 # open the database
32 db = Database(instance_config.DATABASE, name)
34 # Now initialise the schema. Must do this each time.
35 pri = Class(db, "priority",
36 name=String(), order=String())
37 pri.setkey("name")
39 stat = Class(db, "status",
40 name=String(), order=String())
41 stat.setkey("name")
43 keywords = Class(db, "keyword",
44 name=String())
46 user = Class(db, "user",
47 username=String(), password=String(),
48 address=String(), realname=String(),
49 phone=String(), organisation=String())
50 user.setkey("username")
52 msg = FileClass(db, "msg",
53 author=Link("user"), recipients=Multilink("user"),
54 date=Date(), summary=String(),
55 files=Multilink("file"))
57 file = FileClass(db, "file",
58 name=String(), type=String())
60 # bugs and support calls etc
61 rate = Class(db, "rate",
62 name=String(), order=String())
63 rate.setkey("name")
65 source = Class(db, "source",
66 name=String(), order=String())
67 source.setkey("name")
69 platform = Class(db, "platform",
70 name=String(), order=String())
71 platform.setkey("name")
73 product = Class(db, "product",
74 name=String(), order=String())
75 product.setkey("name")
77 timelog = Class(db, "timelog",
78 date=Date(), time=String(),
79 performedby=Link("user"), description=String())
81 support = IssueClass(db, "support",
82 assignedto=Link("user"), status=Link("status"),
83 rate=Link("rate"), source=Link("source"),
84 product=Link("product"), platform=Multilink("platform"),
85 version=String(), timelog=Multilink("timelog"),
86 customername=String())
88 issue = IssueClass(db, "issue",
89 assignedto=Link("user"), priority=Link("priority"),
90 status=Link("status"), product=Link("product"),
91 platform=Multilink("platform"), version=String(),
92 supportcall=Multilink("support"))
94 import detectors
95 detectors.init(db)
97 return db
99 def init(adminpw):
100 ''' as from the roundupdb method initDB
102 Open the new database, and set up a bunch of attributes.
104 '''
105 dbdir = os.path.join(instance_config.DATABASE, 'files')
106 if not os.path.isdir(dbdir):
107 os.makedirs(dbdir)
109 db = open("admin")
110 db.clear()
112 pri = db.getclass('priority')
113 pri.create(name="fatal-bug", order="1")
114 pri.create(name="bug", order="2")
115 pri.create(name="usability", order="3")
116 pri.create(name="feature", order="4")
118 stat = db.getclass('status')
119 stat.create(name="unread", order="1")
120 stat.create(name="deferred", order="2")
121 stat.create(name="chatting", order="3")
122 stat.create(name="need-eg", order="4")
123 stat.create(name="in-progress", order="5")
124 stat.create(name="testing", order="6")
125 stat.create(name="done-cbb", order="7")
126 stat.create(name="resolved", order="8")
128 rate = db.getclass("rate")
129 rate.create(name='basic', order="1")
130 rate.create(name='premium', order="2")
131 rate.create(name='internal', order="3")
133 source = db.getclass("source")
134 source.create(name='phone', order="1")
135 source.create(name='e-mail', order="2")
136 source.create(name='internal', order="3")
137 source.create(name='internal-qa', order="4")
139 platform = db.getclass("platform")
140 platform.create(name='linux', order="1")
141 platform.create(name='windows', order="2")
142 platform.create(name='mac', order="3")
144 product = db.getclass("product")
145 product.create(name='Bizar Shop', order="1")
146 product.create(name='Bizar Shop Developer', order="2")
147 product.create(name='Bizar Shop Manual', order="3")
148 product.create(name='Bizar Shop Developer Manual', order="4")
150 user = db.getclass('user')
151 user.create(username="admin", password=adminpw,
152 address=instance_config.ADMIN_EMAIL)
154 db.close()
156 #
157 # $Log: not supported by cvs2svn $
158 # Revision 1.7 2001/07/29 07:01:39 richard
159 # Added vim command to all source so that we don't get no steenkin' tabs :)
160 #
161 # Revision 1.6 2001/07/25 01:23:07 richard
162 # Added the Roundup spec to the new documentation directory.
163 #
164 # Revision 1.5 2001/07/23 23:20:35 richard
165 # forgot to remove the interfaces from the dbinit module ;)
166 #
167 # Revision 1.4 2001/07/23 08:45:28 richard
168 # ok, so now "./roundup-admin init" will ask questions in an attempt to get a
169 # workable instance_home set up :)
170 # _and_ anydbm has had its first test :)
171 #
172 # Revision 1.3 2001/07/23 07:14:41 richard
173 # Moved the database backends off into backends.
174 #
175 # Revision 1.2 2001/07/23 06:25:50 richard
176 # relfected the move to roundup/backends
177 #
178 # Revision 1.1 2001/07/23 04:33:21 anthonybaxter
179 # split __init__.py into 2. dbinit and instance_config.
180 #
181 # Revision 1.1 2001/07/23 03:50:46 anthonybaxter
182 # moved templates to proper location
183 #
184 # Revision 1.2 2001/07/22 12:09:32 richard
185 # Final commit of Grande Splite
186 #
187 #
188 # vim: set filetype=python ts=4 sw=4 et si