Exemplo n.º 1
0
 def saveparticipant(self, new, eid, player, pseudonym="", id=0, submit=""):
     if (new):
         try:
             for q in Event.get(eid).participants:
                 if (q.player.user_name == player):
                     flash(
                         "Error: %s is already a participant in this event"
                         % player)
                     raise redirect(url("/editevent/" + str(eid)))
             p = Participant(event=Event.get(eid),
                             player=User.by_user_name(player),
                             pseudonym=Pseudonym.byName(player))
         except SQLObjectNotFound:
             flash(
                 "Error: Tried to add a participant to a nonexistent event")
             raise redirect(url("/news"))
     else:
         try:
             p = Participant.get(id)
         except SQLObjectNotFound:
             flash("Error: Tried to edit a nonexistent participant")
             raise redirect(url("/news"))
         try:
             p.player = User.by_user_name(player)
             p.pseudonym = Pseudonym.byName(pseudonym)
         except SQLObjectNotFound:
             flash(
                 "Error: Tried to change pseudonym to one that doesn't exist, or change pseudonym for a player that doesn't exist"
             )
             raise redirect(url("/news"))
     flash("Participant updated!")
     raise redirect(url("/editevent/" + str(eid)))
Exemplo n.º 2
0
 def savepseudonym(self, new, name, playerid, id=0, submit=""):
     if (new):
         try:
             p = Pseudonym(player=User.get(playerid), name=name)
         except SQLObjectNotFound:
             flash("Error: Tried to add a pseudonym to a nonexistent user")
             raise redirect(url("/scoresname"))
     else:
         try:
             p = Pseudonym.get(id)
         except SQLObjectNotFound:
             flash("Error: Tried to edit a nonexistent pseudonym")
             raise redirect(url("/scoresname"))
         p.name = name
     flash("Pseudonym updated!")
     raise redirect(url("/edituser/" + p.player.user_name))
Exemplo n.º 3
0
    def saveparticipant(self,new,eid,player,pseudonym="",id=0,submit=""):
         if(new):
	     try:
	         for q in Event.get(eid).participants:
	             if(q.player.user_name==player):
		         flash("Error: %s is already a participant in this event"%player)
		         raise redirect(url("/editevent/"+str(eid)))
	         p=Participant(event=Event.get(eid),player=User.by_user_name(player),pseudonym=Pseudonym.byName(player))
             except SQLObjectNotFound:
	         flash("Error: Tried to add a participant to a nonexistent event")
		 raise redirect(url("/news"))
	 else:
	     try:
	         p=Participant.get(id)
             except SQLObjectNotFound:
	         flash("Error: Tried to edit a nonexistent participant")
		 raise redirect(url("/news"))
	     try:
	         p.player=User.by_user_name(player)
  	         p.pseudonym=Pseudonym.byName(pseudonym)
	     except SQLObjectNotFound:
	         flash("Error: Tried to change pseudonym to one that doesn't exist, or change pseudonym for a player that doesn't exist")
		 raise redirect(url("/news"))
	 flash("Participant updated!")
	 raise redirect(url("/editevent/"+str(eid)))
Exemplo n.º 4
0
    def savepseudonym(self,new,name,playerid,id=0,submit=""):
        if(new):
	    try:
                p=Pseudonym(player=User.get(playerid),name=name)
	    except SQLObjectNotFound:
	        flash("Error: Tried to add a pseudonym to a nonexistent user")
		raise redirect(url("/scoresname"))
	else:
	    try:
	        p=Pseudonym.get(id)
	    except SQLObjectNotFound:
	        flash("Error: Tried to edit a nonexistent pseudonym")
		raise redirect(url("/scoresname"))
            p.name=name
	flash("Pseudonym updated!")
	raise redirect(url("/edituser/"+p.player.user_name))
Exemplo n.º 5
0
 def saveuser(self, oldname, name, address, college, water, notes, password,
              email, adjustment):
     if (oldname):
         try:
             u = User.by_user_name(oldname)
         except SQLObjectNotFound:
             flash("Error: Tried to edit a nonexistent player")
             raise redirect(url("/scoresname"))
         #u.user_name=name #don't give too much opportunity to break things
         u.address = address
         u.college = college
         u.water = water
         u.notes = notes
         if (password):
             u.password = password
         u.email_address = email
         if (adjustment != u.adjustment and not identity.in_group('admin')):
             flash(
                 "Error: Tried to change a score adjustment while not umpire"
             )
             raise redirect(url('/scoresname'))
         u.adjustment = adjustment
     else:
         u = User(user_name=name,
                  address=address,
                  college=college,
                  water=water,
                  notes=notes,
                  password=password,
                  email_address=email,
                  score=0.0,
                  adjustment=adjustment)
         p = Pseudonym(name=name, player=u)
     self.updatescores()
     flash("Player updated!")
     raise redirect(url("/scoresname"))