Ejemplo n.º 1
0
def sample_account_frais_techniques(account_type: AccountType):
    yield Account(id=3,
                  type=account_type.id,
                  creation_date=datetime.now(),
                  name="MiNET frais techniques",
                  actif=True,
                  compte_courant=True,
                  pinned=True)
Ejemplo n.º 2
0
def sample_account2(sample_account_type2: AccountType):
    return Account(id=2,
                   name='test3',
                   actif=True,
                   creation_date=datetime.datetime(2005, 7, 14, 12, 31),
                   type=sample_account_type2.id,
                   adherent_id=None,
                   compte_courant=False,
                   pinned=False)
Ejemplo n.º 3
0
def sample_account1(sample_account_type1):
    return Account(id=1,
                   name='test1',
                   actif=True,
                   creation_date=datetime.datetime(2005, 7, 14, 12, 30),
                   type=sample_account_type1.id,
                   adherent_id=None,
                   compte_courant=False,
                   pinned=False)
Ejemplo n.º 4
0
def sample_account(account_type: AccountType, sample_member: Adherent):
    yield Account(id=1,
                  type=account_type.id,
                  creation_date=datetime.now(),
                  name="account",
                  actif=True,
                  compte_courant=False,
                  pinned=False,
                  adherent_id=sample_member.id)
Ejemplo n.º 5
0
Archivo: manage.py Proyecto: minet/adh6
def fake(login):
    """Add dummy data to the database."""
    fake = Faker()
    session: Session = db.session

    import datetime as dt

    now = datetime.now()
    adherent = Adherent(
        nom=fake.last_name_nonbinary(),
        prenom=fake.first_name_nonbinary(),
        mail=fake.email(),
        login=login,
        ldap_login=login,
        password="",
        chambre_id=1,
        datesignedminet=now,
        date_de_depart=now + dt.timedelta(days=365),
        subnet="10.0.42.0/28",
        ip="157.159.192.2"
    )

    session.add(adherent)
    session.flush()

    account = Account(
        type=2,
        name=adherent.nom + " " + adherent.prenom,
        actif=True,
        compte_courant=False,
        pinned=False,
        adherent_id=adherent.id
    )

    session.add(account)
    session.flush()

    membership = Membership(
        uuid=str(uuid.uuid4),
        account_id=account.id,
        adherent_id=adherent.id,
        payment_method_id=3,
        has_room=True,
        first_time=True,
        products="",
        update_at=datetime.now(),
        create_at=datetime.now(),
        status=MembershipStatus.COMPLETE.value,
        duration=MembershipDuration.ONE_YEAR.value
    )

    session.add(membership)
    session.flush()

    session.add(Transaction(
        value=9,
        timestamp=now,
        src=account.id,
        dst=2,
        name="Internet - 1 an",
        attachments="",
        type=3,
        author_id=1,
        pending_validation=False,
    ))
    session.add(Transaction(
        value=41,
        timestamp=now,
        src=account.id,
        dst=1,
        name="Internet - 1 an",
        attachments="",
        type=3,
        author_id=1,
        pending_validation=False,
    ))
    
    for _ in range(1, 4):
        session.add(Device(
            mac=fake.mac_address(),
            ip=None,
            adherent_id=adherent.id,
            ipv6=None,
            type=0
        ))
    for _ in range(1, 4):
        session.add(Device(
            mac=fake.mac_address(),
            ip=None,
            adherent_id=adherent.id,
            ipv6=None,
            type=1
        ))
    session.commit()
Ejemplo n.º 6
0
Archivo: manage.py Proyecto: minet/adh6
def seed():
    """Add seed data to the database."""
    session: Session = db.session

    print("Seeding account types")
    account_types = [1,"Special"],[2,"Adherent"],[3,"Club interne"],[4,"Club externe"],[5,"Association externe"]
    session.bulk_save_objects([
        AccountType(
            id=e[0],
            name=e[1]
        ) for e in account_types
    ])

    print("Seeding MiNET accounts")
    accounts = [1, 1, "MiNET frais techniques", True, None, True, True],[2, 1, "MiNET frais asso", True, None, True, True]
    session.bulk_save_objects([
        Account(
            id=e[0],
            type=e[1],
            name=e[2],
            actif=e[3],
            adherent_id=e[4],
            compte_courant=e[5],
            pinned=e[6]
        ) for e in accounts
    ])

    print("Seeding Products")
    products = [1,"Cable 3m", 3, 3],[2,"Cable 5m", 5, 5],[3,"Adaptateur USB/Ethernet", 13.00, 13.00],[4,"Adaptateur USB-C/Ethernet", 12.00, 12.00]
    session.bulk_save_objects([
        Product(
            id=e[0],
            name=e[1],
            buying_price=e[2],
            selling_price=e[3]
        ) for e in products
    ])

    print("Seeding payment methods")
    payment_methods = [1,"Liquide"],[2,"Chèque"],[3,"Carte bancaire"],[4,"Virement"],[5,"Stripe"],[6,"Aucun"]
    session.bulk_save_objects([
        PaymentMethod(
            id=e[0],
            name=e[1]
        ) for e in payment_methods
    ])

    print("Seeding cashbox")
    session.add(Caisse(
        fond=0,
        coffre=0
    ))

    print("Seeding vlans")
    vlans = [41, "157.159.41.0/24", "2001:660:3203:401::/64", "157.159.41.1/32", ""], [35, "10.42.0.0/16", "", "", ""], [36, "157.159.192.0/22", "", "157.159.195.0/24", ""], [30, "172.30.0.0/16", "", "", ""]
    session.bulk_save_objects([
        Vlan(
            numero=e[0], 
            adresses=e[1], 
            adressesv6=e[2], 
            excluded_addr=e[3], 
            excluded_addrv6=e[4]
        ) for e in vlans
    ])

    print("Seeding Rooms")
    session.bulk_save_objects([
        Chambre(
            id=i,
            numero=i,
            description="Chambre " + str(i),
            vlan_id=1
        ) for i in range(1, 30)
    ])

    print("Seeding Switchs")
    switchs = [1, "Switch local", "192.168.102.219", "adh5"],
    session.bulk_save_objects([
        Switch(
            id=e[0],
            description=e[1],
            ip=e[2],
            communaute=e[3],
        ) for e in switchs
    ])

    print("Seeding 30 Ports Switch local + link to room")
    session.bulk_save_objects([
        Port(
            rcom=0,
            numero="1/0/" + str(i),
            oid="1010" + str(i),
            switch_id=1,
            chambre_id=i
        ) for i in range(1, 30)
    ])
    print("Seeding role mapping for oidc")
    session.bulk_save_objects(
        [
            AuthenticationRoleMapping(
                identifier="adh6_admin",
                role=i,
                authentication=AuthenticationMethod.OIDC
            ) for i in [Roles.ADMIN_READ, Roles.ADMIN_WRITE, Roles.NETWORK_READ, Roles.NETWORK_WRITE, Roles.ADMIN_PROD]
        ] 
    )

    session.bulk_save_objects(
        [
            AuthenticationRoleMapping(
                identifier="adh6_treso",
                role=i,
                authentication=AuthenticationMethod.OIDC
            ) for i in [Roles.TRESO_READ, Roles.TRESO_WRITE]
        ] 
    )

    session.commit()