def __get_featured_instances__(featured_instances=FEATURED_INSTANCES): "Helper function iterates through featured instances returns list" output = [] for instance_key in featured_instances: cover_art_key = None instance_link = '/apps/discovery/Instance/{0}'.format( instance_key.split(":")[-1]) for annotation_key in REDIS_DATASTORE.smembers( '{0}:hasAnnotation'.format(instance_key)): if annotation_key.startswith('bf:CoverArt'): cover_art_key = annotation_key work_key = REDIS_DATASTORE.hget(instance_key, 'instanceOf') cover_id = cover_art_key.split(":")[-1] cover_url = '/apps/discovery/CoverArt/{0}-'.format(cover_id) if REDIS_DATASTORE.hexists(cover_art_key, 'annotationBody'): cover_url += "body.jpg" else: cover_url += 'thumbnail.jpg' output.append( {'cover': cover_url, 'title': REDIS_DATASTORE.hget( '{0}:title'.format(work_key), 'rda:preferredTitleForTheWork'), 'instance': instance_link}) return output
def __initializeMARC(): "Initializes all MARC Redis supportting keys" marc_rdf_files = ['00X.rdf', '0XX.rdf', '1XX.rdf', '2XX.rdf', '3XX.rdf', '4XX.rdf', '5XX.rdf'] print("Initializing MARC labels") for marc_filename in marc_rdf_files: marc_rdf_file = os.path.join(PROJECT_HOME, 'marc_batch', 'fixures', marc_filename) marc_rdf = etree.parse(marc_rdf_file) all_descriptions = marc_rdf.findall("{{{0}}}Description".format(RDF)) for description in all_descriptions: label = description.find('{{{0}}}label'.format(RDFS)) if label is not None: raw_name = description.attrib.get('{{{0}}}about'.format(RDF)) redis_key = 'marc:{0}'.format(os.path.split(raw_name)[-1][1:]) if not REDIS_DATASTORE.hexists('marc:labels', redis_key): REDIS_DATASTORE.hset('marc:labels', redis_key, label.text) sys.stderr.write(".") print("\n\tFinished {0}".format(marc_filename)) print("Finished Initializing MARC labels")
def get_prospector_data(app=None): "Returns Google Charts string of Prospector Holdings" # update_institution_count() js_str = '' #! THIS OPERATION SHOULD BE CACHED for row in REDIS_DATASTORE.zrevrange('prospector-holdings', 0, -1, withscores=True): org_key = row[0] if int(row[1]) < 1: continue library_info = [REDIS_DATASTORE.hget(org_key, 'label'), REDIS_DATASTORE.scard( "{0}:bf:Books".format(org_key)), REDIS_DATASTORE.scard( "{0}:bf:MovingImage".format(org_key)), REDIS_DATASTORE.scard( "{0}:bf:MusicalAudio".format(org_key)), row[1] # Total Holdings ] js_str += '["{0}",{1}],\n'.format(library_info[0], ','.join([str(i) for i in library_info[1:]])) js_str = js_str[:-2] # Removes trailing comma return mark_safe(js_str)
def get_work_total(work_name): work_key = "global bf:{0}".format(work_name) if REDIS_DATASTORE.exists(work_key): work_total = '{0:,}'.format(int(REDIS_DATASTORE.get(work_key))) else: work_total = 0 return mark_safe(work_total)
def location_facet(request, name): rlsp_query_key = request.session.get('rlsp-query', None) location_key = REDIS_DATASTORE.hget('carl-prospector-slug-names', name) if not location_key: raise Http404 result = REDIS_DATASTORE.sinter(rlsp_query_key, '{0}:resourceRole:own'.format(location_key)) records = [] for instance_key in result: work_key = REDIS_DATASTORE.hget(instance_key, 'instanceOf') work_classname = work_key.split(":")[1] work_class = getattr(bibframe.models, work_classname) records.append(work_class(redis_datastore=REDIS_DATASTORE, redis_key=work_key)) msg = "{0} Results for {1} owned by {2}".format( len(records), request.session.get('q', None), REDIS_DATASTORE.hget(location_key, 'label')) return render(request, 'discovery/app.html', {'app': APP, 'example':{}, 'feedback_form':FeedbackForm({'subject':'Discovery Facet Display'}), 'feedback_context':request.get_full_path(), 'institution': INSTITUTION, 'facet_list': None, 'message': msg, 'pagination':None, 'results':records, 'search_form': SearchForm(), 'search_query': None, 'user': None})
def get_news(): news = [] # In demo mode, just create a news item regarding the # statistics of the REDIS_DATASTORE if REDIS_DATASTORE is not None: body_text = "<p><strong>Totals:</strong>" for key in CREATIVE_WORK_CLASSES: body_text += '{0} = {1}<br>'.format( key, REDIS_DATASTORE.get('global bf:{0}'.format(key))) body_text += '</p><p>Total number of keys={0}</p>'.format( REDIS_DATASTORE.dbsize()) item = {'heading': 'Current Statistics for Redis Datastore', 'body': body_text} news.append(item) ## body_html = '<ul>' ## for row in REDIS_DATASTORE.zrevrange('prospector-holdings', ## 0, ## -1, ## withscores=True): ## org_key, score = row[0], row[1] ## body_html += '''<li>{0} Total Holdings={1}</li>'''.format( ## REDIS_DATASTORE.hget(org_key, 'label'), ## score) ## body_html += '</ul>' ## item2 = {'heading': 'Institutional Collections', ## 'body': body_html} ## news.append(item2) return news
def add_ils_location(place_key, code_list, REDIS_DATASTORE): if len(code_list) < 1: pass elif len(code_list) == 1: REDIS_DATASTORE.hset(place_key, 'ils-location-code', code_list[0]) else: REDIS_DATASTORE.sadd('{0}:ils-location-codes'.format(place_key), code_list)
def setup_seed_rec(): """ Helper function returns a record based on the SEED_RECORD_ID for the default view """ if REDIS_DATASTORE.hexists(SEED_RECORD_ID,'callno-lcc'): lcc = REDIS_DATASTORE.hget(SEED_RECORD_ID,'callno-lcc') current = redis_helpers.get_record(call_number=lcc) return current else: return None
def display_collection(placeholder): output = "" for i in range(1, int(REDIS_DATASTORE.get('global bf:Manuscript'))): work_key = 'bf:Manuscript:{0}'.format(i) title_key = REDIS_DATASTORE.hget(work_key, 'title') instance_key = REDIS_DATASTORE.hget(work_key, 'hasInstance') title = REDIS_DATASTORE.hget(title_key, 'titleValue') pdf_location = REDIS_DATASTORE.hget(instance_key, 'schema:contentUrl') output += """<li><a href="/apps/discovery/Manuscript/{0}">{1}</a> <a href="{2}"><img src="/static/img/pdficon_small.png"></a></li> """.format(i, title, pdf_location) return mark_safe(output)
def legacy_load_databases_json(): subject_dict = {} alt_title_dict = {} for row in subjects: subject_dict[row['pk']] = {"name":row['fields']['name']} new_topic = TopicalConcept(redis_datastore=REDIS_DATASTORE, description="Topic Used for Database-by-Subject view in dbfinder", label=row['fields']['name']) new_topic.save() subject_dict[row['pk']]["redis_key"] = new_topic.redis_key REDIS_DATASTORE.sadd("dbfinder:subjects", new_topic.redis_key) for row in alt_titles: db_key = row['fields']['database'] if alt_title_dict.has_key(db_key): alt_title_dict[db_key].append(row['fields']['title']) else: alt_title_dict[db_key] = [row['fields']['title'],] for i,row in enumerate(databases): db_pk = row['pk'] description = row['fields']['description'] title = row['fields']['title'] new_work = Work(redis_datastore=REDIS_DATASTORE, description=description, title={'rda:preferredTitleForTheWork':title}) if alt_title_dict.has_key(db_pk): new_work.varientTitle = [] for alt_title in alt_title_dict[db_pk]: new_work.varientTitle.append(alt_title) new_work.varientTitle = set(new_work.varientTitle) new_work.save() subject_keys = [] for subject_id in row['fields']['subjects']: subject_name = subject_dict[subject_id].get("name",None) if subject_name is not None: subject_keys.append(subject_dict[subject_id].get("redis_key")) REDIS_DATASTORE.sadd("dbfinder:subject:{0}".format(subject_name), new_work.redis_key) if len(subject_keys) > 0: new_work.subject = set(subject_keys) new_work.save() alpha_redis_key = "dbfinder:alpha:{0}".format(title[0].upper()) REDIS_DATASTORE.sadd(alpha_redis_key, new_work.redis_key) REDIS_DATASTORE.sadd("dbfinder:alphas",alpha_redis_key) new_instance = Instance(redis_datastore=REDIS_DATASTORE, instanceOf=new_work.redis_key, uri=row['fields']['url']) new_instance.save() REDIS_DATASTORE.sadd("{0}:bibframe:Instances".format(new_work.redis_key), new_instance.redis_key) print("Added {0}".format(title))
def get_brief_view(work_key): work_template = template.loader.get_template('work-brief-view.html') work = { 'url': '/apps/discovery/Manuscript/{0}'.format(work_key.split(":")[-1]) } instance_key = REDIS_DATASTORE.hget(work_key, 'hasInstance') title_key = REDIS_DATASTORE.hget(work_key, 'title') work['title'] = REDIS_DATASTORE.hget(title_key, 'label') work['pdf_url'] = REDIS_DATASTORE.hget(instance_key, 'schema:contentUrl') work['topics'] = [] topic_keys = [] if REDIS_DATASTORE.hexists(work_key, 'subject'): topic_key = REDIS_DATASTORE.hget(work_key, 'subject') topic_keys.append(topic_key) else: topic_keys.extend( list(REDIS_DATASTORE.smembers('{0}:subject'.format(work_key)))) for topic_key in topic_keys: work['topics'].append({ 'label': REDIS_DATASTORE.hget(topic_key, 'label'), 'url': '/apps/discovery/Topic/{0}'.format(topic_key.split(":")[-1]) }) return mark_safe(work_template.render(template.Context({'work': work})))
def handle(self, *args, **options): datastore_size = REDIS_DATASTORE.dbsize() if datastore_size > 0: raise CommandError( "REDIS_DATASTORE must be empty, size is {0}".format( datastore_size)) InitializeEmptyRLSP()
def display_pagination(current_shard): "Filter generates pagination view based on the current shard" pagination_template = template.loader.get_template( 'cc-pagination.html') current_int = int(current_shard.split(":")[-1]) shard_pattern = current_shard[:-2] total_int = int(REDIS_DATASTORE.get('global {0}'.format(shard_pattern))) previous_int = current_int -1 next_int = current_int +1 if previous_int < 1: previous_int = 1 shards = [] for i in range(1, total_int): shards.append('{0}:{1}'.format(shard_pattern, i)) previous_shard = '{0}:{1}'.format(shard_pattern, previous_int) next_shard = '{0}:{1}'.format(shard_pattern, next_int) return mark_safe(pagination_template.render( template.Context({'previous': previous_shard, 'next': next_shard, 'shard_num': current_int})))
def display_topic_cloud(placeholder): topics = [] for i in range(1, int(REDIS_DATASTORE.get('global bf:Topic'))): topic_key = 'bf:Topic:{0}'.format(i) topic_works_key = '{0}:works'.format(topic_key) total_works = int(REDIS_DATASTORE.scard(topic_works_key)) if total_works < 3: topic_size = 12 elif total_works < 10: topic_size = 16 else: topic_size = total_works topics.append("""<a style="font-size: {0}px" href="/apps/discovery/Topic/{1}">{2}</a>""".format( topic_size, i, REDIS_DATASTORE.hget(topic_key, 'label'))) return mark_safe(", ".join(topics))
def author_of(person): "Returns div with a list of Works that the person is an author of" author_role_key = "{0}:resourceRole:aut".format(person.redis_key) if not REDIS_DATASTORE.exists(author_role_key): return mark_safe('') author_html = """<div class="alert alert-info alert-block"> <h3>Author's Creative Works</h3><ul>""" for work_key in REDIS_DATASTORE.smembers(author_role_key): work_info = work_key.split(":") title_key = REDIS_DATASTORE.hget(work_key, 'title') title = REDIS_DATASTORE.hget(title_key, 'label') author_html += """<li>{0} <em><a href="/apps/discovery/{0}/{1}">{2}</a></li></em> """.format(work_info[1], work_info[-1], title) author_html += "</ul></div>" return mark_safe(author_html)
def facet_summary(request,facet_name): """ Displays A general facet with all of its's items """ redis_key = "bf:Annnotation:Facet:{0}s".format(facet_name) if not REDIS_DATASTORE.exists(redis_key): raise Http404 return HttpResponse("In facet_summary, Facet = {0}".format(redis_key))
def display_brief(work): "Returns CC version of a Brief summary based on White While DL design" work_template = template.loader.get_template( 'cc-brief.html') title_entity = REDIS_DATASTORE.hget(work.title, 'label') if REDIS_DATASTORE.hexists(work.redis_key, "rda:isCreatedBy"): creators_keys = [REDIS_DATASTORE.hget(work.redis_key, "rda:isCreatedBy"),] else: creators_keys = list(REDIS_DATASTORE.smembers( "{0}:rda:isCreatedBy".format(work.redis_key))) creators = [] for redis_key in creators_keys[:4]: creator = {'id': redis_key.split(":")[-1]} given_name = REDIS_DATASTORE.hget(redis_key, 'schema:givenName') if given_name is not None: creator['givenName'] = unicode(given_name, errors='ignore') family_name = REDIS_DATASTORE.hget(redis_key, 'schema:familyName') if family_name is not None: creator['familyName'] = unicode(family_name, errors='ignore') creator['name'] = unicode(REDIS_DATASTORE.hget(redis_key, 'rda:preferredNameForThePerson'), errors='ignore') creators.append(creator) context = template.Context({'creators': creators, 'title': title_entity, 'work': work} ) return mark_safe(work_template.render(context))
def get_subjects(creative_work): work_key = creative_work.redis_key output = "" subject_work_key = "{0}:subject".format(work_key) if REDIS_DATASTORE.exists(subject_work_key): for topic_key in REDIS_DATASTORE.smembers(subject_work_key): topic_id = topic_key.split(":")[-1] label = REDIS_DATASTORE.hget(topic_key, 'label') output += """<li><a href="/apps/discovery/Topic/{0}">{1}</a> </li> """.format(topic_id, label) else: topic_key = REDIS_DATASTORE.hget(work_key, 'subject') topic_id = topic_key.split(":")[-1] label = REDIS_DATASTORE.hget(topic_key, 'label') output += """<li><a href="/apps/discovery/Topic/{0}">{1}</a></li> """.format(topic_id, label) return mark_safe(output)
def get_object(self, request, redis_name, redis_id): redis_key = "bf:{0}:{1}".format(redis_name, redis_id) if not REDIS_DATASTORE.exists(redis_key): raise Http404 redis_class = getattr(bibframe.models, redis_name) return redis_class(redis_datastore=REDIS_DATASTORE, redis_key=redis_key)
def display_instances(work): "Generates a display of all of the instances for a work" work_instances_template = template.loader.get_template( 'cc-work-instances.html') instances = [] instance_keys = list(REDIS_DATASTORE.smembers( "{0}:hasInstance".format(work.redis_key))) if len(instance_keys) < 1: instance_key = REDIS_DATASTORE.hget(work.redis_key, 'hasInstance') if instance_key is not None: instance_keys.append(instance_key) for instance_key in instance_keys: instances.append( Instance(redis_key=instance_key, redis_datastore=REDIS_DATASTORE)) context = template.Context({'instances': instances}) return mark_safe(work_instances_template.render(context))
def person_json_ld(request, redis_id): """ Person JSON-LD view for the discovery app :param request: HTTP Request :param redis_id": Redis integer for the Person """ redis_key = "bibframe:Person:{0}".format(redis_id) if REDIS_DATASTORE.exists(redis_key): json_linked_data = get_json_linked_data(redis_datastore=REDIS_DATASTORE, redis_key=redis_key) for work_key in list(REDIS_DATASTORE.smembers("{0}:rda:isCreatorPersonOf")): work_url = "http://{0}/apps/discovery/Work/{1}".format(request.get_host(), work_key.split(":")[-1]) if json_linked_data.has_key('rda:isCreatorPersonOf'): json_linked_data['rda:isCreatorPersonOf'].append(work_url) else: json_linked_data['rda:isCreatorPersonOf'] = [work_url,] return json_linked_data
def __initializeBIBFRAME(): "Initializes all BIBFRAME Keys" print("Initializing BIBFRAME labels") bf_rdf = etree.parse(os.path.join(PROJECT_HOME, 'bibframe', 'fixures', 'vocab.rdf')) rdfs_resources_elems = bf_rdf.findall("{{{0}}}Resource".format(RDFS)) for row in rdfs_resources_elems: attribute_uri = row.attrib.get('{{{0}}}about'.format(RDF)) attrib_name = os.path.split(attribute_uri)[-1] if not REDIS_DATASTORE.hexists('bf:vocab:labels', attrib_name): label = row.find('{{{0}}}label'.format(RDFS)) REDIS_DATASTORE.hset('bf:vocab:labels', attrib_name, label.text) sys.stderr.write(".") print("\nFinished Initializing BIBFRAME labels")
def get_prospector_bar_chart(app=None): "Returns a javascript for a Canvas.js bar chart of Prospector Holdings" js_str = "var ctx=$('#prospector-rlsp-bar').get(0).getContext('2d');" data = {'labels':[], 'data':[]} for row in REDIS_DATASTORE.zrevrange('prospector-holdings', 0, -1, withscores=True): if float(row[1]) > 0: org_key = row[0] data['labels'].append(REDIS_DATASTORE.hget(org_key, 'label')) data['data'].append(str(row[1])) js_str += """var data={{ labels: ["{0}"],""".format('","'.join(data['labels'])) js_str += """datasets: [ {{ fillColor : "rgba(151,187,205,0.5)", strokeColor : "rgba(151,187,205,1)", data : [{0}]}}]}};""".format(','.join(data['data'])) js_str += "new Chart(ctx).Bar(data, {scaleShowLabel: true});" return mark_safe(js_str)
def get_subjects(creative_work): work_key = creative_work.redis_key output = "" subject_work_key = "{0}:subject".format(work_key) if REDIS_DATASTORE.exists(subject_work_key): for topic_key in REDIS_DATASTORE.smembers( subject_work_key): topic_id = topic_key.split(":")[-1] label = REDIS_DATASTORE.hget(topic_key, 'label') output += """<li><a href="/apps/discovery/Topic/{0}">{1}</a> </li> """.format(topic_id, label) else: topic_key = REDIS_DATASTORE.hget(work_key, 'subject') topic_id = topic_key.split(":")[-1] label = REDIS_DATASTORE.hget(topic_key, 'label') output += """<li><a href="/apps/discovery/Topic/{0}">{1}</a></li> """.format(topic_id, label) return mark_safe(output)
def get_news(num_items=5): """ Returns a rendered list of news items with a default number of five news items. :param num_items: The number of news items to display """ news = REDIS_DATASTORE.zrange("prospector:news", -(int(num_items)), -1) news_template = template.loader.get_template('carl-news.html') return mark_safe(news_template.render(template.Context({'news':news})))
def display_cover_image(request, redis_id, type_of, image_ext): """ Returns a cover image based on the CoverArt's redis key, if the type-of is body or thumbnail and the image_ext is either "jpg", "png", or "gif" :param redis_id: Redis key id of the bibframe:CoverArt :param type_of: Should be either "thumbnail" or "body" "param image_ext: The images extension """ redis_key = "bf:CoverArt:{0}".format(redis_id) if type_of == 'thumbnail': raw_image = REDIS_DATASTORE.hget(redis_key, 'thumbnail') elif type_of == 'body': raw_image = REDIS_DATASTORE.hget(redis_key, 'annotationBody') if raw_image is None: raise Http404 return HttpResponse(raw_image, mimetype="image/{0}".format(image_ext))
def bibframe_by_name(request, class_name, slug): """Displays either a disambiguation of multiple BIBFRAME entities that match the slugified title or a single BIBFRAME entity otherwise. Parameters: class_name -- BIBFRAME Class slug -- Title of BIBFRAME entity as a slug """ title_key = REDIS_DATASTORE.hget('title-slugs-hash', slug) if title_key is None: raise Http404 return HttpResponse("{0} {1}".format(class_name, title_key))
def get_creators(bibframe_entity): output = '<ul class="icons-ul">' if type(bibframe_entity) == Instance: redis_key = bibframe_entity.attributes.get('instanceOf') else: redis_key = bibframe_entity.redis_key if REDIS_DATASTORE.hexists(redis_key,"rda:isCreatedBy"): creators = [REDIS_DATASTORE.hget(redis_key,"rda:isCreatedBy"),] else: creators = list(REDIS_DATASTORE.smembers("{0}:rda:isCreatedBy".format(redis_key))) for i, key in enumerate(creators): creator_id = key.split(":")[-1] output += """<li><a href="/apps/discovery/Person/{0}"> <i class="icon-li icon-user"></i> {1}</a></li>""".format( key.split(":")[-1], REDIS_DATASTORE.hget(key, 'rda:preferredNameForThePerson')) output += "</ul>" return mark_safe(output)
def feedback(request): """ Feedback view for the Aristotle Library Apps Project :param request: Web request from client """ if request.method != 'POST': return Http404 today = datetime.datetime.utcnow() feedback_id = REDIS_DATASTORE.incr( "global feedback:{0}:{1}".format(today.year, today.month)) feedback_key = "feedback:{0}:{1}:{2}".format(today.year, today.month, feedback_id) REDIS_DATASTORE.hset(feedback_key, "created", today.isoformat()) REDIS_DATASTORE.hset(feedback_key, "comment", request.POST.get('comment')) REDIS_DATASTORE.hset(feedback_key, "context", request.POST.get('context')) if request.POST.has_key('sender'): REDIS_DATASTORE.hset(feedback_key, "sender", request.POST.get('sender')) return redirect(REDIS_DATASTORE.hget(feedback_key, "context"))
def load_institution_places(prospector_code, json_filename, authority_ds=REDIS_DATASTORE): """Function loads an Institution's Places codes into RLSP Parameters: prospector_code -- Prospector code json_filename -- Filename of an institution's places encoded in JSON """ institution_key = authority_ds.hget('prospector-institution-codes', prospector_code) places = json.load(os.path.join(PROJECT_HOME, "themes", "prospector", "fixures", json_filename)) for name, info in places.iteritems(): place_key = add_place(institution_key, REDIS_DATASTORE) REDIS_DATASTORE.hset(place_key, 'name', name) # Should be the standard case, a listing of ils codes associated if type(info) == list: add_ils_location(place_key, info, REDIS_DATASTORE) elif type(info) == dict: sub_place_keys = [] for key, value in info.iteritems(): sub_place_key = add_place(institution_key, REDIS_DATASTORE) REDIS_DATASTORE.hset(sub_place_key, 'name', key) REDIS_DATASTORE.hset(sub_place_key, 'schema:containedIn', place_key) add_ils_location(sub_place_key, info, REDIS_DATASTORE) sub_place_keys.append(sub_place_key) if len(sub_place_keys) < 1: pass elif len(sub_place_keys) == 1: REDIS_DATASTORE.hset(place_key, "contains", sub_place_keys[0]) else: REDIS_DATASTORE.sadd('{0}:contains'.format(place_key), sub_place_keys)
def get_facet(facet): "Returns accordion group based on template and redis-key" # Assume facet_key is sorted set facet_grp_template = template.loader.get_template('cc-facet-group') facet = {'label': facet_key.split(":")[-1], 'items': []} facet['name'] = facet.get('label').lower().sub(" ","-") for item in REDIS_DATASTORE.zrevrange(facet_key, 0, -1, withscores=True): item = {'label': item[0].split(":")[-1], 'count': item[1]} facet['items'].append(item) return mark_safe(facet_grp_template.render( template.Context(facet)))
def get_featured_instances(num_items=5): """ Returns Creative Works that display as a listing of BIBFRAME Instances, will display CoverArt if available :param num_items: Number of featured items """ featured_instances = [] featured_keys = REDIS_DATASTORE.smembers('prospector:featured') for key in featured_keys: info = {'redis_key': key} featured_instances.append(info) featured_items_template = template.loader.get_template( 'discovery/carl-featured-instances.html') return mark_safe(featured_items_template.render(template.Context({ 'instances': featured_instances})))
def about_work(work): "Filter extracts and renders a DL html list of a bf:Work or subclasses" about_work_template = template.loader.get_template('about-work-dl.html') work_properties = [] pub_date = getattr(work, 'rda:dateOfPublicationManifestation') if pub_date is not None: work_properties.append({'name': 'Publication Date', 'value': pub_date}) lcc_class = getattr(work, 'class-lcc') if lcc_class is not None: work_properties.append({'name': 'LCC Class', 'value': lcc_class}) instance_key = work.hasInstance carrier_type = REDIS_DATASTORE.hget(instance_key, 'rda:carrierTypeManifestation') work_properties.append({'name': 'Format', 'value': carrier_type}) work_properties.sort(key=lambda prop: prop.get('name')) return mark_safe( about_work_template.render( template.Context({'work_properties': work_properties})))
def get_pdf_uri(creative_work): return mark_safe( REDIS_DATASTORE.hget(creative_work.hasInstance, 'schema:contentUrl'))