vigiboard / dashboard / model / bdd_dashboard / grouppermissions.py @ 70c5f034
History | View | Annotate | Download (1.07 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
"""Model For GroupPermissions Table"""
|
3 |
|
4 |
from sqlalchemy.orm import mapper, relation |
5 |
from sqlalchemy import Table, ForeignKeyConstraint, Column |
6 |
from sqlalchemy.types import Integer, String, Text, DateTime |
7 |
|
8 |
from dashboard.model import metadata, Permission |
9 |
|
10 |
from dashboard.model.bdd_dashboard import Groups |
11 |
|
12 |
# Generation par SQLAutoCode
|
13 |
grouppermissions = Table('grouppermissions', metadata,
|
14 |
Column(u'groupname', String(length=100, convert_unicode=False, assert_unicode=None), primary_key=True, nullable=False), |
15 |
Column(u'idpermission', Integer(), primary_key=True, nullable=False), |
16 |
ForeignKeyConstraint([u'groupname'], [u'groups.name'], name=u'grouppermissions_ibfk_1'), |
17 |
) |
18 |
|
19 |
# Classe a mapper
|
20 |
|
21 |
class GroupPermissions(object): |
22 |
def get_grp (self,user_p): |
23 |
events = DBSession.query(Groups).join( |
24 |
( GroupPermissions , Groups.name == GroupPermission.groupname ), |
25 |
( Permission , Permission.permission_id == GroupPermissions.idpermission ) |
26 |
).filter(in_(Permission.permission_name,user_p)) |
27 |
return events
|
28 |
|
29 |
mapper(GroupPermissions,grouppermissions) |
30 |
|