コード例 #1
0
class EventAttendUser(db.Model):
    __tablename__ = 'event_attend_user'
    __table_args__ = (db.UniqueConstraint(
        'user_id', 'event_id', name='event_attend_uix_user_id_event_id'), {})

    id = db.Column(db.Integer,
                   db.Sequence('event_attend_user_id_seq'),
                   primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    event_id = db.Column(db.Integer, db.ForeignKey('event.id'), nullable=False)
    attend_date = db.Column(db.ARRAY(db.DateTime), nullable=True)
    expect_papers = db.Column(db.Boolean, nullable=True, default=False)
    attend_social_gathering = db.Column(db.Boolean,
                                        nullable=True,
                                        default=False)
    payment_status = db.Column(db.TEXT, nullable=True)
    cancel = db.Column(db.Boolean, nullable=True, default=False)
    created_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now(JST))
    updated_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now(JST),
                           onupdate=datetime.now(JST))

    event = db.relationship('Event', backref='event_attend_user')

    def __init__(self, user_id, event_id, attend_date, expect_papers,
                 attend_social_gathering, payment_status):
        self.user_id = user_id
        self.event_id = event_id
        self.attend_date = attend_date
        self.expect_papers = expect_papers
        self.attend_social_gathering = attend_social_gathering
        self.payment_status = payment_status
コード例 #2
0
class EventForm(db.Model):
    __tablename__ = 'event_form'

    id = db.Column(db.Integer,
                   db.Sequence('event_form_id_seq'),
                   primary_key=True)
    name = db.Column(db.TEXT, nullable=False)
    label = db.Column(db.TEXT, nullable=False)
コード例 #3
0
class AddressType(db.Model):
    __tablename__ = 'address_type'

    id = db.Column(db.Integer,
                   db.Sequence('address_type_id_seq'),
                   primary_key=True)
    name = db.Column(db.TEXT, nullable=False)
    label = db.Column(db.TEXT, nullable=False)
コード例 #4
0
class User(db.Model, flask_login.UserMixin):
    username = db.Column(db.String(),
                         unique=True,
                         nullable=False,
                         primary_key=True,
                         index=True)
    password_hash = db.Column(db.String(128), nullable=False)
    first_name = db.Column(db.String(64), nullable=False, index=True)
    last_name = db.Column(db.String(64), nullable=False, index=True)
    privilege = db.Column(db.Boolean, default=False)
    need_reset = db.Column(db.Boolean, default=True)
    actual = db.Column(db.Boolean, default=True)
    info = db.relationship('UserInfo', backref='user', uselist=False)
    lead = db.relationship('Structure', backref='user')

    @property
    def password(self):
        raise AttributeError('password is not a readable attribute')

    @password.setter
    def password(self, password):
        self.password_hash = generate_password_hash(password)

    def verify_password(self, password):
        return check_password_hash(self.password_hash, password)

    @property
    def is_admin(self):
        return self.privilege

    def get_id(self):
        return self.username

    def __repr__(self):
        return '<user> {}'.format(self.username)
コード例 #5
0
class Society(db.Model):
    __tablename__ = 'society'

    id = db.Column(db.Integer, db.Sequence('society_id_seq'), primary_key=True)
    name = db.Column(db.TEXT, nullable=False)
    english_name = db.Column(db.TEXT, nullable=True)
    abbreviation = db.Column(db.TEXT, nullable=True)
    url = db.Column(db.TEXT, nullable=True)
    created_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now(JST))
    updated_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now(JST),
                           onupdate=datetime.now(JST))
コード例 #6
0
ファイル: models.py プロジェクト: stepalxser/Intranet
class Structure(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String, nullable=False)
    lead = db.Column(db.String, db.ForeignKey('user.username'), nullable=False)
    parent_id = db.Column(db.Integer, nullable=False, default=0)
    workers = db.relationship('UserInfo', backref='unit')
