本文整理汇总了Python中invenio.modules.deposit.models.Deposition.get_depositions方法的典型用法代码示例。如果您正苦于以下问题:Python Deposition.get_depositions方法的具体用法?Python Deposition.get_depositions怎么用?Python Deposition.get_depositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invenio.modules.deposit.models.Deposition
的用法示例。
在下文中一共展示了Deposition.get_depositions方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from invenio.modules.deposit.models import Deposition [as 别名]
# 或者: from invenio.modules.deposit.models.Deposition import get_depositions [as 别名]
def get(self):
"""List depositions.
:param type: Upload type identifier (optional)
"""
args = list_parser.parse_args()
result = Deposition.get_depositions(user=current_user, type=args["type"] or None)
return map(lambda o: o.marshal(), result)
示例2: get
# 需要导入模块: from invenio.modules.deposit.models import Deposition [as 别名]
# 或者: from invenio.modules.deposit.models.Deposition import get_depositions [as 别名]
def get(query, from_date, limit=0, **kwargs):
"""Get deposits."""
from invenio.modules.deposit.models import Deposition
dep_generator = Deposition.get_depositions()
total_depids = 1 # Count of depositions is hard to determine
# If limit provided, serve only first n=limit items
if limit > 0:
dep_generator = islice(dep_generator, limit)
total_depids = limit
return total_depids, dep_generator
示例3: render_completed
# 需要导入模块: from invenio.modules.deposit.models import Deposition [as 别名]
# 或者: from invenio.modules.deposit.models.Deposition import get_depositions [as 别名]
def render_completed(cls, d):
"""Page to render when deposition was successfully completed."""
ctx = dict(
deposition=d,
deposition_type=(None if d.type.is_default() else d.type.get_identifier()),
uuid=d.id,
my_depositions=Deposition.get_depositions(current_user, type=d.type),
sip=d.get_latest_sip(),
format_record=format_record,
)
return render_template("deposit/completed.html", **ctx)
示例4: _render_form
# 需要导入模块: from invenio.modules.deposit.models import Deposition [as 别名]
# 或者: from invenio.modules.deposit.models.Deposition import get_depositions [as 别名]
def _render_form(obj, eng):
d = Deposition(obj)
draft = d.get_or_create_draft(draft_id)
if getattr(request, 'is_api_request', False):
form = draft.get_form(validate_draft=True)
if form.errors:
error_messages = []
for field, msgs in form.errors:
for m in msgs:
error_messages.append(
field=field,
message=m,
code=error_codes['validation_error'],
)
d.set_render_context(dict(
response=dict(
message="Bad request",
status=400,
errors=error_messages,
),
status=400,
))
eng.halt("API: Draft did not validate")
else:
if draft.is_completed():
eng.jumpCallForward(1)
else:
form = draft.get_form(validate_draft=draft.validate)
form.validate = True
d.set_render_context(dict(
template_name_or_list=form.get_template(),
deposition=d,
deposition_type=(
None if d.type.is_default() else
d.type.get_identifier()
),
uuid=d.id,
draft=draft,
form=form,
my_depositions=Deposition.get_depositions(
current_user, type=d.type
),
))
d.update()
eng.halt('Wait for form submission.')
示例5: all
# 需要导入模块: from invenio.modules.deposit.models import Deposition [as 别名]
# 或者: from invenio.modules.deposit.models.Deposition import get_depositions [as 别名]
def all(cls):
"""Compute deposit metrics per user."""
data = dict()
for d in Deposition.get_depositions():
if str(d.user_id) not in data:
data[str(d.user_id)] = dict(num=0, size=0)
# Count number of deposits
data[str(d.user_id)]['num'] += 1
# Collected file sizes
for f in d.files:
data[str(d.user_id)]['size'] += f.size
return data.items()
示例6: halt_to_render
# 需要导入模块: from invenio.modules.deposit.models import Deposition [as 别名]
# 或者: from invenio.modules.deposit.models.Deposition import get_depositions [as 别名]
def halt_to_render(obj, eng):
"""Halt the workflow - waiting to be resumed."""
deposition = Deposition(obj)
sip = deposition.get_latest_sip(sealed=False)
deposition.set_render_context(dict(
template_name_or_list="deposit/completed.html",
deposition=deposition,
deposition_type=(
None if deposition.type.is_default() else
deposition.type.get_identifier()
),
uuid=deposition.id,
sip=sip,
my_depositions=Deposition.get_depositions(
current_user, type=deposition.type
),
format_record=format_record,
))
obj.last_task = "halt_to_render"
eng.halt("User submission complete.")
示例7: show_stats
# 需要导入模块: from invenio.modules.deposit.models import Deposition [as 别名]
# 或者: from invenio.modules.deposit.models.Deposition import get_depositions [as 别名]
def show_stats(deposition_type):
"""Render the stats for all the depositions."""
if len(DepositionType.keys()) <= 1 and \
DepositionType.get_default() is not None:
abort(404)
form = FilterDateForm()
deptype = DepositionType.get(deposition_type)
submitted_depositions = [d for d in Deposition.get_depositions(type=deptype) if d.has_sip(sealed=True)]
ctx = process_metadata_for_charts(submitted_depositions,
group_by=request.args.get('group_by', 'type_of_doc'))
ctx.update(dict(
deposition_type=deptype,
depositions=submitted_depositions,
form=form,
chart_types=CHART_TYPES
))
return render_template('deposit/stats/all_depositions.html', **ctx)
示例8: stats_api
# 需要导入模块: from invenio.modules.deposit.models import Deposition [as 别名]
# 或者: from invenio.modules.deposit.models.Deposition import get_depositions [as 别名]
def stats_api(deposition_type):
"""Get stats JSON."""
deptype = DepositionType.get(deposition_type)
submitted_depositions = [d for d in Deposition.get_depositions(type=deptype) if d.has_sip(sealed=True)]
if request.args.get('since_date') is not None:
since_date = datetime.strptime(request.args['since_date'],
"%Y-%m-%d").replace(hour=0, minute=0)
submitted_depositions = [d for d in submitted_depositions if d.created >= since_date]
if request.args.get('until_date') is not None:
until_date = datetime.strptime(request.args['until_date'],
"%Y-%m-%d").replace(hour=23, minute=59)
submitted_depositions = [d for d in submitted_depositions if d.created <= until_date]
result = process_metadata_for_charts(submitted_depositions,
request.args.get('group_by', 'type_of_doc'),
bool(request.args.get('include_hidden', None)))
resp = jsonify(result)
return resp
示例9: _load_record
# 需要导入模块: from invenio.modules.deposit.models import Deposition [as 别名]
# 或者: from invenio.modules.deposit.models.Deposition import get_depositions [as 别名]
def _load_record(obj, eng):
d = Deposition(obj)
sip = d.get_latest_sip(sealed=True)
record = get_record(sip.metadata.get('recid'), reset_cache=True)
if not is_sip_uploaded(sip, record=record):
if getattr(request, 'is_api_request', False):
d.set_render_context(dict(
response=dict(
message="Conflict",
status=409,
errors="Upload not yet fully integrated. Please wait"
" a few moments.",
),
status=409,
))
else:
from flask import flash
flash(
"Editing is only possible after your upload have been"
" fully integrated. Please wait a few moments, then try"
" to reload the page.",
category='warning'
)
d.set_render_context(dict(
template_name_or_list="deposit/completed.html",
deposition=d,
deposition_type=(
None if d.type.is_default() else
d.type.get_identifier()
),
uuid=d.id,
sip=sip,
my_depositions=Deposition.get_depositions(
current_user, type=d.type
),
format_record=format_record,
))
d.update()
eng.halt("Wait for record to be uploaded")
# Check if record is already loaded, if so, skip.
if d.drafts:
eng.jumpCallForward(1)
# Load draft
draft = d.get_or_create_draft(draft_id)
# Fill draft with values from recjson
record_to_draft(
record, draft=draft, post_process=post_process, producer=producer
)
d.update()
# Stop API request
if getattr(request, 'is_api_request', False):
d.set_render_context(dict(
response=d.marshal(),
status=201,
))
eng.halt("API request")