orgtool / orgtool / ext / mobile /

import datetime
from doqu.ext.fields import Field as f
from orgtool.ext.talks import Message
from orgtool.ext.actors.schema import Actor
from orgtool.ext.contacts import Contact
from import Plan

SMS_SOURCE = u'gammu-sms'
CONTACT_SOURCE = u'gammu-contact'
ACTOR_SOURCE = u'gammu-actor'
EVENT_SOURCE = u'gammu-plan'

class GammuSMS(Message):
    source = f(unicode, choices=[SMS_SOURCE], default=SMS_SOURCE)

    defaults = {
        'summary': u'No text',

class GammuActor(Actor):
    source = f(unicode, choices=[ACTOR_SOURCE], default=ACTOR_SOURCE)

    # copy of Person fields, just non-essentian
    first_name = f(unicode)
    second_name = f(unicode)
    last_name = f(unicode)
    details = f(unicode)

    # extra fields
    company = f(unicode)  # TODO: reference to an Organization
    job_title = f(unicode)

class GammuContact(Contact):
    source = f(unicode, choices=[CONTACT_SOURCE], default=CONTACT_SOURCE)

    def from_raw_elems(cls, elems):
        ACTOR_FIELDS = {
            'Text_Name': 'name',
            'Text_FirstName': 'first_name',
            'Text_LastName': 'last_name',
            'Text_JobTitle': 'job_title',
            'Text_Custom1': 'details',
            'Text_Company': 'company',
        CONTACT_FIELDS = {
            'Number_General': (u'phone', u'primary'),
            'Number_Mobile': (u'phone', u'mobile'),
            'Number_Home': (u'phone', u'home'),
            'Number_Work': (u'phone', u'work'),
            'Text_Email': (u'email', u'primary'),
            'Text_URL': (u'url', u'primary'),
        SKIPPED = 'PictureID', 'Number_Messaging'
        actor = GammuActor()
        contacts = []
        for key, value in elems:
            if key in SKIPPED:
            elif key in ACTOR_FIELDS:
                name = ACTOR_FIELDS[key]
                actor[name] = value
            elif key in CONTACT_FIELDS:
                kind, scope = CONTACT_FIELDS[key]
                contact = GammuContact(
                    kind = kind,
                    scope = scope,
                    value = value
                raise KeyError('Unknown element name {0}'.format(key))
        if actor.is_valid():
            for c in contacts:
       = actor
        return actor, contacts

class GammuPlan(Plan):
    tone_alarm_datetime = f(datetime.datetime)
    silent_alarm_datetime = f(datetime.datetime)

    source = f(unicode, choices=[EVENT_SOURCE], default=EVENT_SOURCE)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.