Exemple #1
0
def send_message_auto_complete_processor(request):
    """
    Adds completions for the expression auto-completion to the request context
    """
    completions = []
    user = request.user
    org = None

    if hasattr(user, "get_org"):
        org = request.user.get_org()

    if org:
        completions.append(dict(name="contact",
                                display=str(_("Contact Name"))))
        completions.append(
            dict(name="contact.first_name",
                 display=str(_("Contact First Name"))))
        completions.append(
            dict(name="contact.groups", display=str(_("Contact Groups"))))
        completions.append(
            dict(name="contact.language", display=str(_("Contact Language"))))
        completions.append(
            dict(name="contact.name", display=str(_("Contact Name"))))
        completions.append(
            dict(name="contact.tel", display=str(_("Contact Phone"))))
        completions.append(
            dict(name="contact.tel_e164",
                 display=str(_("Contact Phone - E164"))))
        completions.append(
            dict(name="contact.uuid", display=str(_("Contact UUID"))))

        completions.append(
            dict(name="date", display=str(_("Current Date and Time"))))
        completions.append(
            dict(name="date.now", display=str(_("Current Date and Time"))))
        completions.append(
            dict(name="date.today", display=str(_("Current Date"))))
        completions.append(
            dict(name="date.tomorrow", display=str(_("Tomorrow's Date"))))
        completions.append(
            dict(name="date.yesterday", display=str(_("Yesterday's Date"))))

        for scheme, label in ContactURN.SCHEME_CHOICES:
            if scheme != TEL_SCHEME and scheme in org.get_schemes(
                    Channel.ROLE_SEND):
                completions.append(
                    dict(name="contact.%s" % scheme,
                         display=str(_("Contact %s" % label))))

        for field in org.contactfields(manager="user_fields").filter(
                is_active=True).order_by("label"):
            display = str(_("Contact Field: %(label)s")) % {
                "label": field.label
            }
            completions.append(
                dict(name="contact.%s" % str(field.key), display=display))

    function_completions = get_function_listing()
    return dict(completions=json.dumps(completions),
                function_completions=json.dumps(function_completions))
Exemple #2
0
def send_message_auto_complete_processor(request):
    """
    Adds completions for the expression auto-completion to the request context
    """
    completions = []
    user = request.user
    org = None

    if hasattr(user, 'get_org'):
        org = request.user.get_org()

    if org:
        completions.append(dict(name='contact', display=unicode(_("Contact Name"))))
        completions.append(dict(name='contact.first_name', display=unicode(_("Contact First Name"))))
        completions.append(dict(name='contact.groups', display=unicode(_("Contact Groups"))))
        completions.append(dict(name='contact.language', display=unicode(_("Contact Language"))))
        completions.append(dict(name='contact.name', display=unicode(_("Contact Name"))))
        completions.append(dict(name='contact.tel', display=unicode(_("Contact Phone"))))
        completions.append(dict(name='contact.tel_e164', display=unicode(_("Contact Phone - E164"))))
        completions.append(dict(name='contact.uuid', display=unicode(_("Contact UUID"))))

        completions.append(dict(name="date", display=unicode(_("Current Date and Time"))))
        completions.append(dict(name="date.now", display=unicode(_("Current Date and Time"))))
        completions.append(dict(name="date.today", display=unicode(_("Current Date"))))
        completions.append(dict(name="date.tomorrow", display=unicode(_("Tomorrow's Date"))))
        completions.append(dict(name="date.yesterday", display=unicode(_("Yesterday's Date"))))

        for field in org.contactfields.filter(is_active=True).order_by('label'):
            display = unicode(_("Contact Field: %(label)s")) % {'label': field.label}
            completions.append(dict(name="contact.%s" % str(field.key), display=display))

    function_completions = get_function_listing()
    return dict(completions=json.dumps(completions), function_completions=json.dumps(function_completions))
