コード例 #1
0
ファイル: public.py プロジェクト: ivanm11/dataflytest
def add_blog_record():
     q = 1
     return 'Your data was successfully saved.'
#    print(request)
     page = Page(request.json)
#    print(request.json)
     page.save()
コード例 #2
0
ファイル: public.py プロジェクト: ivanm11/dataflytest
def simple_page(page=None, section=None):
    page_id = request.path.strip('/') if page else 'home'
    page = Page.get_latest(page_id)    
    try:
        return template('%s.html' % page_id, page=page)        
    except TemplateError:
        if not page:
            return abort(404, "Page not found")        
        return template('default.html', page=page, page_id=page_id)
コード例 #3
0
ファイル: admin.py プロジェクト: ivanm11/dataflytest
def simple_page(page, section=None):
    template_context = c = dict(
        show_editor = True,
        page = Page.get_latest(g.page_id)
    )
    try:
        return template('%s.html' % g.page_id, **template_context)
    except TemplateError:
        c['default'] = True
        return template('default.html', **template_context)
コード例 #4
0
ファイル: public.py プロジェクト: rewnocio/basic_todo_list
def home():
    # getting tasks list and changing date format (date -> str)
    tasks_list = list(db.tasks_list.find().sort([("date", 1)]))

    for task in tasks_list:
        try:
            task["date"] = task["date"].strftime("%Y-%m-%d")
        except:
            pass
    
    template_context = dict(
        tasks_list = tasks_list,
        page = Page.get_latest('home')
    )
    return template('home.html', **template_context)
コード例 #5
0
ファイル: editor.py プロジェクト: rewnocio/basic_todo_list
def save_page(page_id):    
    page = Page(request.json['page'])
    page.save()
コード例 #6
0
ファイル: editor.py プロジェクト: rewnocio/basic_todo_list
def get_page(_id):
    p = Page.get_by_id(_id)
    return json.loads(dumps(p))
コード例 #7
0
ファイル: blog.py プロジェクト: ivanm11/dataflytest
def show_posts(page=1, slug=None, year=None, month=None):
    c = template_context = dict(
        addthis_id = public_app.config.get('addthis_id'),
        fb_id = public_app.config.get('fb_id')
    )
    page = int(page)

    query = {
        'id': { '$regex': 'blog' },
        'current': True,
        'meta.hide': { '$ne': True }
    }

    c['latest_posts'] = db.pages.find(query).sort('meta.created', -1)[0:5]

    c['query'] = search = request.query.get('q', '')
    c['author'] = author = request.query.get('author', None)

    if author:
        query['meta.author'] = author
        posts = db.pages.find(query).sort('meta.created', -1)
    elif len(search):
        # posts from search
        regex = re.compile(search, re.IGNORECASE)
        query['content'] = { '$regex': regex }
        posts = db.pages.find(query).sort('meta.created', -1)
    elif slug:
        # single post
        c['single_post'] = True
        c['slug'] = slug        
        post = Page.get_latest('blog/' + slug)
        hidden = post['meta'].get('hide', False)
        if hidden == True:
            return abort(404, "Page not found")
        c['posts'] = [post]
        c['page'] = post
    elif year and month:
        # from archive
        date_from = datetime(year, month, 1)
        c['month_link'] = '/archive/%s/%s' % (year, month)
        c['month'] = date_from.strftime('%B %Y')
        date_to = date_from + relativedelta(months=+1)
        query['meta.created'] = {
            '$gte': date_from,
            '$lt': date_to
        }
        posts = db.pages.find(query).sort('meta.created', -1)
    else:
        # list
        posts = db.pages.find(query).sort('meta.created', -1)

    if slug is None:
        # pagination
        c['current_page'] = page
        per_page = 5
        skip = (page-1) * per_page
        c['count'] = count = posts.count()
        c['posts'] = posts[skip:skip+per_page]
        c['pages'] = count // 5 + 1 if (count % 5 == 0) else count // 5 + 2

    c['home'] = Page.get_latest('home')

    return template('blog.html', **template_context)
コード例 #8
0
ファイル: blog.py プロジェクト: ivanm11/dataflytest
def edit_blog_post(page):
    return template('admin/blog-post.html',
                    editor = True,
                    page = Page.get_latest(g.page_id))