コード例 #1
0
ファイル: views.py プロジェクト: CollabQ/CollabQ
def channel_index(request, format='html'):
  """ the index page for channels, /channel

  should list the channels you administer, the channels you belong to
  and let you create new channels

  if you are not logged in, it should suggest that you log in to create or
  join channels and give a list of public channels
  """
  if not request.user:
    return channel_index_signedout(request, format='html')

  owned_nicks = api.actor_get_channels_admin(
      request.user,
      request.user.nick,
      limit=(CHANNELS_PER_INDEX_PAGE + 1))
  owned_more = len(owned_nicks) > CHANNELS_PER_INDEX_PAGE

  followed_nicks = api.actor_get_channels_member(
      request.user,
      request.user.nick,
      limit=(CHANNELS_PER_INDEX_PAGE + 1))
  followed_more = len(owned_nicks) > CHANNELS_PER_INDEX_PAGE

  channel_nicks = owned_nicks + followed_nicks
  channels = api.channel_get_channels(request.user, channel_nicks)

  owned_channels = [channels[x] for x in owned_nicks if channels[x]]
  for c in owned_channels:
    c.i_am_admin = True

  followed_channels = [
      channels[x] for x in followed_nicks 
          if channels[x] and x not in owned_nicks
  ]
  for c in followed_channels:
    c.i_am_member = True

  try:
    # for the Our Picks section of the sidebar
    ourpicks_channels = api.actor_get_channels_member(request.user, api.ROOT.nick)
    ourpicks_channels = api.channel_get_channels(request.user, ourpicks_channels)  
    ourpicks_channels = [x for x in ourpicks_channels.values() if x]
  except exception.ApiNotFound:
    pass
  
  related_tags = api.channel_get_children_tags(request.user)

  is_admin_user = request.user.nick in settings.ADMINS_POBOX
  
  area = 'channel'
  c = template.RequestContext(request, locals())
  

  if format == 'html':
    t = loader.get_template('channel/templates/index.html')
    return http.HttpResponse(t.render(c))
コード例 #2
0
ファイル: views.py プロジェクト: zhoujh/jaikuengine
def channel_index(request, format='html'):
    """ the index page for channels, /channel

  should list the channels you administer, the channels you belong to
  and let you create new channels

  if you are not logged in, it should suggest that you log in to create or
  join channels and give a list of public channels
  """
    if not request.user:
        return channel_index_signedout(request, format='html')

    owned_nicks = api.actor_get_channels_admin(request.user,
                                               request.user.nick,
                                               limit=(CHANNELS_PER_INDEX_PAGE +
                                                      1))
    owned_more = len(owned_nicks) > CHANNELS_PER_INDEX_PAGE

    followed_nicks = api.actor_get_channels_member(
        request.user, request.user.nick, limit=(CHANNELS_PER_INDEX_PAGE + 1))
    followed_more = len(owned_nicks) > CHANNELS_PER_INDEX_PAGE

    channel_nicks = owned_nicks + followed_nicks
    channels = api.channel_get_channels(request.user, channel_nicks)

    owned_channels = [channels[x] for x in owned_nicks if channels[x]]
    for c in owned_channels:
        c.i_am_admin = True

    followed_channels = [
        channels[x] for x in followed_nicks
        if channels[x] and x not in owned_nicks
    ]
    for c in followed_channels:
        c.i_am_member = True

    try:
        # for the Our Picks section of the sidebar
        ourpicks_channels = api.actor_get_channels_member(
            request.user, api.ROOT.nick)
        ourpicks_channels = api.channel_get_channels(request.user,
                                                     ourpicks_channels)
        ourpicks_channels = [x for x in ourpicks_channels.values() if x]
    except exception.ApiNotFound:
        pass

    area = 'channel'
    c = template.RequestContext(request, locals())

    if format == 'html':
        t = loader.get_template('channel/templates/index.html')
        return http.HttpResponse(t.render(c))
