Пример #1
0
def populate(engine):
    Base.metadata.create_all(engine)
    session = DBSession()

    vactype = VacationType(name='Télétravail')
    session.add(vactype)

    fr_country = Countries.by_name(session, name='fr')
    lu_country = Countries.by_name(session, name='lu')
    us_country = Countries.by_name(session, name='us')
    zh_country = Countries.by_name(session, name='zh')

    # Remote is available for everyone
    vactype.countries.append(fr_country)
    vactype.countries.append(lu_country)
    vactype.countries.append(us_country)
    vactype.countries.append(zh_country)

    session.commit()
Пример #2
0
def populate(engine):

    Base.metadata.create_all(engine)
    session = DBSession()

    user_perm = Permission(name='user_view')
    admin_perm = Permission(name='admin_view')
    manager_perm = Permission(name='manager_view')
    sudo_perm = Permission(name='sudo_view')
    session.add(user_perm)
    session.add(admin_perm)
    session.add(manager_perm)
    session.add(sudo_perm)

    admin_group = Group(name='admin')
    admin_group.permissions.append(user_perm)
    admin_group.permissions.append(admin_perm)
    admin_group.permissions.append(manager_perm)
    admin_group.permissions.append(sudo_perm)
    session.add(admin_group)

    manager_group = Group(name='manager')
    manager_group.permissions.append(user_perm)
    manager_group.permissions.append(manager_perm)
    manager_group.permissions.append(sudo_perm)
    session.add(manager_group)

    user_group = Group(name='user')
    user_group.permissions.append(user_perm)
    session.add(user_group)

    sudoer_group = Group(name='sudoer')
    sudoer_group.permissions.append(sudo_perm)
    session.add(sudoer_group)

    vactype1 = VacationType(name='CP')
    session.add(vactype1)
    vactype2 = VacationType(name='RTT')
    session.add(vactype2)
    vactype3 = VacationType(name='Congé Parental')
    session.add(vactype3)
    vactype4 = VacationType(name='Récupération')
    session.add(vactype4)
    vactype5 = VacationType(name='Maladie', visibility='admin')
    session.add(vactype5)
    vactype6 = VacationType(name='Exceptionnel')
    session.add(vactype6)
    vactype7 = VacationType(name='Compensatoire')
    session.add(vactype7)
    vactype8 = VacationType(name='Télétravail')
    session.add(vactype8)

    fr_country = Countries(name='fr')
    session.add(fr_country)
    lu_country = Countries(name='lu')
    session.add(lu_country)
    us_country = Countries(name='us')
    session.add(us_country)
    zh_country = Countries(name='zh')
    session.add(zh_country)

    now = datetime.now()
    cp_pool1 = Pool(name='acquis',
                    date_start=datetime(now.year, 6, 1),
                    date_end=datetime(now.year + 1, 5, 31),
                    status='active',
                    vacation_type=vactype1,
                    country=fr_country,
                    pool_group=1,
                    date_last_increment=now,
                    )
    session.add(cp_pool1)
    cp_pool2 = Pool(name='restant',
                    date_start=datetime(now.year - 1, 6, 1),
                    date_end=datetime(now.year, 5, 31),
                    status='active',
                    vacation_type=vactype1,
                    country=fr_country,
                    pool_group=1,
                    date_last_increment=now,
                    )
    session.add(cp_pool2)
    cplu_pool1 = Pool(name='acquis',
                      alias='légaux',
                      date_start=datetime(now.year, 1, 1),
                      date_end=datetime(now.year + 1, 3, 31),
                      status='active',
                      vacation_type=vactype1,
                      country=lu_country,
                      pool_group=2,
                      date_last_increment=now,
                      )
    session.add(cplu_pool1)
    cplu_pool2 = Pool(name='restant',
                      alias='report',
                      date_start=datetime(now.year - 1, 1, 1),
                      date_end=datetime(now.year, 3, 31),
                      status='active',
                      vacation_type=vactype1,
                      country=lu_country,
                      pool_group=2,
                      date_last_increment=now,
                      )
    session.add(cplu_pool2)
    rtt_pool = Pool(name=vactype2.name,
                    date_start=datetime(now.year, 1, 1),
                    date_end=datetime(now.year + 1, 12, 31),
                    status='active',
                    vacation_type=vactype2,
                    country=fr_country,
                    date_last_increment=now,
                    )
    session.add(rtt_pool)

    # CP is available for everyone
    vactype1.countries.append(fr_country)
    vactype1.countries.append(lu_country)
    vactype1.countries.append(us_country)
    vactype1.countries.append(zh_country)

    # RTT only available for france
    vactype2.countries.append(fr_country)

    # Parental vacation is available for everyone
    vactype3.countries.append(fr_country)
    vactype3.countries.append(lu_country)
    vactype3.countries.append(us_country)
    vactype3.countries.append(zh_country)

    # Recovery is available for everyone
    vactype4.countries.append(fr_country)
    vactype4.countries.append(lu_country)
    vactype4.countries.append(us_country)
    vactype4.countries.append(zh_country)

    # Sickness vacation is available for all countries
    vactype5.countries.append(fr_country)
    vactype5.countries.append(lu_country)
    vactype5.countries.append(us_country)
    vactype5.countries.append(zh_country)

    # Exception vacation is available for all countries
    vactype6.countries.append(fr_country)
    vactype6.countries.append(lu_country)
    vactype6.countries.append(us_country)
    vactype6.countries.append(zh_country)

    # Holiday recovery is only available for LU
    vactype7.countries.append(lu_country)

    # Remote is available for everyone
    vactype8.countries.append(fr_country)
    vactype8.countries.append(lu_country)
    vactype8.countries.append(us_country)
    vactype8.countries.append(zh_country)

    common_password = '******'

    admin = User(login='******',
                 password=common_password,
                 email='*****@*****.**',
                 firstname='The',
                 lastname='Administrator',
                 role='admin',
                 _country=fr_country)
    admin.groups.append(admin_group)
    session.add(admin)

    session.commit()
