Exemplo n.º 1
0
 def __init__(self, war=None, initial=None):
     if war is not None:
         initial = forms.fill_dict(initial,
             orgamember = war.orgamember,
             status = war.status
         )
     FightUsForm.__init__(self, war, initial)
     self.contact.required = False
     self.status.choices = [(k, v) for k, v in warstates.iteritems()]
     self.orgamember.choices = [(user.id, user.display_name) for user in User.query.namesort().all()]
     self.newmemberstatus.choices = [(k, v) for k, v in memberstates.iteritems()]
     if war is not None:
         self.removemembers.choices = [(member.id, '%s (%s)' % \
                                       (member.display_name, memberstates[war.memberstatus[member]]))
                                       for member in war.members]
         self.newmember.choices = [(-1, u'')] + [(member.id, member.display_name)
                                   for member in User.query.namesort().all() if member not in war.members]
         self.removemaps.choices = [(map.id, map.name) for map in war.maps]
         self.newmap.choices = [(-1, u'')] + [(map.id, map.name)
                                for map in WarMap.query.all() if map not in war.maps]
     else:
         self.newmember.choices = [(-1, u'')] + [(member.id, member.display_name)
                                for member in User.query.namesort().all()]
         self.newmap.choices = [(-1, u'')] + [(map.id, map.name)
                                for map in WarMap.query.all()]
         del self.removemembers
         del self.removemaps
Exemplo n.º 2
0
 def __init__(self, war, warresult=None, initial=None):
     if warresult is not None:
         initial = forms.fill_dict(initial,
             our_points = warresult.our_points,
             enemy_points = warresult.enemy_points,
             comment = warresult.comment,
             status = war.status
         )
     else:
         initial = forms.fill_dict(initial,
             status = war.status if war.status > 3 else 4
         )
     forms.Form.__init__(self, initial)
     self.app = get_application()
     self.warresult = warresult
     self.war = war
     self.status.choices = [(k, v) for k, v in warstates.iteritems() if k > 3]