Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Got CSS & HTML prmostly where I want it for demo. Unified on-page and…

… AJAX SMS so they're using the same template.
  • Loading branch information...
commit 701ed8084727441be79392e9481b130534be24fe 1 parent 362e6ec
@akavlie authored
View
2  sms/model.py
@@ -25,7 +25,7 @@ class SentMessage(db.Model):
__tablename__ = 'sent_messages'
id = db.Column(db.Integer, primary_key=True)
phone = db.Column(db.String)
- date = db.Column(db.Date)
+ date = db.Column(db.DateTime)
message = db.Column(db.String)
status = db.Column(db.String)
sid = db.Column(db.String)
View
22 sms/static/style.css
@@ -22,14 +22,14 @@ textarea {
margin: 0;
}
-input.placeholder {
+input.placeholder, textarea.placeholder {
color: #888;
font-style: italic;
}
.clear {clear: both;}
.hidden {display: none;}
-.highlight {background-color: #FFFF99;}
+.highlight {background-color: #FFFFCC;}
/* ROUNDED CORNERS */
@@ -61,10 +61,13 @@ input.placeholder {
padding: 10px;
}
-/*#db_users {*/
+#db_users {
/*background-color: #CAE1FF;*/
- /*padding: 10px;*/
-/*}*/
+ padding: 30px 60px 50px;
+}
+ #db_users h3 {
+ margin-top: 0;
+ }
#db_table {
background-color: white;
@@ -72,7 +75,7 @@ input.placeholder {
border-collapse: collapse;
}
#db_table td {
- padding: 5px 70px 5px 0px;
+ padding: 5px 70px 5px 10px;
}
/*#other_users {*/
@@ -102,15 +105,18 @@ input.placeholder {
.sent_message {
position: relative;
margin-bottom: 10px;
- height: 120px;
+ height: 130px;
}
+ .sent_message p {
+ margin: 10px 0px;
+ }
.sent_message .status {
padding: 8px;
color: white;
font-weight: bold;
}
.sent_message .sent_body {
- padding: 8px;
+ padding: 8px 12px;
}
.sent_message .phone {
float: left;
View
19 sms/templates/index.html
@@ -20,10 +20,10 @@
{% endfor %}
</table>
</div>
- <div id="other_users" class="rounded">
- <h3>Other</h3>
- <p><input type="text" name="phone_number" size="10" placeholder="Phone"></p>
- </div>
+ <!--<div id="other_users" class="rounded">-->
+ <!--<h3>Other</h3>-->
+ <!--<p><input type="text" name="phone_number" size="10" placeholder="Phone"></p>-->
+ <!--</div>-->
<div id="message" class="rounded">
<textarea rows="2" cols="40" name="message" placeholder="Message"></textarea>
<input type="submit" value="Send">
@@ -34,16 +34,7 @@
<div id="sent_message_list">
<h2>Message History</h2>
{% for message in sent_messages %}
- <div class="sent_message rounded {{ message.status }}">
- <div class="status rounded_top">{{ message.status }}</div>
- <div class="sent_body">
- <div class="phone">{{ message.phone }}</div>
- <div class="time">{{ message.date }}</div>
- <div class="clear"></div>
- <div class="message_text"><p>{{ message.message }}</p></div>
- <div class="sid hidden">{{ message.sid }}</div>
- </div>
- </div>
+ {% include 'sent_message.html' %}
{% endfor %}
</div>
View
20 sms/templates/sent_message.html
@@ -1,10 +1,10 @@
-<div class="sent_message rounded new {{ sms.status }} hidden">
- <div class="status rounded_top">{{ sms.status }}</div>
- <div class="sent_body">
- <div class="phone">{{ sms.to }}</div>
- <div class="time">{{ sms.date_created }}</div>
- <div class="clear"></div>
- <div class="message_text"><p>{{ sms.body }}</p></div>
- <div class="sid hidden">{{ sms.sid }}</div>
- </div>
- </div>
+<div class="sent_message rounded {{ extra_classes|default() }} {{ message.status }}">
+ <div class="status rounded_top">{{ message.status }}</div>
+ <div class="sent_body">
+ <div class="phone">{{ message.phone }}</div>
+ <div class="time">{{ message.date.strftime('%I:%M %p %m/%d') }}</div>
+ <div class="clear"></div>
+ <div class="message_text"><p>{{ message.message }}</p></div>
+ <div class="sid hidden">{{ message.sid }}</div>
+ </div>
+</div>
View
12 sms/views.py
@@ -1,16 +1,18 @@
+from datetime import datetime
import json
from sms import app
from flask import render_template, request, redirect, url_for, flash
from model import db, User, SentMessage, FrequentText
-from datetime import datetime
+from jinja2 import Environment
from tw_send import twilio_send, twilio_update
+
@app.route('/')
def index():
sent_messages = SentMessage.query.order_by(SentMessage.id.desc())[0:10]
- users = User.query.all()
+ users = User.query.order_by(User.first_name).all()
return render_template('index.html', sent_messages=sent_messages,
users=users)
@@ -19,9 +21,6 @@ def sms():
"""Send an SMS to Twilio and save response to DB. """
phone_numbers = request.form.getlist('user_phone')
- # Defaults to 'Phone' with placeholder
- if request.form['phone_number'] != 'Phone':
- phone_numbers.append(request.form['phone_number'])
template = ''
@@ -37,7 +36,8 @@ def sms():
sms = SentMessage(sms_data['to'], sms_data['body'], sms_data['status'],
sms_data['sid'], datetime.now())
db.session.add(sms)
- template += render_template('sent_message.html', sms=sms_data)
+ template += render_template('sent_message.html', message=sms,
+ extra_classes='new hidden')
db.session.commit()
Please sign in to comment.
Something went wrong with that request. Please try again.