Esempio n. 1
0
    def handle(self, n, **options):
        map = os.path.join(settings.BASE_DIR, f'artifact_images/map.jpg')
        for i in range(n):
            user = User.objects.first()

            # Create random artifact
            o = Artifact()
            o.uploaded_by = user
            o.uploaded_at = silly.datetime().date()
            o.status = random.randint(1, 4)
            o.is_private = random.choice([True, False])
            o.is_featured = random.choice([True, False])
            o.name_he = silly.name()
            o.name_en = silly.name()
            o.slug = silly.name(slugify=True)
            o.year_from = random.randint(1700, 2000)
            o.year_to = random.randint(1700, 2000)
            o.origin_country = list(COUNTRIES)[random.randint(0, 200)]
            o.origin_city_he = silly.city()
            o.origin_city_en = silly.city()
            o.donor_name_he = silly.name()
            o.donor_name_en = silly.name()
            o.technical_data_he = silly.thing()
            o.technical_data_en = silly.thing()
            o.description_he = silly.thing()
            o.description_en = silly.thing()
            o.route_he = silly.thing()
            o.route_en = silly.thing()
            o.route_map = UploadedFile(open(map, "br"))
            o.save()

            # Add 4 random images to artifact
            for i in range(4):
                image = ArtifactImage()
                image.artifact = o
                filename = os.path.join(
                    settings.BASE_DIR,
                    f'artifact_images/{random.randint(1, 16)}.jpg')
                image.image = UploadedFile(open(filename, "br"))
                image.is_cover = random.choice([True, False])
                image.year_era_he = silly.name()
                image.year_era_en = silly.name()
                image.location_he = silly.name()
                image.location_en = silly.name()
                image.full_clean()
                image.save()
Esempio n. 2
0
def user_info(user: str = None, id: str = None):
    if id == None:
        set_id = uuid.uuid1()
    else:
        set_id = id
    if user is None:
        username: str = silly.name(capitalize=True)
    else:
        username = user

    title: str = silly.title(capitalize=True)
    company: str = silly.company(capitalize=True)
    address: str = silly.address(capitalize=True)
    city: str = silly.city(capitalize=True)
    country: str = silly.country(capitalize=True)
    postal_code: str = silly.postal_code()
    email = silly.email()
    phone = silly.phone_number()
    description: str = silly.paragraph(length=3)
    website = f'http://www.{silly.domain()}'
    create_date = f'{silly.datetime().year}/{silly.datetime().month}/{silly.datetime().day}'

    result = {
        'useId': str(set_id),
        'username': username,
        'title': title,
        'company': company,
        'address': address,
        'city': city,
        'country': country,
        'postal': postal_code,
        'email': email,
        'phone': phone,
        'website': website,
        'description': description,
        'dateCreate': create_date
    }
    return result
Esempio n. 3
0
def user_test_info():
    set_id = str(uuid.uuid1())
    rand_name: str = silly.noun()
    rand_num: int = random.randint(1, 10000)
    username: str = f"{rand_name}-{rand_num}"
    first_name: str = silly.verb()
    last_name: str = rand_name
    password: str = f"{silly.verb()}-{silly.noun()}"
    title: str = silly.title(capitalize=True)
    company: str = silly.company(capitalize=True)
    address: str = silly.address(capitalize=True)
    city: str = silly.city(capitalize=True)
    country: str = silly.country(capitalize=True)
    postal_code: str = silly.postal_code()
    email = silly.email()
    phone = silly.phone_number()
    description: str = silly.paragraph(length=1)
    website = f"https://www.{silly.domain()}"

    result = {
        "user_id": set_id,
        "user_name": username,
        "first_name": first_name,
        "last_name": last_name,
        "password": password,
        "title": title,
        "company": company,
        "address": address,
        "city": city,
        "country": country,
        "postal": postal_code,
        "email": email,
        "phone": phone,
        "website": website,
        "description": description,
        "is_active": random.choice([True, False]),
    }
    return result
Esempio n. 4
0
def uc_main(howmany: int):
    pw = f'{silly.noun()}{silly.verb()}'

    userList = []
    for i in range(howmany):
        j = {
            "firstName": randFirstName(),
            "lastName": randLastName(),
            "password": pw,
            "title": silly.title(capitalize=True),
            "company": silly.company(capitalize=True),
            "address": silly.address(),
            "city": silly.city(),
            "country": silly.country(),
            "postal": silly.postal_code(),
            "email": silly.email(),
            "website": silly.domain(),
            "description": silly.sentence()
        }
        userList.append(j)

    for u in tqdm(userList, desc='user create'):
        create_user(u)
Esempio n. 5
0
    # credentials = pika.PlainCredentials(username=cfg.USER, password=cfg.USER)
    # parameters = pika.ConnectionParameters(host=cfg.RABBIT_HOST, port=cfg.PORT, '/', credentials)
    credentials = pika.PlainCredentials(username='******', password='******')
    parameters = pika.ConnectionParameters("localhost", 32783, '/',
                                           credentials)
    connection = pika.BlockingConnection(parameters)
    channel = connection.channel()

    channel.queue_declare(queue=cfg.QUEUE_TOPIC)

    count_id += 1
    messType = ["100", "101", "102", "103", "200", "201", "202"]
    sr = SystemRandom()
    srType = sr.choice(messType)
    name = silly.thing()
    city = silly.city()
    company = silly.company()
    description = silly.sentence()
    data = {
        "id": count_id,
        "name": name,
        "city": city,
        "company": company,
        "description": description,
        "type": srType
    }
    message = json.dumps(data)
    channel.basic_publish(exchange='',
                          routing_key=cfg.QUEUE_TOPIC,
                          body=message)
    print(message)