Exemple #3
0
def send_message_auto_complete_processor(request):
    completions = []
    user = request.user
    org = None

    if hasattr(user, 'get_org'):
        org = request.user.get_org()

    if org:
        for field in org.contactfields.filter(is_active=True):
            completions.append(dict(name="contact.%s" % str(field.key), display=unicode(_("Contact Field: %(label)s")) % {'label':field.label}))

        completions.insert(0, dict(name='contact', display=unicode(_("Contact Name"))))
        completions.insert(1, dict(name='contact.first_name', display=unicode(_("Contact First Name"))))
        completions.insert(2, dict(name='contact.groups', display=unicode(_("Contact Groups"))))
        completions.insert(3, dict(name='contact.language', display=unicode(_("Contact Language"))))
        completions.insert(4, dict(name='contact.name', display=unicode(_("Contact Name"))))
        completions.insert(5, dict(name='contact.tel', display=unicode(_("Contact Phone"))))
        completions.insert(6, dict(name='contact.tel_e164', display=unicode(_("Contact Phone - E164"))))
        completions.insert(7, dict(name='contact.uuid', display=unicode(_("Contact UUID"))))

        completions.insert(8, dict(name="date", display=unicode(_("Current Date and Time"))))
        completions.insert(9, dict(name="date.now", display=unicode(_("Current Date and Time"))))
        completions.insert(10, dict(name="date.today", display=unicode(_("Current Date"))))
        completions.insert(11, dict(name="date.tomorrow", display=unicode(_("Tomorrow's Date"))))
        completions.insert(12, dict(name="date.yesterday", display=unicode(_("Yesterday's Date"))))

    function_completions = get_function_listing()
    return dict(completions=json.dumps(completions), function_completions=json.dumps(function_completions))
Exemple #4
0
def send_message_auto_complete_processor(request):
    """
    Adds completions for the expression auto-completion to the request context
    """
    completions = []
    user = request.user
    org = None

    if hasattr(user, 'get_org'):
        org = request.user.get_org()

    if org:
        completions.append(dict(name='contact', display=unicode(_("Contact Name"))))
        completions.append(dict(name='contact.first_name', display=unicode(_("Contact First Name"))))
        completions.append(dict(name='contact.groups', display=unicode(_("Contact Groups"))))
        completions.append(dict(name='contact.language', display=unicode(_("Contact Language"))))
        completions.append(dict(name='contact.name', display=unicode(_("Contact Name"))))
        completions.append(dict(name='contact.tel', display=unicode(_("Contact Phone"))))
        completions.append(dict(name='contact.tel_e164', display=unicode(_("Contact Phone - E164"))))
        completions.append(dict(name='contact.uuid', display=unicode(_("Contact UUID"))))

        completions.append(dict(name="date", display=unicode(_("Current Date and Time"))))
        completions.append(dict(name="date.now", display=unicode(_("Current Date and Time"))))
        completions.append(dict(name="date.today", display=unicode(_("Current Date"))))
        completions.append(dict(name="date.tomorrow", display=unicode(_("Tomorrow's Date"))))
        completions.append(dict(name="date.yesterday", display=unicode(_("Yesterday's Date"))))

        for field in org.contactfields.filter(is_active=True).order_by('label'):
            display = unicode(_("Contact Field: %(label)s")) % {'label': field.label}
            completions.append(dict(name="contact.%s" % str(field.key), display=display))

    function_completions = get_function_listing()
    return dict(completions=json.dumps(completions), function_completions=json.dumps(function_completions))
Exemple #5
0
def send_message_auto_complete_processor(request):
    """
    Adds completions for the expression auto-completion to the request context
    """
    completions = []
    user = request.user
    org = None

    if hasattr(user, "get_org"):
        org = request.user.get_org()

    if org:
        completions.append(dict(name="contact", display=str(_("Contact Name"))))
        completions.append(dict(name="contact.first_name", display=str(_("Contact First Name"))))
        completions.append(dict(name="contact.groups", display=str(_("Contact Groups"))))
        completions.append(dict(name="contact.language", display=str(_("Contact Language"))))
        completions.append(dict(name="contact.name", display=str(_("Contact Name"))))
        completions.append(dict(name="contact.tel", display=str(_("Contact Phone"))))
        completions.append(dict(name="contact.tel_e164", display=str(_("Contact Phone - E164"))))
        completions.append(dict(name="contact.uuid", display=str(_("Contact UUID"))))

        completions.append(dict(name="date", display=str(_("Current Date and Time"))))
        completions.append(dict(name="date.now", display=str(_("Current Date and Time"))))
        completions.append(dict(name="date.today", display=str(_("Current Date"))))
        completions.append(dict(name="date.tomorrow", display=str(_("Tomorrow's Date"))))
        completions.append(dict(name="date.yesterday", display=str(_("Yesterday's Date"))))

        for scheme, label in ContactURN.SCHEME_CHOICES:
            if scheme != TEL_SCHEME and scheme in org.get_schemes(Channel.ROLE_SEND):
                completions.append(dict(name="contact.%s" % scheme, display=str(_("Contact %s" % label))))

        for field in org.contactfields(manager="user_fields").filter(is_active=True).order_by("label"):
            display = str(_("Contact Field: %(label)s")) % {"label": field.label}
            completions.append(dict(name="contact.%s" % str(field.key), display=display))

    function_completions = get_function_listing()
    return dict(completions=json.dumps(completions), function_completions=json.dumps(function_completions))