コード例 #1
0
ファイル: collections.py プロジェクト: victorsndvg/sregistry
def my_collections(request):
    collections = Collection.objects.filter(owner=request.user)

    # Get information about if they have storage, and repo access
    context = validate_credentials(user=request.user)
    context["collections"] = collections
    context["page_title"] = "My Container Collections"
    return render(request, 'collections/all_collections.html', context)
コード例 #2
0
def my_collections(request):
    """this view will provide a list of collections for the logged in user"""
    user = request.user
    collections = Collection.objects.filter(
        Q(owners=user) | Q(contributors=user)).distinct()

    # Get information about if they have storage, and repo access
    context = validate_credentials(user=request.user)
    context["collections"] = collections
    context["my_collections"] = True
    return render(request, "collections/all_collections.html", context)
コード例 #3
0
ファイル: collections.py プロジェクト: victorsndvg/sregistry
def user_collections(request, uid):
    '''this view will provide a list of user collections.
    '''
    try:
        user = User.objects.get(id=uid)
    except:
        messages.info(request, "This user does not exist.")
        return redirect('collections')

    collections = Collection.objects.filter(owner=user)

    # Get information about if they have storage, and repo access
    context = validate_credentials(user=request.user)
    context["collections"] = collections
    context['page_title'] = "User %s Collections" % user.username
    return render(request, 'collections/all_collections.html', context)
コード例 #4
0
def all_collections(request):

    # public collections
    collections = Collection.objects.filter(private=False)

    # private that the user can see
    private_collections = [x for x in Collection.objects.filter(private=True)
                           if x.has_edit_permission(request)]

    collections = list(chain(collections,private_collections))

    # Get information about if they have storage, and repo access
    context = validate_credentials(user=request.user)
    context["collections"] = collections
    context['page_title'] = "Container Collections"

    return render(request, 'collections/all_collections.html', context)
コード例 #5
0
ファイル: collections.py プロジェクト: mythic-ai/sregistry
def all_collections(request):
    '''view all container collections. This only includes public collections,
       and we add collections for which the user has permission.

    '''
    limit = min(Collection.objects.count(), collection_count)
    collections = Collection.objects.filter(private=False).annotate(Count('star', distinct=True)).order_by('-star__count')[:limit]

    # private that the user can view
    private_collections = [x for x in Collection.objects.filter(private=True)
                           if x.has_view_permission(request)]

    collections = set(list(chain(collections, private_collections)))

    # Get information about if they have storage, and repo access
    context = validate_credentials(user=request.user)
    context["collections"] = collections

    return render(request, 'collections/all_collections.html', context)
コード例 #6
0
ファイル: collections.py プロジェクト: jbd/sregistry
def all_collections(request):
    '''view all container collections. This only includes public collections,
       and we add collections for which the user has permission.

    '''

    # public collections
    collections = Collection.objects.filter(private=False)

    # private that the user can see
    private_collections = [
        x for x in Collection.objects.filter(private=True)
        if x.has_edit_permission(request)
    ]

    collections = set(list(chain(collections, private_collections)))

    # Get information about if they have storage, and repo access
    context = validate_credentials(user=request.user)
    context["collections"] = collections

    return render(request, 'collections/all_collections.html', context)