Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
Description
===========
Setup
=====
Install application
pip install -e git+https://dev.webu.coop/shared/estimevent
Usage
=====
from estimevent.api import EstimEventAPI
api = EstimEventAPI(user=my_user, password=my_password)
api.save_event({
'titre': 'mon_titre'
'date_debut': today(),
'date_fin': today(),
'id_structure_organisatrice': 12345
'adresse': '38 rue des Tournelles, 67890'
'tranche_dages': AGE_0_A_3_ANS,
'thematiques': [THE_AGRI_ALI]
'publics_cibles': [PUB_CIB_GROUP, PUB_CIB_MEDIA]
'types_evenement': [TYP_EVT_SPEC_VIV]
'description': 'ma description'
})
api.delete_event({
'titre': 'mon_titre'
'date_debut': today(),
'date_fin': today(),
'id_structure_organisatrice': 12345
'adresse': '38 rue des Tournelles, 67890'
})
Django
======
## setup
- Ajouter estimevent to INSTALLED_APPS
- Écrire une classe héritant de EstimEventWrapperBase et la décorer avec estim_wrapper
from estimevent.contrib.django.estimevent.models import estim_wrapper
from estimevent.contrib.django.estimevent.models import EstimEventWrapperBase
@estim_wrapper
class EstimNoteWrapper(EstimEventWrapperBase):
user = getattr(settings, 'ESTIMEVENT_USER')
password = getattr(settings, 'ESTIMEVENT_PASSWORD')
dry_run = getattr(settings, 'ESTIMEVENT_DRY_RUN', False)
@staticmethod
def titre(note):
return note.name
...
@classmethod
def events_to_sync(cls, until=None):
for note in Note.published.all():
data = cls.properties(note)
for overrided_data in cls.occurences(note, until):
data = data.copy()
data.update(overrided_data)
yield (note, data)
@classmethod
def has_to_keep(cls, event):
if event.status not in [event.STATUS_PUBLISHED, event.STATUS_MODERATE]:
return False
return super(EstimNoteWrapper, cls).has_to_sync(event)
## usage
Cette application ajoute la command estimsync qui synchronise l'ensemble des evenements.
./manage.py estimsync [--dry-run] [event_id event_id ...]
API
===
## class estimevent.api.EstimEventAPI
All ESTIM constants (see estimevent.api contant)
### __init__(user, password, production=True, host=None, proto=None)
### save_event(date, production=True)
Les champs sont nommés à la manière python. Par exemple, `trancheDages` devient `tranche_dages`.
### delete_event(date, production=True)
## class estimevent.contrib.django.estimevent.models.EstimEventWrapperBase
### classmethod events_to_sync()
Retourne l'ensemble des événements à synchroniser sous la forme d'une liste de tuple.
(object, data)
### classmethod has_to_keep(event)
Permet de savoir si un évenement doit être conservé sur le PORTAIL estim.
### classmethod has_to_add(event)
Permet de savoir si un évenement doit être ajouté sur le PORTAIL estim.