def index(request): # Get the current user's Business Units user = request.user # Count the number of users. If there is only one, they need to be made a GA if User.objects.count() == 1: # The first user created by syncdb won't have a profile. If there isn't # one, make sure they get one. try: profile = UserProfile.objects.get(user=user) except UserProfile.DoesNotExist: profile = UserProfile(user=user) profile.level = ProfileLevel.global_admin profile.save() user_is_ga = is_global_admin(user) if not user_is_ga: # user has many BU's display them all in a friendly manner if user.businessunit_set.count() == 0: c = { 'user': request.user, } return render(request, 'server/no_access.html', c) if user.businessunit_set.count() == 1: # user only has one BU, redirect to it return redirect('bu_dashboard', bu_id=user.businessunit_set.all()[0].id) # Load in the default plugins if needed utils.load_default_plugins() plugins = sal.plugin.PluginManager().get_all_plugins() reports = utils.get_report_names(plugins) output = utils.get_plugin_placeholder_markup(plugins) # If the user is GA level, and hasn't decided on a data sending # choice, template will reflect this. data_choice = False if ( user_is_ga and utils.get_setting('send_data') is None) else True # get the user level - if they're a global admin, show all of the # machines. If not, show only the machines they have access to if user_is_ga: business_units = BusinessUnit.objects.all() else: business_units = user.businessunit_set.all() context = { 'user': request.user, 'business_units': business_units, 'output': output, 'data_setting_decided': data_choice, 'reports': reports } context.update(utils.check_version()) return render(request, 'server/index.html', context)
def index(request): # Get the current user's Business Units user = request.user # Count the number of users. If there is only one, they need to be made a GA if User.objects.count() == 1: # The first user created by syncdb won't have a profile. If there isn't # one, make sure they get one. try: profile = UserProfile.objects.get(user=user) except UserProfile.DoesNotExist: profile = UserProfile(user=user) profile.level = ProfileLevel.global_admin profile.save() user_is_ga = is_global_admin(user) if not user_is_ga: # user has many BU's display them all in a friendly manner if user.businessunit_set.count() == 0: c = {'user': request.user, } return render(request, 'server/no_access.html', c) if user.businessunit_set.count() == 1: # user only has one BU, redirect to it return redirect('bu_dashboard', bu_id=user.businessunit_set.all()[0].id) # Load in the default plugins if needed utils.load_default_plugins() plugins = sal.plugin.PluginManager().get_all_plugins() reports = utils.get_report_names(plugins) output = utils.get_plugin_placeholder_markup(plugins) # If the user is GA level, and hasn't decided on a data sending # choice, template will reflect this. data_choice = False if (user_is_ga and utils.get_setting('send_data') is None) else True # get the user level - if they're a global admin, show all of the # machines. If not, show only the machines they have access to if user_is_ga: business_units = BusinessUnit.objects.all() else: business_units = user.businessunit_set.all() context = { 'user': request.user, 'business_units': business_units, 'output': output, 'data_setting_decided': data_choice, 'reports': reports} context.update(utils.check_version()) return render(request, 'server/index.html', context)
def group_dashboard(request, **kwargs): machine_group = kwargs['instance'] machines = machine_group.machine_set.filter(deployed=True) # noqa: F841 plugins = sal.plugin.PluginManager().get_all_plugins() output = utils.get_plugin_placeholder_markup( plugins, group_type='machine_group', group_id=machine_group.id) reports = utils.get_report_names(plugins) context = { 'user': request.user, 'machine_group': machine_group, 'business_unit': kwargs['business_unit'], 'output': output, 'request': request, 'reports': reports} return render(request, 'server/group_dashboard.html', context)
def group_dashboard(request, **kwargs): machine_group = kwargs['instance'] machines = machine_group.machine_set.filter(deployed=True) # noqa: F841 output = utils.get_plugin_placeholder_markup(group_type='machine_group', group_id=machine_group.id) reports = utils.get_report_names() context = { 'user': request.user, 'machine_group': machine_group, 'business_unit': kwargs['business_unit'], 'output': output, 'request': request, 'reports': reports } return render(request, 'server/group_dashboard.html', context)
def bu_dashboard(request, **kwargs): business_unit = kwargs['business_unit'] machine_groups = business_unit.machinegroup_set.all() # Load in the default plugins if needed utils.load_default_plugins() reports = utils.get_report_names() output = utils.get_plugin_placeholder_markup(group_type='business_unit', group_id=business_unit.id) context = { 'user': request.user, 'machine_groups': machine_groups, 'business_unit': business_unit, 'output': output, 'reports': reports } return render(request, 'server/bu_dashboard.html', context)
def bu_dashboard(request, **kwargs): business_unit = kwargs['business_unit'] machine_groups = business_unit.machinegroup_set.all() # Load in the default plugins if needed utils.load_default_plugins() plugins = sal.plugin.PluginManager().get_all_plugins() reports = utils.get_report_names(plugins) output = utils.get_plugin_placeholder_markup( plugins, group_type='business_unit', group_id=business_unit.id) context = { 'user': request.user, 'machine_groups': machine_groups, 'business_unit': business_unit, 'output': output, 'reports': reports} return render(request, 'server/bu_dashboard.html', context)