コード例 #7
0
class UserInfo(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    info_owner = db.Column(db.String,
                           db.ForeignKey('user.username'),
                           nullable=False)
    position = db.Column(db.String)
    email = db.Column(db.String, unique=True)
    internal_phone = db.Column(db.String, unique=True)
    mobil_phone = db.Column(db.String, unique=True)
    corp_messenger = db.Column(db.String, unique=True)
    office = db.Column(db.String)
    work_before = db.Column(db.String)
    first_day = db.Column(db.DateTime)
    birthday = db.Column(db.DateTime)
    work_unit = db.Column(db.Integer, db.ForeignKey('structure.id'))
    avatar_s = db.Column(db.String(64))
    avatar_m = db.Column(db.String(64))
    avatar_l = db.Column(db.String(64))
コード例 #8
0
class EventFee(db.Model):
    __tablename__ = 'event_fee'
    __table_args__ = (db.UniqueConstraint(
        'event_id',
        'member_type_id',
        name='event_fee_uix_event_id_member_type_id'), {})

    id = db.Column(db.Integer,
                   db.Sequence('event_fee_id_seq'),
                   primary_key=True)
    event_id = db.Column(db.Integer, db.ForeignKey('event.id'), nullable=False)
    member_type_id = db.Column(db.Integer,
                               db.ForeignKey('member_type.id'),
                               nullable=False)
    participation = db.Column(db.Integer, nullable=False, default=0)
    papers = db.Column(db.Integer, nullable=False, default=0)
    social_gathering = db.Column(db.Integer, nullable=False, default=0)
    corporate_exhibition = db.Column(db.Integer, nullable=False, default=0)
    web_advertising_banner = db.Column(db.Integer, nullable=False, default=0)
    web_advertising_small = db.Column(db.Integer, nullable=False, default=0)
    web_advertising_medium = db.Column(db.Integer, nullable=False, default=0)
    web_advertising_large = db.Column(db.Integer, nullable=False, default=0)
コード例 #9
0
class Event(db.Model):
    __tablename__ = 'event'

    id = db.Column(db.Integer, db.Sequence('event_id_seq'), primary_key=True)
    name = db.Column(db.TEXT, nullable=False)
    english_name = db.Column(db.TEXT, nullable=True)
    url = db.Column(db.TEXT, nullable=True)
    event_form_id = db.Column(db.Integer,
                              db.ForeignKey('event_form.id'),
                              nullable=True)
    has_papers = db.Column(db.Boolean, nullable=True)
    has_social_gathering = db.Column(db.Boolean, nullable=True)
    date = db.Column(db.ARRAY(db.DateTime), nullable=True)
    attend_period = db.Column(db.DateTime, nullable=True)
    presenting_papers_period = db.Column(db.DateTime, nullable=True)
    created_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now(JST))
    updated_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now(JST),
                           onupdate=datetime.now(JST))

    event_form = db.relationship('EventForm', backref='event')
    event_fee = db.relationship('EventFee', backref='event')
コード例 #10
0
class User(db.Model):
    __tablename__ = 'user'

    id = db.Column(db.Integer, db.Sequence('user_id_seq'), primary_key=True)
    name = db.Column(db.TEXT, nullable=True)
    email = db.Column(db.TEXT, nullable=False)
    password = db.Column(db.TEXT, nullable=False)
    member_id = db.Column(db.TEXT, nullable=True)
    member_type_id = db.Column(db.Integer,
                               db.ForeignKey('member_type.id'),
                               nullable=True)
    member_validate = db.Column(db.Boolean, nullable=False, default=False)
    salt = db.Column(db.TEXT, nullable=False)
    role = db.Column(db.Integer, db.ForeignKey('role.id'), nullable=False)
    state = db.Column(db.Integer, db.ForeignKey('state.id'), nullable=False)
    token = db.Column(db.TEXT, nullable=True)
    token_period = db.Column(db.DateTime, nullable=True)
    created_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now(JST))
    updated_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now(JST),
                           onupdate=datetime.now(JST))

    user_profile = db.relation('UserProfile',
                               uselist=False,
                               backref='user',
                               cascade='all, delete-orphan')
    member_type = db.relation('MemberType', backref='user_profile')

    def __init__(self, name, email, password, member_id, member_type_id,
                 member_validate, salt, role, state, token, token_period):
        self.name = name
        self.email = email
        self.password = password
        self.member_id = member_id
        self.member_type_id = member_type_id
        self.member_validate = member_validate
        self.salt = salt
        self.role = role
        self.state = state
        self.token = token
        self.token_period = token_period
コード例 #11
0
class UserProfile(db.Model):
    __tablename__ = 'user_profile'

    user_id = db.Column(db.Integer,
                        db.ForeignKey('user.id'),
                        primary_key=True,
                        nullable=False)
    first_name = db.Column(db.TEXT, nullable=False)
    last_name = db.Column(db.TEXT, nullable=False)
    first_name_kana = db.Column(db.TEXT, nullable=False)
    last_name_kana = db.Column(db.TEXT, nullable=False)
    first_name_roman = db.Column(db.TEXT, nullable=False)
    last_name_roman = db.Column(db.TEXT, nullable=False)
    organization = db.Column(db.TEXT, nullable=False)
    department = db.Column(db.TEXT, nullable=True)
    address_type_id = db.Column(db.Integer,
                                db.ForeignKey('address_type.id'),
                                nullable=False)
    zip = db.Column(db.Integer, nullable=False)
    prefecture = db.Column(db.TEXT, nullable=False)
    municipalities = db.Column(db.TEXT, nullable=False)
    address1 = db.Column(db.TEXT, nullable=False)
    address2 = db.Column(db.TEXT, nullable=True)
    phone = db.Column(db.TEXT, nullable=False)

    address_type = db.relation('AddressType', backref='user_profile')

    def __init__(self, user_id, first_name, last_name, first_name_kana,
                 last_name_kana, first_name_roman, last_name_roman,
                 organization, department, address_type_id, zip, prefecture,
                 municipalities, address1, address2, phone):
        self.user_id = user_id
        self.first_name = first_name
        self.last_name = last_name
        self.first_name_kana = first_name_kana
        self.last_name_kana = last_name_kana
        self.first_name_roman = first_name_roman
        self.last_name_roman = last_name_roman
        self.organization = organization
        self.department = department
        self.address_type_id = address_type_id
        self.zip = zip
        self.prefecture = prefecture
        self.municipalities = municipalities
        self.address1 = address1
        self.address2 = address2
        self.phone = phone
コード例 #12
0
class State(db.Model):
    __tablename__ = 'state'

    id = db.Column(db.Integer, db.Sequence('state_id_seq'), primary_key=True)
    name = db.Column(db.TEXT, nullable=False)