Esempio n. 1
0
def update_basic_startup(startup_object, request):
    fields = list(Startup.basic_info_fields)
    fields.remove('_id')
    utils.mergeFrom(request, startup_object, fields, require=False)
    #put the object ids for all the markets in the request into the startup
    put_markets(startup_object, request)
   # startup_object['markets']=[market._id for market in get_markets_from_name(request['markets'])]
    database_wrapper.save_entity(startup_object)
    return startup_object
def user_basic_info(user_id):
    entry = user.findUserByID(user_id)
    if entry is None:
        return '', HTTP_404_NOT_FOUND

    req = request.get_json()
    try:
        utils.mergeFrom(req, entry, user.User.basic_info_fields, require=False)
        database_wrapper.save_entity(entry)
    except:
        return jsonify(error='Invalid key'), HTTP_400_BAD_REQUEST
    return '', HTTP_200_OK
Esempio n. 3
0
def user_basic_info(user_id):
    entry = user.findUserByID(user_id)
    if entry is None:
        return '', HTTP_404_NOT_FOUND

    req = request.get_json()
    try:
        utils.mergeFrom(req, entry, user.User.basic_info_fields, require=False)
        database_wrapper.save_entity(entry)
    except:
        return jsonify(error='Invalid key'), HTTP_400_BAD_REQUEST
    return '', HTTP_200_OK
Esempio n. 4
0
def create_startup(user_id, request):
    startup = Startups.Startup()
    utils.mergeFrom(request, startup, Startup.required_fields)
    startup.date = datetime.datetime.utcnow()
    startup.owners.append(str(user_id))
    startup.people.append(str(user_id))
    #convert the market names in the request into market ids, increment and decrement occurences accordingly
    put_markets(startup, request)
    optional = Startup.basic_info_fields.difference(Startup.required_fields)
    optional.remove('_id')
    utils.mergeFrom(request, startup, optional, require=False)
    database_wrapper.save_entity(startup)
    return startup
Esempio n. 5
0
def create_user(attributes):
    new_user = Users.User()
    attributes = prepare(attributes)

    utils.mergeFrom(attributes, new_user, User.required_fields)

    optional = User.basic_info_fields.difference(User.required_fields)
    optional.remove('_id')

    utils.mergeFrom(attributes, new_user, optional, require=False)

    new_user.save()

    # give them a few invites
    for i in range(config['NEW_USER_INVITE_NUM']):
        invite.create_invite(new_user['_id'])
    return new_user