def oparl_meeting_data(params): data = db.get_meeting(search_params={'_id': ObjectId(params['_id'])}, deref={'values': ['invitation', 'resultsProtocol', 'agendaItem', 'auxiliaryFile']}) if len(data) == 1: return oparl_meeting_layout(data[0], params) elif len(data) == 0: abort(404)
def view_paper(id): """ Gibt Dokumenten-Detailseite aus """ result = db.get_paper(search_params = {'_id': ObjectId(id)}, deref = {'values': ['body', 'mainFile', 'auxiliaryFile', 'subordinatedPaper', 'superordinatedPaper']}) if len(result) == 0: abort(404) result = result[0] result['numberOfFiles'] = 0 if 'mainFile' in result: result['numberOfFiles'] += 1 if 'auxiliaryFile' in result: result['numberOfFiles'] += len(result['auxiliaryFile']) result['consultation'] = db.get_consultation(search_params = {'paper': DBRef('paper', ObjectId(id))}) for consultation_id in range(len(result['consultation'])): agendaItem_result = db.get_agendaItem(search_params = {'consultation': DBRef('consultation', result['consultation'][consultation_id]['_id'])}) if len(agendaItem_result): result['consultation'][consultation_id]['agendaItem'] = agendaItem_result[0] meeting_result = db.get_meeting(search_params = {'agendaItem': DBRef('agendaItem', result['consultation'][consultation_id]['agendaItem']['_id'])}) if len(meeting_result): result['consultation'][consultation_id]['agendaItem']['meeting'] = meeting_result[0] """references=[identifier], get_attachments=True, get_consultations=True, get_thumbnails=True)""" return render_template('paper_details.html', paper=result)
def oparl_agendaItem_data(params): data = db.get_agendaItem(search_params={'_id': ObjectId(params['_id'])}) if len(data) == 1: data = oparl_agendaItem_layout(data[0], params) meeting = db.get_meeting(search_params={'agendaItem': DBRef('agendaItem', ObjectId(params['_id']))}) if len(meeting): data['meeting'] = "%s/oparl/meeting/%s%s" % (app.config['api_url'], meeting[0]['_id'], generate_postfix(params)) return data elif len(data) == 0: abort(404)
def oparl_file_meeting_data(params): invitation_data = db.get_meeting(meeting_list = True, search_params = {'invitation': DBRef('file', ObjectId(params['file_id']))}, add_prefix = "%s/oparl/meeting/" % app.config['api_url'], add_postfix = generate_postfix(params)) auxiliaryFile_data = db.get_meeting(meeting_list = True, search_params = {'auxiliaryFile': DBRef('file', ObjectId(params['file_id']))}, add_prefix = "%s/oparl/meeting/" % app.config['api_url'], add_postfix = generate_postfix(params)) resultsProtocol_data = db.get_meeting(meeting_list = True, search_params = {'resultsProtocol': DBRef('file', ObjectId(params['file_id']))}, add_prefix = "%s/oparl/meeting/" % app.config['api_url'], add_postfix = generate_postfix(params)) verbatimProtocol_data = db.get_meeting(meeting_list = True, search_params = {'verbatimProtocol': DBRef('file', ObjectId(params['file_id']))}, add_prefix = "%s/oparl/meeting/" % app.config['api_url'], add_postfix = generate_postfix(params)) data = invitation_data + auxiliaryFile_data + resultsProtocol_data + verbatimProtocol_data return data
def oparl_file_data(params): data = db.get_file(search_params={'_id': ObjectId(params['_id'])}) if len(data) == 1: data = oparl_file_layout(data[0], params) # Get Backrefs for Meeting data['meeting'] = [] meeting = db.get_meeting(search_params={'invitation': DBRef('file', ObjectId(params['_id']))}) if len(meeting): data['meeting'].append("%s/oparl/meeting/%s%s" % (app.config['api_url'], meeting[0]['_id'], generate_postfix(params))) meeting = db.get_meeting(search_params={'resultsProtocol': DBRef('file', ObjectId(params['_id']))}) if len(meeting): data['meeting'].append("%s/oparl/meeting/%s%s" % (app.config['api_url'], meeting[0]['_id'], generate_postfix(params))) meeting = db.get_meeting(search_params={'verbatimProtocol': DBRef('file', ObjectId(params['_id']))}) if len(meeting): data['meeting'].append("%s/oparl/meeting/%s%s" % (app.config['api_url'], meeting[0]['_id'], generate_postfix(params))) meeting = db.get_meeting(search_params={'verbatimProtocol': DBRef('auxiliaryFile', ObjectId(params['_id']))}) for single_meeting in meeting: data['meeting'].append("%s/oparl/meeting/%s%s" % (app.config['api_url'], single_meeting['_id'], generate_postfix(params))) if len(data['meeting']) == 0: del data['meeting'] # Get Backrefs for AgendaItem data['agendaItem'] = [] agendaItem = db.get_agendaItem(search_params={'resolutionFile': DBRef('file', ObjectId(params['_id']))}) if len(agendaItem): data['agendaItem'].append("%s/oparl/agendaItem/%s%s" % (app.config['api_url'], agendaItem[0]['_id'], generate_postfix(params))) agendaItem = db.get_agendaItem(search_params={'auxiliaryFile': DBRef('file', ObjectId(params['_id']))}) for single_agendaItem in agendaItem: data['agendaItem'].append("%s/oparl/agendaItem/%s%s" % (app.config['api_url'], single_agendaItem['_id'], generate_postfix(params))) if len(data['agendaItem']) == 0: del data['agendaItem'] # Get Backrefs for Paper data['paper'] = [] paper = db.get_agendaItem(search_params={'mainFile': DBRef('file', ObjectId(params['_id']))}) if len(paper): data['paper'].append("%s/oparl/paper/%s%s" % (app.config['api_url'], paper[0]['_id'], generate_postfix(params))) paper = db.get_agendaItem(search_params={'auxiliaryFile': DBRef('file', ObjectId(params['_id']))}) for single_paper in paper: data['paper'].append("%s/oparl/paper/%s%s" % (app.config['api_url'], single_paper['_id'], generate_postfix(params))) if len(data['paper']) == 0: del data['paper'] return data elif len(data) == 0: abort(404)
def file_show(file_id): """ Anzeigen eines Files """ result = db.get_file(search_params = {'_id': ObjectId(file_id)}, deref = {'values': ['body']}) if len(result) == 0: abort(404) # add meeting usage = [] meeting_invitation = db.get_meeting(search_params = {'invitation': DBRef('file', ObjectId(file_id))}) for item in meeting_invitation: usage.append({ 'data': item, 'type': 'meeting', 'function': 'invitation'}) meeting_resultsProtocol = db.get_meeting(search_params = {'resultsProtocol': DBRef('file', ObjectId(file_id))}) for item in meeting_resultsProtocol: usage.append({ 'data': item, 'type': 'meeting', 'function': 'resultsProtocol'}) meeting_verbatimProtocol = db.get_meeting(search_params = {'verbatimProtocol': DBRef('file', ObjectId(file_id))}) for item in meeting_verbatimProtocol: usage.append({ 'data': item, 'type': 'meeting', 'function': 'verbatimProtocol'}) meeting_auxiliaryFile = db.get_meeting(search_params = {'auxiliaryFile': DBRef('file', ObjectId(file_id))}) for item in meeting_auxiliaryFile: usage.append({ 'data': item, 'type': 'meeting', 'function': 'auxiliaryFile'}) # add agendaItem agendaItem_resolutionFile = db.get_agendaItem(search_params = {'resolutionFile': DBRef('file', ObjectId(file_id))}) for item in agendaItem_resolutionFile: usage.append({ 'data': item, 'type': 'agendaItem', 'function': 'resolutionFile'}) agendaItem_auxiliaryFile = db.get_agendaItem(search_params = {'auxiliaryFile': DBRef('file', ObjectId(file_id))}) for item in agendaItem_auxiliaryFile: usage.append({ 'data': item, 'type': 'agendaItem', 'function': 'auxiliaryFile'}) # add paper paper_mainFile = db.get_paper(search_params = {'mainFile': DBRef('file', ObjectId(file_id))}) for item in paper_mainFile: usage.append({ 'data': item, 'type': 'paper', 'function': 'mainFile'}) paper_auxiliaryFile = db.get_paper(search_params = {'auxiliaryFile': DBRef('file', ObjectId(file_id))}) for item in paper_auxiliaryFile: usage.append({ 'data': item, 'type': 'paper', 'function': 'auxiliaryFile'}) if len(usage): result[0]['usage'] = usage return render_template('file_details.html', file=result[0])
def oparl_body_meeting_data(params): search_params = oparl_generate_list_search_params(params) data = db.get_meeting(search_params = search_params, limit=app.config['oparl_items_per_page'], deref={'values': ['invitation', 'resultsProtocol', 'agendaItem', 'auxiliaryFile']}) data = oparl_generate_list_items(params=params, search_params=search_params, result_count=db.get_meeting_count(search_params=search_params), data=data, type='meeting') for key_meeting, single_meeting in enumerate(data['items']): data['items'][key_meeting] = oparl_meeting_layout(data=single_meeting, params=params) # auxiliaryFiles if 'auxiliaryFile' in data['items'][key_meeting]: auxiliaryFiles = [] for single_auxiliaryFile in data['items'][key_meeting]['auxiliaryFile']: if single_auxiliaryFile: auxiliaryFiles.append(oparl_file_layout(single_auxiliaryFile, params)) if len(auxiliaryFiles): data['items'][key_meeting]['auxiliaryFile'] = auxiliaryFiles else: del data['items'][key_meeting]['auxiliaryFile'] # agendaItems if 'agendaItem' in data['items'][key_meeting]: agendaItems = [] print data['items'][key_meeting] for single_agendaItem in data['items'][key_meeting]['agendaItem']: if single_agendaItem: agendaItems.append(oparl_agendaItem_layout(single_agendaItem, params)) if len(agendaItems): data['items'][key_meeting]['agendaItem'] = agendaItems else: del data['items'][key_meeting]['agendaItem'] # resultsProtocol if 'resultsProtocol' in data['items'][key_meeting]: if data['items'][key_meeting]['resultsProtocol']: data['items'][key_meeting]['resultsProtocol'] = oparl_file_layout(data['items'][key_meeting]['resultsProtocol'], params) else: del data['items'][key_meeting]['resultsProtocol'] # invitation if 'invitation' in data['items'][key_meeting]: if isinstance(data['items'][key_meeting]['invitation'], list): # TODO: invitation = list? wtf?! del data['items'][key_meeting]['invitation'] else: if data['items'][key_meeting]['invitation']: data['items'][key_meeting]['invitation'] = oparl_file_layout(data['items'][key_meeting]['invitation'], params) else: del data['items'][key_meeting]['invitation'] return data
def oparl_body_meeting_data(params): search_params = oparl_generate_list_search_params(params) data = db.get_meeting(search_params = search_params, limit=app.config['oparl_items_per_page'], deref={'values': ['invitation', 'resultsProtocol', 'agendaItem', 'auxiliaryFile']}) data = oparl_generate_list_items(params=params, search_params=search_params, result_count=db.get_meeting_count(search_params=search_params), data=data, type='meeting') for key_meeting, single_meeting in enumerate(data['data']): data['data'][key_meeting] = oparl_meeting_layout(data=single_meeting, params=params) return data
def oparl_meeting_data(params): data = db.get_meeting(search_params={'_id': ObjectId(params['_id'])}) if len(data) == 1: data[0]['body'] = generate_single_url(params=params, type='body', id=data[0]['body'].id) data[0]['organization'] = generate_sublist_url(params=params, main_type='meeting', sublist_type='organization') data[0]['agendaItem'] = generate_sublist_url(params=params, main_type='meeting', sublist_type='agendaItem') data[0]['invitation'] = generate_sublist_url(params=params, main_type='meeting', sublist_type='invitation') if 'resultsProtocol' in data[0]: data[0]['resultsProtocol'] = generate_single_url(params=params, type='file', id=data[0]['resultsProtocol'].id) if 'verbatimProtocol' in data[0]: data[0]['verbatimProtocol'] = generate_single_url(params=params, type='file', id=data[0]['verbatimProtocol'].id) data[0]['auxiliaryFile'] = generate_sublist_url(params=params, main_type='meeting', sublist_type='auxiliaryFile') data[0]['@type'] = 'OParlMeeting' data[0]['@id'] = data[0]['_id'] return data[0] elif len(data) == 0: abort(404)
def view_paper(id): """ Gibt Dokumenten-Detailseite aus """ result = db.get_paper(search_params={'_id': ObjectId(id)}, deref={ 'values': [ 'body', 'mainFile', 'auxiliaryFile', 'relatedPaper', 'subordinatedPaper', 'superordinatedPaper' ] }) if len(result) == 0: abort(404) result = result[0] result['numberOfFiles'] = 0 if 'mainFile' in result: result['numberOfFiles'] += 1 if 'auxiliaryFile' in result: result['numberOfFiles'] += len(result['auxiliaryFile']) result['consultation'] = db.get_consultation( search_params={'paper': DBRef('paper', ObjectId(id))}) for consultation_id in range(len(result['consultation'])): agendaItem_result = db.get_agendaItem( search_params={ 'consultation': DBRef('consultation', result['consultation'][consultation_id] ['_id']) }) if len(agendaItem_result): result['consultation'][consultation_id][ 'agendaItem'] = agendaItem_result[0] meeting_result = db.get_meeting( search_params={ 'agendaItem': DBRef( 'agendaItem', result['consultation'][consultation_id] ['agendaItem']['_id']) }) if len(meeting_result): result['consultation'][consultation_id]['agendaItem'][ 'meeting'] = meeting_result[0] return render_template('paper_details.html', paper=result)
def oparl_organization_meeting_data(params): data = db.get_meeting(meeting_list = True, search_params = {'organization': DBRef('organization', ObjectId(params['organization_id']))}, add_prefix = "%s/oparl/meeting/" % app.config['api_url'], add_postfix = generate_postfix(params)) return data
def file_show(file_id): """ Anzeigen eines Files """ result = db.get_file(search_params={'_id': ObjectId(file_id)}, deref={'values': ['body']}) if len(result) == 0: abort(404) # add meeting usage = [] meeting_invitation = db.get_meeting( search_params={'invitation': DBRef('file', ObjectId(file_id))}) for item in meeting_invitation: usage.append({ 'data': item, 'type': 'meeting', 'function': 'invitation' }) meeting_resultsProtocol = db.get_meeting( search_params={'resultsProtocol': DBRef('file', ObjectId(file_id))}) for item in meeting_resultsProtocol: usage.append({ 'data': item, 'type': 'meeting', 'function': 'resultsProtocol' }) meeting_verbatimProtocol = db.get_meeting( search_params={'verbatimProtocol': DBRef('file', ObjectId(file_id))}) for item in meeting_verbatimProtocol: usage.append({ 'data': item, 'type': 'meeting', 'function': 'verbatimProtocol' }) meeting_auxiliaryFile = db.get_meeting( search_params={'auxiliaryFile': DBRef('file', ObjectId(file_id))}) for item in meeting_auxiliaryFile: usage.append({ 'data': item, 'type': 'meeting', 'function': 'auxiliaryFile' }) # add agendaItem agendaItem_resolutionFile = db.get_agendaItem( search_params={'resolutionFile': DBRef('file', ObjectId(file_id))}) for item in agendaItem_resolutionFile: usage.append({ 'data': item, 'type': 'agendaItem', 'function': 'resolutionFile' }) agendaItem_auxiliaryFile = db.get_agendaItem( search_params={'auxiliaryFile': DBRef('file', ObjectId(file_id))}) for item in agendaItem_auxiliaryFile: usage.append({ 'data': item, 'type': 'agendaItem', 'function': 'auxiliaryFile' }) # add paper paper_mainFile = db.get_paper( search_params={'mainFile': DBRef('file', ObjectId(file_id))}) for item in paper_mainFile: usage.append({'data': item, 'type': 'paper', 'function': 'mainFile'}) paper_auxiliaryFile = db.get_paper( search_params={'auxiliaryFile': DBRef('file', ObjectId(file_id))}) for item in paper_auxiliaryFile: usage.append({ 'data': item, 'type': 'paper', 'function': 'auxiliaryFile' }) if len(usage): result[0]['usage'] = usage return render_template('file_details.html', file=result[0])
def oparl_meeting_auxiliaryFile_data(params): data = db.get_meeting(deref={'value': 'auxiliaryFile', 'list_select': '_id'}, search_params={'_id': ObjectId(params['meeting_id'])}, add_prefix = "%s/oparl/file/" % app.config['api_url'], add_postfix = generate_postfix(params)) return data
def oparl_meeting_organization_data(params): data = db.get_meeting(deref={'value': 'organization', 'list_select': '_id'}, search_params={'_id': ObjectId(params['meeting_id'])}, add_prefix = "%s/oparl/organization/" % app.config['api_url'], add_postfix = generate_postfix(params)) return data
def oparl_meetings_data(params): return db.get_meeting(meeting_list = True, add_prefix = "%s/oparl/meeting/" % app.config['api_url'], add_postfix=generate_postfix(params))
def oparl_meeting_data(params): data = db.get_meeting(search_params={'_id': ObjectId(params['_id'])}) if len(data) == 1: return oparl_meeting_layout(data[0], params) elif len(data) == 0: abort(404)
def oparl_organization_meeting_data(params): meetings = db.get_meeting(search_params={'organization': DBRef('organization', ObjectId(params['_id']))}) result = [] for meeting in meetings: result.append(oparl_meeting_layout(meeting, params)) return result