Skip to content

Commit f84dec3

Browse files
committed
chore: format schema.pys in templates so ruff is ok.
Also makes comparing them easier.
1 parent e49407d commit f84dec3

File tree

5 files changed

+54
-19
lines changed

5 files changed

+54
-19
lines changed

share/roundup/templates/classic/schema.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,19 @@
103103

104104
# May users view other user information? Comment these lines out
105105
# if you don't want them to
106-
p = db.security.addPermission(name='View', klass='user',
106+
p = db.security.addPermission(name='View', klass='user',
107107
properties=('id', 'organisation', 'phone', 'realname', 'timezone',
108108
'username'))
109109
db.security.addPermissionToRole('User', p)
110110

111+
111112
# Users should be able to edit their own details -- this permission is
112113
# limited to only the situation where the Viewed or Edited item is their own.
113114
def own_record(db, userid, itemid):
114115
'''Determine whether the userid matches the item being accessed.'''
115116
return userid == itemid
117+
118+
116119
p = db.security.addPermission(name='View', klass='user', check=own_record,
117120
description="User is allowed to view their own user details")
118121
db.security.addPermissionToRole('User', p)
@@ -122,15 +125,20 @@ def own_record(db, userid, itemid):
122125
description="User is allowed to edit their own user details")
123126
db.security.addPermissionToRole('User', p)
124127

128+
125129
# Users should be able to edit and view their own queries. They should also
126130
# be able to view any marked as not private. They should not be able to
127131
# edit others' queries, even if they're not private
128132
def view_query(db, userid, itemid):
129133
private_for = db.query.get(itemid, 'private_for')
130134
if not private_for: return True
131135
return userid == private_for
136+
137+
132138
def edit_query(db, userid, itemid):
133139
return userid == db.query.get(itemid, 'creator')
140+
141+
134142
p = db.security.addPermission(name='View', klass='query', check=view_query,
135143
description="User is allowed to view their own and public queries")
136144
db.security.addPermissionToRole('User', p)
@@ -181,7 +189,7 @@ def edit_query(db, userid, itemid):
181189
# anonymous, you should remove this entry as it can be used to perform
182190
# a username guessing attack against a roundup install.
183191
p = db.security.addPermission(name='Search', klass='user')
184-
db.security.addPermissionToRole ('Anonymous', p)
192+
db.security.addPermissionToRole('Anonymous', p)
185193

186194
# [OPTIONAL]
187195
# Allow anonymous users access to create or edit "issue" items (and the

share/roundup/templates/devel/schema.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
revision=String())
2828

2929

30-
3130
# Component
3231
component = Class(db, 'component',
3332
name=String(),
@@ -76,7 +75,7 @@
7675
name=String(),
7776
description=String())
7877
keyword.setkey("name")
79-
78+
8079

8180
# User-defined saved searches
8281
query = Class(db, "query",
@@ -209,7 +208,7 @@
209208
db.security.addPermissionToRole(r, 'Email Access')
210209
db.security.addPermissionToRole(r, 'Rest Access')
211210
db.security.addPermissionToRole(r, 'Xmlrpc Access')
212-
211+
213212
##########################
214213
# User permissions
215214
##########################
@@ -225,11 +224,12 @@
225224
'version', 'priority', 'status', 'resolution',
226225
'bug_type', 'bug', 'file', 'msg'):
227226
db.security.addPermissionToRole('User', 'Create', cl)
228-
227+
229228

230229
def may_edit_file(db, userid, itemid):
231230
return userid == db.file.get(itemid, "creator")
232231

232+
233233
p = db.security.addPermission(name='Edit', klass='file', check=may_edit_file,
234234
description="User is allowed to remove their own files")
235235
db.security.addPermissionToRole('User', p)
@@ -297,7 +297,7 @@ def may_edit_file(db, userid, itemid):
297297

