Ejemplo n.º 1
0
    def handle(self, filename, **options):
        domain = options["domain"]
        user = options["user"]
        display_superuser = options["display_superuser"]

        dimagi_username = ""
        if not display_superuser:
            dimagi_username = "******"

        if not domain and not user:
            raise CommandError("Please provide one of 'domain' or 'user'")

        if domain:
            domain_object = Domain.get_by_name(domain)
            if not domain_object:
                raise CommandError("Domain not found")

        users, super_users = get_users_to_export(user, domain)

        with open(filename, 'wb') as csvfile:
            writer = csv.writer(csvfile)
            writer.writerow(['Date', 'User', 'Domain', 'IP Address', 'Request Path'])
            for user in users:
                write_log_events(
                    writer, user, domain,
                    start_date=options['start'], end_date=options['end']
                )

            for user in super_users:
                write_log_events(
                    writer, user, domain,
                    override_user=dimagi_username,
                    start_date=options['start'], end_date=options['end']
                )
Ejemplo n.º 2
0
    def handle(self, filename, **options):
        domain = options["domain"]
        user = options["user"]
        display_superuser = options["display_superuser"]

        dimagi_username = ""
        if not display_superuser:
            dimagi_username = "******"

        if not domain and not user:
            raise CommandError("Please provide one of 'domain' or 'user'")

        if domain:
            domain_object = Domain.get_by_name(domain)
            if not domain_object:
                raise CommandError("Domain not found")

        users, super_users = get_users_to_export(user, domain)

        with open(filename, 'wb') as csvfile:
            writer = csv.writer(csvfile)
            writer.writerow(['Date', 'User', 'Domain', 'IP Address', 'Request Path'])
            for user in users:
                write_log_events(
                    writer, user, domain,
                    start_date=options['start'], end_date=options['end']
                )

            for user in super_users:
                write_log_events(
                    writer, user, domain,
                    override_user=dimagi_username,
                    start_date=options['start'], end_date=options['end']
                )