Example #1
0
  def wrapped(self, *args, **kwargs):
    from maeve.models import Character
    char_id = self.request.get('char')
    if not char_id:
      return self.redirect('/profile')

    char = Character.by_char_id(char_id)
    if not char:
      self.session.add_flash('No character with that id found', key='top_messages')
      return self.redirect('/profile')

    if users.is_current_user_admin() or users.get_current_user() == char.user:
      self.character = char
      return fn(self, *args, **kwargs)
    else:
      return self.redirect('/profile')
Example #2
0
def index_all_characters():

  characters = Character.query(Character.active == True)
  task_count = 0
  update_after = datetime.now() - timedelta(hours=1)
  for character in characters:
    if not character.last_update or character.last_update < update_after:
      task_count += 1
      taskqueue.add(url='/_task/sync',
                    params={'char': character.key.urlsafe()},
                    queue_name='transaction-sync',
                    )
    else:
      logging.debug('Skipping char {0}'.format(character.name))

  logging.info('{0} sync tasks enqueued'.format(task_count))
Example #3
0
  def get(self):
    env = dict()
    flash_env = self.session.get_flashes(key='env_flash')
    if flash_env:
      for e, _ in flash_env:
        env.update(e)

    active_chars, inactive_chars = [], []

    for char in Character.by_user():
      if char.active:
        active_chars.append(char)
      else:
        inactive_chars.append(char)

    env.update(dict(active_chars=active_chars,
                    inactive_chars=inactive_chars))

    self.render_response('profile/index.html', env)
Example #4
0
def get_characters_async():
  characters = yield Character.query().fetch_async()
  raise ndb.Return(characters)