예제 #1
0
파일: views.py 프로젝트: cucy/2017
    def get_queryset(self):
        date_now = timezone.localtime(timezone.now())
        date_to_default = date_now.strftime(self.date_format)
        date_from_default = (date_now - timezone.timedelta(7)) \
            .strftime(self.date_format)
        self.command = self.request.GET.get('command', '')
        self.username = self.request.GET.get('username')
        self.ip = self.request.GET.get('ip')
        self.system_user = self.request.GET.get('system_user')
        self.date_from_s = \
            self.request.GET.get('date_from', date_from_default)
        self.date_to_s = \
            self.request.GET.get('date_to', date_to_default)

        filter_kwargs = {}
        if self.date_from_s:
            date_from = datetime.strptime(self.date_from_s, self.date_format)\
                .replace(tzinfo=timezone.get_current_timezone())
            # date_from_utc = date_from.astimezone(pytz.utc)
            date_from_ts = time.mktime(date_from.timetuple())
            filter_kwargs['date_from_ts'] = date_from_ts
        if self.date_to_s:
            date_to = datetime.strptime(
                self.date_to_s + ' 23:59:59', '%m/%d/%Y %H:%M:%S')\
                .replace(tzinfo=timezone.get_current_timezone())
            date_to_ts = time.mktime(date_to.timetuple())
            filter_kwargs['date_to_ts'] = date_to_ts
        if self.username:
            filter_kwargs['user'] = self.username
        if self.ip:
            filter_kwargs['asset'] = self.ip
        if self.system_user:
            filter_kwargs['system_user'] = self.system_user
        if self.command:
            filter_kwargs['command'] = self.command
        self.queryset = command_store.filter(**filter_kwargs).order_by(
            *self.ordering)
        return self.queryset
예제 #2
0
 def commands(self):
     from audits.backends import command_store
     return command_store.filter(proxy_log_id=self.id)
예제 #3
0
파일: views.py 프로젝트: cucy/2017
 def get_queryset(self):
     return list(command_store.filter(proxy_log_id=self.object.id))
예제 #4
0
def proxy_log_commands(log_id):
    return command_store.filter(proxy_log_id=log_id)