aboutsummaryrefslogtreecommitdiff
path: root/sgdfi/_dbs
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 /sgdfi/_dbs
parent11e40c69748dcfd0fe5b38bfa290cd7d68ac3d33 (diff)
Corrected code decoding and added related documentation.
Diffstat (limited to 'sgdfi/_dbs')
-rwxr-xr-xsgdfi/_dbs/_code.py67
-rwxr-xr-xsgdfi/_dbs/_ops.py12
-rwxr-xr-xsgdfi/_dbs/_st.py43
-rwxr-xr-xsgdfi/_dbs/_ststatus.py10
4 files changed, 92 insertions, 40 deletions
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 = {}