本文整理汇总了Python中webui.models.Collection.collection_paths方法的典型用法代码示例。如果您正苦于以下问题:Python Collection.collection_paths方法的具体用法?Python Collection.collection_paths怎么用?Python Collection.collection_paths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webui.models.Collection
的用法示例。
在下文中一共展示了Collection.collection_paths方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: collections
# 需要导入模块: from webui.models import Collection [as 别名]
# 或者: from webui.models.Collection import collection_paths [as 别名]
def collections( request ):
"""
We are displaying collection status vis-a-vis the project Gitolite server.
It takes too long to run git-status on every repo so, if repo statuses are not
cached they will be updated by jQuery after page load has finished.
"""
collections = []
collection_status_urls = []
for object_id in gitolite.get_repos_orgs():
identifier = Identifier(object_id)
# TODO Identifier: Organization object instead of repo and org
repo,org = identifier.parts.values()
collection_paths = Collection.collection_paths(settings.MEDIA_BASE, repo, org)
colls = []
for collection_path in collection_paths:
if collection_path:
identifier = Identifier(path=collection_path)
collection = Collection.from_identifier(identifier)
colls.append(collection)
gitstatus = collection.gitstatus()
if gitstatus and gitstatus.get('sync_status'):
collection.sync_status = gitstatus['sync_status']
else:
collection_status_urls.append( "'%s'" % collection.sync_status_url())
collections.append( (object_id,repo,org,colls) )
# load statuses in random order
random.shuffle(collection_status_urls)
return render_to_response(
'webui/collections/index.html',
{'collections': collections,
'collection_status_urls': ', '.join(collection_status_urls),},
context_instance=RequestContext(request, processors=[])
)
示例2: new_manual
# 需要导入模块: from webui.models import Collection [as 别名]
# 或者: from webui.models.Collection import collection_paths [as 别名]
def new_manual( request, oid ):
"""Ask for Entity ID, then create new Entity.
"""
git_name = request.session.get('git_name')
git_mail = request.session.get('git_mail')
if not git_name and git_mail:
messages.error(request, WEBUI_MESSAGES['LOGIN_REQUIRED'])
oidentifier = Identifier(oid).object()
idparts = oidentifier.idparts
collection_ids = sorted([
os.path.basename(cpath)
for cpath in Collection.collection_paths(
settings.MEDIA_BASE,
idparts['repo'],
idparts['org']
)
])
collection_ids.reverse()
if request.method == 'POST':
form = NewCollectionForm(request.POST)
if form.is_valid():
# TODO get this from Entity class or something
idparts['model'] = 'collection'
idparts['cid'] = str(form.cleaned_data['cid'])
cidentifier = Identifier(parts=idparts)
if not cidentifier:
messages.error(request, "Could not generate a legal ID from your input. Try again.")
elif cidentifier.parent_id(stubs=True) != oidentifier.id:
messages.error(request, "Can only create collections for this organization. Try again.")
elif cidentifier.id in collection_ids:
messages.error(request, "Object ID %s already exists. Try again." % cidentifier.id)
else:
# Create collection and redirect to edit page
collection = _create_collection(request, cidentifier, git_name, git_mail)
if collection:
messages.warning(request, 'IMPORTANT: Register this ID with the ID service as soon as possible!')
return HttpResponseRedirect(reverse('webui-collection-edit', args=[collection.id]))
else:
data = {
'repo': idparts['repo'],
'org': idparts['org'],
}
form = NewCollectionForm(data)
return render(request, 'webui/collections/new-manual.html', {
'form': form,
'collection_ids': collection_ids,
})
示例3: newexpert
# 需要导入模块: from webui.models import Collection [as 别名]
# 或者: from webui.models.Collection import collection_paths [as 别名]
def newexpert( request, repo, org ):
"""Ask for Entity ID, then create new Entity.
"""
git_name = request.session.get('git_name')
git_mail = request.session.get('git_mail')
if not git_name and git_mail:
messages.error(request, WEBUI_MESSAGES['LOGIN_REQUIRED'])
if request.method == 'POST':
form = NewCollectionForm(request.POST)
if form.is_valid():
idparts = {
'model':'collection',
'repo':repo, 'org':org,
'cid':str(form.cleaned_data['cid'])
}
identifier = Identifier(parts=idparts)
collection_id = identifier.id
collection_ids = [
os.path.basename(cpath)
for cpath
in Collection.collection_paths(settings.MEDIA_BASE, repo, org)
]
already_exists = False
if collection_id in collection_ids:
already_exists = True
messages.error(request, "That collection ID already exists. Try again.")
if collection_id and not already_exists:
collection_new_expert(
request,
settings.MEDIA_BASE,
collection_id,
git_name, git_mail
)
return HttpResponseRedirect(reverse('webui-collections'))
else:
data = {
'repo':repo,
'org':org,
}
form = NewCollectionForm(data)
return render_to_response(
'webui/collections/new.html',
{'form': form,
},
context_instance=RequestContext(request, processors=[])
)