aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2019-02-18 10:48:19 +0100
committerThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2019-02-18 10:48:19 +0100
commit090f4597cd2f254099467e7c830fcb9288c21ef5 (patch)
tree59363ca308f14ac36d32bc05c84328f6f3851a59
parent56b7f45fc1804cfa8eb6b419a90f13d1aec063b5 (diff)
Latest updates (request_code updated because of intranet update)
-rw-r--r--.python-version1
-rw-r--r--docs/environment.rst4
-rw-r--r--docs/intranet/ids.rst21
-rwxr-xr-xsgdfi/__init__.py9
-rwxr-xr-xsgdfi/_decode.py18
-rwxr-xr-xsgdfi/_intranet.py38
-rwxr-xr-xsgdfi/_manager.py18
-rwxr-xr-xsgdfi/_util.py2
8 files changed, 62 insertions, 49 deletions
diff --git a/.python-version b/.python-version
new file mode 100644
index 0000000..0b2eb36
--- /dev/null
+++ b/.python-version
@@ -0,0 +1 @@
+3.7.2
diff --git a/docs/environment.rst b/docs/environment.rst
index e58b607..a5f4e14 100644
--- a/docs/environment.rst
+++ b/docs/environment.rst
@@ -108,6 +108,8 @@ on the main website. These redirects are the following:
`<https://www.sgdf.fr/espace-chefs-et-cadres>`_.
- `<https://design.sgdf.fr/>`_:
`<https://www.sgdf.fr/actualites-chefs-cadres/toute-l-actualites-chefs-cadres/les-actualites/2417-refonte-identite-visuelle-reponds-a-l-enquete>`_.
+- `<https://connecte.sgdf.fr/>`_:
+ `<https://www.sgdf.fr/component/content/article/2481-connecte-accueil>`_.
Technical domains
-----------------
@@ -158,6 +160,8 @@ can find:
`FOSUserBundle`_).
- `<https://campagnederentree.sgdf.fr/>`_: ordering platform for
communication products for the current season's start.
+- `<escapegame-welcome.sgdf.fr/>`_: digital support for the escape game
+ at Welcome (November 10 and 11, 2018).
- `<https://collaboratif.sgdf.fr/>`_: collaborative platform built
with `Alfresco`_.
- `<https://trouvetoncamp.fr/>`_: a search tool for camps, intended for
diff --git a/docs/intranet/ids.rst b/docs/intranet/ids.rst
index fd40ce8..04cbe5f 100644
--- a/docs/intranet/ids.rst
+++ b/docs/intranet/ids.rst
@@ -15,9 +15,26 @@ An IID can be used on the intranet for two objects of different types.
It happens often that IIDs used by calendar events are also used for
representing membership form printouts.
-Codes
------
+9-character codes
+-----------------
Inherited from the Intr@ssoc base is a common code system for adherents and
structures. Codes are described more in depth in `its own document
<codes.html>`_.
+
+Other codes
+-----------
+
+Structures and people also have internal codes (usually made of 7 digits)
+codes referenced and used in a few places:
+
+- adherent autocompletion.
+- structure selection for the calendar.
+
+The object type depends on the first digit:
+
+- ``1`` for structures.
+- ``2``, ``3``, ``5``, ``6`` for adherents.
+
+There seem to be exceptions I can't yet understand, such as ``48686`` for
+an adherent.
diff --git a/sgdfi/__init__.py b/sgdfi/__init__.py
index 465d2df..113e19d 100755
--- a/sgdfi/__init__.py
+++ b/sgdfi/__init__.py
@@ -13,4 +13,13 @@ from ._repr import Structure, Adherent, RallyRegistration, Camp, Place, \
from ._util import InvalidCredentialsError, InvalidUserError, \
InvalidPasswordError, UnauthorizedAccountError
+__all__ = ["version", "Manager",
+
+ "Structure", "Adherent", "RallyRegistration", "Camp", "Place",
+ "Operation", "OperationType", "Function", "Event", "StructureType",
+ "StructureStatus", "AllocationsRegime",
+
+ "InvalidCredentialsError", "InvalidUserError",
+ "InvalidPasswordError", "UnauthorizedAccountError"]
+
# End of file.
diff --git a/sgdfi/_decode.py b/sgdfi/_decode.py
index ea65cf5..17b1755 100755
--- a/sgdfi/_decode.py
+++ b/sgdfi/_decode.py
@@ -8,11 +8,11 @@
from itertools import count as _count
from datetime import datetime as _datetime, date as _date
from re import finditer as _rfindter, sub as _rreplace, split as _rsplit
-from io import IOBase as _IOBase, StringIO as _StringIO, BytesIO as _BytesIO, \
- TextIOWrapper as _TextIOWrapper
+from io import (IOBase as _IOBase, StringIO as _StringIO,
+ BytesIO as _BytesIO, TextIOWrapper as _TextIOWrapper)
from base64 import b64decode as _b64decode
-from urllib.parse import urlparse as _urlparse, parse_qs as _parse_qs, \
- unquote as _unquote
+from urllib.parse import (urlparse as _urlparse, parse_qs as _parse_qs,
+ unquote as _unquote)
from html import unescape as _htmlunescape
from json import load as _jsonload, loads as _jsonloads
from csv import reader as _csvreader
@@ -20,11 +20,11 @@ from csv import reader as _csvreader
from bs4 import BeautifulSoup as _BeautifulSoup
from pandas import read_excel as _read_excel
-from ._repr import Structure as _Structure, Adherent as _Adherent, \
- Place as _Place, RallyRegistration as _RallyRegistration, Camp as _Camp, \
- Operation as _Operation, FunctionRawData as _FunctionRawData
-from ._util import NotFoundError as _NotFoundError, \
- ForbiddenError as _ForbiddenError, Pagination as _Pagination
+from ._repr import (Structure as _Structure, Adherent as _Adherent,
+ Place as _Place, RallyRegistration as _RallyRegistration, Camp as _Camp,
+ Operation as _Operation, FunctionRawData as _FunctionRawData)
+from ._util import (NotFoundError as _NotFoundError,
+ ForbiddenError as _ForbiddenError, Pagination as _Pagination)
__all__ = ["Decoder"]
diff --git a/sgdfi/_intranet.py b/sgdfi/_intranet.py
index 9d410a2..9174559 100755
--- a/sgdfi/_intranet.py
+++ b/sgdfi/_intranet.py
@@ -391,40 +391,18 @@ class AnonymousIntranetSession:
raise ValueError("Birth date must be a date.")
# Make the request.
- # This is just pro level reverse engineering.
- # Please do not read this if you do not want to lose your sanity.
- # Please read this if you don't care.
- # Please modify it if you ought to break it.
-
- path = '/securite/OubliMotDePasse.aspx?num=1'
- dfr = d.strftime("%d/%m/%Y")
- dus = d.strftime("%Y-%m-%d")
- cus = _datetime.now().strftime("%Y-%m-01")
- eo_obj_states = _b64encode(b'\x01!\x01BA' \
- b'ctl00_MainContent__eocDateNaissance__picker:' + \
- cus.encode('ASCII') + b'|' + dus.encode('ASCII')).decode('ASCII')
- result = self.get_page(path, args = {
- '__eo_obj_states': eo_obj_states,
- '__eo_sc': '/wEdAAcSMJ8leNaA/vPZOzulfZuPEvHhCaPIDCCxX3XQg2l5e+BQ' \
- 'RR32SiwZGot7RnRIo09TjFeQwbB4Eo7GP2ptXnbAnMyq24KvMxlGsP7uRmE' \
- 'TdaVE1CbS15+9uPB4lF6xMlznDHPtMay3TLJDvEyyRG6LaDe0jqt5G6yCDS' \
- 'sQZSEP8hLNmoo=',
- '_eo_js_modules': '',
- '_eo_obj_inst': '',
-
- '_eo_ctl00_MainContent__eocDateNaissance__picker_picker': dfr,
- '_eo_ctl00_MainContent__eocDateNaissance__picker_h': dus,
- 'ctl00': {
- 'MainContent': {
- '_tbNom': common_name,
- '_tbPrenom': first_name}}},
+ result = self.get_page('/Default.aspx', args = {
+ '_dpbDateNaissance': {
+ '_tbDate': d.strftime('%d/%m/%Y')},
+ '_tbNom': common_name,
+ '_tbPrenom': first_name},
method = self.METHOD_FORM,
hint = 'sic')
# Check the result.
- espan = result.find(id = 'ctl00__erreur__lblErreur')
+ espan = result.find(id = '_erreur__lblErreur')
if espan is not None:
# There has been an error!
@@ -442,7 +420,7 @@ class AnonymousIntranetSession:
class IntranetSession(AnonymousIntranetSession):
""" Class for interacting with the intranet while logged in. """
- def __init__(self, manager, user = None, pw = None, *args, **kwargs):
+ def __init__(self, manager, *args, user = None, pw = None, **kwargs):
super().__init__(manager, *args, **kwargs)
self.__user = user
@@ -791,7 +769,7 @@ class IntranetSession(AnonymousIntranetSession):
state['ActiveTabIndex'] = 0
args[stname] = _jsondumps(state)
result = self.get_page(path, args, method = self.METHOD_AJAX,
- hint = 'intranet_adherent_summary')[0]
+ hint = 'intranet_adherent_summary')
#state['ActiveTabIndex'] = 1
#args[stname] = _jsondumps(state)
diff --git a/sgdfi/_manager.py b/sgdfi/_manager.py
index ac8eb11..8e83755 100755
--- a/sgdfi/_manager.py
+++ b/sgdfi/_manager.py
@@ -110,10 +110,11 @@ def _validsym(s):
class _IntranetSessionsManager:
""" Intranet sessions manager. """
- def __init__(self, mgr):
+ def __init__(self, mgr, *_, base = 'https://intranet.sgdf.fr'):
self.__mgr = mgr
self.__anon = None
self.__sessions = []
+ self.__base = base
pass
def __getitem__(self, key):
@@ -121,7 +122,8 @@ class _IntranetSessionsManager:
if self.__anon is None:
# The session will reference itself into this manager.
- _AnonymousIntranetSession(self.__mgr)
+ _AnonymousIntranetSession(self.__mgr, base = self.__base)
+
return self.__anon
if _isany(key):
@@ -216,7 +218,8 @@ class _IntranetSessionsManager:
if s is None:
# The session will reference itself into this manager.
- _IntranetSession(self.__mgr, user = user, pw = pw)
+ _IntranetSession(self.__mgr, user = user, pw = pw,
+ base = self.__base)
return
if s.pw == pw:
@@ -230,9 +233,9 @@ class _IntranetSessionsManager:
class _SessionsManager:
""" Sessions manager. """
- def __init__(self, mgr):
+ def __init__(self, mgr, *, intranet = 'https://intranet.sgdf.fr'):
self.__mgr = mgr
- self.__i = _IntranetSessionsManager(mgr)
+ self.__i = _IntranetSessionsManager(mgr, base = intranet)
@property
def intranet(self):
@@ -335,12 +338,13 @@ class _EventsManager:
class Manager(_Decoder):
""" Manage objects from SGDF's intranet. """
- def __init__(self, save = False, folder = None, debug = False):
+ def __init__(self, *_, intranet = 'https://intranet.sgdf.fr',
+ save = False, folder = None, debug = False):
super().__init__()
self.__save = save
self.__folder = folder
- self.__sessions = _SessionsManager(self)
+ self.__sessions = _SessionsManager(self, intranet = intranet)
self.__dbg = bool(debug)
# Work out the folder, and make sure it exists.
diff --git a/sgdfi/_util.py b/sgdfi/_util.py
index dc07414..e8cf77c 100755
--- a/sgdfi/_util.py
+++ b/sgdfi/_util.py
@@ -254,7 +254,7 @@ class BoolProperty(Property):
self.__value = self.__default
def defaultdoc(self, element, name):
- return f"The {name.replace('_', ' ')} doc for the {element}."
+ return f"If the {element} has {name.replace('_', ' ')}."
def get(self):
return self.__value