Example #1
0
#!/usr/bin/python

import session
from model import *
from cStringIO import StringIO
import timeutil
import sys
import os
import urllib

user = session.user()
tz = timeutil.get_tz(user)

def renderEvent(event):
    out = StringIO()
    print >>out, '<div class="event %s" id="event-%d">' % (
        event.inbound and 'inbound' or 'outbound',
        event.id)

    if event.status:
        print >>out, '<div class="status stat-%s">%s</div>' % (
            event.status,
            event.status
            )

    print >>out, '<div class="when">%s</div>' % timeutil.convert(event.time,tz).strftime('%x %H:%M')

    if event.call_duration:
        print >>out, '<div class="call">Call, %d seconds</div>' % event.call_duration
    if event.message_body:
        print >>out, '<div class="text">%s</div>' % event.message_body
Example #2
0
#!/usr/bin/python
"""Routines and request handler for getting information about the inbox."""

import session
session.user(doLogin=False)

import os
import control
import json
import render
import calendar
import timeutil
import sys
from model import *
import config

user = session.user()
argv = session.argv()

def lastitem():
    try:
        latest = user.threads.order_by(Conversation.last_update.desc()).get().last_update
    except Conversation.DoesNotExist:
        latest = timeutil.getTime()
    return timeutil.toStamp(latest)

def updatedThreads(since):
    ref = timeutil.fromStamp(since)
    updThreads = user.threads.where(Conversation.last_update > ref)
    return [{'tid' : t.id,
             'events' : [
Example #3
0
#!/usr/bin/python
"""Routines and request handler for getting information about the inbox."""

import session

session.user(doLogin=False)

import os
import control
import json
import render
import calendar
import timeutil
import sys
from model import *
import config

user = session.user()
argv = session.argv()


def lastitem():
    try:
        latest = user.threads.order_by(
            Conversation.last_update.desc()).get().last_update
    except Conversation.DoesNotExist:
        latest = timeutil.getTime()
    return timeutil.toStamp(latest)


def updatedThreads(since):
Example #4
0
#!/usr/bin/python

import session
import control
import model
import timeutil
from model import Event, Inbox
from twilio.rest import TwilioRestClient
import twilio
import config
import sys
import urllib
import render

user = session.user()
form = session.form()

for check in ['Body', 'From', 'To']:
    if not form.getfirst(check):
        print render.pageHead("Send a message")
        print '''<body>
<form method="POST" action="sendmsg.py" class="sms">
<select name="From">'''
        for inbox in user.inboxes.order_by(Inbox.priority):
            print '<option value="%s" %s>%s (%s)</option>' % (
                inbox.phone_number,
                form.getfirst('From') == inbox.phone_number and ' selected' or '',
                inbox.phone_number,
                inbox.name
                )
        print '''</select>
 def username():
     return session.user()['name']
 def user():
     return session.user()