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.")
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)
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