Esempio 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)
Esempio 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)
Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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