Пример #1
0
def api_keys(request):

  # special case this because we want to redirect to the edit page
  if 'oauth_generate_consumer' in request.POST:
    action = 'oauth_generate_consumer'
    (called, rv) = common_views.call_api_from_request(request, action)
    return util.RedirectFlash(rv.url(), messages.flash(action))

  handled = common_views.handle_view_action(
      request,
      {}
  )
  if handled:
    return handled

  # Get list of consumer tokenss for this actor
  consumer_tokens = api.oauth_get_actor_consumers(request.user,
                                                  request.user.nick)

  # TODO(termie): Get list of access tokens this actor has given others
  access_tokens = []

  # for templates
  full_page = 'Keys'
  page = 'keys'
  area = 'api'

  c = template.RequestContext(request, locals())
  t = loader.get_template('api/templates/keys.html')
  return http.HttpResponse(t.render(c))
Пример #2
0
def api_keys(request):

    # special case this because we want to redirect to the edit page
    if 'oauth_generate_consumer' in request.POST:
        action = 'oauth_generate_consumer'
        (called, rv) = common_views.call_api_from_request(request, action)
        return util.RedirectFlash(rv.url(), messages.flash(action))

    handled = common_views.handle_view_action(request, {})
    if handled:
        return handled

    # Get list of consumer tokenss for this actor
    consumer_tokens = api.oauth_get_actor_consumers(request.user,
                                                    request.user.nick)

    # TODO(termie): Get list of access tokens this actor has given others
    access_tokens = []

    # for templates
    full_page = 'Keys'
    page = 'keys'
    area = 'api'

    c = template.RequestContext(request, locals())
    t = loader.get_template('api/templates/keys.html')
    return http.HttpResponse(t.render(c))
Пример #3
0
def handle_view_action(request, actions):
  """Call an API function based on the request parameters if there is a match
  to the keys in 'actions'. Redirect to the corresponding value in 'actions'
  after the call.
  """
  for action in actions.keys():
    called, ret = call_api_from_request(request, action)
    if called:
      redirect = actions[action]
      return util.RedirectFlash(redirect, messages.flash(action))
  return None
Пример #4
0
 def test_delete_channel_as_admin(self):
     self.login('popular')
     r = self.client.post(
         '/channel/popular/settings/delete', {
             'nick': '#[email protected]',
             'actor_remove': '',
             '_nonce': util.create_nonce('popular', 'actor_remove'),
         })
     r = self.assertRedirectsPrefix(r, '/channel')
     self.assertContains(r, messages.flash('actor_remove'))
     self.assertWellformed(r)
Пример #5
0
def handle_view_action(request, actions):
    """Call an API function based on the request parameters if there is a match
  to the keys in 'actions'. Redirect to the corresponding value in 'actions'
  after the call.
  """
    for action in actions.keys():
        called, ret = call_api_from_request(request, action)
        if called:
            redirect = actions[action]
            return util.RedirectFlash(redirect, messages.flash(action))
    return None
Пример #6
0
 def test_delete_channel_as_admin(self):
   self.login('popular')
   r = self.client.post('/channel/popular/settings/delete',
                        {'nick': '#[email protected]',
                         'actor_remove': '',
                         '_nonce' : 
                             util.create_nonce('popular', 'actor_remove'),
                         }
                        )
   r = self.assertRedirectsPrefix(r, '/channel')
   self.assertContains(r, messages.flash('actor_remove'))
   self.assertWellformed(r)