Пример #3
0
def populate(engine):

    Base.metadata.create_all(engine)
    session = DBSession()

    user_perm = Permission(name=u'user_view')
    admin_perm = Permission(name=u'admin_view')
    manager_perm = Permission(name=u'manager_view')
    sudo_perm = Permission(name=u'sudo_view')
    session.add(user_perm)
    session.add(admin_perm)
    session.add(manager_perm)
    session.add(sudo_perm)

    admin_group = Group(name=u'admin')
    admin_group.permissions.append(user_perm)
    admin_group.permissions.append(admin_perm)
    admin_group.permissions.append(manager_perm)
    admin_group.permissions.append(sudo_perm)
    session.add(admin_group)

    manager_group = Group(name=u'manager')
    manager_group.permissions.append(user_perm)
    manager_group.permissions.append(manager_perm)
    manager_group.permissions.append(sudo_perm)
    session.add(manager_group)

    user_group = Group(name=u'user')
    user_group.permissions.append(user_perm)
    session.add(user_group)

    sudoer_group = Group(name=u'sudoer')
    sudoer_group.permissions.append(sudo_perm)
    session.add(sudoer_group)

    vactype1 = VacationType(name=u'CP')
    session.add(vactype1)
    vactype2 = VacationType(name=u'RTT')
    session.add(vactype2)
    vactype3 = VacationType(name=u'Congé Parental')
    session.add(vactype3)
    vactype4 = VacationType(name=u'Récupération')
    session.add(vactype4)
    vactype5 = VacationType(name=u'Maladie', visibility=u'admin')
    session.add(vactype5)
    vactype6 = VacationType(name=u'Exceptionnel')
    session.add(vactype6)
    vactype7 = VacationType(name=u'Compensatoire')
    session.add(vactype7)

    fr_country = Countries(name=u'fr')
    session.add(fr_country)
    lu_country = Countries(name=u'lu')
    session.add(lu_country)
    us_country = Countries(name=u'us')
    session.add(us_country)
    zh_country = Countries(name=u'zh')
    session.add(zh_country)

    # CP is available for everyone
    vactype1.countries.append(fr_country)
    vactype1.countries.append(lu_country)
    vactype1.countries.append(us_country)
    vactype1.countries.append(zh_country)

    # RTT only available for france
    vactype2.countries.append(fr_country)

    # Parental vacation is available for everyone
    vactype3.countries.append(fr_country)
    vactype3.countries.append(lu_country)
    vactype3.countries.append(us_country)
    vactype3.countries.append(zh_country)

    # Recovery is available for everyone
    vactype4.countries.append(fr_country)
    vactype4.countries.append(lu_country)
    vactype4.countries.append(us_country)
    vactype4.countries.append(zh_country)

    # Sickness vacation is available for all countries
    vactype5.countries.append(fr_country)
    vactype5.countries.append(lu_country)
    vactype5.countries.append(us_country)
    vactype5.countries.append(zh_country)

    # Exception vacation is available for all countries
    vactype6.countries.append(fr_country)
    vactype6.countries.append(lu_country)
    vactype6.countries.append(us_country)
    vactype6.countries.append(zh_country)

    # Holiday recovery is only available for LU
    vactype7.countries.append(lu_country)

    common_password = u'changeme'

    admin = User(login=u'admin',
                 password=common_password,
                 email=u'*****@*****.**',
                 firstname=u'The',
                 lastname=u'Administrator',
                 role=u'admin',
                 _country=fr_country)
    admin.groups.append(admin_group)
    session.add(admin)

    session.commit()