コード例 #1
0
ファイル: auth.py プロジェクト: rfire01/nb
def addInvite(key, id_user, id_ensemble, id_section, admin):
    if id_section == 'None':
        o = M.Invite(key=key,
                     user_id=id_user,
                     ensemble_id=id_ensemble,
                     admin=admin)
    else:
        o = M.Invite(key=key,
                     user_id=id_user,
                     ensemble_id=id_ensemble,
                     section_id=id_section,
                     admin=admin)
    o.save()
コード例 #2
0
 def post(self):
     user = users.get_current_user()
     toEmail = self.request.get('invited')
     if toEmail:
         prefs = models.Prefs.gql('where userEmail = :1', toEmail).get()
         if prefs:
             invite = models.Invite(toUser=prefs.user, toEmail=toEmail)
             invite.put()
             notify.sendInvite(user, invite)
         else:
             invite = models.Invite(toEmail=toEmail)
             invite.put()
             notify.sendInviteEmail(user, invite)
     if self.request.get('submit') == 'Delete':
         invites = self.request.get_all('select')
         for i in invites:
             invite = db.get(i)
             invite.delete()
     if self.request.get('submit') == 'Accept':
         invites = self.request.get_all('select')
         for i in invites:
             invite = db.get(i)
             if invite:
                 invite.status = models.INVITE_ACCEPTED
                 if invite.fromPlayAs == models.PLAYAS_RANDOM:
                     invite.fromPlayAs = random.choice(
                         [models.PLAYAS_WHITE, models.PLAYAS_BLACK])
                 invite.put()
                 if invite.fromPlayAs == models.PLAYAS_WHITE:
                     game = models.Game(whitePlayer=invite.fromUser,
                                        blackPlayer=invite.toUser)
                 else:
                     game = models.Game(whitePlayer=invite.toUser,
                                        blackPlayer=invite.fromUser)
                 game.put()
                 notify.sendYourMove(game.whitePlayer, game.blackPlayer,
                                     str(game.key()))
     if self.request.get('submit') == 'Reject':
         invites = self.request.get_all('select')
         for i in invites:
             invite = db.get(i)
             if invite:
                 invite.status = models.INVITE_REJECTED
                 invite.put()
     self.redirect('/')
コード例 #3
0
def addInvite(key, id_user, id_ensemble, admin):
    o = M.Invite(key=key,
                 user_id=id_user,
                 ensemble_id=id_ensemble,
                 admin=admin)
    o.save()