def post(self):
     """Adds new leader to list or changes existing"""
     if self.request.POST['llKey']:
         new_fio = self.request.POST['llFio']
         new_command = self.request.POST['llComand']
         new_terry = self.request.POST['llTerritory']
         new_contact = self.request.POST['llContact']
         lead_key = self.request.POST['llKey']
         leader = Leader.get(lead_key)
         leader.nickname = new_fio
         leader.contact = new_contact
         team = leader.command
         team.name = new_command
         team.territory = new_terry
         team.put()
         leader.put()
         tooltip_message = u'Руководитель %s изменен' % new_fio
     else:
         fio = self.request.POST['llFio']
         command = self.request.POST['llComand']
         terry = self.request.POST['llTerritory']
         contact = self.request.POST['llContact']
         team = Command(name=command, territory=terry)
         team.put()
         new_lead = Leader(user=users.User(email=contact), nickname=fio, command=team, contact=contact)
         new_lead.put()
         global tooltip_message
         global tooltip_show
         tooltip_message = u'Руководитель %s добавлен базу' % fio
     tooltip_show = 'block'
     time.sleep(0.1)
     self.redirect('/reg/leaderList')
    def get(self):
        """(for developing mode) Adds initial data to database"""
        user = users.get_current_user()
        com1 = Command(name=u'Фортуна', territory=u'Ангарск')
        com2 = Command(name=u'Фортуна', territory=u'Москва')
        com1.put()
        com2.put()
        paswd = '123'
        paswd = salt_pass(paswd)
        org1 = Organizer(user=users.User('*****@*****.**'), nickname=u'Олишевская Анна', contact='*****@*****.**')
        org2 = Organizer(user=users.User('*****@*****.**'), nickname=u'Тест Тестович', contact='*****@*****.**')
        org3 = Organizer(user=users.User('*****@*****.**'), nickname=u'Плотникова Дарья', contact='*****@*****.**')
        org4 = Organizer(user=users.User('*****@*****.**'), nickname=u'Потапейко Дмитрий', contact='*****@*****.**')
        lead1 = Leader(user=users.User('*****@*****.**'), nickname=u'Олишевская Анна', contact='*****@*****.**', command=com2)

        memb1 = Member(pass_to_edit=paswd, sex=u'Женский', nickname='*****@*****.**', surname=u'Плотникова Дарья',
                       command=com1, birthdate=1994, qualification='I')
        memb2 = Member(pass_to_edit=paswd, sex=u'Мужской', nickname='[email protected]', surname=u'Хайруллин Марат', command=com1,
                       birthdate=1994, qualification='I')
        memb3 = Member(pass_to_edit=paswd, sex=u'Мужской', nickname='*****@*****.**', surname=u'Потапейко Дмитрий',
                       command=com2, birthdate=1995, qualification='I')
        memb1.put()
        memb2.put()
        memb3.put()
        org1.put()
        org2.put()
        org3.put()
        org4.put()
        lead1.put()