コード例 #1
0
ファイル: notification.py プロジェクト: AloneRoad/Inforlearn
 def setUp(self):
   super(NotificationTest, self).setUp()
   self.popular = api.actor_get(api.ROOT, '*****@*****.**')
   self.unpopular = api.actor_get(api.ROOT, '*****@*****.**')
   self.girlfriend = api.actor_get(api.ROOT, '*****@*****.**')
   self.boyfriend = api.actor_get(api.ROOT, '*****@*****.**')
   self.otherboyfriend = api.actor_get(api.ROOT, '*****@*****.**')
   self.channel = api.channel_get(api.ROOT, '#[email protected]')
   self.popular_entry = api.entry_get(
       api.ROOT, 'stream/[email protected]/presence/12345')
   self.girlfriend_entry = api.entry_get(
       api.ROOT, 'stream/[email protected]/presence/16961')
   self.channel_entry = api.entry_get(
       api.ROOT, 'stream/#[email protected]/presence/13345')
コード例 #2
0
ファイル: notification.py プロジェクト: Git-Host/jaikuengine
 def setUp(self):
   super(NotificationTest, self).setUp()
   self.popular = api.actor_get(api.ROOT, '*****@*****.**')
   self.unpopular = api.actor_get(api.ROOT, '*****@*****.**')
   self.girlfriend = api.actor_get(api.ROOT, '*****@*****.**')
   self.boyfriend = api.actor_get(api.ROOT, '*****@*****.**')
   self.otherboyfriend = api.actor_get(api.ROOT, '*****@*****.**')
   self.channel = api.channel_get(api.ROOT, '#[email protected]')
   self.popular_entry = api.entry_get(
       api.ROOT, 'stream/[email protected]/presence/12345')
   self.girlfriend_entry = api.entry_get(
       api.ROOT, 'stream/[email protected]/presence/16961')
   self.channel_entry = api.entry_get(
       api.ROOT, 'stream/#[email protected]/presence/13345')
   self.pshb_endpoints = [x.target for x in api.pshb_get_firehoses(api.ROOT)
                          if x.state == 'subscribed']
コード例 #3
0
ファイル: tests.py プロジェクト: lotux/JaikuEngine
  def test_post_signed_in(self):
    message = "test post"
    r = self.sign_in(self.popular, 'popular')
    r = self.send(self.popular, message)

    self.exhaust_queue_any()

    inbox = api.inbox_get_actor_overview(api.ROOT, '*****@*****.**')
    entry_ref = api.entry_get(api.ROOT, inbox[0])
    self.assertEqual(entry_ref.title(), message)
コード例 #4
0
 def setUp(self):
     super(NotificationTest, self).setUp()
     self.popular = api.actor_get(api.ROOT, '*****@*****.**')
     self.unpopular = api.actor_get(api.ROOT, '*****@*****.**')
     self.girlfriend = api.actor_get(api.ROOT, '*****@*****.**')
     self.boyfriend = api.actor_get(api.ROOT, '*****@*****.**')
     self.otherboyfriend = api.actor_get(api.ROOT,
                                         '*****@*****.**')
     self.channel = api.channel_get(api.ROOT, '#[email protected]')
     self.popular_entry = api.entry_get(
         api.ROOT, 'stream/[email protected]/presence/12345')
     self.girlfriend_entry = api.entry_get(
         api.ROOT, 'stream/[email protected]/presence/16961')
     self.channel_entry = api.entry_get(
         api.ROOT, 'stream/#[email protected]/presence/13345')
     self.pshb_endpoints = [
         x.target for x in api.pshb_get_firehoses(api.ROOT)
         if x.state == 'subscribed'
     ]
コード例 #5
0
    def test_post_signed_in(self):
        message = "test post"
        r = self.sign_in(self.popular, 'popular')
        r = self.send(self.popular, message)

        self.exhaust_queue_any()

        inbox = api.inbox_get_actor_overview(api.ROOT, '*****@*****.**')
        entry_ref = api.entry_get(api.ROOT, inbox[0])
        self.assertEqual(entry_ref.title(), message)
コード例 #6
0
ファイル: views.py プロジェクト: jimpick/jaikuengine
def channel_item(request, nick, item=None, format='html'):
  nick = clean.channel(nick)
  view = api.actor_lookup_nick(request.user, nick)

  if not view:
    raise http.Http404()

  stream_ref = api.stream_get_presence(request.user, view.nick)

  entry = '%s/%s' % (stream_ref.key().name(), item)

  entry_ref = api.entry_get(request.user, entry)
  if not entry_ref:
    raise http.Http404()

  handled = common_views.handle_view_action(
      request,
      {'entry_add_comment': entry_ref.url(), 
       'entry_remove': view.url(),
       'entry_remove_comment': entry_ref.url(),
       'entry_mark_as_spam': entry_ref.url()
       }
      )
  if handled:
    return handled

  admins = api.channel_get_admins(request.user, channel=view.nick)
  user_is_admin = request.user and request.user.nick in admins

  comments = api.entry_get_comments(request.user, entry)

  actor_nicks = [entry_ref.owner, entry_ref.actor] + [c.actor for c in comments]
  actors = api.actor_get_actors(request.user, actor_nicks)

  # display munge
  entry = display.prep_entry(entry_ref,
                             { stream_ref.key().name(): stream_ref },
                             actors)
  comments = display.prep_comment_list(comments, actors)

  # config for template
  green_top = True
  sidebar_green_top = True

  # rendering
  c = template.RequestContext(request, locals())
  if format == 'html':
    t = loader.get_template('channel/templates/item.html')
    return http.HttpResponse(t.render(c))
  elif format == 'json':
    t = loader.get_template('actor/templates/item.json')
    r = http.HttpResponse(t.render(c))
    r['Content-type'] = 'text/javascript'
    return r
