##// END OF EJS Templates
Use path resolver instead of url where possible
Use path resolver instead of url where possible

File last commit:

r1864:c0d80fa2 default
r1987:c91779e9 default
Show More
enforce_privacy.py
34 lines | 1.0 KiB | text/x-python | PythonLexer
neko259
Enforce privacy accepts a number of days before now
r1864 from datetime import datetime, timedelta, date
from datetime import time as dtime
neko259
Added command to remove user and poster ip from all posts
r727 from django.core.management import BaseCommand
from django.db import transaction
neko259
Enforce privacy accepts a number of days before now
r1864 from django.utils import timezone
neko259
Added command to remove user and poster ip from all posts
r727
from boards.models import Post
neko259
Split post module into post and manager
r1234 from boards.models.post.manager import NO_IP
neko259
Added command to remove user and poster ip from all posts
r727
__author__ = 'neko259'
class Command(BaseCommand):
neko259
Enforce privacy accepts a number of days before now
r1864 help = 'Removes user and IP data from posts'
def add_arguments(self, parser):
parser.add_argument('--days-before', type=int,
help='Clean posts only before the number of days before today.')
neko259
Added command to remove user and poster ip from all posts
r727
@transaction.atomic
def handle(self, *args, **options):
neko259
Enforce privacy accepts a number of days before now
r1864 days_before = options.get('days_before')
if days_before:
day_end = date.today() - timedelta(1)
day_time_end = timezone.make_aware(datetime.combine(
day_end, dtime()), timezone.get_current_timezone())
posts = Post.objects.filter(pub_time__lte=day_time_end)
else:
posts = Post.objects.all()
posts.update(poster_ip=NO_IP)