def about_project_preload(context, request): context = default_preload(context, request) query_args = url_params(request) project_id = query_args['id'][0] project_json = ProjectCache.get(project_id) if project_json is not None: context['title'] = project_json['project_name'] + ' | DemocracyLab' context['description'] = project_json['project_short_description'] or project_json['project_description'][:300] if 'project_thumbnail' in project_json: context['og_image'] = project_json['project_thumbnail']['publicUrl'] else: print('Failed to preload project info, no cache entry found: ' + project_id) return context
def about_group_preload(context, request): context = default_preload(context, request) query_args = url_params(request) group_id = query_args['id'] group_json = GroupCache.get(group_id) if group_json is not None: context['title'] = group_json['group_name'] + ' | DemocracyLab' context['description'] = group_json['group_short_description'] if 'group_thumbnail' in group_json: context['og_image'] = group_json['group_thumbnail']['publicUrl'] else: print('Failed to preload group info, no cache entry found: ' + group_id) return context
def about_event_preload(context, request): context = default_preload(context, request) query_args = url_params(request) event_id = query_args['id'][0] event = Event.get_by_id_or_slug(event_id, get_request_contributor(request)) event_json = event.hydrate_to_json() if event_json is not None: context['title'] = event_json['event_name'] + ' | DemocracyLab' context['description'] = event_json['event_short_description'] if 'event_thumbnail' in event_json: context['og_image'] = event_json['event_thumbnail']['publicUrl'] else: print('Failed to preload event info, no cache entry found: ' + event_id) return context
def about_event_preload(context, request): context = default_preload(context, request) query_args = url_params(request) event_id = query_args['id'] event = Event.get_by_id_or_slug(event_id) event_json = event.hydrate_to_json() if event_json is not None: context['title'] = event_json['event_name'] + ' | DemocracyLab' context['description'] = event_json['event_short_description'] if 'event_thumbnail' in event_json: context['og_image'] = event_json['event_thumbnail']['publicUrl'] slug_or_id = event.event_slug or event.id context['canonical_url'] = section_url(FrontEndSection.AboutEvent, {'id': slug_or_id}) else: print('Failed to preload event info, no cache entry found: ' + event_id) return context