comparison roundup/templates/classic/dbinit.py @ 905:502a5ae11cc5

Very close now. The cgi and mailgw now use the new security API. The two templates have been migrated to that setup. Lots of unit tests. Still some issue in the web form for editing Roles assigned to users.
author Richard Jones <richard@users.sourceforge.net>
date Fri, 26 Jul 2002 08:27:00 +0000
parents bd6211d39328
children 23c9d4f86380
comparison
equal deleted inserted replaced
904:02763530b9e8 905:502a5ae11cc5
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 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" 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, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: dbinit.py,v 1.20 2002-07-17 12:39:10 gmcm Exp $ 18 # $Id: dbinit.py,v 1.21 2002-07-26 08:26:59 richard Exp $
19 19
20 import os 20 import os
21 21
22 import instance_config 22 import instance_config
23 from select_db import Database, Class, FileClass, IssueClass 23 from select_db import Database, Class, FileClass, IssueClass
54 query = Class(db, "query", 54 query = Class(db, "query",
55 klass=String(), name=String(), 55 klass=String(), name=String(),
56 url=String()) 56 url=String())
57 query.setkey("name") 57 query.setkey("name")
58 58
59 # Note: roles is a comma-separated string of Role names
59 user = Class(db, "user", 60 user = Class(db, "user",
60 username=String(), password=Password(), 61 username=String(), password=Password(),
61 address=String(), realname=String(), 62 address=String(), realname=String(),
62 phone=String(), organisation=String(), 63 phone=String(), organisation=String(),
63 alternate_addresses=String(), queries=Multilink("query")) 64 alternate_addresses=String(),
65 queries=Multilink('query'), roles=String())
64 user.setkey("username") 66 user.setkey("username")
65 67
66 # FileClass automatically gets these properties: 68 # FileClass automatically gets these properties:
67 # content = String() [saved to disk in <instance home>/db/files/] 69 # content = String() [saved to disk in <instance home>/db/files/]
68 # (it also gets the Class properties creation, activity and creator) 70 # (it also gets the Class properties creation, activity and creator)
83 # superseder = Multilink("issue") 85 # superseder = Multilink("issue")
84 # (it also gets the Class properties creation, activity and creator) 86 # (it also gets the Class properties creation, activity and creator)
85 issue = IssueClass(db, "issue", 87 issue = IssueClass(db, "issue",
86 assignedto=Link("user"), topic=Multilink("keyword"), 88 assignedto=Link("user"), topic=Multilink("keyword"),
87 priority=Link("priority"), status=Link("status")) 89 priority=Link("priority"), status=Link("status"))
90
91 #
92 # SECURITY SETTINGS
93 #
94 # new permissions for this schema
95 for cl in 'issue', 'file', 'msg':
96 db.security.addPermission(name="Edit", klass=cl,
97 description="User is allowed to edit "+cl)
98 db.security.addPermission(name="View", klass=cl,
99 description="User is allowed to access "+cl)
100
101 # Assign the appropriate permissions to the anonymous user's Anonymous
102 # Role. Choices here are:
103 # - Allow anonymous users to register through the web
104 p = db.security.getPermission('Web Registration')
105 db.security.addPermissionToRole('Anonymous', p)
106 # - Allow anonymous (new) users to register through the email gateway
107 p = db.security.getPermission('Email Registration')
108 db.security.addPermissionToRole('Anonymous', p)
109 # - Allow anonymous users access to the "issue" class of data
110 # Note: this also grants access to related information like files,
111 # messages, statuses etc that are linked to issues
112 #p = db.security.getPermission('View', 'issue')
113 #db.security.addPermissionToRole('Anonymous', p)
114 # - Allow anonymous users access to edit the "issue" class of data
115 # Note: this also grants access to create related information like
116 # files and messages etc that are linked to issues
117 #p = db.security.getPermission('Edit', 'issue')
118 #db.security.addPermissionToRole('Anonymous', p)
119
120 # Assign the access and edit permissions for issue, file and message
121 # to regular users now
122 for cl in 'issue', 'file', 'msg':
123 p = db.security.getPermission('View', cl)
124 db.security.addPermissionToRole('User', p)
125 p = db.security.getPermission('Edit', cl)
126 db.security.addPermissionToRole('User', p)
88 127
89 import detectors 128 import detectors
90 detectors.init(db) 129 detectors.init(db)
91 130
92 # schema is set up - run any post-initialisation 131 # schema is set up - run any post-initialisation
105 os.makedirs(dbdir) 144 os.makedirs(dbdir)
106 145
107 db = open("admin") 146 db = open("admin")
108 db.clear() 147 db.clear()
109 148
149 #
150 # INITIAL PRIORITY AND STATUS VALUES
151 #
110 pri = db.getclass('priority') 152 pri = db.getclass('priority')
111 pri.create(name="critical", order="1") 153 pri.create(name="critical", order="1")
112 pri.create(name="urgent", order="2") 154 pri.create(name="urgent", order="2")
113 pri.create(name="bug", order="3") 155 pri.create(name="bug", order="3")
114 pri.create(name="feature", order="4") 156 pri.create(name="feature", order="4")
122 stat.create(name="in-progress", order="5") 164 stat.create(name="in-progress", order="5")
123 stat.create(name="testing", order="6") 165 stat.create(name="testing", order="6")
124 stat.create(name="done-cbb", order="7") 166 stat.create(name="done-cbb", order="7")
125 stat.create(name="resolved", order="8") 167 stat.create(name="resolved", order="8")
126 168
169 # create the two default users
127 user = db.getclass('user') 170 user = db.getclass('user')
128 user.create(username="admin", password=adminpw, 171 user.create(username="admin", password=adminpw,
129 address=instance_config.ADMIN_EMAIL) 172 address=instance_config.ADMIN_EMAIL, roles='Admin')
173 user.create(username="anonymous", roles='Anonymous')
174
130 db.commit() 175 db.commit()
131 176
132 # 177 #
133 # $Log: not supported by cvs2svn $ 178 # $Log: not supported by cvs2svn $
179 # Revision 1.20 2002/07/17 12:39:10 gmcm
180 # Saving, running & editing queries.
181 #
134 # Revision 1.19 2002/07/14 02:05:54 richard 182 # Revision 1.19 2002/07/14 02:05:54 richard
135 # . all storage-specific code (ie. backend) is now implemented by the backends 183 # . all storage-specific code (ie. backend) is now implemented by the backends
136 # 184 #
137 # Revision 1.18 2002/07/09 03:02:53 richard 185 # Revision 1.18 2002/07/09 03:02:53 richard
138 # More indexer work: 186 # More indexer work:

Roundup Issue Tracker: http://roundup-tracker.org/