Exemple #1
0
  def post(self):
    message = xmpp.Message(self.request.POST)
    user = models.get_user_(users.User(message.sender.split('/')[0]))
    if user is not None:
      models.create_comment(user, message.body)
      memcache.delete("comments")

      body = user.nickname + '> ' + message.body
      xmpp.send_message(models.get_jids(), body, APP_URL + ".appspot.com", xmpp.MESSAGE_TYPE_CHAT)
Exemple #2
0
  def get(self):
    if not requires_registered(self):
      return

    template_file = os.path.join(os.path.dirname(__file__), 'templates/profile.html')
    template_values = {
      'greeting': get_greeting(),
      'is_admin': is_admin(),
      'is_registered': is_registered(),
      'user': models.get_user_(users.get_current_user())
    }

    self.response.out.write(Template(filename=template_file,lookup=mylookup).render_unicode(**template_values))
Exemple #3
0
  def post(self):
    if not requires_registered(self):
      return

    if self.request.get('text'):
      text = self.request.get('text')
      user = models.get_user_(users.get_current_user())
      models.create_comment(user, text)
      memcache.delete("comments")

      body = user.nickname + '> ' + text
      xmpp.send_message(models.get_jids(), body, APP_URL + ".appspot.com", xmpp.MESSAGE_TYPE_CHAT)

    self.redirect('/comment')
    return
Exemple #4
0
  def get(self):
    if not requires_registered(self):
      return

    template_file = os.path.join(os.path.dirname(__file__), 'templates/simulate.html')
    template_values = {
      'greeting': get_greeting(),
      'is_admin': is_admin(),
      'is_registered': is_registered(),
      'me': models.get_user_(users.get_current_user()),
      'registered_users': models.get_possible_opponents(),
      'score1': 0,
      'score2': 0,
      'opponent': 0,
      'userscore1': 0,
      'userscore2': 0
    }
    self.response.out.write(Template(filename=template_file,lookup=mylookup).render_unicode(**template_values))
Exemple #5
0
  def post(self):
    if not requires_registered(self):
      return

    match_id = models.create_new_match(users.get_current_user(), self.request)
    memcache.delete_multi([ "ranks", "matches_home_admin", "matches_home" ])

    if match_id is None:
      self.redirect('/') # TODO error message
      return

    models.update_scores(match_id)

    body = "%s %s - %s %s" % (models.get_user_(users.get_current_user()).nickname, self.request.get('score1'),\
                              self.request.get('score2'), models.get_user(long(self.request.get('player2'))).nickname)
    xmpp.send_message(models.get_jids(), body, APP_URL + "@appspot.com", xmpp.MESSAGE_TYPE_CHAT)
    
    self.redirect('/')
Exemple #6
0
  def post(self):
    if not requires_registered(self):
      return

    score1 = long(self.request.get('score1', 0))
    score2 = long(self.request.get('score2', 0))
    opponent = long(self.request.get('player2', 0))

    if (score1 != 3 and score2 != 3) or (score1 == 3 and score2 == 3):
      self.redirect('/match/simulate')
      return

    me = models.get_user_(users.get_current_user())
    userscore1 = me.score
    userscore2 = models.get_user(opponent).score

    if score1 > score2:
      [ userscore1, userscore2 ] = elo.compute_score(userscore1, userscore2, abs(score1 - score2))
    else:
      [ userscore2, userscore1 ] = elo.compute_score(userscore2, userscore1, abs(score1 - score2))

    template_file = os.path.join(os.path.dirname(__file__), 'templates/simulate.html')
    template_values = {
      'greeting': get_greeting(),
      'is_admin': is_admin(),
      'is_registered': is_registered(),
      'me': me,
      'registered_users': models.get_possible_opponents(),
      'score1': score1,
      'score2': score2,
      'opponent': opponent,
      'opponent_nickname': models.get_user(opponent).nickname,
      'userscore1': userscore1,
      'userscore2': userscore2
    }
    self.response.out.write(Template(filename=template_file,lookup=mylookup).render_unicode(**template_values))