Example #1
0
def history_data(name):
    """Ajax provider for paginated history data."""
    if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous:
        return current_app.login_manager.unauthorized()
    draw = int(request.args.get('draw', 0))
    start = int(request.args.get('start', 0))
    length = int(request.args.get('length', 10))
    page = g.current_wiki.get_page(name)
    items = list(itertools.islice(page.history, start, start + length))
    for item in items:
        item['gravatar'] = gravatar_url(item['author_email'])
        item['DT_RowId'] = item['sha']
        date = datetime.fromtimestamp(item['time'])
        item['date'] = date.strftime(
            current_app.config.get('DATETIME_FORMAT', '%b %d, %Y %I:%M %p'))
        item['link'] = url_for('.commit', name=name, sha=item['sha'])
    total_records, hist_complete = page.history_cache
    if not hist_complete:
        # Force datatables to fetch more data when it gets to the end
        total_records += 1
    return {
        'draw': draw,
        'recordsTotal': total_records,
        'recordsFiltered': total_records,
        'data': items,
        'fully_loaded': hist_complete
    }
Example #2
0
def history_data(name):
    """Ajax provider for paginated history data."""
    if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous:
        return current_app.login_manager.unauthorized()
    draw = int(request.args.get('draw', 0))
    start = int(request.args.get('start', 0))
    length = int(request.args.get('length', 10))
    page = g.current_wiki.get_page(name)
    items = list(itertools.islice(page.history, start, start + length))     # type: list[dict]
    for item in items:
        item['gravatar'] = gravatar_url(item['author_email'])
        item['DT_RowId'] = item['sha']
        date = datetime.fromtimestamp(item['time'])
        item['date'] = date.strftime(current_app.config.get('DATETIME_FORMAT', '%b %d, %Y %I:%M %p'))
        item['link'] = url_for('.commit', name=name, sha=item['sha'])
    total_records, hist_complete = page.history_cache
    if not hist_complete:
        # Force datatables to fetch more data when it gets to the end
        total_records += 1
    return {
        'draw': draw,
        'recordsTotal': total_records,
        'recordsFiltered': total_records,
        'data': items,
        'fully_loaded': hist_complete
    }
Example #3
0
def history(name):
    if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous():
        return current_app.login_manager.unauthorized()

    hist = g.current_wiki.get_history(name)
    for item in hist:
        item['gravatar'] = gravatar_url(item['author_email'])
    return render_template('wiki/history.html', name=name, history=hist)
Example #4
0
def history(name):
    if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous():
        return current_app.login_manager.unauthorized()

    hist = g.current_wiki.get_history(name)
    for item in hist:
        item['gravatar'] = gravatar_url(item['author_email'])
    return render_template('wiki/history.html', name=name, history=hist)
Example #5
0
 def avatar(self):
     return gravatar_url(self.email)
Example #6
0
 def avatar(self):
     return gravatar_url(self.email)