aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-10-10 19:23:34 +0200
committerThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-10-10 19:23:34 +0200
commitd176763a25e042c0d35d9b2d6f2d50ea7c155519 (patch)
tree6f9d52434241f625e22d5a6edf0bca2fd5980d44
parent11e40c69748dcfd0fe5b38bfa290cd7d68ac3d33 (diff)
Corrected code decoding and added related documentation.
-rw-r--r--docs/env/intranet/index.rst338
-rwxr-xr-xsgdfi/_dbs/_code.py67
-rwxr-xr-xsgdfi/_dbs/_ops.py12
-rwxr-xr-xsgdfi/_dbs/_st.py43
-rwxr-xr-xsgdfi/_dbs/_ststatus.py10
5 files changed, 430 insertions, 40 deletions
diff --git a/docs/env/intranet/index.rst b/docs/env/intranet/index.rst
index 7200d36..6547c12 100644
--- a/docs/env/intranet/index.rst
+++ b/docs/env/intranet/index.rst
@@ -30,6 +30,344 @@ Returned documents are usually one of these:
`Microsoft Ajax`_ response.
- ``application/json``: a JSON document.
+Codes
+-----
+
+The intranet represents structures and adherents through a central code system,
+where each code is composed of nine (9) characters, usually decimal digits.
+One code is usually attributed to only one element, although there are
+exceptions of this (see the examples).
+
+A code cannot be used to predict an element's type (because of exceptions), but
+it can in most cases, using these rules (empirically obtained, where ``#``
+represent any character):
+
+- if the code is ``000000000``, then the element is a top.
+- if the code is ``##0000000`` or ``##9999999``, then the element is a
+ “centre national”.
+- if the code starts with ``12``, ``13``, ``14``, ``15``, ``16`` (or ``17``?),
+ then the element is an adherent.
+- if the code starts with ``98``:
+
+ - if the five following characters are ``88001``:
+
+ - if the code ends with ``#8``, then the element is a
+ “membres associés national”.
+ - otherwise, then the element is a “centre national”.
+ - otherwise:
+
+ - if the code ends with ``8#``, then the element is a “membres
+ associés national”.
+ - otherwise, then the element is a “centre national”.
+- otherwise:
+
+ - the department code is the two following characters.
+ - the territory number is the following character.
+ - the group number is the two following characters.
+ - if the group number is ``00``:
+
+ - if the two last characters are ``00``, then the element is a territory.
+ - otherwise, then the element is a “membres associés territorial”.
+ - otherwise:
+
+ - if the two last characters are ``00``, then the element is a group.
+ - if the two last characters are ``1#``, then the element is a
+ louveteaux-jeanettes unit.
+ - if the two last characters are ``2#``, then the element is a
+ scouts-guides unit.
+ - if the two last characters are ``3#``, then the element is a
+ pionniers-caravelles unit.
+ - if the two last characters are ``7#``, then the element is a
+ farfadet unit.
+ - if the two last characters are ``9#``, then the element is a
+ Vent du Large unit.
+ - otherwise, then the element is a “membres associés local”.
+
+Code examples follow:
+
+``000000000``
+ “SCOUTS ET GUIDES DE FRANCE” or “GUIDES DE FRANCE” (sommet)
+
+``010000000``
+ “CENTRE NATIONAL” or “REGION ALSACE” (centre national).
+
+``010100000``
+ “CONSEIL ADMINISTRATION” (territoire).
+
+``010200000``
+ “EQUIPE NATIONALE” (territoire) or “GUIDE” (groupe).
+
+``016700000``
+ “DEPARTEMENT BAS RHIN” (territoire).
+
+``016703200``
+ “GROUPE DISTRICT STRASBOURG SUD” (groupe).
+
+``016703300``
+ “DISTRICT DOMPETER” (territoire).
+
+``034300000``
+ “DEPARTEMENT HAUTE LOIRE” (territoire).
+
+``090000000``
+ “REGION FRANCHE-COMTE” (centre national).
+
+``100000000``
+ “CR ILE DE FRANCE” (centre national).
+
+``107530000``
+ “CODEPIE PARIS EST” (territoire).
+
+``107700100``
+ “GROUPE DE MONTEREAU” (groupe).
+
+``107700141``
+ “1ERE COMPAGNONS MONTEREAU” (unité 17-20 ans).
+
+``107700301``
+ “GROUPE 1E MEAUX - UNITE” (Autres).
+
+``107700371``
+ “1ERE SARABANDE MEAUX” (Unité Farfadet).
+
+``107700781``
+ “RESEAU DES PARENTS ET AMIS DE MONTEREAU” (Membres associés local).
+
+``107840391``
+ “VENT DU LARGE ST SYMPHORIEN” (Unité Vent du Large).
+
+``109999999``
+ “REGION ILE DE FRANCE” (centre national).
+
+``121160477``
+ Anonymous (adhérent)
+
+``163382220``
+ Anonymous (adhérent).
+
+``3B0000000``
+ “ILE DE FRANCE EST” (centre national).
+
+``700000000``
+ “OUEST” (centre national).
+
+``709999999``
+ “MOUVEMENTS ASSOCIES” (centre national).
+
+``969711400``
+ “GROUPE ABYMES” (groupe).
+
+``980010000``
+ “EQUIPES NATIONALES ADMINISTRATION GENERALE” (centre national).
+
+``988600310``
+ “COLIBRI” (centre national).
+
+``988601081``
+ “MEMBRES ASSOCIES JAMBVILLE” (centre national).
+
+``988800130``
+ “FORMATION CR NORD EST” (centre national).
+
+``988800180``
+ “FORMATION CR OUTRE MER” (centre national).
+
+``988900901``
+ “EQUIPE NATIONALE RESEAU IMPESA” (centre national).
+
+``991000700``
+ “GROUPE V.N - LIMOGES” (groupe).
+
+``TO0000000``
+ “NOUVELLE CALEDONIE” (centre national).
+
+``TO9810000``
+ “NOUVELLE CALEDONIE NORD” (territoire).
+
+Where to find things
+--------------------
+
+Paths usually start with ``/Specialisation/Sgdf``, probably because the app
+is an adaptation of `Intr@ssoc`_ and needs its own path, although pages can
+also be accessed without this prefix (duplicate content, well done guys).
+
+``/Default.aspx``
+ Login page.
+
+``/Accueil.aspx``
+ A home page where you are redirected when you can find some tips and
+ announcements, plus the menu.
+
+``/erreurs/Erreur.aspx``
+ An error has occured and the user is redirected to this page, which
+ takes a few GET parameters:
+
+ ``aspxerrorpath``
+ The path of the error, e.g.
+ ``/Specialisation/Sgdf/animation/ModifDateCalendrier.aspx``.
+
+``/adherents/RechercherAdherent.aspx``
+ The main search page for adherents. Loads the results through page
+ fragments.
+
+``/adherents/ListeAdherents.aspx``
+ An adherents list, less complete than the search form above. Loads the
+ results through page fragments.
+
+``/adherents/ResumeAdherent.aspx``
+ A page containing information about an adherent. Information is requested
+ through fragments.
+
+``/structures/ResumeStructure.aspx``
+ A summary page for a structure. Loads the tabs through forms (not
+ fragments).
+
+``/Commun/ResumeLieuActivite.aspx``
+ Place summary. Takes an ``id`` GET parameter which is the intranet
+ ID for the place.
+
+``/animation/ConsulterCalendrier.aspx``
+ A calendar. Loads month/structure relationships through fragments.
+
+``/animation/CreerDateCalendrier.aspx``
+ A form to create or duplicate an event (transmitted to this page by the
+ previous one). While creating, it takes the following GET parameters:
+
+ ``date``
+ The number of seconds of the day since January 1st, 1, with seven
+ zeroes behind. This can be obtained with the following calculation
+ in Python, ``dt`` being the ``datetime.datetime`` instance of the
+ date you want to encode:
+
+ .. code-block:: python
+
+ td = dt - datetime(1, 1, 1, 0, 0)
+ dateparam = f"{td.total_seconds()}0000000"
+
+ ``idStructure``
+ The identifier for the structure to which to link the event to.
+
+ And while duplicating, it takes the following GET parameters:
+
+ ``idDuplique``
+ The identifier of the event to duplicate.
+
+ ``idStructure``
+ The identifier for the structure to which to link the event to.
+
+``/animation/ModifDateCalendrier.aspx``
+ A form to edit an event. It takes the following GET parameters:
+
+ ``id``
+ The identifier of the event to modify.
+
+``/ActivitesAnnee/EditerRegistrePresence.aspx``
+ A form to modify the attendee register.
+
+``/nominations/DemandeNomination.aspx``
+ A form to request for nomination.
+
+``/Popups/RechercheStructure.aspx``
+ Searches through public structures. Uses the following GET parameters:
+
+ ``dummy``
+ Must be ``1``. The form won't work correctly without it, for
+ some reason.
+
+ ``operations``
+ An intranet identifier (?), e.g. ``fCx2YIJV6Qq+qLBWSyMcwA==``.
+
+``/popups/JournalEvenements.aspx``
+ Get events corresponding to an entity on the application. Takes the
+ following GET parameters:
+
+ ``typeEntite``
+ The entity type, amongst:
+
+ ``1``
+ Structure/season relation. (?)
+
+ ``2``
+ ?
+
+ ``3``
+ Patrimony (??)
+
+ ``4``
+ Adherent.
+
+ ``5``
+ ?
+
+ ``6``
+ ?
+
+ ``7``
+ ?
+
+ ``8``
+ Event (calendar date).
+
+ ``9``
+ ?
+
+ ``10``
+ ?
+
+ ``11``
+ Training course.
+
+ ``12``
+ Training course registration.
+
+ ``13``
+ Camp.
+
+ ``14``
+ Place.
+
+ ``15``
+ Membership form (?).
+
+ ``16``
+ J&S declaration (?).
+
+ ``17``
+ ?
+
+ ``18``
+ ?
+
+ ``19``
+ Rally registration.
+
+ ``20``
+ ?
+
+ ``21``
+ ?
+
+ ``22``
+ ?
+
+ ``23``
+ ?
+
+ ``24``
+ ?
+
+ ``25``
+ ?
+
+ ``idEntite``
+ An intranet identifier (16 byte sequence, base64 encoded).
+
+``/WebServices/AutoComplete.asmx/GetFonctions``
+ An XML document containing function data for autocompleting.
+
+ Takes a ``q`` GET parameter which can be empty (e.g. ``?q=``) to get
+ all functions.
+
.. _Intr@ssoc: http://www.intrassoc.com/
.. _ASP.NET: https://www.asp.net/
.. _Microsoft IIS: https://www.iis.net/
diff --git a/sgdfi/_dbs/_code.py b/sgdfi/_dbs/_code.py
index eb48d46..29ac9ef 100755
--- a/sgdfi/_dbs/_code.py
+++ b/sgdfi/_dbs/_code.py
@@ -23,10 +23,10 @@ class CodeType(_Enum):
ADHERENT = 2
# If a code starts with:
-# - 0, then it is the top (000000000).
+# - 000000000, then it is the top.
# - X0 or X1, then it is a structure (see below for subtypes).
# - X2 to X6, then it is an adherent.
-# - X8, then it is a structure related to the national.
+# - 0 or X8, then it is a structure related to the national.
#
# If it is a structure and its code ends with:
# - 0000, then it is a territory (territoire).
@@ -67,32 +67,49 @@ class Code:
self.__code = _strcode(value)
# Try to deduce things of this code.
+ # This algorithm is an implementation of the one described in
+ # the documentation, in `env/intranet/index.rst`.
typ = CodeType.UNKNOWN
styp = None
+ sec = value[:2]
dep = None
depn = None
grpn = None
- if value[0] == '0':
+ if value == '000000000':
typ = CodeType.STRUCTURE
styp = _StructureType.SOMMET
- elif value[1] in '01':
- dep = int(value[2:4])
- depn = int(value[4]) + (0, 10)[value[1] == '1']
+ elif value[2:] in ('0000000', '9999999'):
+ typ = CodeType.STRUCTURE
+ styp = _StructureType.CENTRE_NATIONAL
+ elif value[:2] in ('12', '13', '14', '15', '16', '17'):
+ typ = CodeType.ADHERENT
+ elif value[:2] == '98':
+ typ = CodeType.STRUCTURE
+
+ if value[2:7] == '88001':
+ if value[8] == '8':
+ styp = _StructureType.ASSOCIES_N
+ else:
+ styp = _StructureType.CENTRE_NATIONAL
+ else:
+ if value[7] == '8':
+ styp = _StructureType.ASSOCIES_N
+ else:
+ styp = _StructureType.CENTRE_NATIONAL
+ else:
+ dep = value[2:4]
+ depn = int(value[4])
typ = CodeType.STRUCTURE
if value[5:7] == '00':
- # That's related to a territory!
-
if value[7:9] == '00':
styp = _StructureType.TERRITOIRE
else:
styp = _StructureType.ASSOCIES_T
else:
- # That's related to a group!
-
grpn = int(value[5:7]) - 1
if value[7:9] == '00':
@@ -104,26 +121,15 @@ class Code:
elif value[7] == '3':
styp = _StructureType.UNITE_14_17_ANS
elif value[7] == '7':
- styp = _StructureType.UNITE_6_8_ANS
+ styp = _StructureType.UNITE_FARFADET
+ elif value[7] == '9':
+ styp = _StructureType.UNITE_VENT_DU_LARGE
else:
styp = _StructureType.ASSOCIES_L
- elif value[1] in '234567':
- # Adherent. X7 is unused for now, but is probably reserved.
-
- typ = CodeType.ADHERENT
- elif value[1:3] in ('80', '86', '88'):
- if value[7] == '0' or value[7:9] == '10':
- typ = CodeType.STRUCTURE
- styp = _StructureType.CENTRE_NATIONAL
- elif value[7] in '1234567' and value[8] == '8':
- typ = CodeType.STRUCTURE
- styp = _StructureType.ASSOCIES_N
- elif value[7] == '8':
- typ = CodeType.STRUCTURE
- styp = _StructureType.ASSOCIES_N
self.__type = typ
self.__subtype = styp
+ self.__sector = sec
self.__dep = dep
self.__depn = depn
self.__grpn = grpn
@@ -134,6 +140,8 @@ class Code:
p.append(f"type = {self.__type}")
if self.__type == CodeType.STRUCTURE:
p.append(f"subtype = {self.__subtype}")
+ if self.__sector is not None:
+ p.append(f"sector = {self.__sector}")
if self.__dep is not None:
p.append(f"dep = {self.__dep}")
if self.__depn is not None:
@@ -146,9 +154,6 @@ class Code:
def __str__(self):
return self.__code
- def __int__(self):
- return int(self.__code)
-
def __eq__(self, value):
return self.__code == _strcode(value)
@@ -165,6 +170,12 @@ class Code:
return self.__subtype
@property
+ def sector(self):
+ """ The sector (first two characters). """
+
+ return self.__sector
+
+ @property
def department(self):
""" The code of the associated administrative department. """
diff --git a/sgdfi/_dbs/_ops.py b/sgdfi/_dbs/_ops.py
index 1ee3bd9..4fe82d5 100755
--- a/sgdfi/_dbs/_ops.py
+++ b/sgdfi/_dbs/_ops.py
@@ -23,6 +23,12 @@ class OperationType(_Enum):
""" Animation / Suppression d'une date. """
ANIM_DATE_DEL = 47
+ """ Animation / Création d'un message. """
+ ANIM_MSG_NEW = 49
+
+ """ Animation / Création d'une tâche. """
+ ANIM_TASK_NEW = 50
+
""" Bulletin d'adhésion / Impression locale d'un bulletin d'adhésion. """
BUL_PRINT = 3
@@ -155,7 +161,7 @@ class OperationType(_Enum):
""" Structure / Recopie nouvelle saison. """
ST_COPY = 46
- # TODO: other types (last index: 49).
+ # TODO: other types (next index: 51).
_OperationTypeIds = {
"Animation / Création d'une date": \
@@ -164,6 +170,10 @@ _OperationTypeIds = {
OperationType.ANIM_DATE_EDIT,
"Animation / Suppression d'une date": \
OperationType.ANIM_DATE_DEL,
+ "Animation / Création d'un message": \
+ OperationType.ANIM_MSG_NEW,
+ "Animation / Création d'une tâche": \
+ OperationType.ANIM_TASK_NEW,
"Bulletin d'adhésion / Impression locale d'un bulletin d'adhésion": \
OperationType.BUL_PRINT,
"Camp / Ajout d'un animateur à un camp": \
diff --git a/sgdfi/_dbs/_st.py b/sgdfi/_dbs/_st.py
index bf01e29..dcdd7fa 100755
--- a/sgdfi/_dbs/_st.py
+++ b/sgdfi/_dbs/_st.py
@@ -14,29 +14,32 @@ class StructureType(_Enum):
""" The default type (unknown). """
UNKNOWN = 0
+ """ Autres. """
+ AUTRES = 1
+
""" Sommet. """
- SOMMET = 1
+ SOMMET = 10
""" Territoire. """
- TERRITOIRE = 2
+ TERRITOIRE = 11
""" Groupe. """
- GROUPE = 3
+ GROUPE = 12
""" Membres associés national. """
- ASSOCIES_N = 10
+ ASSOCIES_N = 13
""" Membres associés territorial. """
- ASSOCIES_T = 11
+ ASSOCIES_T = 14
""" Membres associés local. """
- ASSOCIES_L = 12
+ ASSOCIES_L = 15
""" Centre national. """
- CENTRE_NATIONAL = 15
+ CENTRE_NATIONAL = 16
""" Unité farfadets. """
- UNITE_6_8_ANS = 30
+ UNITE_FARFADET = 30
""" Unité louveteaux-jeanettes. """
UNITE_8_11_ANS = 31
@@ -47,9 +50,29 @@ class StructureType(_Enum):
""" Unité pionniers-caravelles. """
UNITE_14_17_ANS = 33
+ """ Unité compagnons. """
+ UNITE_17_20_ANS = 34
+
+ """ Unité Vent du Large. """
+ UNITE_VENT_DU_LARGE = 35
+
_StructureTypeData = {
- StructureType.UNITE_8_11_ANS: "Unité 8-11 ans",
- StructureType.UNITE_14_17_ANS: "Unité 14-17 ans",
+ StructureType.AUTRES: "Autres",
+
+ StructureType.SOMMET: "Sommet",
+ StructureType.TERRITOIRE: "Territoire",
+ StructureType.GROUPE: "Groupe",
+ StructureType.ASSOCIES_N: "Membres associés National",
+ StructureType.ASSOCIES_T: "Membres associés Territorial",
+ StructureType.ASSOCIES_L: "Membres associés local",
+ StructureType.CENTRE_NATIONAL: "Centre National",
+
+ StructureType.UNITE_FARFADET: "Unité Farfadet",
+ StructureType.UNITE_8_11_ANS: "Unité 8-11 ans",
+ StructureType.UNITE_11_14_ANS: "Unité 11-14 ans",
+ StructureType.UNITE_14_17_ANS: "Unité 14-17 ans",
+ StructureType.UNITE_17_20_ANS: "Unité 17-20 ans",
+ StructureType.UNITE_VENT_DU_LARGE: "Unité Vent du Large",
}
_StructureTypeLeads = {}
diff --git a/sgdfi/_dbs/_ststatus.py b/sgdfi/_dbs/_ststatus.py
index ee7b0ed..e02cb48 100755
--- a/sgdfi/_dbs/_ststatus.py
+++ b/sgdfi/_dbs/_ststatus.py
@@ -17,8 +17,16 @@ class StructureStatus(_Enum):
""" Ouverte. """
OPEN = 1
+ """ Fermée. """
+ CLOSED = 2
+
+ """ Suspendue. """
+ SUSPENDED = 3
+
_StructureStatusData = {
- StructureStatus.OPEN: "Ouverte"
+ StructureStatus.OPEN: "Ouverte",
+ StructureStatus.CLOSED: "Fermée",
+ StructureStatus.SUSPENDED: "Suspendue"
}
_StructureStatusLeads = {}