Пример #1
0
def user_uweets(request, username):
    try:
        poster = User.objects.get_by_natural_key(username)
    except User.DoesNotExist:
        raise Http404

    ms = get_message_service()
    uweets = ms.user_messages(poster.id)

    return render(request, 'uweet_list.html', {'poster': poster, 'uweets': uweets})
Пример #2
0
def user_uweets(request, username):
    try:
        poster = User.objects.get_by_natural_key(username)
    except User.DoesNotExist:
        raise Http404

    ms = get_message_service()
    uweets = ms.user_messages(poster.id)

    return render(request, 'uweet_list.html', {
        'poster': poster,
        'uweets': uweets
    })
Пример #3
0
def post_uweet(request):
    if request.method == 'POST':
        post_form = PostForm(request.POST)
        if post_form.is_valid():
            ms = get_message_service()
            ms.post_message(request.user.id, post_form.cleaned_data['message'])
            notify_of_post(request.user.username, post_form.cleaned_data['message'])
            messages.success(request, "You have Uweeted, sweet!")
            return redirect('frontend.views.user_uweets', username=request.user.username)
    else:
        post_form = PostForm()

    return render(request, 'post.html', {'post_form': post_form})
Пример #4
0
def post_uweet(request):
    if request.method == 'POST':
        post_form = PostForm(request.POST)
        if post_form.is_valid():
            ms = get_message_service()
            ms.post_message(request.user.id, post_form.cleaned_data['message'])
            notify_of_post(request.user.username,
                           post_form.cleaned_data['message'])
            messages.success(request, "You have Uweeted, sweet!")
            return redirect('frontend.views.user_uweets',
                            username=request.user.username)
    else:
        post_form = PostForm()

    return render(request, 'post.html', {'post_form': post_form})
Пример #5
0
def search_uweets(request):
    ms = get_message_service()
    uweets = ms.search_messages(request.GET.get('search', ''))
    return render(request, 'uweet_list.html', {'uweets': uweets})
Пример #6
0
def index(request):
    ms = get_message_service()
    uweets = ms.all_messages()
    return render(request, 'uweet_list.html', {'uweets': uweets})
Пример #7
0
def search_uweets(request):
    ms = get_message_service()
    uweets = ms.search_messages(request.GET.get('search', ''))
    return render(request, 'uweet_list.html', {'uweets': uweets})
Пример #8
0
def index(request):
    ms = get_message_service()
    uweets = ms.all_messages()
    return render(request, 'uweet_list.html', {'uweets': uweets})