コード例 #1
0
def menu_main(context):
    """Main navigation menu"""
    user = context['request'].user
    name = context['SITE_NAME']
    logo = context['SITE_LOGO']
    info = context['SITE_INFO']
    my_bookmark = []

    if user.is_authenticated():
        if user.profile.bookmarks:
            bookmarks = user.profile.bookmarks.split(',')

            for bm in bookmarks:
                app, id = bm.split('-')
                if app == 'boards':
                    app_table = BoardTable()
                elif app == 'teams':
                    app_table = TeamTable()
                else:
                    continue
                my_bookmark.append([
                    app_table.get_table_name(id),
                    app_table.get_table_url(id)
                ])

    return {
        'user': user,
        'SITE_NAME': name,
        'SITE_LOGO': logo,
        'SITE_INFO': info,
        'my_bookmark': my_bookmark,
    }
コード例 #2
0
def edit_bookmarks(request):
    """Edit bookmarks"""
    my_bookmark = []
    if request.user.profile.bookmarks:
        bookmarks = request.user.profile.bookmarks.split(',')

        for bm in bookmarks:
            app, id = bm.split('-')
            if app == 'boards':
                app_table = BoardTable()
            elif app == 'teams':
                app_table = TeamTable()
            else:
                continue
            my_bookmark.append(
                [bm, app_table.get_table_name(id)]
            )

    return render(
        request,
        "accounts/edit_bookmarks.html",
        {
            'my_bookmark': my_bookmark,
        }
    )