class DemoView(HomeView): crumbs = ({'url': 'admin:demo1', 'name': 'Demo boxes'}, ) grid = Grid( Row(Column(MenuBox())), Row( Column(Box( title='Demo paragraph', widgets=[ Widget(html_id='paragraph_widget', content='This is an example of paragraph render.', template='dashboard/paragraph.html') ]), Box(title='Demo list', widgets=[ Widget(html_id='list_widget', content=[ 'This is', 'an example of', 'list render.' ], template='dashboard/list.html') ]), width=6), Column(Box(title='Demo table', widgets=[ Widget(html_id='table_widget', content=[['This', 'is', 'an example'], ['of', 'table', 'render']], template='dashboard/table.html') ]), width=6)))
class MachineView(HomeView): crumbs = ({'url': 'admin:machine', 'name': 'Machine'}, ) grid = Grid( Row(Column(MenuBox())), Row( Column(MachineInfoBox(), width=6), Column(MachineUsageBox(), width=6)))
class UserView(HomeView): crumbs = ({'url': 'admin:users', 'name': 'Users'}, ) grid = Grid( Row( Column(MenuBox())), Row( Column(RegistrationsBox(), width=6), Column(LoggedInUsersBox(), width=6)))
class LogsStatusCodesByDate(LogsMenu): """View for status codes by date.""" crumbs = ({ 'name': _('Status codes by date'), 'url': 'admin:logs_status_code_by_date' }, ) grid = Grid(Row(Column(BoxLogsLinks())), Row(Column(BoxLogsStatusCodesByDate())))
class LogsMostVisitedPages(LogsMenu): """View for most visited pages.""" crumbs = ({ 'name': _('Most visited pages'), 'url': 'admin:logs_most_visited_pages' }, ) grid = Grid( Row(Column(BoxLogsLinks(), width=5), Column(BoxLogsMostVisitedPagesLegend(), width=7)), Row(Column(BoxLogsMostVisitedPages())))
class DashboardMainView(DashboardView): template_name = 'main.html' crumbs = ({'url': 'admin:index', 'name': _("Dashboard")},) grid = Grid( Row( Column(boxes.CaseStatePieBox(), width=4), Column(boxes.CaseTypeLineBox(), width=4), Column(boxes.CaseTypePieBox(), width=4), ), Row( Column(boxes.CaseContentWordCloudBox(), width=4), Column(boxes.CaseRegionLineBox(), width=4), Column(boxes.CaseRegionPieBox(), width=4), ), )
class Privileges(Index): """Menu for privileges.""" context = { 'role_types': [{ 'verbose': app_settings.mapping.get_class(t)._meta.verbose_name, 'slug': t } for t in app_settings.mapping.role_types()], 'resource_types': [{ 'verbose': app_settings.mapping.get_class(t)._meta.verbose_name, 'slug': t } for t in app_settings.mapping.resource_types()] } title = _('Privileges Matrix - Cerberus AC') crumbs = ({ 'name': _('Privileges Matrix'), 'url': 'admin:cerberus:privileges' }, ) grid = Grid( Row( Column( Box(title=_('Privileges Matrix'), template='cerberus_ac/privileges.html', context=context))))
class HomeView(DashboardView): """Main view. Parent class and entry point for other views.""" template_name = 'meerkat/main.html' crumbs = ({'name': _('Home'), 'url': 'admin:index'}, ) # TODO: find a way to add menu boxes for each meerkat plugin grid = Grid(Row(Column()))
def get(self, request, *args, **kwargs): user_class = app_settings.mapping.user_classes()[0] user = user_class.objects.get(id=kwargs['member_id']) self.grid = Grid( Row( Column( Box(template='cerberus_ac/member_info.html', context={'member': user})))) return super(MemberInfo, self).get(request, *args, **kwargs)
def get(self, request, *args, **kwargs): member_class = app_settings.mapping.user_classes()[0] members = member_class.objects.all() # members = get_paginated_data( # members, request.GET.get('page_user_list'), 50) self.grid = Grid( Row( Column( Box(title=_('Member list'), template='cerberus_ac/member_list.html', context={'members': members})))) return super(MemberList, self).get(request, *args, **kwargs)
def get(self, request, *args, **kwargs): role_type = kwargs.pop('role_type') resource_type = kwargs.pop('resource_type') role_class = app_settings.mapping.get_class(role_type) resource_class = app_settings.mapping.get_class(resource_type) role_instances = role_class.objects.all() resource_instances = resource_class.objects.all() self.grid = Grid( Row( Column( Box(template='cerberus_ac/view_privileges.html', context={ 'roles': role_instances, 'resources': resource_instances })))) return super(ViewPrivileges, self).get(request, *args, **kwargs)
class Index(DashboardView): """Cerberus menu.""" title = _('Index - Cerberus AC') crumbs = ( { 'name': _('Home'), 'url': 'admin:index' }, { 'name': _('Cerberus AC'), 'url': 'admin:cerberus:index' }, ) grid = Grid( Row( Column( Box(title='Cerberus Access Control', template='cerberus_ac/index.html'))))
def get(self, request, *args, **kwargs): role_type = kwargs.pop('role_type') resource_type = kwargs.pop('resource_type') role_class = app_settings.mapping.get_class(role_type) resource_class = app_settings.mapping.get_class(resource_type) role_instances = role_class.objects.all() resource_instances = resource_class.objects.all() self.grid = Grid( Row( Column( Box(title=_('Edit role privileges between %s and %s') % (role_class._meta.verbose_name_plural, resource_class._meta.verbose_name_plural), template='cerberus_ac/edit_privileges.html', context={ 'roles': role_instances, 'resources': resource_instances, 'role_type': role_type, 'resource_type': resource_type })))) return super(EditPrivileges, self).get(request, *args, **kwargs)
def get(self, request, *args, **kwargs): # link # {"source": 3, "target": 11} # node # {"size": 10, "score": 0, "id": "security", "type": "circle"} roles = [] links = [] count = {} for tuple4 in list( RoleHierarchy.objects.values_list('role_type_a', 'role_id_a', 'role_type_b', 'role_id_b')): role_a = ( '%s %s' % (tuple4[0], tuple4[1])) if tuple4[1] else tuple4[0] # noqa role_b = ( ('%s %s' % (tuple4[2], tuple4[3])) if tuple4[3] else tuple4[2] ) # noqa if role_a not in count: count[role_a] = 1 roles.append(role_a) else: count[role_a] += 1 if role_b not in count: count[role_b] = 1 roles.append(role_b) else: count[role_b] += 1 # I think we can add scores on links links.append({ 'source': roles.index(role_b), 'target': roles.index(role_a) }) # possible types: circle, square, triangle-up/down, diamond, cross data = { 'directed': True, 'multigraph': False, 'links': links, 'nodes': [ { 'size': min(count[r], 50), 'score': min(count[r] / 100, 1), 'id': r if ' ' not in r else str( app_settings.mapping.get_instance(*r.split(' '))), 'type': { # FIXME: put this outside of cerberus: it's genida related 'member': 'circle', 'relative': 'square', 'cohort': 'diamond', 'gene': 'cross', 'copy_number_variant': 'cross', }.get(r.split(' ')[0], 'triangle-down') } for r in roles ] } self.grid = Grid( Row( Column( Box(title='Role Hierarchy Graph', template='cerberus_ac/view_role_hierarchy.html', context=json.dumps(data))))) return super(ViewRoleHierarchy, self).get(request, *args, **kwargs)
class LogsStatusCodes(LogsMenu): """View for status codes.""" crumbs = ({'name': _('Status codes'), 'url': 'admin:logs_status_codes'}, ) grid = Grid(Row(Column(BoxLogsLinks(), BoxLogsStatusCodes())))
class RandomCurveView(DemoView): crumbs = ({'url': 'admin:curve', 'name': 'Real-time random curve'}, ) grid = Grid(Row(Column(MenuBox())), Row(Column(Box(widgets=[realtime(RandomCurveWidget())]))))
class HomeView(DashboardView): template_name = 'dashboard/main.html' crumbs = ({'url': 'admin:index', 'name': 'Home'}, ) grid = Grid(Row(Column(MenuBox())))
class ArchanView(HomeView): crumbs = ({'name': 'Archan', 'url': 'admin:dashboard:archan'}, ) grid = Grid(Row(Column(BoxArchan())))
class LogsMenu(HomeView): """View for logs menu.""" crumbs = ({'name': 'Logs analysis', 'url': 'admin:logs'}, ) grid = Grid(Row(Column(BoxLogsLinks())))