示例#1
0
文件: views.py 项目: beneboy/uwitter
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
文件: views.py 项目: beneboy/uwitter
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})
示例#3
0
文件: views.py 项目: beneboy/uwitter
def search_uweets(request):
    ms = get_message_service()
    uweets = ms.search_messages(request.GET.get('search', ''))
    return render(request, 'uweet_list.html', {'uweets': uweets})
示例#4
0
文件: views.py 项目: beneboy/uwitter
def index(request):
    ms = get_message_service()
    uweets = ms.all_messages()
    return render(request, 'uweet_list.html', {'uweets': uweets})