Mercurial > p > roundup > code
comparison website/issues/schema.py @ 4024:c2d0d3e9099d website
svn repository setup
| author | Stefan Seefeld <stefan@users.sourceforge.net> |
|---|---|
| date | Fri, 06 Feb 2009 13:16:31 +0000 |
| parents | |
| children | a4dc087f3088 |
comparison
equal
deleted
inserted
replaced
| 4023:86c38b5aed66 | 4024:c2d0d3e9099d |
|---|---|
| 1 | |
| 2 # | |
| 3 # TRACKER SCHEMA | |
| 4 # | |
| 5 | |
| 6 # Class automatically gets these properties: | |
| 7 # creation = Date() | |
| 8 # activity = Date() | |
| 9 # creator = Link('user') | |
| 10 # actor = Link('user') | |
| 11 | |
| 12 # Issue Type | |
| 13 issue_type = Class(db, 'issue_type', | |
| 14 name=String(), | |
| 15 description=String(), | |
| 16 order=Number()) | |
| 17 issue_type.setkey('name') | |
| 18 | |
| 19 # Component | |
| 20 component = Class(db, 'component', | |
| 21 name=String(), | |
| 22 description=String(), | |
| 23 order=Number(), | |
| 24 assign_to=Link('user')) | |
| 25 component.setkey('name') | |
| 26 | |
| 27 # Version | |
| 28 version = Class(db, 'version', | |
| 29 name=String(), | |
| 30 description=String(), | |
| 31 order=Number()) | |
| 32 version.setkey('name') | |
| 33 | |
| 34 # Severity | |
| 35 severity = Class(db, 'severity', | |
| 36 name=String(), | |
| 37 description=String(), | |
| 38 order=Number()) | |
| 39 severity.setkey('name') | |
| 40 | |
| 41 # Priority | |
| 42 priority = Class(db, 'priority', | |
| 43 name=String(), | |
| 44 description=String(), | |
| 45 order=Number()) | |
| 46 priority.setkey('name') | |
| 47 | |
| 48 # Status | |
| 49 status = Class(db, "status", | |
| 50 name=String(), | |
| 51 description=String(), | |
| 52 order=Number()) | |
| 53 status.setkey("name") | |
| 54 | |
| 55 # Resolution | |
| 56 resolution = Class(db, "resolution", | |
| 57 name=String(), | |
| 58 description=String(), | |
| 59 order=Number()) | |
| 60 resolution.setkey('name') | |
| 61 | |
| 62 # Keyword | |
| 63 keyword = Class(db, "keyword", | |
| 64 name=String(), | |
| 65 description=String()) | |
| 66 keyword.setkey("name") | |
| 67 | |
| 68 | |
| 69 # User-defined saved searches | |
| 70 query = Class(db, "query", | |
| 71 klass=String(), | |
| 72 name=String(), | |
| 73 url=String(), | |
| 74 private_for=Link('user')) | |
| 75 | |
| 76 # add any additional database schema configuration here | |
| 77 | |
| 78 user = Class(db, "user", | |
| 79 username=String(), | |
| 80 password=Password(), | |
| 81 address=String(), | |
| 82 realname=String(), | |
| 83 phone=String(), | |
| 84 organisation=String(), | |
| 85 alternate_addresses=String(), | |
| 86 queries=Multilink('query'), | |
| 87 roles=String(), # comma-separated string of Role names | |
| 88 timezone=String()) | |
| 89 user.setkey("username") | |
| 90 | |
| 91 # FileClass automatically gets this property in addition to the Class ones: | |
| 92 # content = String() [saved to disk in <tracker home>/db/files/] | |
| 93 # type = String() [MIME type of the content, default 'text/plain'] | |
| 94 msg = FileClass(db, "msg", | |
| 95 author=Link("user", do_journal='no'), | |
| 96 recipients=Multilink("user", do_journal='no'), | |
| 97 date=Date(), | |
| 98 summary=String(), | |
| 99 files=Multilink("file"), | |
| 100 messageid=String(), | |
| 101 inreplyto=String(), | |
| 102 spambayes_score=Number(), | |
| 103 spambayes_misclassified=Boolean(),) | |
| 104 | |
| 105 file = FileClass(db, "file", | |
| 106 name=String(), | |
| 107 description=String(indexme='yes'), | |
| 108 spambayes_score=Number(), | |
| 109 spambayes_misclassified=Boolean(),) | |
| 110 | |
| 111 # IssueClass automatically gets these properties in addition to the Class ones: | |
| 112 # title = String() | |
| 113 # messages = Multilink("msg") | |
| 114 # files = Multilink("file") | |
| 115 # nosy = Multilink("user") | |
| 116 # superseder = Multilink("issue") | |
| 117 issue = IssueClass(db, "issue", | |
| 118 type=Link('issue_type'), | |
| 119 components=Multilink('component'), | |
| 120 versions=Multilink('version'), | |
| 121 severity=Link('severity'), | |
| 122 priority=Link('priority'), | |
| 123 dependencies=Multilink('issue'), | |
| 124 assignee=Link('user'), | |
| 125 status=Link('status'), | |
| 126 resolution=Link('resolution'), | |
| 127 superseder=Link('issue'), | |
| 128 keywords=Multilink("keyword")) | |
| 129 | |
| 130 # | |
| 131 # TRACKER SECURITY SETTINGS | |
| 132 # | |
| 133 # See the configuration and customisation document for information | |
| 134 # about security setup. | |
| 135 | |
| 136 db.security.addRole(name='Developer', description='A developer') | |
| 137 db.security.addRole(name='Coordinator', description='A coordinator') | |
| 138 | |
| 139 db.security.addPermission(name="SB: May Classify") | |
| 140 db.security.addPermission(name="SB: May Report Misclassified") | |
| 141 | |
| 142 # | |
| 143 # REGULAR USERS | |
| 144 # | |
| 145 # Give the regular users access to the web and email interface | |
| 146 for r in 'User', 'Developer', 'Coordinator': | |
| 147 db.security.addPermissionToRole(r, 'Web Access') | |
| 148 db.security.addPermissionToRole(r, 'Email Access') | |
| 149 | |
| 150 ########################## | |
| 151 # User permissions | |
| 152 ########################## | |
| 153 | |
| 154 for cl in ('issue_type', 'severity', 'component', | |
| 155 'version', 'priority', 'status', 'resolution', | |
| 156 'issue', 'keyword'): | |
| 157 db.security.addPermissionToRole('User', 'View', cl) | |
| 158 db.security.addPermissionToRole('Anonymous', 'View', cl) | |
| 159 | |
| 160 class may_view_spam: | |
| 161 def __init__(self, klassname): | |
| 162 self.klassname = klassname | |
| 163 | |
| 164 def __call__(self, db, userid, itemid): | |
| 165 cutoff_score = float(db.config.detectors['SPAMBAYES_SPAM_CUTOFF']) | |
| 166 klass = db.getclass(self.klassname) | |
| 167 | |
| 168 try: | |
| 169 score = klass.get(itemid, 'spambayes_score') | |
| 170 except KeyError: | |
| 171 return True | |
| 172 | |
| 173 if score > cutoff_score: | |
| 174 return False | |
| 175 | |
| 176 return True | |
| 177 | |
| 178 for cl in ('file', 'msg'): | |
| 179 p = db.security.addPermission(name='View', klass=cl, | |
| 180 description="allowed to see metadata object regardless of spam status", | |
| 181 properties=('creation', 'activity', | |
| 182 'creator', 'actor', | |
| 183 'name', 'spambayes_score', | |
| 184 'spambayes_misclassified', | |
| 185 'author', 'recipients', | |
| 186 'date', 'files', 'messageid', | |
| 187 'inreplyto', 'type', | |
| 188 'description', | |
| 189 )) | |
| 190 | |
| 191 db.security.addPermissionToRole('Anonymous', p) | |
| 192 db.security.addPermissionToRole('User', p) | |
| 193 | |
| 194 db.security.addPermissionToRole('User', 'Create', cl) | |
| 195 | |
| 196 p = db.security.addPermission(name='View', klass=cl, | |
| 197 description="Allowed to see content of object regardless of spam status", | |
| 198 properties = ('content', 'summary')) | |
| 199 | |
| 200 db.security.addPermissionToRole('User', p) | |
| 201 | |
| 202 #spamcheck = db.security.addPermission(name='View', klass=cl, | |
| 203 # description="allowed to see content if not spam", | |
| 204 # properties=('content', 'summary'), | |
| 205 # check=may_view_spam(cl)) | |
| 206 | |
| 207 #db.security.addPermissionToRole('Anonymous', spamcheck) | |
| 208 | |
| 209 def may_edit_file(db, userid, itemid): | |
| 210 return userid == db.file.get(itemid, "creator") | |
| 211 p = db.security.addPermission(name='Edit', klass='file', check=may_edit_file, | |
| 212 description="User is allowed to remove their own files") | |
| 213 db.security.addPermissionToRole('User', p) | |
| 214 | |
| 215 p = db.security.addPermission(name='Create', klass='issue', | |
| 216 properties=('title', 'type', | |
| 217 'components', 'versions', | |
| 218 'severity', | |
| 219 'messages', 'files', 'nosy'), | |
| 220 description='User can report and discuss issues') | |
| 221 db.security.addPermissionToRole('User', p) | |
| 222 | |
| 223 p = db.security.addPermission(name='Edit', klass='issue', | |
| 224 properties=('title', 'type', | |
| 225 'components', 'versions', | |
| 226 'severity', | |
| 227 'messages', 'files', 'nosy'), | |
| 228 description='User can report and discuss issues') | |
| 229 db.security.addPermissionToRole('User', p) | |
| 230 | |
| 231 #db.security.addPermissionToRole('User', 'SB: May Report Misclassified') | |
| 232 | |
| 233 | |
| 234 | |
| 235 ########################## | |
| 236 # Developer permissions | |
| 237 ########################## | |
| 238 for cl in ('issue_type', 'severity', 'component', | |
| 239 'version', 'priority', 'status', 'resolution', | |
| 240 'issue', 'file', 'msg', 'keyword'): | |
| 241 db.security.addPermissionToRole('Developer', 'View', cl) | |
| 242 | |
| 243 for cl in ('issue', 'file', 'msg', 'keyword'): | |
| 244 db.security.addPermissionToRole('Developer', 'Edit', cl) | |
| 245 db.security.addPermissionToRole('Developer', 'Create', cl) | |
| 246 | |
| 247 | |
| 248 ########################## | |
| 249 # Coordinator permissions | |
| 250 ########################## | |
| 251 for cl in ('issue_type', 'severity', 'component', | |
| 252 'version', 'priority', 'status', 'resolution', 'issue', 'file', 'msg'): | |
| 253 db.security.addPermissionToRole('Coordinator', 'View', cl) | |
| 254 db.security.addPermissionToRole('Coordinator', 'Edit', cl) | |
| 255 db.security.addPermissionToRole('Coordinator', 'Create', cl) | |
| 256 | |
| 257 db.security.addPermissionToRole('Coordinator', 'SB: May Classify') | |
| 258 | |
| 259 # May users view other user information? Comment these lines out | |
| 260 # if you don't want them to | |
| 261 db.security.addPermissionToRole('User', 'View', 'user') | |
| 262 db.security.addPermissionToRole('Developer', 'View', 'user') | |
| 263 db.security.addPermissionToRole('Coordinator', 'View', 'user') | |
| 264 | |
| 265 # Allow Coordinator to edit any user, including their roles. | |
| 266 db.security.addPermissionToRole('Coordinator', 'Edit', 'user') | |
| 267 db.security.addPermissionToRole('Coordinator', 'Web Roles') | |
| 268 | |
| 269 # Users should be able to edit their own details -- this permission is | |
| 270 # limited to only the situation where the Viewed or Edited item is their own. | |
| 271 def own_record(db, userid, itemid): | |
| 272 '''Determine whether the userid matches the item being accessed.''' | |
| 273 return userid == itemid | |
| 274 p = db.security.addPermission(name='View', klass='user', check=own_record, | |
| 275 description="User is allowed to view their own user details") | |
| 276 for r in 'User', 'Developer', 'Coordinator': | |
| 277 db.security.addPermissionToRole(r, p) | |
| 278 p = db.security.addPermission(name='Edit', klass='user', check=own_record, | |
| 279 description="User is allowed to edit their own user details", | |
| 280 properties=('username', 'password', | |
| 281 'address', 'realname', | |
| 282 'phone', 'organization', | |
| 283 'alternate_addresses', | |
| 284 'queries', | |
| 285 'timezone')) # Note: 'roles' excluded - users should not be able to edit their own roles. | |
| 286 for r in 'User', 'Developer': | |
| 287 db.security.addPermissionToRole(r, p) | |
| 288 | |
| 289 # Users should be able to edit and view their own queries. They should also | |
| 290 # be able to view any marked as not private. They should not be able to | |
| 291 # edit others' queries, even if they're not private | |
| 292 def view_query(db, userid, itemid): | |
| 293 private_for = db.query.get(itemid, 'private_for') | |
| 294 if not private_for: return True | |
| 295 return userid == private_for | |
| 296 def edit_query(db, userid, itemid): | |
| 297 return userid == db.query.get(itemid, 'creator') | |
| 298 p = db.security.addPermission(name='View', klass='query', check=view_query, | |
| 299 description="User is allowed to view their own and public queries") | |
| 300 for r in 'User', 'Developer', 'Coordinator': | |
| 301 db.security.addPermissionToRole(r, p) | |
| 302 p = db.security.addPermission(name='Edit', klass='query', check=edit_query, | |
| 303 description="User is allowed to edit their queries") | |
| 304 for r in 'User', 'Developer', 'Coordinator': | |
| 305 db.security.addPermissionToRole(r, p) | |
| 306 p = db.security.addPermission(name='Create', klass='query', | |
| 307 description="User is allowed to create queries") | |
| 308 for r in 'User', 'Developer', 'Coordinator': | |
| 309 db.security.addPermissionToRole(r, p) | |
| 310 | |
| 311 | |
| 312 # | |
| 313 # ANONYMOUS USER PERMISSIONS | |
| 314 # | |
| 315 # Let anonymous users access the web interface. Note that almost all | |
| 316 # trackers will need this Permission. The only situation where it's not | |
| 317 # required is in a tracker that uses an HTTP Basic Authenticated front-end. | |
| 318 db.security.addPermissionToRole('Anonymous', 'Web Access') | |
| 319 | |
| 320 # Let anonymous users access the email interface (note that this implies | |
| 321 # that they will be registered automatically, hence they will need the | |
| 322 # "Create" user Permission below) | |
| 323 # This is disabled by default to stop spam from auto-registering users on | |
| 324 # public trackers. | |
| 325 #db.security.addPermissionToRole('Anonymous', 'Email Access') | |
| 326 | |
| 327 # Assign the appropriate permissions to the anonymous user's Anonymous | |
| 328 # Role. Choices here are: | |
| 329 # - Allow anonymous users to register | |
| 330 db.security.addPermissionToRole('Anonymous', 'Create', 'user') | |
| 331 | |
| 332 # Allow anonymous users access to view issues (and the related, linked | |
| 333 # information). | |
| 334 | |
| 335 for cl in 'issue', 'severity', 'status', 'resolution', 'msg', 'file': | |
| 336 db.security.addPermissionToRole('Anonymous', 'View', cl) | |
| 337 | |
| 338 # [OPTIONAL] | |
| 339 # Allow anonymous users access to create or edit "issue" items (and the | |
| 340 # related file and message items) | |
| 341 #for cl in 'issue', 'file', 'msg': | |
| 342 # db.security.addPermissionToRole('Anonymous', 'Create', cl) | |
| 343 # db.security.addPermissionToRole('Anonymous', 'Edit', cl) | |
| 344 | |
| 345 | |
| 346 # vim: set filetype=python sts=4 sw=4 et si : | |
| 347 |
