Ejemplo n.º 1
0
def index():
    page = get_page()
    pagination = Paste.objects(is_private=False).order_by('-updated_at').paginate(page=page, per_page=20)

    print datetime.today()

    return render_template('index.html',
                           pagination=pagination,
                           hot_pastes=Paste.objects(is_private=False).order_by('-views')[:10],
                           pastes_count=Paste.objects().count(),
                           comments_count=Comment.objects().count(),
                           users_count=User.objects().count(),
                           syntax_count=Syntax.objects().count(),
                           bookmarks_count=Bookmark.objects().count(),
                           users_increased=User.objects(created_at__gt=date.today()).count(),
                           pastes_increased=Paste.objects(created_at__gt=date.today()).count(),
                           comments_increased=Comment.objects(created_at__gt=date.today()).count(),
                           bookmarks_increased=Bookmark.objects(created_at__gt=date.today()).count(),
                           tags=Tag.objects().order_by('-popularity')[:10])
Ejemplo n.º 2
0
def comments(hash_id):
    paste = Paste.objects.get_or_404(hash_id=hash_id)

    form = CommentForm(request.form)
    if form.validate():
        comment = Comment(user=current_user.user,
                          paste=paste,
                          content=form.content.data)
        comment.save()
        if comment.user != paste.user:
            content = NEW_COMMENT.format(user_username=current_user.user.username,
                                         user_url=url_for('user_app.view', username=current_user.user.username),
                                         paste_title=paste.title,
                                         paste_url=url_for('paste_app.view_paste', hash_id=paste.hash_id))

            message = Message(user=paste.user,
                              who=current_user.user,
                              content=content)
            message.save()

    return redirect(url_for('paste_app.view_paste', hash_id=hash_id))
Ejemplo n.º 3
0
def comments(hash_id):
    paste = Paste.objects.get_or_404(hash_id=hash_id)

    form = CommentForm(request.form)
    if form.validate():
        comment = Comment(user=current_user.user,
                          paste=paste,
                          content=form.content.data)
        comment.save()
        if comment.user != paste.user:
            content = NEW_COMMENT.format(
                user_username=current_user.user.username,
                user_url=url_for('user_app.view',
                                 username=current_user.user.username),
                paste_title=paste.title,
                paste_url=url_for('paste_app.view_paste',
                                  hash_id=paste.hash_id))

            message = Message(user=paste.user,
                              who=current_user.user,
                              content=content)
            message.save()

    return redirect(url_for('paste_app.view_paste', hash_id=hash_id))
Ejemplo n.º 4
0
def index():
    page = get_page()
    pagination = Paste.objects(
        is_private=False).order_by('-updated_at').paginate(page=page,
                                                           per_page=20)

    print datetime.today()

    return render_template(
        'index.html',
        pagination=pagination,
        hot_pastes=Paste.objects(is_private=False).order_by('-views')[:10],
        pastes_count=Paste.objects().count(),
        comments_count=Comment.objects().count(),
        users_count=User.objects().count(),
        syntax_count=Syntax.objects().count(),
        bookmarks_count=Bookmark.objects().count(),
        users_increased=User.objects(created_at__gt=date.today()).count(),
        pastes_increased=Paste.objects(created_at__gt=date.today()).count(),
        comments_increased=Comment.objects(
            created_at__gt=date.today()).count(),
        bookmarks_increased=Bookmark.objects(
            created_at__gt=date.today()).count(),
        tags=Tag.objects().order_by('-popularity')[:10])