from datetime import datetime

from offenesparlament.core import db
from offenesparlament.model.util import ModelCore

beschluesse_dokumente = db.Table(
    'beschluesse_dokumente',
    db.Column('dokument_id', db.Integer, db.ForeignKey('beschluss.id')),
    db.Column('beschluss_id', db.Integer, db.ForeignKey('dokument.id')))


class Dokument(db.Model, ModelCore):
    __tablename__ = 'dokument'

    nummer = db.Column(db.Unicode())
    hrsg = db.Column(db.Unicode())
    typ = db.Column(db.Unicode())
    link = db.Column(db.Unicode())

    referenzen = db.relationship('Referenz',
                                 backref='dokument',
                                 lazy='dynamic')

    positionen = db.relationship('Position',
                                 backref='dokument',
                                 lazy='dynamic')

    beschluesse = db.relationship('Beschluss',
                                  secondary=beschluesse_dokumente,
                                  backref=db.backref('dokumente',
                                                     lazy='dynamic'))
from offenesparlament.core import db
from offenesparlament.model.util import ModelCore

referenzen = db.Table(
    'referenzen',
    db.Column('referenz_id', db.Integer, db.ForeignKey('referenz.id')),
    db.Column('ablauf_id', db.Integer, db.ForeignKey('ablauf.id')))


class Referenz(db.Model, ModelCore):
    __tablename__ = 'referenz'

    seiten = db.Column(db.Unicode())
    text = db.Column(db.Unicode())
    dokument_id = db.Column(db.Integer, db.ForeignKey('dokument.id'))

    ablaeufe = db.relationship('Ablauf',
                               secondary=referenzen,
                               backref=db.backref('referenzen',
                                                  lazy='dynamic'))

    def to_ref(self):
        return {
            'id': self.id,
            'seiten': self.seiten,
            'text': self.text,
            'dokument': self.dokument.id
        }

    def to_dict(self):
        data = self.to_ref()
示例#3
0
from datetime import datetime

from offenesparlament.core import db


current_schlagwort = db.Table('current_schlagwort', db.metadata,
        db.Column('schlagwort', db.Unicode),
        db.Column('num', db.Integer),
        db.Column('period', db.Unicode))

period_sachgebiet = db.Table('period_sachgebiet', db.metadata,
        db.Column('sachgebiet', db.Unicode),
        db.Column('num', db.Integer),
        db.Column('period', db.Unicode))

person_schlagwort = db.Table('person_schlagwort', db.metadata,
        db.Column('person_id', db.Integer),
        db.Column('schlagwort', db.Unicode),
        db.Column('num', db.Integer))

from offenesparlament.core import db

schlagworte = db.Table('schlagworte',
    db.Column('schlagwort_id', db.Integer, db.ForeignKey('schlagwort.id')),
    db.Column('ablauf_id', db.Integer, db.ForeignKey('ablauf.id'))
)


class Schlagwort(db.Model):
    __tablename__ = 'schlagwort'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Unicode())

示例#5
0
import re
from datetime import datetime
from collections import OrderedDict

from offenesparlament.core import db
from offenesparlament.model.util import ModelCore


obleute = db.Table('obleute',
    db.Column('gremium_id', db.Integer, db.ForeignKey('gremium.id')),
    db.Column('person_id', db.Integer, db.ForeignKey('person.id'))
)

mitglieder = db.Table('mitglieder',
    db.Column('gremium_id', db.Integer, db.ForeignKey('gremium.id')),
    db.Column('person_id', db.Integer, db.ForeignKey('person.id'))
)

stellvertreter = db.Table('stellvertreter',
    db.Column('gremium_id', db.Integer, db.ForeignKey('gremium.id')),
    db.Column('person_id', db.Integer, db.ForeignKey('person.id'))
)


class Person(db.Model, ModelCore):
    __tablename__ = 'person'

    slug = db.Column(db.Unicode)
    fingerprint = db.Column(db.Unicode)
    source_url = db.Column(db.Unicode)
    mdb_id = db.Column(db.Integer)