Project

General

Profile

Download (883 Bytes) Statistics
| Branch: | Tag: | Revision:

calebasse / scripts / cleaning_acts.py @ 2686d95a

1
# -*- coding: utf-8 -*-
2
#!/usr/bin/env python
3

    
4
import os
5
import datetime
6

    
7

    
8
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "calebasse.settings")
9
log = open('acts_cleaning.log', 'a+')
10

    
11
i = 0
12
j = 0
13

    
14
from calebasse.agenda.models import EventWithAct
15

    
16
for event in EventWithAct.objects.all():
17
    if event.is_recurring():
18
        for a in event.act_set.all():
19
            if not event.today_occurrence(today=a.date) and \
20
               not a.is_billed:
21
                log.write("rec %d\n" % a.id)
22
                a.delete()
23
                i += 1
24
    else:
25
        if event.canceled and not event.act.is_billed \
26
           and event.act.id:
27
            try:
28
               log.write("%d\n" % event.act.id)
29
               event.act.delete()
30
               j += 1
31
            except:
32
               pass
33

    
34
print "acte sup %d recurrence" % i
35
print "acte sup %d canceled" % j
36

    
37
log.close()
38

    
(7-7/47)