コード例 #1
0
ファイル: test_models.py プロジェクト: jasonmyers/gamelocal
    def test_base_model_unicode_repr(self):
        from app.clubs.models import Club

        club = Club(name='©')

        self.assertEqual(club.__repr__(), b'Club \xc2\xa9')
        self.assertEqual(club.__str__(), b'Club \xc2\xa9')
コード例 #2
0
class ClubForm(Form):

    name = TextField(_('Club Name'), [Required()])
    game = SelectField(
        _('Game'),
        [Required()],
        choices=Club.choices_for('game').items(),
    )

    recaptcha = RecaptchaField()
コード例 #3
0
def new_club():
    form = ClubForm(request.form)

    if form.validate_on_submit():
        club = Club(
            name=form.name.data,
            game=form.game.data,
        )

        db.session.add(club)
        db.session.commit()
        flash(_('{club.name} has been added!'.format(club=club)))
        return redirect(url_for('.list_clubs'))

    return render_template('clubs/new.html', form=form)
コード例 #4
0
ファイル: test_models.py プロジェクト: jasonmyers/gamelocal
    def test_base_model_kwargs(self):
        from app.clubs.models import Club

        club = Club(name='test')

        self.assertEqual(club.name, 'test')
コード例 #5
0
 def name(club, n):
     game = gettext_for(locale)(Club.label_for_choice('game', club.game))
     return fmt.format(
         game=game,
         n=n,
     )