예제 #1
0
def get_more_narrative(start_cursor):
    ''' get the next batch of Narratives visible to the role the current user is playing after the cursor provided '''
    playing_role = _get_my_profile().playing
    query = Narrative.query(Narrative.observed == playing_role).order(-Narrative.created)
    narrative_list, next_cursor, more = query.fetch_page(NARRATIVE_PAGE_SIZE, start_cursor=Cursor(urlsafe=start_cursor))
    narrative_properties = [get_narrative_properties(narrative.key.get()) for narrative in narrative_list]
    return {"narrative":narrative_properties, 
                 "next":next_cursor.urlsafe() if more else None, 
                 "more":more}
예제 #2
0
def create_narrative(place_id, narrative_body):
    ''' create Narrative text for a Role in a Place '''
    profile = _get_my_profile()
    playing_role = profile.playing.urlsafe()
    if playing_role is None:
        raise ActionException('Not playing a Role')
    if not is_present(playing_role, place_id):
        raise ActionException('Role not present')
    place = _get_place(place_id)
    narrative = Narrative(role=_get_playing(), place=place.key)
    roles = _get_roles_in_place(place_id)
    roles.append(place.key.parent())
    narrative.observed = roles
    narrative.body = narrative_body
    narrative.created = datetime.now()
    narrative.createdby = profile.playing
    narrative.put()
    return narrative.key.urlsafe()