# Path: pyledger/server/config.py
# SECRET = b'test'
# LIFETIME = 1
# 
# Path: pyledger/server/config.py
# SECRET = b'test'
# LIFETIME = 1


import base64
from enum import Enum
from cryptography.exceptions import InvalidKey
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, \
    LargeBinary
from sqlalchemy import create_engine, desc
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy.orm import sessionmaker, scoped_session
from pyledger.server.config import args
from pyledger.server.config import password_backend, SECRET
    key = Column(LargeBinary, unique=True)  # Crash if there is a key collision.
    when = Column(DateTime)
    owner = Column(String)

    def __repr__(self):
        return '<Status key: {}>'.format(self.key)

    @classmethod
    def query(cls):
        return DB.session.query(cls)


class Contract(Model):
    __tablename__ = 'contracts'
    id = Column(Integer, primary_key=True)
    name = Column(String, unique=True)
    description = Column(String)
    created = Column(DateTime)
    status = relationship("Status", lazy="subquery")
    user_id = Column(Integer, ForeignKey('users.id'))
    user = relationship("User", back_populates="contracts")

    @classmethod
    def query(cls):
        return DB.session.query(cls)

    @staticmethod
    def from_name(name):
        return Contract.query().filter(Contract.name == name).one_or_none()


# Path: pyledger/server/config.py
# SECRET = b'test'
# LIFETIME = 1
# 
# Path: pyledger/server/config.py
# SECRET = b'test'
# LIFETIME = 1


# Path: pyledger/server/db.py
import base64
from enum import Enum
from cryptography.exceptions import InvalidKey
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, \
    LargeBinary
from sqlalchemy import create_engine, desc
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy.orm import sessionmaker, scoped_session
from pyledger.server.config import args
from pyledger.server.config import password_backend, SECRET

    key = Column(LargeBinary, unique=True)  # Crash if there is a key collision.
    when = Column(DateTime)
    owner = Column(String)

    def __repr__(self):
        return '<Status key: {}>'.format(self.key)

    @classmethod
    def query(cls):
        return DB.session.query(cls)


class Contract(Model):
    __tablename__ = 'contracts'
    id = Column(Integer, primary_key=True)
    name = Column(String, unique=True)
    description = Column(String)
    created = Column(DateTime)
    status = relationship("Status", lazy="subquery")
    user_id = Column(Integer, ForeignKey('users.id'))
    user = relationship("User", back_populates="contracts")

    @classmethod
    def query(cls):
        return DB.session.query(cls)

    @staticmethod
    def from_name(name):
        return Contract.query().filter(Contract.name == name).one_or_none()


    def last_status(self):