~sircmpwn/meta.sr.ht

ref: 72548bd7545f78670878667674cc7645835a17bd meta.sr.ht/metasrht/types/delegatedscope.py -rw-r--r-- 1.1 KiB
72548bd7Drew DeVault API: Updates per core-go auth changes 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sqlalchemy as sa
import sqlalchemy_utils as sau
from srht.database import Base

class DelegatedScope(Base):
    __tablename__ = 'delegatedscope'
    id = sa.Column(sa.Integer, primary_key=True)
    created = sa.Column(sa.DateTime, nullable=False)
    updated = sa.Column(sa.DateTime, nullable=False)
    name = sa.Column(sa.String(256), nullable=False)
    description = sa.Column(sa.String(512), nullable=False)
    write = sa.Column(sa.Boolean, nullable=False, default=False)

    client_id = sa.Column(sa.Integer,
            sa.ForeignKey('oauthclient.id', ondelete='CASCADE'),
            nullable=False)
    client = sa.orm.relationship('OAuthClient',
            backref=sa.orm.backref('scopes', cascade='all, delete'))

    def __init__(self, client, name, description):
        self.client_id = client.id
        self.name = name
        self.description = description

    def to_dict(self):
        return {
            "id": self.id,
            "created": self.created,
            "updated": self.updated,
            "name": self.name,
            "description": self.description,
            "writable": self.write
        }