コード例 #3
0
ファイル: views.py プロジェクト: zhoujh/jaikuengine
def channel_browse(request, format='html'):
    per_page = CHANNELS_PER_PAGE
    prev_offset, _ = util.page_offset_nick(request)

    # Use +1 to identify if there are more that need to be displayed.
    channel_list = api.channel_browse(request.user, (per_page + 1),
                                      prev_offset)

    actors, more = util.page_actors(request, channel_list, per_page)
    offset_text = 'More'

    # for the Our Picks section of the sidebar
    ourpicks_channels = api.actor_get_channels_member(request.user,
                                                      api.ROOT.nick)
    ourpicks_channels = api.channel_get_channels(request.user,
                                                 ourpicks_channels)
    ourpicks_channels = [x for x in ourpicks_channels.values() if x]

    area = 'channel'
    c = template.RequestContext(request, locals())

    # TODO(tyler): Other output formats.
    if format == 'html':
        t = loader.get_template('channel/templates/browse.html')
        return http.HttpResponse(t.render(c))
コード例 #4
0
ファイル: views.py プロジェクト: hfeeki/jaikuengine
def channel_index_signedout(request, format='html'):
  # for the Our Picks section of the sidebar
  ourpicks_channels = api.actor_get_channels_member(request.user, api.ROOT.nick)
  ourpicks_channels = api.channel_get_channels(request.user, ourpicks_channels)  
  ourpicks_channels = [x for x in ourpicks_channels.values() if x]

  area = 'channel'
  c = template.RequestContext(request, locals())

  if format == 'html':
    t = loader.get_template('channel/templates/index_signedout.html')
    return http.HttpResponse(t.render(c))
コード例 #5
0
ファイル: views.py プロジェクト: zhoujh/jaikuengine
def channel_index_signedout(request, format='html'):
    # for the Our Picks section of the sidebar
    ourpicks_channels = api.actor_get_channels_member(request.user,
                                                      api.ROOT.nick)
    ourpicks_channels = api.channel_get_channels(request.user,
                                                 ourpicks_channels)
    ourpicks_channels = [x for x in ourpicks_channels.values() if x]

    area = 'channel'
    c = template.RequestContext(request, locals())

    if format == 'html':
        t = loader.get_template('channel/templates/index_signedout.html')
        return http.HttpResponse(t.render(c))
コード例 #6
0
ファイル: views.py プロジェクト: hfeeki/jaikuengine
def channel_browse(request, format='html'):
  per_page = CHANNELS_PER_PAGE
  prev_offset, _ = util.page_offset_nick(request)

  # Use +1 to identify if there are more that need to be displayed.
  channel_list = api.channel_browse(request.user, (per_page+1), prev_offset)

  actors, more = util.page_actors(request, channel_list, per_page)
  offset_text = 'More'
  
  # for the Our Picks section of the sidebar
  ourpicks_channels = api.actor_get_channels_member(request.user, api.ROOT.nick)
  ourpicks_channels = api.channel_get_channels(request.user, ourpicks_channels)  
  ourpicks_channels = [x for x in ourpicks_channels.values() if x]

  area = 'channel'
  c = template.RequestContext(request, locals())

  # TODO(tyler): Other output formats.
  if format == 'html':
    t = loader.get_template('channel/templates/browse.html')
    return http.HttpResponse(t.render(c))
