Add headers and rearrange so things look clean.
[xonotic/xonstat.git] / xonstat / security.py
1 import logging
2 from pyramid.security import Allow, Everyone
3 from xonstat.models import DBSession, Player, PlayerGroups
4
5 log = logging.getLogger(__name__)
6
7 USERS = {
8     'admin':'admin',
9     'viewer':'viewer',
10 }
11
12 GROUPS = {
13     'admin':['group:admins'],
14 }
15
16 # default ACL
17 class ACLFactory(object):
18     __acl__ = [
19         # permission, principal, permission
20         (Allow, Everyone, 'view'),
21         (Allow, 'admin', 'merge')
22     ]
23     def __init__(self, request):
24         pass
25
26
27 def groupfinder(userid, request):
28     groups = []
29     try:
30         groups_q = DBSession.query(PlayerGroups.group_name).\
31             filter(Player.email_addr == userid).all()
32
33         for g in groups_q:
34             groups.append(g.group_name)
35     except:
36         pass
37
38     return groups