##// END OF EJS Templates
Enforce privacy accepts a number of days before now
neko259 -
r1864:c0d80fa2 default
parent child Browse files
Show More
@@ -1,5 +1,9 b''
1 from datetime import datetime, timedelta, date
2 from datetime import time as dtime
3
1 from django.core.management import BaseCommand
4 from django.core.management import BaseCommand
2 from django.db import transaction
5 from django.db import transaction
6 from django.utils import timezone
3
7
4 from boards.models import Post
8 from boards.models import Post
5 from boards.models.post.manager import NO_IP
9 from boards.models.post.manager import NO_IP
@@ -8,8 +12,23 b' from boards.models.post.manager import N'
8
12
9
13
10 class Command(BaseCommand):
14 class Command(BaseCommand):
11 help = 'Removes user and IP data from all posts'
15 help = 'Removes user and IP data from posts'
16
17 def add_arguments(self, parser):
18 parser.add_argument('--days-before', type=int,
19 help='Clean posts only before the number of days before today.')
12
20
13 @transaction.atomic
21 @transaction.atomic
14 def handle(self, *args, **options):
22 def handle(self, *args, **options):
15 Post.objects.all().update(poster_ip=NO_IP) No newline at end of file
23 days_before = options.get('days_before')
24
25 if days_before:
26 day_end = date.today() - timedelta(1)
27
28 day_time_end = timezone.make_aware(datetime.combine(
29 day_end, dtime()), timezone.get_current_timezone())
30 posts = Post.objects.filter(pub_time__lte=day_time_end)
31 else:
32 posts = Post.objects.all()
33 posts.update(poster_ip=NO_IP)
34
@@ -134,7 +134,6 b' class PostManager(models.Manager):'
134 pub_time__lte=day_time_end,
134 pub_time__lte=day_time_end,
135 pub_time__gte=day_time_start).count()
135 pub_time__gte=day_time_start).count()
136
136
137
138 @transaction.atomic
137 @transaction.atomic
139 def import_post(self, title: str, text: str, pub_time: str, global_id,
138 def import_post(self, title: str, text: str, pub_time: str, global_id,
140 opening_post=None, tags=list(), files=list(),
139 opening_post=None, tags=list(), files=list(),
General Comments 0
You need to be logged in to leave comments. Login now