Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SMSr app working to send SMS messages via Twilio and store phone numb…

…er/message in the DB.
  • Loading branch information...
commit 615fb7119c8d3242b3c64a4fbfc1ab4f37ea6d5e 1 parent 4fce90c
@akavlie authored
View
2  sms/model.py
@@ -7,7 +7,7 @@ class Sent(db.Model):
""" Record of a sent message """
__tablename__ = 'sent_messages'
id = db.Column(db.Integer, primary_key=True)
- phone = db.Column(db.Integer)
+ phone = db.Column(db.String)
date = db.Column(db.Date)
message = db.Column(db.String)
status = db.Column(db.String)
View
BIN  sms/model.pyc
Binary file not shown
View
12 sms/static/style.css
@@ -16,3 +16,15 @@ h1 {
border: 1px solid #AACBE2;
}
+#sent_messages {
+ border-collapse: collapse;
+ border: 1px solid #AACBE2;
+}
+
+ #sent_messages tr:first-child {
+ background: #CEE5F5;
+ }
+
+ #sent_messages th, #sent_messages td {
+ padding: 4px 20px;
+ }
View
18 sms/templates/index.html
@@ -2,7 +2,19 @@
{% block body %}
-<form action="/sms" method="post">
+<script type="text/javascript">
+ $SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
+
+ $(function() {
+ $("#sms_form").submit(function() {
+ $.post("/sms", $("#sms_form").serialize());
+ });
+ return false;
+ });
+
+</script>
+
+<form id="sms_form" action="">
<p><label for="phone">Phone Number: </label>
<input type="text" name="phone_number" /></p>
<p><label for="phone_number">Message: </label>
@@ -10,9 +22,8 @@
<input type="submit" value="Send" /></p>
</form>
-<div id="sent_messages">
{% if sent_messages %}
- <table>
+ <table id="sent_messages">
<tr>
<th>Time</th>
<th>Phone Number</th>
@@ -31,6 +42,5 @@
{% else %}
No messages yet!
{% endif %}
-</div>
{% endblock %}
View
1  sms/templates/layout.html
@@ -2,6 +2,7 @@
<head>
<title>SMSr</title>
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
+ <script type=text/javascript src="{{url_for('static', filename='jquery-1.4.2.min.js') }}"></script>
</head>
<body>
View
4 sms/views.py
@@ -6,7 +6,7 @@
@app.route('/')
def index():
- sent_messages = Sent.query.all()
+ sent_messages = Sent.query.order_by(Sent.id.desc()).all()
return render_template('index.html', sent_messages=sent_messages)
@app.route('/sms', methods=['POST'])
@@ -17,4 +17,4 @@ def sms():
db.session.commit()
flash('SMS sent to %s' % request.form['phone_number'])
- return redirect(url_for('index'))
+ #return redirect(url_for('index'))
Please sign in to comment.
Something went wrong with that request. Please try again.