コード例 #7
0
ファイル: views.py プロジェクト: hfeeki/jaikuengine
def channel_item(request, nick, item=None, format='html'):
  nick = clean.channel(nick)
  view = api.actor_lookup_nick(request.user, nick)

  if not view:
    raise http.Http404()

  stream_ref = api.stream_get_presence(request.user, view.nick)

  entry = '%s/%s' % (stream_ref.key().name(), item)

  entry_ref = api.entry_get(request.user, entry)
  if not entry_ref:
    raise http.Http404()

  handled = common_views.handle_view_action(
      request,
      {'entry_add_comment': entry_ref.url(request=request), 
       'entry_remove': view.url(request=request),
       'entry_remove_comment': entry_ref.url(request=request),
       'entry_mark_as_spam': entry_ref.url(request=request)
       }
      )
  if handled:
    return handled

  admins = api.channel_get_admins(request.user, channel=view.nick)
  user_is_admin = request.user and request.user.nick in admins

  comments = api.entry_get_comments(request.user, entry)

  actor_nicks = [entry_ref.owner, entry_ref.actor] + [c.actor for c in comments]
  actors = api.actor_get_actors(request.user, actor_nicks)

  # Creates a copy of actors with lowercase keys (Django #6904: template filter
  # dictsort sorts case sensitive), excluding channels and the currently
  # logged in user.
  participants = {}
  for k, v in actors.iteritems():
    if (v and
        not v.is_channel() and
        not (hasattr(request.user, 'nick') and request.user.nick == v.nick)):
      participants[k.lower()] = v

  # display munge
  entry = display.prep_entry(entry_ref,
                             { stream_ref.key().name(): stream_ref },
                             actors)
  comments = display.prep_comment_list(comments, actors)

  # config for template
  green_top = True
  sidebar_green_top = True

  # rendering
  c = template.RequestContext(request, locals())
  if format == 'html':
    t = loader.get_template('channel/templates/item.html')
    return http.HttpResponse(t.render(c))
  elif format == 'json':
    t = loader.get_template('actor/templates/item.json')
    r = http.HttpResponse(t.render(c))
    r['Content-type'] = 'text/javascript'
    return r
コード例 #8
0
ファイル: views.py プロジェクト: zhoujh/jaikuengine
def channel_item(request, nick, item=None, format='html'):
    nick = clean.channel(nick)
    view = api.actor_lookup_nick(request.user, nick)

    if not view:
        raise http.Http404()

    stream_ref = api.stream_get_presence(request.user, view.nick)

    entry = '%s/%s' % (stream_ref.key().name(), item)

    entry_ref = api.entry_get(request.user, entry)
    if not entry_ref:
        raise http.Http404()

    handled = common_views.handle_view_action(
        request, {
            'entry_add_comment': entry_ref.url(request=request),
            'entry_remove': view.url(request=request),
            'entry_remove_comment': entry_ref.url(request=request),
            'entry_mark_as_spam': entry_ref.url(request=request)
        })
    if handled:
        return handled

    admins = api.channel_get_admins(request.user, channel=view.nick)
    user_is_admin = request.user and request.user.nick in admins

    comments = api.entry_get_comments(request.user, entry)

    actor_nicks = [entry_ref.owner, entry_ref.actor
                   ] + [c.actor for c in comments]
    actors = api.actor_get_actors(request.user, actor_nicks)

    # Creates a copy of actors with lowercase keys (Django #6904: template filter
    # dictsort sorts case sensitive), excluding channels and the currently
    # logged in user.
    participants = {}
    for k, v in actors.iteritems():
        if (v and not v.is_channel()
                and not (hasattr(request.user, 'nick')
                         and request.user.nick == v.nick)):
            participants[k.lower()] = v

    # display munge
    entry = display.prep_entry(entry_ref,
                               {stream_ref.key().name(): stream_ref}, actors)
    comments = display.prep_comment_list(comments, actors)

    # config for template
    green_top = True
    sidebar_green_top = True

    # rendering
    c = template.RequestContext(request, locals())
    if format == 'html':
        t = loader.get_template('channel/templates/item.html')
        return http.HttpResponse(t.render(c))
    elif format == 'json':
        t = loader.get_template('actor/templates/item.json')
        r = http.HttpResponse(t.render(c))
        r['Content-type'] = 'text/javascript'
        return r