Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
estimevent
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WebU
shared
estimevent
Commits
4301b632
Commit
4301b632
authored
9 years ago
by
Olivier Le Brouster
Browse files
Options
Downloads
Patches
Plain Diff
Mise à jour de README.md
parent
dd9e1356
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+98
-82
98 additions, 82 deletions
README.md
with
98 additions
and
82 deletions
README.md
+
98
−
82
View file @
4301b632
Description
===========
Setup
=====
Cette bibliotheque facilite la publication d'événement sur le portail ESTIM
(https://www.estim-science.fr/) dans le cadre d'une application python.
Elle contient également une application django.
Install application
Installation
============
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
======
Utilisation
===========
## setup
```
python
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
'
})
```
-
Ajouter estimevent to INSTALLED_APPS
-
Écrire une classe héritant de EstimEventWrapperBase et la décorer avec estim_wrapper
Django
======
from estimevent.contrib.django.estimevent.models import estim_wrapper
from estimevent.contrib.django.estimevent.models import EstimEventWrapperBase
## Mise en place
@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)
### Ajouter estimevent to INSTALLED_APPS
```
python
INSTALLED_APPS
=
[
…
'
estimevent.contrib.django.estimevent
'
,
…
]
```
##
usage
##
# Écrire une classe héritant de EstimEventWrapperBase et la décorer avec estim_wrapper
Cette application ajoute la command estimsync qui synchronise l'ensemble des evenements.
```
python
from
estimevent.contrib.django.estimevent.models
import
estim_wrapper
from
estimevent.contrib.django.estimevent.models
import
EstimEventWrapperBase
./manage.py estimsync [--dry-run] [event_id event_id ...]
@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
)
```
## Utilisation
Cette application ajoute la commande
`estimsync`
qui synchronise l'ensemble des
événements, les met à jour au besoin et supprime les évenements à ne pas
conserver.
./manage.py estimsync [--dry-run] [event_id event_id ...]
API
===
## class estimevent.api.EstimEventAPI
## class
`
estimevent.api.EstimEventAPI
`
All ESTIM constants (see estimevent.api
contant
)
Cette classe contient toutes les
con
s
tant
es ESTIM.
### __init__(user, password, production=True, host=None, proto=None)
###
`
__init__
`
(user, password, production=True, host=None, proto=None)
### save_event(date, production=True)
###
`
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)
### `delete_event`(date, production=True)
## class estimevent.contrib.django.estimevent.models.EstimEventWrapperBase
##
#
class
method events_to_sync()
## class
`estimevent.contrib.django.estimevent.models.EstimEventWrapperBase`
Retourne l'ensemble des événements à synchroniser sous la forme d'une liste de tuple.
### Methodes
(object, data
)
*
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)
*
classmethod has_to_keep(event)
Permet de savoir si un évenement doit être conservé sur le
PORTAIL estim
.
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
.
Permet de savoir si un évenement doit être ajouté sur le
portail ESTIM
.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment