def get_context_data(self, **kwargs): """ Preparing the Context Variable required in the template rendering. """ context = super(CommandList, self).get_context_data(**kwargs) datatable_headers = [ { 'mData': 'name', 'sTitle': 'Name', 'sWidth': 'auto', }, { 'mData': 'alias', 'sTitle': 'Alias', 'sWidth': 'auto', }, { 'mData': 'command_line', 'sTitle': 'Command Line', 'sWidth': 'auto', }, ] if in_group(self.request.user, 'admin'): datatable_headers.append({ 'mData': 'actions', 'sTitle': 'Actions', 'sWidth': '5%', 'bSortable': False }) context['datatable_headers'] = json.dumps(datatable_headers) return context
def dispatch(self, request, *args, **kwargs): has_perm = True try: if request.user.is_superuser: return super(PermissionsRequiredMixin, self).dispatch(request, *args, **kwargs) if type(self.required_permissions) != type(str()): perm_codename = self.required_permissions[0].split('.')[1] else: perm_codename = self.required_permissions.split('.')[1] has_permission = in_group(user=request.user, perm_codename=perm_codename) if has_permission: return super(PermissionsRequiredMixin, self).dispatch(request, *args, **kwargs) else: has_perm = False # if not request.user.has_perms(self.required_permissions): # has_perm = False # raise PermissionDenied raise PermissionDenied except Exception, e: if not has_perm: raise PermissionDenied pass
def get_context_data(self, **kwargs): """ Preparing the Context Variable required in the template rendering. """ context = super(MachineList, self).get_context_data(**kwargs) datatable_headers = [{ 'mData': 'name', 'sTitle': 'Name', 'sWidth': 'auto' }, { 'mData': 'alias', 'sTitle': 'Alias', 'sWidth': 'auto', 'sClass': 'hidden-xs' }, { 'mData': 'machine_ip', 'sTitle': 'Machine IP', 'sWidth': 'auto' }, { 'mData': 'agent_port', 'sTitle': 'Agent Port', 'sWidth': 'auto', 'sClass': 'hidden-xs' }, { 'mData': 'description', 'sTitle': 'Description', 'sWidth': 'auto' }] if in_group(self.request.user, 'admin'): datatable_headers.append({ 'mData': 'actions', 'sTitle': 'Actions', 'sWidth': '5%', 'bSortable': False }) context['datatable_headers'] = json.dumps(datatable_headers) return context
def get_context_data(self, **kwargs): """ Preparing the Context Variable required in the template rendering. """ context = super(LevelList, self).get_context_data(**kwargs) datatable_headers = [ { 'mData': 'organization__alias', 'sTitle': 'Organization', 'sWidth': 'auto', 'sClass': 'hidden-xs' }, { 'mData': 'name', 'sTitle': 'Level', 'sWidth': 'auto', }, { 'mData': 'emails', 'sTitle': 'Email', 'sWidth': 'auto', 'sClass': 'hidden-xs' }, { 'mData': 'phones', 'sTitle': 'SMS', 'sWidth': '10%', }, { 'mData': 'service__alias', 'sTitle': 'Service', 'sWidth': 'auto', }, { 'mData': 'device_type__alias', 'sTitle': 'Device Type', 'sWidth': '10%', }, { 'mData': 'service_data_source__alias', 'sTitle': 'Service Data Source', 'sWidth': '10%', }, { 'mData': 'alarm_age', 'sTitle': 'Escalation Age', 'sWidth': '10%', }, ] # if the user role is Admin or operator or superuser then the action column will appear on the datatable is_edit_perm = in_group( self.request.user, 'admin', 'change_escalationlevel') or in_group( self.request.user, 'operator', 'change_escalationlevel') is_delete_perm = in_group( self.request.user, 'admin', 'delete_escalationlevel') or in_group( self.request.user, 'operator', 'delete_escalationlevel') if is_edit_perm or is_delete_perm: datatable_headers.append({ 'mData': 'actions', 'sTitle': 'Actions', 'sWidth': '10%', 'bSortable': False }) context['datatable_headers'] = json.dumps(datatable_headers) return context
def get_context_data(self, **kwargs): """ Preparing the Context Variable required in the template rendering. """ context = super(DownloaderCompleteHeaders, self).get_context_data(**kwargs) datatable_headers = [ { 'mData': 'file', 'sTitle': 'File', 'sWidth': 'auto', 'bSortable': False }, { 'mData': 'file_name', 'sTitle': 'Filename', 'sWidth': 'auto' }, { 'mData': 'file_type', 'sTitle': 'File Type', 'sWidth': 'auto' }, { 'mData': 'rows_view', 'sTitle': 'Module', 'sWidth': 'auto', 'bSortable': False }, { 'mData': 'status', 'sTitle': 'Status', 'sWidth': 'auto' }, { 'mData': 'description', 'sTitle': 'Description', 'sWidth': 'auto' }, { 'mData': 'downloaded_by', 'sTitle': 'Downloaded By', 'sWidth': 'auto' }, { 'mData': 'requested_on', 'sTitle': 'Requested On', 'sWidth': 'auto' }, { 'mData': 'request_completion_on', 'sTitle': 'Request Completion Date', 'sWidth': 'auto' }, ] if in_group(self.request.user, 'admin'): datatable_headers.append({ 'mData': 'actions', 'sTitle': 'Actions', 'sWidth': '5%', 'bSortable': False }) context['datatable_headers'] = json.dumps(datatable_headers) return context
def get_context_data(self, **kwargs): """ Preparing the Context Variable required in the template rendering. """ # get download name download_name = self.request.GET.get('download_name', None) # get download type download_type = self.request.GET.get('download_type', None) # get extra parameters params = self.request.GET.get('params', None) context = super(DownloaderHeaders, self).get_context_data(**kwargs) datatable_headers = [ { 'mData': 'file_path', 'sTitle': 'File', 'sWidth': 'auto' }, { 'mData': 'file_type', 'sTitle': 'File Type', 'sWidth': 'auto' }, { 'mData': 'status', 'sTitle': 'Status', 'sWidth': 'auto' }, { 'mData': 'description', 'sTitle': 'Description', 'sWidth': 'auto' }, { 'mData': 'downloaded_by', 'sTitle': 'Downloaded By', 'sWidth': 'auto' }, { 'mData': 'requested_on', 'sTitle': 'Requested On', 'sWidth': 'auto' }, { 'mData': 'request_completion_on', 'sTitle': 'Request Completion Date', 'sWidth': 'auto' }, ] if in_group(self.request.user, 'admin'): datatable_headers.append({ 'mData': 'actions', 'sTitle': 'Actions', 'sWidth': '5%', 'bSortable': False }) context['datatable_headers'] = json.dumps(datatable_headers) context['download_name'] = download_name context['download_type'] = download_type context['params'] = params return context