298298
# May users view other user information? Comment these lines out
299299
# if you don't want them to
300-
p = db.security.addPermission(name='View', klass='user',
300+
p = db.security.addPermission(name='View', klass='user',
301301
properties=('id', 'organisation', 'phone', 'realname', 'timezone',
302302
'vcs_name', 'username'))
303303
db.security.addPermissionToRole('User', p)
@@ -310,11 +310,14 @@ def may_edit_file(db, userid, itemid):
310310
db.security.addPermissionToRole('Coordinator', 'Edit', 'user')
311311
db.security.addPermissionToRole('Coordinator', 'Web Roles')
312312

313+
313314
# Users should be able to edit their own details -- this permission is
314315
# limited to only the situation where the Viewed or Edited item is their own.
315316
def own_record(db, userid, itemid):
316317
'''Determine whether the userid matches the item being accessed.'''
317318
return userid == itemid
319+
320+
318321
p = db.security.addPermission(name='View', klass='user', check=own_record,
319322
description="User is allowed to view their own user details")
320323
for r in 'User', 'Developer', 'Coordinator':
@@ -326,19 +329,24 @@ def own_record(db, userid, itemid):
326329
'phone', 'organisation',
327330
'alternate_addresses',
328331
'queries',
329-
'timezone')) # Note: 'roles' excluded - users should not be able to edit their own roles.
332+
'timezone')) # Note: 'roles' excluded - users should not be able to edit their own roles.
330333
for r in 'User', 'Developer':
331334
db.security.addPermissionToRole(r, p)
332335

336+
333337
# Users should be able to edit and view their own queries. They should also
334338
# be able to view any marked as not private. They should not be able to
335339
# edit others' queries, even if they're not private
336340
def view_query(db, userid, itemid):
337341
private_for = db.query.get(itemid, 'private_for')
338342
if not private_for: return True
339343
return userid == private_for
344+
345+
340346
def edit_query(db, userid, itemid):
341347
return userid == db.query.get(itemid, 'creator')
348+
349+
342350
p = db.security.addPermission(name='View', klass='query', check=view_query,
343351
description="User is allowed to view their own and public queries")
344352
p = db.security.addPermission(name='Search', klass='query')
@@ -387,7 +395,7 @@ def edit_query(db, userid, itemid):
387395
# anonymous, you should remove this entry as it can be used to perform
388396
# a username guessing attack against a roundup install.
389397
p = db.security.addPermission(name='Search', klass='user')
390-
db.security.addPermissionToRole ('Anonymous', p)
398+
db.security.addPermissionToRole('Anonymous', p)
391399

392400
# [OPTIONAL]
393401
# Allow anonymous users access to create or edit "issue" items (and the

share/roundup/templates/jinja2/schema.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,19 @@
103103

104104
# May users view other user information? Comment these lines out
105105
# if you don't want them to
106-
p = db.security.addPermission(name='View', klass='user',
106+
p = db.security.addPermission(name='View', klass='user',
107107
properties=('id', 'organisation', 'phone', 'realname', 'timezone',
108108
'username'))
109109
db.security.addPermissionToRole('User', p)
110110

111+
111112
# Users should be able to edit their own details -- this permission is
112113
# limited to only the situation where the Viewed or Edited item is their own.
113114
def own_record(db, userid, itemid):
114115
'''Determine whether the userid matches the item being accessed.'''
115116
return userid == itemid
117+
118+
116119
p = db.security.addPermission(name='View', klass='user', check=own_record,
117120
description="User is allowed to view their own user details")
118121
db.security.addPermissionToRole('User', p)
@@ -122,15 +125,20 @@ def own_record(db, userid, itemid):
122125
description="User is allowed to edit their own user details")
123126
db.security.addPermissionToRole('User', p)
124127

128+
125129
# Users should be able to edit and view their own queries. They should also
126130
# be able to view any marked as not private. They should not be able to
127131
# edit others' queries, even if they're not private
128132
def view_query(db, userid, itemid):
129133
private_for = db.query.get(itemid, 'private_for')
130134
if not private_for: return True
131135
return userid == private_for
136+
137+
132138
def edit_query(db, userid, itemid):
133139
return userid == db.query.get(itemid, 'creator')
140+
141+
134142
p = db.security.addPermission(name='View', klass='query', check=view_query,
135143
description="User is allowed to view their own and public queries")
136144
db.security.addPermissionToRole('User', p)
@@ -181,7 +189,7 @@ def edit_query(db, userid, itemid):
181189
# anonymous, you should remove this entry as it can be used to perform
182190
# a username guessing attack against a roundup install.
183191
p = db.security.addPermission(name='Search', klass='user')
184-
db.security.addPermissionToRole ('Anonymous', p)
192+
db.security.addPermissionToRole('Anonymous', p)
185193

186194
# [OPTIONAL]
187195
# Allow anonymous users access to create or edit "issue" items (and the

share/roundup/templates/minimal/schema.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,18 @@
3434

