def get_template(template): if isinstance(template, MessageTemplate): return template if type(template) in [str, unicode, ObjectId]: return MessageTemplate.objects(pk=str(template)).first() else: return None
def template_view(type='email', id=None): return render_template( 'message_templates/view.html', template=MessageTemplate.objects(pk=str(id)).first(), type=type)
<!-- Change this to a button or input when using this as a form --> <a href="index.html" class="btn btn-lg btn-success btn-block">Login</a> </fieldset> </form> </div> </div> </div> </div> </div> """ if MessageTemplate.objects.count() is 0: types = [EMAIL, SMS, PUSH_NOTIFICATION] for i in xrange(100): templates.append( MessageTemplate(title='title %d' % i, subject='Test Subject Here', type=types[i % len(types)], body=body).save()) if SingleTask.objects.count() is 0: for i in xrange(20): notification_type = [EMAIL, SMS, PUSH_NOTIFICATION][i % 3] SingleTask(notification_type=notification_type, status=PENDING, template=MessageTemplate.objects.first(), scheduled_time=datetime.datetime.now()).save() if RecurringTask.objects.count() is 0: for i in xrange(20): notification_type = [EMAIL, SMS, PUSH_NOTIFICATION][i % 3] RecurringTask(notification_type=notification_type, status=PENDING,
def templates(type='email'): return render_template('message_templates/list.html', templates=MessageTemplate.objects(type=type).all(), type=type)
def template_view(type='email', id=None): return render_template('message_templates/view.html', template=MessageTemplate.objects(pk=str(id)).first(), type=type)