Mercurial > p > roundup > code
annotate roundup/templates/classic/dbinit.py @ 1142:eac669d738d1 0.5.0-b2
doc
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 13 Sep 2002 04:57:38 +0000 |
| parents | 7e193bbda38e |
| children | 7441653e5330 |
| rev | line source |
|---|---|
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
1 # |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/) |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
3 # This module is free software, and you may redistribute it and/or modify |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
4 # under the same terms as Python, so long as this copyright message and |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
5 # disclaimer are retained in their original form. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
6 # |
| 214 | 7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR |
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
10 # POSSIBILITY OF SUCH DAMAGE. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
11 # |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
188
diff
changeset
|
17 # |
|
1136
7e193bbda38e
added generic item editing
Richard Jones <richard@users.sourceforge.net>
parents:
1113
diff
changeset
|
18 # $Id: dbinit.py,v 1.29 2002-09-13 03:31:18 richard Exp $ |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 import os |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 |
|
1085
04a6b3bfbf23
instance_config -> config, and other related cleanups
Richard Jones <richard@users.sourceforge.net>
parents:
1007
diff
changeset
|
22 import config |
|
858
2dd862af72ee
all storage-specific code (ie. backend) is now implemented by the backends
Richard Jones <richard@users.sourceforge.net>
parents:
825
diff
changeset
|
23 from select_db import Database, Class, FileClass, IssueClass |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 def open(name=None): |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 ''' as from the roundupdb method openDB |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 ''' |
|
270
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
28 from roundup.hyperdb import String, Password, Date, Link, Multilink |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 # open the database |
|
1085
04a6b3bfbf23
instance_config -> config, and other related cleanups
Richard Jones <richard@users.sourceforge.net>
parents:
1007
diff
changeset
|
31 db = Database(config, name) |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
32 |
|
748
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
33 # |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
34 # Now initialise the schema. Must do this each time the database is |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
35 # opened. |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
36 # |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
37 |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
38 # Class automatically gets these properties: |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
39 # creation = Date() |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
40 # activity = Date() |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
41 # creator = Link('user') |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 pri = Class(db, "priority", |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 name=String(), order=String()) |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 pri.setkey("name") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
45 |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
46 stat = Class(db, "status", |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 name=String(), order=String()) |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 stat.setkey("name") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
49 |
|
60
e9735680d5b3
Oops - accidentally duped the keywords class
Richard Jones <richard@users.sourceforge.net>
parents:
57
diff
changeset
|
50 keyword = Class(db, "keyword", |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
51 name=String()) |
|
60
e9735680d5b3
Oops - accidentally duped the keywords class
Richard Jones <richard@users.sourceforge.net>
parents:
57
diff
changeset
|
52 keyword.setkey("name") |
|
872
bd6211d39328
Saving, running & editing queries.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
858
diff
changeset
|
53 |
|
bd6211d39328
Saving, running & editing queries.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
858
diff
changeset
|
54 query = Class(db, "query", |
|
bd6211d39328
Saving, running & editing queries.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
858
diff
changeset
|
55 klass=String(), name=String(), |
|
bd6211d39328
Saving, running & editing queries.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
858
diff
changeset
|
56 url=String()) |
|
bd6211d39328
Saving, running & editing queries.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
858
diff
changeset
|
57 query.setkey("name") |
|
bd6211d39328
Saving, running & editing queries.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
858
diff
changeset
|
58 |
|
905
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
59 # Note: roles is a comma-separated string of Role names |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
60 user = Class(db, "user", |
|
270
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
61 username=String(), password=Password(), |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
62 address=String(), realname=String(), |
|
617
edd210915e64
Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
63 phone=String(), organisation=String(), |
|
905
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
64 alternate_addresses=String(), |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
65 queries=Multilink('query'), roles=String()) |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
66 user.setkey("username") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
67 |
|
748
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
68 # FileClass automatically gets these properties: |
|
1085
04a6b3bfbf23
instance_config -> config, and other related cleanups
Richard Jones <richard@users.sourceforge.net>
parents:
1007
diff
changeset
|
69 # content = String() [saved to disk in <tracker home>/db/files/] |
|
748
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
70 # (it also gets the Class properties creation, activity and creator) |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
71 msg = FileClass(db, "msg", |
|
1007
fec6af48558b
don't journal author and recipient link events by default
Richard Jones <richard@users.sourceforge.net>
parents:
1002
diff
changeset
|
72 author=Link("user", do_journal='no'), |
|
fec6af48558b
don't journal author and recipient link events by default
Richard Jones <richard@users.sourceforge.net>
parents:
1002
diff
changeset
|
73 recipients=Multilink("user", do_journal='no'), |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
74 date=Date(), summary=String(), |
|
475
a1a44636bace
Fix breakage caused by transaction changes.
Richard Jones <richard@users.sourceforge.net>
parents:
431
diff
changeset
|
75 files=Multilink("file"), |
|
a1a44636bace
Fix breakage caused by transaction changes.
Richard Jones <richard@users.sourceforge.net>
parents:
431
diff
changeset
|
76 messageid=String(), inreplyto=String()) |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
77 |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
78 file = FileClass(db, "file", |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
79 name=String(), type=String()) |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
80 |
|
748
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
81 # IssueClass automatically gets these properties: |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
82 # title = String() |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
83 # messages = Multilink("msg") |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
84 # files = Multilink("file") |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
85 # nosy = Multilink("user") |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
86 # superseder = Multilink("issue") |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
87 # (it also gets the Class properties creation, activity and creator) |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
88 issue = IssueClass(db, "issue", |
|
60
e9735680d5b3
Oops - accidentally duped the keywords class
Richard Jones <richard@users.sourceforge.net>
parents:
57
diff
changeset
|
89 assignedto=Link("user"), topic=Multilink("keyword"), |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
90 priority=Link("priority"), status=Link("status")) |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
91 |
|
905
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
92 # |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
93 # SECURITY SETTINGS |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
94 # |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
95 # new permissions for this schema |
|
1136
7e193bbda38e
added generic item editing
Richard Jones <richard@users.sourceforge.net>
parents:
1113
diff
changeset
|
96 for cl in 'issue', 'file', 'msg', 'user', 'query', 'keyword': |
|
905
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
97 db.security.addPermission(name="Edit", klass=cl, |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
98 description="User is allowed to edit "+cl) |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
99 db.security.addPermission(name="View", klass=cl, |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
100 description="User is allowed to access "+cl) |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
101 |
|
928
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
102 # Assign the access and edit permissions for issue, file and message |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
103 # to regular users now |
|
1136
7e193bbda38e
added generic item editing
Richard Jones <richard@users.sourceforge.net>
parents:
1113
diff
changeset
|
104 for cl in 'issue', 'file', 'msg', 'query', 'keyword': |
|
928
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
105 p = db.security.getPermission('View', cl) |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
106 db.security.addPermissionToRole('User', p) |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
107 p = db.security.getPermission('Edit', cl) |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
108 db.security.addPermissionToRole('User', p) |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
109 # and give the regular users access to the web and email interface |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
110 p = db.security.getPermission('Web Access') |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
111 db.security.addPermissionToRole('User', p) |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
112 p = db.security.getPermission('Email Access') |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
113 db.security.addPermissionToRole('User', p) |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
114 |
| 1002 | 115 # May users view other user information? Comment these lines out |
| 116 # if you don't want them to | |
| 117 p = db.security.getPermission('View', 'user') | |
| 118 db.security.addPermissionToRole('User', p) | |
| 119 | |
|
905
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
120 # Assign the appropriate permissions to the anonymous user's Anonymous |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
121 # Role. Choices here are: |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
122 # - Allow anonymous users to register through the web |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
123 p = db.security.getPermission('Web Registration') |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
124 db.security.addPermissionToRole('Anonymous', p) |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
125 # - Allow anonymous (new) users to register through the email gateway |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
126 p = db.security.getPermission('Email Registration') |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
127 db.security.addPermissionToRole('Anonymous', p) |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
128 # - Allow anonymous users access to the "issue" class of data |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
129 # Note: this also grants access to related information like files, |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
130 # messages, statuses etc that are linked to issues |
|
1105
62485452f514
anonymous may view by default
Richard Jones <richard@users.sourceforge.net>
parents:
1085
diff
changeset
|
131 p = db.security.getPermission('View', 'issue') |
|
62485452f514
anonymous may view by default
Richard Jones <richard@users.sourceforge.net>
parents:
1085
diff
changeset
|
132 db.security.addPermissionToRole('Anonymous', p) |
|
905
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
133 # - Allow anonymous users access to edit the "issue" class of data |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
134 # Note: this also grants access to create related information like |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
135 # files and messages etc that are linked to issues |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
136 #p = db.security.getPermission('Edit', 'issue') |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
137 #db.security.addPermissionToRole('Anonymous', p) |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
138 |
|
928
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
139 # oh, g'wan, let anonymous access the web interface too |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
140 p = db.security.getPermission('Web Access') |
|
23c9d4f86380
Added the web access and email access permissions..
Richard Jones <richard@users.sourceforge.net>
parents:
905
diff
changeset
|
141 db.security.addPermissionToRole('Anonymous', p) |
|
905
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
142 |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
143 import detectors |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
144 detectors.init(db) |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
145 |
|
825
0779ea9f1f18
More indexer work:
Richard Jones <richard@users.sourceforge.net>
parents:
748
diff
changeset
|
146 # schema is set up - run any post-initialisation |
|
0779ea9f1f18
More indexer work:
Richard Jones <richard@users.sourceforge.net>
parents:
748
diff
changeset
|
147 db.post_init() |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
148 return db |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
149 |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
150 def init(adminpw): |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
151 ''' as from the roundupdb method initDB |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
152 |
|
748
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
153 Open the new database, and add new nodes - used for initialisation. You |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
154 can edit this before running the "roundup-admin initialise" command to |
|
2e70123bbf5a
Added commentage to the dbinit files to help people with their customisation.
Richard Jones <richard@users.sourceforge.net>
parents:
619
diff
changeset
|
155 change the initial database entries. |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
156 ''' |
|
1085
04a6b3bfbf23
instance_config -> config, and other related cleanups
Richard Jones <richard@users.sourceforge.net>
parents:
1007
diff
changeset
|
157 dbdir = os.path.join(config.DATABASE, 'files') |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
158 if not os.path.isdir(dbdir): |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
159 os.makedirs(dbdir) |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
160 |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
161 db = open("admin") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
162 db.clear() |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
163 |
|
905
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
164 # |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
165 # INITIAL PRIORITY AND STATUS VALUES |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
166 # |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
167 pri = db.getclass('priority') |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
168 pri.create(name="critical", order="1") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
169 pri.create(name="urgent", order="2") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
170 pri.create(name="bug", order="3") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
171 pri.create(name="feature", order="4") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
172 pri.create(name="wish", order="5") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
173 |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
174 stat = db.getclass('status') |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
175 stat.create(name="unread", order="1") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
176 stat.create(name="deferred", order="2") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
177 stat.create(name="chatting", order="3") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
178 stat.create(name="need-eg", order="4") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
179 stat.create(name="in-progress", order="5") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
180 stat.create(name="testing", order="6") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
181 stat.create(name="done-cbb", order="7") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
182 stat.create(name="resolved", order="8") |
|
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
183 |
|
905
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
184 # create the two default users |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
185 user = db.getclass('user') |
|
905
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
186 user.create(username="admin", password=adminpw, |
|
1085
04a6b3bfbf23
instance_config -> config, and other related cleanups
Richard Jones <richard@users.sourceforge.net>
parents:
1007
diff
changeset
|
187 address=config.ADMIN_EMAIL, roles='Admin') |
|
905
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
188 user.create(username="anonymous", roles='Anonymous') |
|
502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents:
872
diff
changeset
|
189 |
|
430
350685601f37
Database transactions.
Richard Jones <richard@users.sourceforge.net>
parents:
411
diff
changeset
|
190 db.commit() |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
191 |
|
127
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
68
diff
changeset
|
192 # vim: set filetype=python ts=4 sw=4 et si |
|
57
6ff85bc2dd56
Adding the classic template
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
193 |