3535
# May users view other user information?
3636
# Comment these lines out if you don't want them to
37-
p = db.security.addPermission(name='View', klass='user',
37+
p = db.security.addPermission(name='View', klass='user',
3838
properties=('id', 'username'))
3939
db.security.addPermissionToRole('User', p)
4040

41+
4142
# Users should be able to edit their own details -- this permission is
4243
# limited to only the situation where the Viewed or Edited item is their own.
4344
def own_record(db, userid, itemid):
4445
'''Determine whether the userid matches the item being accessed.'''
4546
return userid == itemid
47+
48+
4649
p = db.security.addPermission(name='View', klass='user', check=own_record,
4750
description="User is allowed to view their own user details")
4851
db.security.addPermissionToRole('User', p)

share/roundup/templates/responsive/schema.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
revision=String())
2828

2929

30-
3130
# Component
3231
component = Class(db, 'component',
3332
name=String(),
@@ -76,7 +75,7 @@
7675
name=String(),
7776
description=String())
7877
keyword.setkey("name")
79-
78+
8079

8180
# User-defined saved searches
8281
query = Class(db, "query",
@@ -209,7 +208,7 @@
209208
db.security.addPermissionToRole(r, 'Rest Access')
210209
db.security.addPermissionToRole(r, 'Xmlrpc Access')
211210

212-
211+
213212
##########################
214213
# User permissions
215214
##########################
@@ -225,11 +224,12 @@
225224
'version', 'priority', 'status', 'resolution',
226225
'bug_type', 'bug', 'file', 'msg'):
227226
db.security.addPermissionToRole('User', 'Create', cl)
228-
227+
229228

230229
def may_edit_file(db, userid, itemid):
231230
return userid == db.file.get(itemid, "creator")
232231

232+
233233
p = db.security.addPermission(name='Edit', klass='file', check=may_edit_file,
234234
description="User is allowed to remove their own files")
235235
db.security.addPermissionToRole('User', p)
@@ -297,7 +297,7 @@ def may_edit_file(db, userid, itemid):
297297

298298
# May users view other user information? Comment these lines out
299299
# if you don't want them to
300-
p = db.security.addPermission(name='View', klass='user',
300+
p = db.security.addPermission(name='View', klass='user',
301301
properties=('id', 'organisation', 'phone', 'realname', 'timezone',
302302
'username', 'vcs_name'))
303303
db.security.addPermissionToRole('User', p)
@@ -310,11 +310,14 @@ def may_edit_file(db, userid, itemid):
310310
db.security.addPermissionToRole('Coordinator', 'Edit', 'user')
311311
db.security.addPermissionToRole('Coordinator', 'Web Roles')
312312

313+
313314
# Users should be able to edit their own details -- this permission is
314315
# limited to only the situation where the Viewed or Edited item is their own.
315316
def own_record(db, userid, itemid):
316317
'''Determine whether the userid matches the item being accessed.'''
317318
return userid == itemid
319+
320+
318321
p = db.security.addPermission(name='View', klass='user', check=own_record,
319322
description="User is allowed to view their own user details")
320323
for r in 'User', 'Developer', 'Coordinator':
@@ -326,19 +329,24 @@ def own_record(db, userid, itemid):
326329
'phone', 'organisation',
327330
'alternate_addresses',
328331
'queries',
329-
'timezone')) # Note: 'roles' excluded - users should not be able to edit their own roles.
332+
'timezone')) # Note: 'roles' excluded - users should not be able to edit their own roles.
330333
for r in 'User', 'Developer':
331334
db.security.addPermissionToRole(r, p)
332335

336+
333337
# Users should be able to edit and view their own queries. They should also
334338
# be able to view any marked as not private. They should not be able to
335339
# edit others' queries, even if they're not private
336340
def view_query(db, userid, itemid):
337341
private_for = db.query.get(itemid, 'private_for')
338342
if not private_for: return True
339343
return userid == private_for
344+
345+
340346
def edit_query(db, userid, itemid):
341347
return userid == db.query.get(itemid, 'creator')
348+
349+
342350
p = db.security.addPermission(name='View', klass='query', check=view_query,
343351
description="User is allowed to view their own and public queries")
344352
p = db.security.addPermission(name='Search', klass='query')
@@ -387,7 +395,7 @@ def edit_query(db, userid, itemid):
387395
# anonymous, you should remove this entry as it can be used to perform
388396
# a username guessing attack against a roundup install.
389397
p = db.security.addPermission(name='Search', klass='user')
390-
db.security.addPermissionToRole ('Anonymous', p)
398+
db.security.addPermissionToRole('Anonymous', p)
391399

392400
# [OPTIONAL]
393401
# Allow anonymous users access to create or edit "issue" items (and the

0 commit comments

Comments
 (0)