Code

3333e55ca4aa7ba3e0fe4e2851a695102f982f4d
[roundup.git] / share / roundup / templates / minimal / schema.py
1 #
2 # TRACKER SCHEMA
3 #
5 # Class automatically gets these properties:
6 #   creation = Date()
7 #   activity = Date()
8 #   creator = Link('user')
9 #   actor = Link('user')
11 # The "Minimal" template gets only one class, the required "user"
12 # class. That's it. And even that has the bare minimum of properties.
14 # Note: roles is a comma-separated string of Role names
15 user = Class(db, "user", username=String(), password=Password(),
16     address=String(), alternate_addresses=String(), roles=String())
17 user.setkey("username")
18 #
19 # TRACKER SECURITY SETTINGS
20 #
21 # See the configuration and customisation document for information
22 # about security setup.
24 #
25 # REGULAR USERS
26 #
27 # Give the regular users access to the web and email interface
28 db.security.addPermissionToRole('User', 'Web Access')
29 db.security.addPermissionToRole('User', 'Email Access')
31 # May users view other user information?
32 # Comment these lines out if you don't want them to
33 db.security.addPermissionToRole('User', 'View', 'user')
35 # Users should be able to edit their own details -- this permission is
36 # limited to only the situation where the Viewed or Edited item is their own.
37 def own_record(db, userid, itemid):
38     '''Determine whether the userid matches the item being accessed.'''
39     return userid == itemid
40 p = db.security.addPermission(name='View', klass='user', check=own_record,
41     description="User is allowed to view their own user details")
42 db.security.addPermissionToRole('User', p)
43 p = db.security.addPermission(name='Edit', klass='user', check=own_record,
44     description="User is allowed to edit their own user details")
45 db.security.addPermissionToRole('User', p)
47 #
48 # ANONYMOUS USER PERMISSIONS
49 #
50 # Let anonymous users access the web interface. Note that almost all
51 # trackers will need this Permission. The only situation where it's not
52 # required is in a tracker that uses an HTTP Basic Authenticated front-end.
53 db.security.addPermissionToRole('Anonymous', 'Web Access')
55 # Let anonymous users access the email interface (note that this implies
56 # that they will be registered automatically, hence they will need the
57 # "Create" user Permission below)
58 db.security.addPermissionToRole('Anonymous', 'Email Access')
60 # Assign the appropriate permissions to the anonymous user's
61 # Anonymous Role. Choices here are:
62 # - Allow anonymous users to register
63 db.security.addPermissionToRole('Anonymous', 'Register', 'user')
65 # vim: set et sts=4 sw=4 :