コード例 #1
0
ファイル: views.py プロジェクト: linkedinyou/vumi-go
def contacts(request, conversation_key):
    conversation = conversation_or_404(request.user_api, conversation_key)
    if request.method == 'POST':
        action = request.POST.get('action')
        if action == 'draft':
            # save and go back to list.
            return redirect('conversations:index')

        group_keys = request.POST.getlist('group')

        # TODO: Remove all groups
        for group_key in group_keys:
            conversation.add_group(group_key)
        conversation.save()

        return redirect('conversations:conversation',
                        conversation_key=conversation.key,
                        path_suffix='')

    groups = sorted(request.user_api.list_groups(),
                    key=lambda group: group.created_at,
                    reverse=True)

    selected_groups = list(group.key for group in conversation.get_groups())

    for group in groups:
        if group.key in selected_groups:
            group.selected = True

    query = request.GET.get('query', '')
    p = request.GET.get('p', 1)

    paginator = Paginator(groups, 15)
    try:
        page = paginator.page(p)
    except PageNotAnInteger:
        page = paginator.page(1)
    except EmptyPage:
        page = paginator.page(paginator.num_pages)

    pagination_params = urlencode({
        'query': query,
    })

    return render(
        request, 'wizard_views/wizard_3_contacts.html', {
            'paginator': paginator,
            'page': page,
            'pagination_params': pagination_params,
            'conversation_key': conversation_key,
            'conversation': conversation,
        })
コード例 #2
0
ファイル: views.py プロジェクト: TouK/vumi-go
def contacts(request, conversation_key):
    conversation = conversation_or_404(request.user_api, conversation_key)
    if request.method == 'POST':
        action = request.POST.get('action')
        if action == 'draft':
            # save and go back to list.
            return redirect('conversations:index')

        group_keys = request.POST.getlist('group')

        # TODO: Remove all groups
        for group_key in group_keys:
            conversation.add_group(group_key)
        conversation.save()

        return redirect('conversations:conversation',
                        conversation_key=conversation.key, path_suffix='')

    groups = sorted(request.user_api.list_groups(),
                    key=lambda group: group.created_at,
                    reverse=True)

    selected_groups = list(group.key for group in conversation.get_groups())

    for group in groups:
        if group.key in selected_groups:
            group.selected = True

    query = request.GET.get('query', '')
    p = request.GET.get('p', 1)

    paginator = Paginator(groups, 15)
    try:
        page = paginator.page(p)
    except PageNotAnInteger:
        page = paginator.page(1)
    except EmptyPage:
        page = paginator.page(paginator.num_pages)

    pagination_params = urlencode({
        'query': query,
    })

    return render(request, 'wizard_views/wizard_3_contacts.html', {
        'paginator': paginator,
        'page': page,
        'pagination_params': pagination_params,
        'conversation_key': conversation_key,
        'conversation': conversation,
    })
コード例 #3
0
ファイル: views.py プロジェクト: linkedinyou/vumi-go
def incoming_detail(request, conversation_key, contact_key):
    conversation = conversation_or_404(request.user_api, conversation_key)
    form = ReplyToMessageForm()

    if request.method == 'POST':
        # TODO: process sending message from form
        pass

    # TODO: Conversation data.
    # FAKE DATA FOR BADLARD.
    message_list = (
        {
            'contact': 'You',
            'message': 'Thank you'
        },
        {
            'contact': '55555 539 521',
            'message': 'Saturday'
        },
        {
            'contact': 'You',
            'message': 'What days do you eat?'
        },
        {
            'contact': '55555 539 521',
            'message': 'Hotdogs'
        },
        {
            'contact': 'You',
            'message': 'What is your favourite meal?'
        },
    )

    return render(request, 'conversation/incoming_detail.html', {
        'conversation': conversation,
        'form': form,
        'message_list': message_list
    })
コード例 #4
0
ファイル: views.py プロジェクト: TouK/vumi-go
def incoming_detail(request, conversation_key, contact_key):
    conversation = conversation_or_404(request.user_api, conversation_key)
    form = ReplyToMessageForm()

    if request.method == 'POST':
        # TODO: process sending message from form
        pass

    # TODO: Conversation data.
    # FAKE DATA FOR BADLARD.
    message_list = (
        {'contact': 'You', 'message': 'Thank you'},
        {'contact': '55555 539 521', 'message': 'Saturday'},
        {'contact': 'You', 'message': 'What days do you eat?'},
        {'contact': '55555 539 521', 'message': 'Hotdogs'},
        {'contact': 'You', 'message': 'What is your favourite meal?'},
    )

    return render(request, 'conversation/incoming_detail.html', {
        'conversation': conversation,
        'form': form,
        'message_list': message_list
    })
コード例 #5
0
ファイル: views.py プロジェクト: TouK/vumi-go
def conversation_action(request, conversation_key, action_name):
    conv = conversation_or_404(request.user_api, conversation_key)
    view_def = get_conversation_view_definition(
        conv.conversation_type, conv)
    view = view_def.get_action_view(action_name)
    return view(request, conv)
コード例 #6
0
ファイル: views.py プロジェクト: TouK/vumi-go
def conversation(request, conversation_key, path_suffix):
    conv = conversation_or_404(request.user_api, conversation_key)
    view_def = get_conversation_view_definition(
        conv.conversation_type, conv)
    view = view_def.get_view(path_suffix)
    return view(request, conv)
コード例 #7
0
ファイル: views.py プロジェクト: linkedinyou/vumi-go
def conversation_action(request, conversation_key, action_name):
    conv = conversation_or_404(request.user_api, conversation_key)
    view_def = get_conversation_view_definition(conv.conversation_type, conv)
    view = view_def.get_action_view(action_name)
    return view(request, conv)
コード例 #8
0
ファイル: views.py プロジェクト: linkedinyou/vumi-go
def conversation(request, conversation_key, path_suffix):
    conv = conversation_or_404(request.user_api, conversation_key)
    view_def = get_conversation_view_definition(conv.conversation_type, conv)
    view = view_def.get_view(path_suffix)
    return view(request, conv)