Beispiel #1
0
def store_data_user(data):
    detail = UserDetail(
        fullname=data['fullname'],
        phone_number=data['phone_number'],
    )

    user = User(username=data['username'],
                email=data['email'],
                password=data['password'],
                user_detail=detail)
    # try:
    user.commit()
    return user
Beispiel #2
0
def add_seek():
    from apps.user.models import User, UserDetail
    # from apps.category_access.models import CategoryAccess
    seek_data = open('seek_data.json')
    seek_data = json.load(seek_data)

    for user in seek_data['users']:
        # ca = CategoryAccess(
        #     name=user['ca']['name'],
        #     root_access=user['ca']['root_access'],
        #     add_user=user['ca']['add_user'],
        #     delete_user=user['ca']['delete_user'],
        #     edit_user=user['ca']['edit_user'],
        #     add_job=user['ca']['add_job'],
        #     delete_job=user['ca']['delete_job'],
        #     update_job=user['ca']['update_job'],
        #     show_job=user['ca']['show_job'],
        #     show_user=user['ca']['show_user'],
        #     print_job=user['ca']['print_job'],
        #     check_job=user['ca']['check_job'],
        #     service_job=user['ca']['service_job']
        # )
        detail = UserDetail(
            fullname=user['fullname'],
            phone_number=user['phone_number']
        )

        user = User(
            username=user['username'],
            email=user['email'],
            password=user['password'],
            user_detail=detail
        )
        user.commit()
        # ca.users.append(user)
        # ca.commit()
        click.echo("Add Data Done.!! :)")
Beispiel #3
0
def add_seek():
    from apps.user.models import User, UserDetail
    from apps.category_access.models import CategoryAccess
    seek_data = open('seek_data.json')
    seek_data = json.load(seek_data)

    for user in seek_data['users']:
        ca = CategoryAccess(name=user['ca']['name'],
                            root_access=user['ca']['root_access'],
                            add_user=user['ca']['add_user'],
                            delete_user=user['ca']['delete_user'],
                            edit_user=user['ca']['edit_user'],
                            add_job=user['ca']['add_job'],
                            delete_job=user['ca']['delete_job'],
                            update_job=user['ca']['update_job'],
                            show_job=user['ca']['show_job'],
                            show_user=user['ca']['show_user'],
                            print_job=user['ca']['print_job'],
                            check_job=user['ca']['check_job'],
                            service_job=user['ca']['service_job'])
        detail = UserDetail(
            fullname=user['fullname'],
            address=user['address'],
            phone_number=user['phone_number'],
            work_start_time=datetime.strptime(user['work_start_time'],
                                              "%d-%m-%Y").date(),
            activate=user['activate'],
        )

        user = User(username=user['username'],
                    email=user['email'],
                    password=user['password'],
                    user_detail=detail)
        user.commit()
        ca.users.append(user)
        ca.commit()
        click.echo("Add Data Done.!! :)")