Exemple #1
0
def import_boards():
    c = conn.cursor()
    sql = """
SELECT
    ID_BOARD
    ,ID_CAT
    ,ID_PARENT
    ,boardOrder
    ,name
    ,description
    ,numTopics
    ,numPosts
FROM
    smf_boards
ORDER BY ID_PARENT;"""

    c.execute(sql)
    for row in c.fetchall():
        b = Board()
        b.category = categories[row[1]]
        if row[2] > 0:
            b.parent = boards[row[2]]
        b.order = row[3]
        b.name = row[4]
        b.description = row[5]
        b.topic_count = row[6]
        b.post_count = row[7]
        b.save()

        boards[row[0]] = b

    c.close()
Exemple #2
0
def index(request):
    if request.user:
        groups = request.user.groups
    else:
        groups = ['everyone']
    boards = Board.objects(read_groups__in=groups)
    cat_ids = [c.id for c in boards.distinct('category')]
    categories = Category.objects(id__in=cat_ids).order_by('order')
    return dict(categories=categories)