コード例 #7
0
ファイル: views.py プロジェクト: jimpick/jaikuengine
def front_front(request):
  # if the user is logged in take them to their overview
  if request.user:
    return HttpResponseRedirect(request.user.url() + "/overview")

  # NOTE: grab a bunch of extra so that we don't ever end up with
  #       less than 5
  per_page = ENTRIES_PER_PAGE * 2

  inbox = api.inbox_get_explore(request.user, limit=per_page)

  # START inbox generation chaos
  # TODO(termie): refacccttttooorrrrr
  entries = api.entry_get_entries(request.user, inbox)
  per_page = per_page - (len(inbox) - len(entries))
  entries, more = util.page_entries(request, entries, per_page)

  stream_keys = [e.stream for e in entries]
  streams = api.stream_get_streams(request.user, stream_keys)

  actor_nicks = [e.owner for e in entries] + [e.actor for e in entries]
  actors = api.actor_get_actors(request.user, actor_nicks)

  # take it back down and don't show a more link
  entries = entries[:ENTRIES_PER_PAGE]
  more = None

  # here comes lots of munging data into shape
  streams = prep_stream_dict(streams, actors)
  entries = prep_entry_list(entries, streams, actors)

  # END inbox generation chaos

  try:
    # Featured Channels -- Ones to which the ROOT user is a member
    featured_channels = api.actor_get_channels_member(
        request.user, api.ROOT.nick, limit=SIDEBAR_FETCH_LIMIT)
    random.shuffle(featured_channels)

    # Just in case any are deleted:
    featured_channels = featured_channels[:2*SIDEBAR_LIMIT]
    featured_channels = api.channel_get_channels(
        request.user, featured_channels)
    featured_channels = [x for x in featured_channels.values() if x]
    featured_channels = featured_channels[:SIDEBAR_LIMIT]

    featured_members = api.actor_get_contacts(
        request.user, api.ROOT.nick, limit=SIDEBAR_FETCH_LIMIT)
    random.shuffle(featured_members)

    # Just in case any are deleted:
    featured_members = featured_members[:2*SIDEBAR_LIMIT]
    featured_members = api.actor_get_actors(request.user, featured_members)
    featured_members = [x for x in featured_members.values() if x]
    featured_members = featured_members[:SIDEBAR_LIMIT]

  except exception.ApiNotFound:
    pass

  root = api.ROOT

  area = 'frontpage'

  t = loader.get_template('front/templates/front.html')
  c = RequestContext(request, locals())

  return HttpResponse(t.render(c));
コード例 #8
0
def front_front(request):
  # if the user is logged in take them to their overview
  if request.user:
    url = request.user.url(request=request)
    return HttpResponseRedirect(url + "/overview")

  # NOTE: grab a bunch of extra so that we don't ever end up with
  #       less than 5
  per_page = ENTRIES_PER_PAGE * 2

  inbox = api.inbox_get_explore(request.user, limit=per_page)

  # START inbox generation chaos
  # TODO(termie): refacccttttooorrrrr
  entries = api.entry_get_entries(request.user, inbox)
  per_page = per_page - (len(inbox) - len(entries))
  entries, more = util.page_entries(request, entries, per_page)

  stream_keys = [e.stream for e in entries]
  streams = api.stream_get_streams(request.user, stream_keys)

  actor_nicks = [e.owner for e in entries] + [e.actor for e in entries]
  actors = api.actor_get_actors(request.user, actor_nicks)

  # take it back down and don't show a more link
  entries = entries[:ENTRIES_PER_PAGE]
  more = None

  # here comes lots of munging data into shape
  streams = prep_stream_dict(streams, actors)
  entries = prep_entry_list(entries, streams, actors)

  # END inbox generation chaos

  try:
    # Featured Channels -- Ones to which the ROOT user is a member
    featured_channels = api.actor_get_channels_member(
        request.user, api.ROOT.nick, limit=SIDEBAR_FETCH_LIMIT)
    random.shuffle(featured_channels)

    # Just in case any are deleted:
    featured_channels = featured_channels[:2*SIDEBAR_LIMIT]
    featured_channels = api.channel_get_channels(
        request.user, featured_channels)
    featured_channels = [x for x in featured_channels.values() if x]
    featured_channels = featured_channels[:SIDEBAR_LIMIT]

    featured_members = api.actor_get_contacts(
        request.user, api.ROOT.nick, limit=SIDEBAR_FETCH_LIMIT)
    random.shuffle(featured_members)

    # Just in case any are deleted:
    featured_members = featured_members[:2*SIDEBAR_LIMIT]
    featured_members = api.actor_get_actors(request.user, featured_members)
    featured_members = [x for x in featured_members.values() if x]
    featured_members = featured_members[:SIDEBAR_LIMIT]

  except exception.ApiNotFound:
    pass

  root = api.ROOT

  area = 'frontpage'

  t = loader.get_template('front/templates/front.html')
  c = RequestContext(request, locals())

  return HttpResponse(t.render(c));