Project

General

Profile

« Previous | Next » 

Revision 8c92ff14

Added by Benjamin Dauvergne over 11 years ago

agenda: remove createacts command, it is no more needed

View differences:

calebasse/agenda/management/commands/createacts.py
1
from datetime import date, timedelta, datetime, time
2
from django.core.management.base import BaseCommand
3
from django.db.transaction import commit_on_success
4
from django.db.models import Q
5
from ... import models
6
from ....actes.models import Act
7

  
8
class Command(BaseCommand):
9
    help = 'Create acts for events in the following days'
10

  
11
    @commit_on_success
12
    def handle(self, *args, **options):
13
        today = date.today()
14
        print 'on', today
15
        qs = models.EventWithAct.objects.filter(
16
                Q(recurrence_periodicity__isnull=False, recurrence_end_date__isnull=True) |
17
                Q(recurrence_periodicity__isnull=False, recurrence_end_date__gte=today) |
18
                Q(start_datetime__gte=datetime.combine(today, time.min)))
19
        print 'handling', qs.count(), 'active events'
20
        before = Act.objects.count()
21
        for event in qs:
22
            event.save()
23
        count = Act.objects.count()-before
24
        print 'created', count , 'acts'

Also available in: Unified diff