def __call__(self): layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('community') page_title = 'Edit %s' % self.context.title api = TemplateAPI(self.context, self.request, page_title) api.karl_client_data['text'] = dict(enable_imagedrawer_upload=True, ) return {'api': api, 'layout': layout, 'actions': []}
def viewall_referencemanual_view(context, request): backto = { 'href': model_url(context.__parent__, request), 'title': context.__parent__.title, } page_title = context.title api = TemplateAPI(context, request, page_title) # Get a layout layout_provider = get_layout_provider(context, request) layout = layout_provider('intranet') # provide client data for rendering current tags in the tagbox client_json_data = dict( tagbox = get_tags_client_data(context, request), ) return render_template_to_response( 'templates/viewall_referencemanual.pt', api=api, actions=[], head_data=convert_to_script(client_json_data), sections=_get_viewall(context, request, api), backto=backto, layout=layout, )
def month_users_view(context, request): year = context.__parent__.__name__ month = context.__name__ api = TemplateAPI(context, request, '%s - %s user metrics' % (year, month)) layout_provider = get_layout_provider(context, request) layout = layout_provider() if 'csv' in request.GET: def generate_csv_row(row): return [ row['total'], row['staff'], row['core_office'], row['national_foundation'], row['former'], row['affiliate'], row['active'], ] return csv_response(request, '%s-%s-users.csv' % (year, month), [ 'Total', 'Staff', 'Core Office', 'National Foundation', 'Former Staff', 'Affiliate', 'Active' ], [context.users['total']], generate_csv_row) return dict(api=api, layout=layout, metricsmacros=_metrics_macros(), userdata=context.users['total'], backto=backto_year(context, request))
def __call__(self): layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') self.api.karl_client_data['text'] = dict( enable_imagedrawer_upload=True, ) return {'api': self.api, 'layout': layout, 'actions': []}
def month_profiles_view(context, request): year = context.__parent__.__name__ month = context.__name__ api = TemplateAPI(context, request, '%s - %s profile metrics' % (year, month)) layout_provider = get_layout_provider(context, request) layout = layout_provider() profiles = [ dict(name=k, created=v['created'], is_staff=v['is_staff']) for k, v in context.profiles.items() ] profiles.sort(key=lambda x: x['name']) if 'csv' in request.GET: def generate_csv_row(profile): return [ profile['name'].title(), profile['is_staff'], profile['created'], ] return csv_response(request, '%s-%s-profiles.csv' % (year, month), ['User', 'Staff', 'Created'], profiles, generate_csv_row) return dict(api=api, layout=layout, metricsmacros=_metrics_macros(), profiles=profiles, backto=backto_year(context, request))
def __call__(self): layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') self.api.karl_client_data['text'] = dict( enable_imagedrawer_upload = True, ) return {'api': self.api, 'layout': layout, 'actions': []}
def delete_resource_view(context, request, num_children=0): page_title = 'Delete ' + context.title api = TemplateAPI(context, request, page_title) confirm = request.params.get('confirm') if confirm: location = resource_url(context.__parent__, request, query=dict(status_message='Deleted %s' % context.title)) del context.__parent__[context.__name__] return HTTPFound(location=location) # Get a layout layout_provider = get_layout_provider(context, request) layout_name = 'generic' if find_intranet(context): layout_name = 'intranet' elif find_community(context): layout_name = 'community' layout = layout_provider(layout_name) return { 'api': api, # deprecated UX2 'old_layout': layout, # deprecated UX2 'num_children': num_children, }
def delete_resource_view(context, request, num_children=0): page_title = 'Delete ' + context.title api = TemplateAPI(context, request, page_title) confirm = request.params.get('confirm') if confirm: location = model_url( context.__parent__, request, query=dict(status_message= 'Deleted %s' % context.title) ) del context.__parent__[context.__name__] return HTTPFound(location=location) # Get a layout layout_provider = get_layout_provider(context, request) layout_name = 'generic' if find_intranet(context): layout_name = 'intranet' elif find_community(context): layout_name = 'community' layout = layout_provider(layout_name) return {'api': api, 'layout': layout, 'num_children': num_children, }
def month_contenttype_view(context, request): year = context.__parent__.__name__ month = context.__name__ api = TemplateAPI(context, request, '%s - %s contenttype metrics' % (year, month)) layout_provider = get_layout_provider(context, request) layout = layout_provider() contenttypes = [ dict(name=k, total=v['total'], created=v['created']) for k, v in context.contenttypes.items() ] contenttypes.sort(key=lambda x: x['name']) if 'csv' in request.GET: def generate_csv_row(contenttype): return [ contenttype['name'].title(), contenttype['created'], contenttype['total'], ] return csv_response(request, '%s-%s-contenttype.csv' % (year, month), ['Content Type', 'Created', 'Total'], contenttypes, generate_csv_row) return dict(api=api, layout=layout, metricsmacros=_metrics_macros(), contenttypes=contenttypes, backto=backto_year(context, request))
def __call__(self): context = self.context request = self.request api = TemplateAPI(context, request, self.page_title) layout_provider = get_layout_provider(context, request) layout = layout_provider('intranet') return {'api': api, 'layout': layout, 'actions': []}
def __call__(self): layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('community') api = TemplateAPI(self.context, self.request, 'Add Forum Topic') api.karl_client_data['text'] = dict( enable_imagedrawer_upload = True, ) return {'api':api, 'actions':(), 'layout':layout}
def __call__(self): api = TemplateAPI(self.context, self.request, 'Add Folder') layout_provider = get_layout_provider(self.context, self.request) if layout_provider is None: layout = api.community_layout else: layout = layout_provider('community') return {'api':api, 'actions':(), 'layout':layout}
def __call__(self): context = self.context request = self.request api = TemplateAPI(context, request, self.page_title) layout_provider = get_layout_provider(context, request) layout = layout_provider() return {'api': api, 'layout': layout, 'actions': []}
def __call__(self): api = self.api layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') self.request.form.edge_div_class = 'k3_admin_role' form_title = 'Add User' return {'api':api, 'actions':(), 'layout':layout, 'form_title': form_title, 'include_blurb': False}
def __call__(self): api = TemplateAPI(self.context, self.request, "Change Password") layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider("generic") snippets = get_template("forms/templates/snippets.pt") snippets.doctime = xhtml blurb_macro = snippets.macros["change_password_blurb"] return {"api": api, "layout": layout, "actions": [], "blurb_macro": blurb_macro}
def __call__(self): api = self.api layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('community') return { 'api': api, 'layout': layout, 'actions': []}
def __call__(self): api = self.api layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('community') return { 'api': api, # deprecated UX1 'old_layout': layout, # deprecated UX1 'actions': []} # deprecated UX1
def show_forum_view(context, request): page_title = context.title api = TemplateAPI(context, request, page_title) actions = [] if has_permission('create', context, request): actions.append(('Add Forum Topic', 'add_forum_topic.html')) if has_permission('edit', context, request): actions.append(('Edit', 'edit.html')) if has_permission('delete', context, request): actions.append(('Delete', 'delete.html')) profiles = find_profiles(context) karldates = getUtility(IKarlDates) topic_batch = get_topic_batch(context, request) topic_entries = topic_batch['entries'] topics = [] for topic in topic_entries: D = {} profile = profiles.get(topic.creator) posted_by = getattr(profile, 'title', None) date = karldates(topic.created, 'longform') D['url'] = resource_url(topic, request) D['title'] = topic.title D['posted_by'] = posted_by D['date'] = date D['number_of_comments'] = len(topic['comments']) topics.append(D) # In the intranet side, the backlinks should go to the show_forums # view (the default) forums = context.__parent__ backto = { 'href': resource_url(forums, request), 'title': forums.title, } # Get a layout layout_provider = get_layout_provider(context, request) layout = layout_provider('generic') ux2_layout = request.layout_manager.layout ux2_layout.section_style = "none" return render_to_response( 'templates/show_forum.pt', dict(api = api, actions = actions, title = context.title, topics = topics, batch_info = topic_batch, backto=backto, old_layout=layout), request=request, )
def __call__(self): context = self.context request = self.request page_title = 'Edit %s' % context.title api = TemplateAPI(context, request, page_title) layout_provider = get_layout_provider(context, request) layout = layout_provider('intranet') return {'api': api, 'layout': layout, 'actions': []}
def __call__(self): api = self.api layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('community') return { 'api': api, # deprecated UX1 'old_layout': layout, # deprecated UX1 'actions': [] } # deprecated UX1
def __call__(self): api = TemplateAPI(self.context, self.request, 'Change Password') layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') snippets = get_renderer('forms/templates/snippets.pt').implementation() snippets.doctime = xhtml blurb_macro = snippets.macros['change_password_blurb'] return {'api': api, 'layout': layout, 'actions': [], 'blurb_macro': blurb_macro}
def reference_outline_view(context, request): # Look for moveUp or moveDown in QUERY_STRING, telling us to # reorder something status_message = None subpath = request.params.get('subpath') backto = { 'href': resource_url(context.__parent__, request), 'title': context.__parent__.title, } user_can_edit = False 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): user_can_edit = True actions.append(('Edit', 'edit.html')) if subpath: direction = request.params['direction'] status_message = move_subpath(context, subpath, direction) if has_permission('delete', context, request): actions.append(('Delete', 'delete.html')) if has_permission('administer', context, request): actions.append(('Advanced', 'advanced.html')) page_title = context.title api = TemplateAPI(context, request, page_title) # Get a layout layout_provider = get_layout_provider(context, request) layout = layout_provider() # provide client data for rendering current tags in the tagbox client_json_data = dict( tagbox=get_tags_client_data(context, request), ) previous, next = get_previous_next(context, request) api.status_message = status_message return render_to_response( 'templates/show_referencemanual.pt', dict(api=api, actions=actions, user_can_edit=user_can_edit, head_data=convert_to_script(client_json_data), tree=getTree(context, request, api), backto=backto, layout=layout, previous_entry=previous, next_entry=next), request=request, )
def __call__(self): api = TemplateAPI(self.context, self.request, self.page_title) layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('community') intranet = find_intranet(self.context) if intranet is not None: ux2_layout = self.request.layout_manager.layout ux2_layout.section_style = "none" return {'api': api, 'actions': (), 'old_layout': layout}
def __call__(self): _fix_website_validation_errors(self.request.form) api = TemplateAPI(self.context, self.request, self.page_title) layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') self.request.form.edge_div_class = 'k3_admin_role' form_title = 'Add User' return {'api':api, 'actions':(), 'layout':layout, 'form_title': form_title, 'include_blurb': False, 'reactivate_user': self.reactivate_user}
def __call__(self): api = TemplateAPI(self.context, self.request, self.page_title) layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('community') intranet = find_intranet(self.context) if intranet is not None: ux2_layout = self.request.layout_manager.layout ux2_layout.section_style = "none" return {'api':api, 'actions':(), 'old_layout':layout}
def reference_outline_view(context, request): # Look for moveUp or moveDown in QUERY_STRING, telling us to # reorder something status_message = None subpath = request.params.get('subpath') backto = { 'href': resource_url(context.__parent__, request), 'title': context.__parent__.title, } user_can_edit = False 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): user_can_edit = True actions.append(('Edit', 'edit.html')) if subpath: direction = request.params['direction'] status_message = move_subpath(context, subpath, direction) if has_permission('delete', context, request): actions.append(('Delete', 'delete.html')) if has_permission('administer', context, request): actions.append(('Advanced', 'advanced.html')) page_title = context.title api = TemplateAPI(context, request, page_title) # Get a layout layout_provider = get_layout_provider(context, request) layout = layout_provider() # provide client data for rendering current tags in the tagbox client_json_data = dict(tagbox=get_tags_client_data(context, request), ) previous, next = get_previous_next(context, request) api.status_message = status_message return render_to_response( 'templates/show_referencemanual.pt', dict(api=api, actions=actions, user_can_edit=user_can_edit, head_data=convert_to_script(client_json_data), tree=getTree(context, request, api), backto=backto, layout=layout, previous_entry=previous, next_entry=next), request=request, )
def __call__(self): api = TemplateAPI(self.context, self.request, 'Change Password') layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') snippets = get_renderer('forms/templates/snippets.pt').implementation() snippets.doctime = xhtml blurb_macro = snippets.macros['change_password_blurb'] return {'api': api, 'old_layout': layout, # deprecated UX1 'actions': [], 'admin_email': api.settings.admin_email, #ux2 'blurb_macro': blurb_macro}
def __call__(self): context = self.context request = self.request api = TemplateAPI(context, request, 'Add Page') community = find_community(context) layout_provider = get_layout_provider(context, request) if community is not None: layout = layout_provider('community') else: layout = layout_provider('generic') return {'api': api, 'actions': (), 'layout': layout}
def __call__(self): _fix_website_validation_errors(self.request.form) page_title = self.request.layout_manager.layout.page_title api = TemplateAPI(self.context, self.request, page_title) layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') self.request.form.edge_div_class = 'k3_admin_role' form_title = 'Add User' return {'api':api, 'actions':(), 'old_layout':layout, 'form_title': form_title, 'include_blurb': False, 'reactivate_user': self.reactivate_user}
def __call__(self): api = self.api layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') if api.user_is_staff: self.request.form.edge_div_class = 'k3_staff_role' else: self.request.form.edge_div_class = 'k3_nonstaff_role' form_title = 'Edit Profile' return {'api':api, 'actions':(), 'layout':layout, 'form_title': form_title, 'include_blurb': True}
def __call__(self): layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('community') page_title = 'Edit %s' % self.context.title api = TemplateAPI(self.context, self.request, page_title) api.karl_client_data['text'] = dict( enable_imagedrawer_upload=True) return { 'api': api, 'layout': layout, 'actions': []}
def __call__(self): _fix_website_validation_errors(self.request.form) page_title = self.request.layout_manager.layout.page_title api = TemplateAPI(self.context, self.request, page_title) layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') self.request.form.edge_div_class = 'k3_admin_role' form_title = 'Edit User and Profile Information' return {'api':api, 'actions':(), 'old_layout':layout, 'form_title': form_title, 'include_blurb': False, 'admin_edit': True, 'is_active': self.is_active}
def __call__(self): page_title = 'Edit %s' % self.context.title api = TemplateAPI(self.context, self.request, page_title) layout_provider = get_layout_provider(self.context, self.request) if layout_provider is None: layout = api.community_layout else: layout = layout_provider('community') return {'api':api, 'actions':(), 'layout':layout}
def __call__(self): context = self.context request = self.request api = TemplateAPI(context, request, 'Add Page') community = find_community(context) layout_provider = get_layout_provider(context, request) if community is not None: layout = layout_provider('community') else: layout = layout_provider('generic') api.karl_client_data['text'] = dict(enable_imagedrawer_upload=True, ) return {'api': api, 'actions': (), 'layout': layout}
def container_view(context, request): api = TemplateAPI(context, request, 'Metrics') layout_provider = get_layout_provider(context, request) layout = layout_provider() years = context.keys() return dict( api=api, layout=layout, metricsmacros=_metrics_macros(), years=years, )
def __call__(self): context = self.context request = self.request page_title = 'Edit %s' % context.title api = TemplateAPI(context, request, page_title) layout_provider = get_layout_provider(context, request) layout = layout_provider() return { 'api': api, 'layout': layout, 'actions': []}
def show_newsitem_view(context, request): backto = { 'href': resource_url(context.__parent__, request), 'title': context.__parent__.title, } actions = [] if has_permission('edit', context, request): actions.append(('Edit', 'edit.html')) if has_permission('delete', context, request): actions.append(('Delete', 'delete.html')) if has_permission('administer', context, request): actions.append(('Advanced', 'advanced.html')) page_title = context.title api = TemplateAPI(context, request, page_title) previous, next = get_previous_next(context, request) # provide client data for rendering current tags in the tagbox client_json_data = dict( tagbox = get_tags_client_data(context, request), ) # Display photo photo = context.get('photo') if photo is not None: photo = { "url": thumb_url(photo, request, PHOTO_DISPLAY_SIZE), } # Get a layout layout_provider = get_layout_provider(context, request) layout = layout_provider('generic') ux2_layout = request.layout_manager.layout ux2_layout.section_style = None return render_to_response( 'templates/show_newsitem.pt', dict(api=api, actions=actions, attachments=fetch_attachments(context['attachments'], request), formfields=api.formfields, head_data=convert_to_script(client_json_data), backto=backto, previous=previous, next=next, old_layout=layout, photo=photo), request=request, )
def __call__(self): _fix_website_validation_errors(self.request.form) api = TemplateAPI(self.context, self.request, self.page_title) if api.user_is_admin: return HTTPFound(location=model_url(self.context, self.request, "admin_edit_profile.html")) layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider("generic") if api.user_is_staff: self.request.form.edge_div_class = "k3_staff_role" else: self.request.form.edge_div_class = "k3_nonstaff_role" form_title = "Edit Profile" return {"api": api, "actions": (), "layout": layout, "form_title": form_title, "include_blurb": True}
def year_users_view(context, request): year = context.__name__ api = TemplateAPI(context, request, '%s user metrics' % year) layout_provider = get_layout_provider(context, request) layout = layout_provider() months_data = [] for month_num, month in sorted(context.items()): if IMetricsMonthFolder.providedBy(month): month_data = dict( month=month_name(year, month_num), total=month.users['total'], ) months_data.append(month_data) if 'csv' in request.GET: def generate_csv_row(row): data = row['total'] return [ row['month'], data['staff'], data['core_office'], data['national_foundation'], data['former'], data['affiliate'], data['active'], data['total'], ] header_row = [ 'Month', 'Staff', 'Core Offices', 'National Foundations', 'Former Staff', 'Affiliates', 'Active', 'Total', ] return csv_response(request, '%s-users.csv' % year, header_row, months_data, generate_csv_row) return dict( api=api, layout=layout, metricsmacros=_metrics_macros(), backto=backto_metrics(context, request), months_data=months_data, year=year, )
def advanced_folder_view(context, request): page_title = 'Advanced Settings For ' + context.title api = TemplateAPI(context, request, page_title) if 'form.cancel' in request.POST: return HTTPFound(location=model_url(context, request)) if 'form.submitted' in request.POST: marker = request.POST.get('marker', False) if marker == 'reference_manual': alsoProvides(context, IReferencesFolder) noLongerProvides(context, INetworkNewsMarker) noLongerProvides(context, INetworkEventsMarker) elif marker == 'network_news': alsoProvides(context, INetworkNewsMarker) noLongerProvides(context, IReferencesFolder) noLongerProvides(context, INetworkEventsMarker) elif marker == 'network_events': alsoProvides(context, INetworkEventsMarker) noLongerProvides(context, IReferencesFolder) noLongerProvides(context, INetworkNewsMarker) if marker: location = model_url(context, request, query= {'status_message': 'Marker changed'}) return HTTPFound(location=location) # Get a layout layout_provider = get_layout_provider(context, request) layout = layout_provider('community') if IReferencesFolder.providedBy(context): selected = 'reference_manual' elif INetworkNewsMarker.providedBy(context): selected = 'network_news' elif INetworkEventsMarker.providedBy(context): selected = 'network_events' else: selected = None return render_template_to_response( 'templates/advanced_folder.pt', api=api, actions=[], formfields=api.formfields, post_url=model_url(context, request, 'advanced.html'), layout=layout, fielderrors={}, selected=selected, )
def __call__(self): context = self.context request = self.request api = TemplateAPI(context, request, 'Add Page') community = find_community(context) layout_provider = get_layout_provider(context, request) if community is not None: layout = layout_provider('community') else: layout = layout_provider('generic') api.karl_client_data['text'] = dict( enable_imagedrawer_upload = True, ) return {'api': api, 'actions': (), 'layout': layout}
def show_newsitem_view(context, request): backto = { 'href': resource_url(context.__parent__, request), 'title': context.__parent__.title, } actions = [] if has_permission('edit', context, request): actions.append(('Edit', 'edit.html')) if has_permission('delete', context, request): actions.append(('Delete', 'delete.html')) if has_permission('administer', context, request): actions.append(('Advanced', 'advanced.html')) page_title = context.title api = TemplateAPI(context, request, page_title) previous, next = get_previous_next(context, request) # provide client data for rendering current tags in the tagbox client_json_data = dict(tagbox=get_tags_client_data(context, request), ) # Display photo photo = context.get('photo') if photo is not None: photo = { "url": thumb_url(photo, request, PHOTO_DISPLAY_SIZE), } # Get a layout layout_provider = get_layout_provider(context, request) layout = layout_provider('generic') ux2_layout = request.layout_manager.layout ux2_layout.section_style = None return render_to_response( 'templates/show_newsitem.pt', dict(api=api, actions=actions, attachments=fetch_attachments(context['attachments'], request), formfields=api.formfields, head_data=convert_to_script(client_json_data), backto=backto, previous=previous, next=next, old_layout=layout, photo=photo), request=request, )
def show_file_view(context, request): page_title = context.title api = TemplateAPI(context, request, page_title) client_json_data = dict( tagbox = get_tags_client_data(context, request), ) actions = [] if has_permission('create', context, request): actions.append( ('Edit', 'edit.html'), ) actions.append( ('Delete', 'delete.html'), ) # If we are in an attachments folder, the backto skips the # attachments folder and goes up to the grandparent from karl.models.interfaces import IAttachmentsFolder from repoze.bfg.traversal import find_interface attachments = find_interface(context, IAttachmentsFolder) if attachments is not None: up_to = context.__parent__.__parent__ else: up_to = context.__parent__ backto = { 'href': model_url(up_to, request), 'title': up_to.title, } fileinfo = getMultiAdapter((context, request), IFileInfo) previous, next = get_previous_next(context, request) # Get a layout layout_provider = get_layout_provider(context, request) layout = layout_provider('community') return render_template_to_response( 'templates/show_file.pt', api=api, actions=actions, fileinfo=fileinfo, head_data=convert_to_script(client_json_data), backto=backto, previous=previous, next=next, layout=layout, )
def reference_viewall_view(context, request): backto = { 'href': resource_url(context.__parent__, request), 'title': context.__parent__.title, } 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, request): actions.append(('Delete', 'delete.html')) if has_permission('administer', context, request): actions.append(('Advanced', 'advanced.html')) page_title = context.title api = TemplateAPI(context, request, page_title) # Get a layout layout_provider = get_layout_provider(context, request) old_layout = layout_provider('intranet') # provide client data for rendering current tags in the tagbox client_json_data = dict( tagbox = get_tags_client_data(context, request), ) previous, next = get_previous_next(context, request, 'view_all.html') intranet = find_intranet(context) if intranet is not None: ux2_layout = request.layout_manager.layout ux2_layout.section_style = "none" return render_to_response( 'templates/viewall_referencemanual.pt', dict(api=api, actions=actions, head_data=convert_to_script(client_json_data), tree=getTree(context, request, api), backto=backto, old_layout=old_layout, previous_entry=previous, next_entry=next), request=request, )
def show_newsitem_view(context, request): backto = { 'href': model_url(context.__parent__, request), 'title': context.__parent__.title, } actions = [] if has_permission('create', context, request): actions.append( ('Edit', 'edit.html') ) actions.append( ('Delete', 'delete.html'), ) page_title = context.title api = TemplateAPI(context, request, page_title) previous, next = get_previous_next(context, request) # provide client data for rendering current tags in the tagbox client_json_data = dict( tagbox = get_tags_client_data(context, request), ) # Display photo photo = context.get_photo() if photo is not None: photo = { "url": model_url(photo, request), } # Get a layout layout_provider = get_layout_provider(context, request) layout = layout_provider('generic') return render_template_to_response( 'templates/show_newsitem.pt', api=api, actions=actions, attachments=fetch_attachments(context['attachments'], request), formfields=api.formfields, head_data=convert_to_script(client_json_data), backto=backto, previous=previous, next=next, layout=layout, photo=photo, )
def __call__(self): _fix_website_validation_errors(self.request.form) api = TemplateAPI(self.context, self.request, self.page_title) layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider("generic") self.request.form.edge_div_class = "k3_admin_role" form_title = "Add User" return { "api": api, "actions": (), "layout": layout, "form_title": form_title, "include_blurb": False, "reactivate_user": self.reactivate_user, }
def __call__(self): _fix_website_validation_errors(self.request.form) api = TemplateAPI(self.context, self.request, self.page_title) if api.user_is_admin: return HTTPFound(location=resource_url(self.context, self.request, 'admin_edit_profile.html')) layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') if api.user_is_staff: self.request.form.edge_div_class = 'k3_staff_role' else: self.request.form.edge_div_class = 'k3_nonstaff_role' form_title = 'Edit Profile' return {'api':api, 'actions':(), 'layout':layout, 'form_title': form_title, 'include_blurb': True}
def month_communities_view(context, request): year = context.__parent__.__name__ month = context.__name__ api = TemplateAPI(context, request, '%s - %s community metrics' % (year, month)) layout_provider = get_layout_provider(context, request) layout = layout_provider() communities = context.communities['created'].values() communities.sort(key=lambda x: x['title']) def update_date_values(community_data): result = community_data.copy() result['created'] = format_date(result['created']) result['last_activity'] = format_date(result['last_activity']) return result communities = [update_date_values(c) for c in communities] if 'csv' in request.GET: def generate_csv_row(community): return [ community['title'], community['security_state'], community['created'], community['last_activity'], community['blogs'], community['comments'], community['wikis'], community['files'], community['events'], community['members'], community['moderators'], community['total'], ] return csv_response(request, '%s-%s-communities.csv' % (year, month), [ 'Community', 'Security', 'Created', 'Last Activity', 'Blog posts', 'Comments', 'Wiki pages', 'Files', 'Events', 'Members', 'Moderators', 'Total' ], communities, generate_csv_row) return dict(api=api, layout=layout, metricsmacros=_metrics_macros(), communities=communities, backto=backto_year(context, request))
def __call__(self): layout_provider = get_layout_provider(self.context, self.request) old_layout = layout_provider('community') api = TemplateAPI(self.context, self.request, 'Add Forum Topic') # ux1 api.karl_client_data['text'] = dict( enable_imagedrawer_upload = True, ) # ux2 layout = self.request.layout_manager.layout layout.section_style = "none" layout.head_data['panel_data']['tinymce'] = api.karl_client_data['text'] return { 'api': api, # deprecated UX1 'old_layout': old_layout, # deprecated UX1 'actions': []} # deprecated UX1
def __call__(self): _fix_website_validation_errors(self.request.form) api = TemplateAPI(self.context, self.request, self.page_title) layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') self.request.form.edge_div_class = 'k3_admin_role' form_title = 'Edit User and Profile Information' return { 'api': api, 'actions': (), 'layout': layout, 'form_title': form_title, 'include_blurb': False, 'admin_edit': True, 'is_active': self.is_active }
def __call__(self): context = self.context request = self.request page_title = 'Edit %s' % context.title api = TemplateAPI(context, self.request, page_title) # Get a layout layout_provider = get_layout_provider(context, request) old_layout = layout_provider('community') # ux1 api.karl_client_data['text'] = dict( enable_imagedrawer_upload = True, ) # ux2 layout = self.request.layout_manager.layout layout.head_data['panel_data']['tinymce'] = api.karl_client_data['text'] return {'api': api, 'actions': (), 'old_layout': old_layout}
def __call__(self): context = self.context request = self.request page_title = 'Edit %s' % context.title api = TemplateAPI(context, request, page_title) layout_provider = get_layout_provider(context, request) layout = layout_provider('intranet') intranet = find_intranet(self.context) if intranet is not None: ux2_layout = self.request.layout_manager.layout ux2_layout.section_style = "none" return { 'api': api, # deprecated UX1 'old_layout': layout, # deprecated UX1 'actions': []} # deprecated UX1
def __call__(self): layout_provider = get_layout_provider(self.context, self.request) old_layout = layout_provider('generic') # ux1 self.api.karl_client_data['text'] = dict( enable_imagedrawer_upload=True, ) # ux2 layout = self.request.layout_manager.layout layout.section_style = None layout.head_data['panel_data']['tinymce'] = self.api.karl_client_data[ 'text'] return { 'api': self.api, # deprecated UX1 'old_layout': old_layout, # deprecated UX1 'actions': [] } # deprecated UX1
def year_contenttype_view(context, request): year = context.__name__ api = TemplateAPI(context, request, '%s content type metrics' % year) layout_provider = get_layout_provider(context, request) layout = layout_provider() months = [] contenttypes = {} # pull the data into a dict structure for month_num, month in sorted(context.items()): if IMetricsMonthFolder.providedBy(month): months.append(month_name(year, month_num)) for typename, typedata in month.contenttypes.items(): contenttypes.setdefault(typename, {})[month_num] = typedata # assemble the data to make it easy for the template to consume it contenttypes_result = [] contenttypes_list = sorted(contenttypes.items(), key=lambda x: x[0]) for contenttype_name, contenttype_data in contenttypes_list: months_result = [] months_list = sorted(contenttype_data.items(), key=lambda x: int(x[0])) for month_num, month_data in months_list: months_result.append(month_data) contenttypes_result.append( dict(name=contenttype_name, months=months_result)) if 'csv' in request.GET: def generate_csv_row(contenttype): return ([contenttype['name'].title()] + [x['created'] for x in contenttype['months']]) header_row = ['Content Type'] + [month.title() for month in months] return csv_response(request, '%s-contenttype.csv' % year, header_row, contenttypes_result, generate_csv_row) return dict( api=api, layout=layout, metricsmacros=_metrics_macros(), backto=backto_metrics(context, request), months=months, year=year, contenttypes=contenttypes_result, )
def show_page_view(context, request): backto = { 'href': resource_url(context.__parent__, request), 'title': context.__parent__.title, } actions = [] if has_permission('edit', context, request): actions.append(('Edit', 'edit.html')) if has_permission('delete', context, request): actions.append(('Delete', 'delete.html')) if has_permission('administer', context, request): actions.append(('Advanced', 'advanced.html')) page_title = context.title api = TemplateAPI(context, request, page_title) previous, next = get_previous_next(context, request) # provide client data for rendering current tags in the tagbox client_json_data = dict(tagbox=get_tags_client_data(context, request), ) # Get a layout community = find_community(context) layout_provider = get_layout_provider(context, request) if community is not None: layout = layout_provider('community') else: layout = layout_provider('generic') ux2_layout = request.layout_manager.layout ux2_layout.section_style = "none" return render_to_response( 'templates/show_page.pt', dict(api=api, actions=actions, attachments=fetch_attachments(context['attachments'], request), formfields=api.formfields, head_data=convert_to_script(client_json_data), backto=backto, previous_entry=previous, next_entry=next, old_layout=layout), request=request, )
def year_view(context, request): year = context.__name__ api = TemplateAPI(context, request, 'Metrics for %s' % year) layout_provider = get_layout_provider(context, request) layout = layout_provider() months_data = [] for month in sorted(context.keys()): months_data.append(dict(num=month, name=month_name(year, month))) return dict( api=api, layout=layout, metricsmacros=_metrics_macros(), months_data=months_data, backto=backto_metrics(context, request), )
def __call__(self): _fix_website_validation_errors(self.request.form) page_title = self.request.layout_manager.layout.page_title api = TemplateAPI(self.context, self.request, page_title) if api.user_is_admin: return HTTPFound(location=resource_url(self.context, self.request, 'admin_edit_profile.html')) layout_provider = get_layout_provider(self.context, self.request) layout = layout_provider('generic') if api.user_is_staff: self.request.form.edge_div_class = 'k3_staff_role' else: self.request.form.edge_div_class = 'k3_nonstaff_role' form_title = 'Edit Profile' same_user = authenticated_userid(self.request) == self.context.__name__ return {'api':api, 'actions':(), 'old_layout':layout, 'same_user': same_user, 'form_title': form_title, 'include_blurb': True}