~sircmpwn/core.sr.ht

core.sr.ht/srht/oauth/client.py -rw-r--r-- 574 bytes
04703e6aDrew DeVault layout.html: remove workaround for chromium#332189 11 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import sqlalchemy as sa
from sqlalchemy.ext.declarative import declared_attr

class OAuthClientMixin:
    @declared_attr
    def __tablename__(cls):
        return "oauthclient"

    id = sa.Column(sa.Integer, primary_key=True)
    created = sa.Column(sa.DateTime, nullable=False)
    updated = sa.Column(sa.DateTime, nullable=False)

    @declared_attr
    def user_id(cls):
        return sa.Column(sa.Integer, sa.ForeignKey('user.id'))

    @declared_attr
    def user(cls):
        return sa.orm.relationship('User',
            backref=sa.orm.backref('oauth_clients'))