def retail_view(context, request): page_title = context.title api = TemplateAPI(context, request, page_title) middle_portlet_html = _get_portlet_html(context, request, context.middle_portlets) right_portlet_html = _get_portlet_html(context, request, context.right_portlets) current_intranet = api.current_intranet feature = getattr(find_intranets(current_intranet), 'feature', u'') # Rendering this separately gives us a chance later to think about # some kind of caching. body = render( 'templates/intranethome_body.pt', dict(current_intranet=current_intranet, feature=feature, middle_portlet_html=middle_portlet_html, right_portlet_html=right_portlet_html), request=request ) return render_to_response( 'templates/intranet_homepage.pt', dict(api=api, body=body), request=request, )
def retail_view(context, request): page_title = context.title api = TemplateAPI(context, request, page_title) middle_portlet_html = _get_portlet_html(context, request, context.middle_portlets) right_portlet_html = _get_portlet_html(context, request, context.right_portlets) current_intranet = api.current_intranet feature = getattr(find_intranets(current_intranet), 'feature', u'') # Rendering this separately gives us a chance later to think about # some kind of caching. body = render('templates/intranethome_body.pt', dict(current_intranet=current_intranet, feature=feature, middle_portlet_html=middle_portlet_html, right_portlet_html=right_portlet_html), request=request) return render_to_response( 'templates/intranet_homepage.pt', dict(api=api, body=body), request=request, )
def intranets_info(self): """Get information for the footer and intranets listing""" if self._intranets_info is None: intranets_info = [] intranets = find_intranets(self.context) if not intranets: # Maybe there aren't any intranets defined yet return [] request = self.request intranets_url = model_url(intranets, request) for name, entry in intranets.items(): try: content_iface = get_content_type(entry) except ValueError: continue href = "%s%s/" % (intranets_url, quote_path_segment(name)) if content_iface == ICommunity: intranets_info.append( {"title": entry.title, "intranet_href": href, "edit_href": href + "/edit_intranet.html"} ) # Sort the list def intranet_sort(x, y): if x["title"] > y["title"]: return 1 else: return -1 self._intranets_info = sorted(intranets_info, intranet_sort) return self._intranets_info
def global_nav(context, request): layout = request.layout_manager.layout site = layout.site menu_items = [ dict(title="Communities", url=request.resource_url(site, 'communities'), selected='selected'), dict(title="People", url=layout.people_url, selected=None), dict(title="Feeds", url=request.resource_url(site, 'contentfeeds.html'), selected=None), ] intranets = find_intranets(site) if layout.current_intranet is not None: menu_items.insert(0, dict(title="Intranet", url=request.resource_url(intranets), selected=None)) if layout.should_show_calendar_tab: menu_items.append(dict(title="Calendar", url=request.resource_url(site, 'offices', 'calendar'), selected=None)) if layout.user_is_staff: menu_items.append(dict(title="Tags", url=request.resource_url(site, 'tagcloud.html'), selected=None)) return {'nav_menu': menu_items}
def intranets_info(context, request): """Get information for the footer and intranets listing""" intranets_info = [] intranets = find_intranets(context) if intranets: intranets_url = resource_url(intranets, request) for name, entry in intranets.items(): try: content_iface = get_content_type(entry) except ValueError: continue if content_iface == ICommunity: if not has_permission('view', entry, request): continue href = '%s%s/' % (intranets_url, quote_path_segment(name)) intranets_info.append({ 'title': entry.title, 'intranet_href': href, 'edit_href': href + '/edit_intranet.html', }) # Sort the list def intranet_sort(x, y): if x['title'] > y['title']: return 1 else: return -1 intranets_info.sort(intranet_sort) return intranets_info
def global_logo(context, request): layout = request.layout_manager.layout site = layout.site home_context, home_path = get_user_home(context, request) logo_link = request.resource_url(home_context, *home_path) intranets = find_intranets(site) if layout.current_intranet is not None: logo_link = request.resource_url(intranets) return {'logo_title': request.registry.settings.get('system_name', 'KARL'), 'logo_href': logo_link}
def global_logo(context, request): layout = request.layout_manager.layout site = layout.site home_context, home_path = get_user_home(context, request) logo_link = request.resource_url(home_context, *home_path) intranets = find_intranets(site) if layout.current_intranet is not None: logo_link = request.resource_url(intranets) return { 'logo_title': request.registry.settings.get('system_name', 'KARL'), 'logo_href': logo_link }
def global_nav(context, request): def menu_item(title, url, id=None, count=None, secondary=None): if id is None: id = make_name(EMPTY_CONTEXT, title) selected = request.resource_url(context).startswith(url) if secondary is not None and not selected: selected = request.resource_url(context).startswith(secondary) item = dict(title=title, url=url, id=id, selected=selected and 'selected' or None) if count is not None: item['count'] = count return item layout = request.layout_manager.layout site = layout.site menu_items = [ menu_item("Communities", request.resource_url(site, 'communities')), menu_item("People", layout.people_url, secondary=layout.profiles_url), menu_item("Feeds", request.resource_url(site, 'contentfeeds.html')), ] intranets = find_intranets(site) if layout.current_intranet is not None: menu_items.insert( 0, menu_item("Intranet", request.resource_url(intranets))) if layout.should_show_calendar_tab: menu_items.append( menu_item("Calendar", request.resource_url(site, 'offices', 'calendar'))) if layout.user_is_staff: menu_items.append( menu_item("Tags", request.resource_url(site, 'tagcloud.html'), id='tagcloud')) chatter = find_chatter(site) menu_items.append(menu_item("Chatter", request.resource_url(chatter))) # XXX Radar is disabled for the time. ## menu_items.append(menu_item("Radar", "#", count="7")) overflow_menu = [] #if layout.user_is_staff: # overflow_menu.append(menu_item("Tags", # request.resource_url(site, 'tagcloud.html'), id='tagcloud')) return {'nav_menu': menu_items, 'overflow_menu': overflow_menu}
def global_nav(context, request): def menu_item(title, url, id=None, count=None, secondary=None): if id is None: id = make_name(EMPTY_CONTEXT, title) selected = request.resource_url(context).startswith(url) if secondary is not None and not selected: selected = request.resource_url(context).startswith(secondary) item = dict(title=title, url=url, id=id, selected=selected and 'selected' or None) if count is not None: item['count'] = count return item layout = request.layout_manager.layout site = layout.site menu_items = [ menu_item("Communities", request.resource_url(site, 'communities')), menu_item("People", layout.people_url, secondary=layout.profiles_url), menu_item("Feeds", request.resource_url(site, 'contentfeeds.html')), ] intranets = find_intranets(site) if layout.current_intranet is not None: menu_items.insert(0, menu_item("Intranet", request.resource_url(intranets))) if layout.should_show_calendar_tab: menu_items.append(menu_item("Calendar", request.resource_url(site, 'offices', 'calendar'))) if layout.user_is_staff: menu_items.append(menu_item("Tags", request.resource_url(site, 'tagcloud.html'), id='tagcloud')) chatter = find_chatter(site) menu_items.append(menu_item("Chatter", request.resource_url(chatter))) # XXX Radar is disabled for the time. ## menu_items.append(menu_item("Radar", "#", count="7")) overflow_menu = [] #if layout.user_is_staff: # overflow_menu.append(menu_item("Tags", # request.resource_url(site, 'tagcloud.html'), id='tagcloud')) return {'nav_menu': menu_items, 'overflow_menu': overflow_menu}
class CustomFolderView(object): _past_events = None past_events_url = None future_events_url = None def __init__(self, context, request): self.context = context self.request = request searchterm = request.params.get('searchterm', None) if searchterm == '': searchterm = None self.searchterm = searchterm year = request.params.get('year', None) if year == 'all': year = None self.year = year month = request.params.get('month', None) if month == 'all': month = None self.month = month def __call__(self): """ Folder contents for the INetworkEvents marker""" context = self.context request = self.request page_title = context.title api = TemplateAPI(context, request, page_title) # Data for the filter bar, get the list of possible years and months this_year = datetime.datetime.now().year fb_years = [str(i) for i in range(2007, this_year+1)] fb_months = [('1', 'January'), ('2', 'February'), ('3', 'March'), ('4', 'April'), ('5', 'May'), ('6', 'June'), ('7', 'July'), ('8', 'August'), ('9', 'September'), ('10', 'October'), ('11', 'November'), ('12', 'December')] # Flatten the search results into ZPT data try: batch = self._get_batch() except ParseError, e: api.set_error_message('Error: %s' % e) batch = {'entries': (), 'batching_required': False} entries = [] for entry in batch["entries"]: info = {} info['url'] = resource_url(entry, request) info['title'] = entry.title info['date'] = self._get_date(entry) entries.append(info) # Actions and backlink actions = [] if has_permission('create', context, request): addables = get_folder_addables(context, request) if addables is not None: actions.extend(addables()) if has_permission('edit', context, request): actions.append(('Edit', 'edit.html')) if has_permission('delete', context.__parent__, request): actions.append(('Delete', 'delete.html')) if has_permission('administer', context, request): # admins see an Advanced action that puts markers on a folder. actions.append(('Advanced', 'advanced.html')) back_target, extra_path = get_user_home(context, request) backto = { 'href': resource_url(back_target, request, *extra_path), 'title': getattr(back_target, "title", "Home") } client_json_data = dict( tagbox = get_tags_client_data(context, request), ) # Get a layout layout_provider = get_layout_provider(context, request) layout = layout_provider('community') intranet = find_intranet(self.context) intranets = find_intranets(self.context) community = find_community(self.context) if intranet is not None or community == intranets: ux2_layout = self.request.layout_manager.layout ux2_layout.section_style = "none" return dict( api=api, actions=actions, head_data=convert_to_script(client_json_data), backto=backto, old_layout=layout, entries=entries, fb_years=fb_years, fb_months=fb_months, searchterm=self.searchterm, selected_year=self.year, selected_month=self.month, batch_info=batch, past_events_url=self.past_events_url, future_events_url=self.future_events_url, )