Ejemplo n.º 1
0
 def index(self):
     form = SendMessageForm()
     if form.validate_on_submit():
         send_messages(form.users_list, form.message.data)
     else:
         flash_errors(form)
     return self.render('admin/message.html', form=form)
Ejemplo n.º 2
0
 def index(self):
     form = SendMessageForm()
     if form.validate_on_submit():
         send_messages(form.users_list, form.message.data)
     else:
         flash_errors(form)
     return self.render('admin/message.html', form=form)
Ejemplo n.º 3
0
 def test_validate_success(self, user):
     form = SendMessageForm(users=[user.id], message='Test')
     form.users.choices = [(user.id, user.full_name)]
     assert form.validate() is True
     assert user in form.users_list
Ejemplo n.º 4
0
 def test_validate_empty_message(self, user):
     form = SendMessageForm(users=[user.id])
     assert form.validate() is False
     assert 'This field is required.' in form.message.errors
Ejemplo n.º 5
0
 def test_validate_no_recipients_selected(self, user):
     pass
     form = SendMessageForm(message='Test Message')
     assert form.validate() is False
     assert 'This field is required.' in form.users.errors
Ejemplo n.º 6
0
 def test_validate_success(self, user):
     form = SendMessageForm(users=[user.id], message='Test')
     form.users.choices = [(user.id, user.full_name)]
     assert form.validate() is True
     assert user in form.users_list
Ejemplo n.º 7
0
 def test_validate_empty_message(self, user):
     form = SendMessageForm(users=[user.id])
     assert form.validate() is False
     assert 'This field is required.' in form.message.errors
Ejemplo n.º 8
0
 def test_validate_no_recipients_selected(self, user):
     pass
     form = SendMessageForm(message='Test Message')
     assert form.validate() is False
     assert 'This field is required.' in form.users.errors