def bu_dashboard(request, bu_id): user = request.user user_level = user.userprofile.level business_unit = get_object_or_404(BusinessUnit, pk=bu_id) bu = business_unit config_installed = 'config' in settings.INSTALLED_APPS if business_unit not in user.businessunit_set.all() and user_level != 'GA': print 'not letting you in ' + user_level return redirect(index) # Get the groups within the Business Unit machine_groups = business_unit.machinegroup_set.all() if user_level == 'GA' or user_level == 'RW': is_editor = True else: is_editor = False machines = utils.getBUmachines(bu_id) now = datetime.now() hour_ago = now - timedelta(hours=1) today = date.today() week_ago = today - timedelta(days=7) month_ago = today - timedelta(days=30) three_months_ago = today - timedelta(days=90) # Build the manager manager = PluginManager() # Tell it the default place(s) where to find plugins manager.setPluginPlaces([ settings.PLUGIN_DIR, os.path.join(settings.PROJECT_DIR, 'server/plugins') ]) # Load all plugins manager.collectPlugins() output = [] # Loop round the plugins and print their names. for plugin in manager.getAllPlugins(): data = {} data['name'] = plugin.name (data['html'], data['width']) = plugin.plugin_object.show_widget( 'bu_dashboard', machines, bu.id) output.append(data) output = utils.orderPluginOutput(output, 'bu_dashboard', bu.id) c = { 'user': request.user, 'machine_groups': machine_groups, 'is_editor': is_editor, 'business_unit': business_unit, 'user_level': user_level, 'output': output, 'config_installed': config_installed } return render_to_response('server/bu_dashboard.html', c, context_instance=RequestContext(request))
def bu_dashboard(request, bu_id): user = request.user user_level = user.userprofile.level business_unit = get_object_or_404(BusinessUnit, pk=bu_id) bu = business_unit if business_unit not in user.businessunit_set.all() and user_level != "GA": print "not letting you in " + user_level return redirect(index) # Get the groups within the Business Unit machine_groups = business_unit.machinegroup_set.all() if user_level == "GA" or user_level == "RW": is_editor = True else: is_editor = False machines = utils.getBUmachines(bu_id) now = datetime.now() hour_ago = now - timedelta(hours=1) today = date.today() week_ago = today - timedelta(days=7) month_ago = today - timedelta(days=30) three_months_ago = today - timedelta(days=90) # Build the manager manager = PluginManager() # Tell it the default place(s) where to find plugins manager.setPluginPlaces([settings.PLUGIN_DIR, os.path.join(settings.PROJECT_DIR, "server/plugins")]) # Load all plugins manager.collectPlugins() output = [] # Loop round the plugins and print their names. for plugin in manager.getAllPlugins(): data = {} data["name"] = plugin.name (data["html"], data["width"]) = plugin.plugin_object.show_widget("bu_dashboard", machines, bu.id) output.append(data) output = utils.orderPluginOutput(output, "bu_dashboard", bu.id) c = { "user": request.user, "machine_groups": machine_groups, "is_editor": is_editor, "business_unit": business_unit, "user_level": user_level, "output": output, } return render_to_response("server/bu_dashboard.html", c, context_instance=RequestContext(request))
def bu_dashboard(request, bu_id): user = request.user user_level = user.userprofile.level business_unit = get_object_or_404(BusinessUnit, pk=bu_id) bu = business_unit config_installed = 'config' in settings.INSTALLED_APPS if business_unit not in user.businessunit_set.all() and user_level != 'GA': print 'not letting you in ' + user_level return redirect(index) # Get the groups within the Business Unit machine_groups = business_unit.machinegroup_set.all() if user_level == 'GA' or user_level == 'RW': is_editor = True else: is_editor = False machines = utils.getBUmachines(bu_id) now = datetime.now() hour_ago = now - timedelta(hours=1) today = date.today() week_ago = today - timedelta(days=7) month_ago = today - timedelta(days=30) three_months_ago = today - timedelta(days=90) # Build the manager manager = PluginManager() # Tell it the default place(s) where to find plugins manager.setPluginPlaces([settings.PLUGIN_DIR, os.path.join(settings.PROJECT_DIR, 'server/plugins')]) # Load all plugins manager.collectPlugins() output = [] # Get all the enabled plugins enabled_plugins = Plugin.objects.all().order_by('order') for enabled_plugin in enabled_plugins: # Loop round the plugins and print their names. for plugin in manager.getAllPlugins(): if plugin.name == enabled_plugin.name: data = {} data['name'] = plugin.name (data['html'], data['width']) = plugin.plugin_object.show_widget('bu_dashboard', machines, bu.id) output.append(data) break output = utils.orderPluginOutput(output, 'bu_dashboard', bu.id) c = {'user': request.user, 'machine_groups': machine_groups, 'is_editor': is_editor, 'business_unit': business_unit, 'user_level': user_level, 'output':output, 'config_installed':config_installed } return render_to_response('server/bu_dashboard.html', c, context_instance=RequestContext(request))