Ejemplo n.º 1
0
  def context(self, data, check, mutator):
    context = {
        'page_name': '%s - Home page' % data.organization.name,
        'about_us': AboutUs(data),
        'contact_us': ContactUs(data),
        'feed_url': data.organization.feed_url,
    }

    if data.timeline.tasksPubliclyVisible():
      context['open_tasks_list'] = OpenTasksList(data)
      context['completed_tasks_list'] = CompletedTasksList(data)

    if data.is_host or accounts.isDeveloper():
      context['host_actions'] = HostActions(data)

    return context
Ejemplo n.º 2
0
    def context(self, data, check, mutator):
        context = {
            'page_name': '%s - Home page' % data.organization.name,
            'about_us': AboutUs(data),
            'contact_us': ContactUs(data),
            'feed_url': data.organization.feed_url,
        }

        if data.timeline.tasksPubliclyVisible():
            context['open_tasks_list'] = OpenTasksList(data)
            context['completed_tasks_list'] = CompletedTasksList(data)

        if data.is_host or accounts.isDeveloper():
            context['host_actions'] = HostActions(data)

        return context
Ejemplo n.º 3
0
  def testIsDeveloper(self):
    """Tests if the current user is a developer.
    """
    default_developer_setting = os.environ.get('USER_IS_ADMIN', None)
    default_account_setting = os.environ.get('USER_EMAIL', None)
    #test currently logged in user  
    try:
      os.environ['USER_EMAIL'] = '*****@*****.**'
      os.environ['USER_IS_ADMIN'] = '0'
      self.assertFalse(accounts.isDeveloper())
      account = users.User(email=os.environ['USER_EMAIL'])
      self.assertFalse(accounts.isDeveloper(account))
    finally:
      if default_account_setting is None:
        del os.environ['USER_EMAIL']
      else:
        os.environ['USER_EMAIL'] = default_account_setting
      if default_developer_setting is None:
        del os.environ['USER_IS_ADMIN']
      else:
        os.environ['USER_IS_ADMIN'] = default_developer_setting

    #test currently logged in user as a developer  
    try:
      os.environ['USER_EMAIL'] = '*****@*****.**'
      os.environ['USER_IS_ADMIN'] = '1'
      self.assertTrue(accounts.isDeveloper())
      account = users.User(email=os.environ['USER_EMAIL'])
      self.assertTrue(accounts.isDeveloper(account))
    finally:
      if default_account_setting is None:
        del os.environ['USER_EMAIL']
      else:
        os.environ['USER_EMAIL'] = default_account_setting
      if default_developer_setting is None:
        del os.environ['USER_IS_ADMIN']
      else:
        os.environ['USER_IS_ADMIN'] = default_developer_setting

    #no currently logged in user and google acc not passed
    try:
      os.environ['USER_EMAIL'] = ''
      os.environ['USER_IS_ADMIN'] = '0'
      self.assertFalse(accounts.isDeveloper())
    finally:
      if default_account_setting is None:
        del os.environ['USER_EMAIL']
      else:
        os.environ['USER_EMAIL'] = default_account_setting
      if default_developer_setting is None:
        del os.environ['USER_IS_ADMIN']
      else:
        os.environ['USER_IS_ADMIN'] = default_developer_setting

    #no user logged in but the environ variable for developer is set to true
    try:
      os.environ['USER_EMAIL'] = ''
      os.environ['USER_IS_ADMIN'] = '1'
      self.assertFalse(accounts.isDeveloper())
    finally:
      os.environ['USER_EMAIL'] = self.account.email()
      if default_account_setting is None:
        del os.environ['USER_EMAIL']
      else:
        os.environ['USER_EMAIL'] = default_account_setting
      if default_developer_setting is None:
        del os.environ['USER_IS_ADMIN']
      else:
        os.environ['USER_IS_ADMIN'] = default_developer_setting