Ejemplo n.º 1
0
def get_details(startup_object, current_user_id):
    qa = startup_object.qa
    if not is_owner(current_user_id, startup_object):
        # get only answered messages
        qa = filter(lambda q: q['status'] == Startup.question_status['ANSWERED'], qa)

    for qa_item in qa:
        asker_user = user.findUserByID(ObjectId(qa_item['asker']))
        qa_item['asker'] = utils.jsonFields(asker_user, user.User.basic_info_fields, response=False)

    all_people_needed = set()
    annotated_wall = []
    for wall_item in startup_object.wall:
        all_people_needed.add(wall_item['user'])
        annotated_wall_item = wall_item.copy()
        annotated_wall_item['user'] = str(annotated_wall_item['user'])
        annotated_wall.append(annotated_wall_item)

    users = {}
    for basic_info in user.get_basic_info_from_ids(list(all_people_needed)):
        users[basic_info['_id']] = basic_info

    for wall_item in annotated_wall:
        wall_item['user'] = utils.jsonFields(users[wall_item['user']], user.User.basic_info_fields, response=False)

    people_info = user.get_basic_info_from_ids(map(ObjectId, startup_object.people))
    return {'qa': qa, 'wall': annotated_wall, 'people': people_info, 'overview': startup_object.overview}
Ejemplo n.º 2
0
def get_basic_info_from_users(users):
    basic_users = []
    for user_object in users:
        basicuser = utils.jsonFields(user_object,
                                     User.basic_info_fields,
                                     response=False)
        basic_users.append(basicuser)
    return basic_users
Ejemplo n.º 3
0
def post_wall(startup_object, request, current_user_id):
    msg = {'user': current_user_id, 'message': request['message'], 'date': datetime.datetime.utcnow(), 'id': str(ObjectId())}
    startup_object.wall.insert(0, msg)

    database_wrapper.save_entity(startup_object)

    msg['user'] = utils.jsonFields(user.findUserByID(current_user_id), user.User.basic_info_fields, response=False)
    return msg
Ejemplo n.º 4
0
def get_basic_startup(startup_object, current_user_id=None):
    fields = list(Startup.basic_info_fields)
    current_user_id = current_user_id if current_user_id else user.getUserID('me')
    owner = {'isOwner': is_owner(current_user_id, startup_object)}
    output = utils.jsonFields(startup_object, fields, response=False, extra=owner)
    #append the string names for the markets to the basic info
    output['markets'] = [str(market['name']) for market in get_markets_from_id(startup_object['markets'])]
    return output
Ejemplo n.º 5
0
def get_basic_info_with_security(userObject):  # O(N)
    fields = list(User.basic_info_fields)
    conn_type = connection_type(userObject)
    if conn_type == User.connection_types['CONNECTED']:
        fields.append('email')

    return utils.jsonFields(userObject,
                            fields,
                            response=True,
                            extra={'connectionType': conn_type})
Ejemplo n.º 6
0
def get_invite_attributes(invite):
    return utils.jsonFields(invite, Invite.basic_fields, response=False)
def get_invite_attributes(invite):
    return utils.jsonFields(invite, Invite.basic_fields, response=False)