Project

General

Profile

« Previous | Next » 

Revision 84fd22a0

Added by Benjamin Dauvergne over 11 years ago

[domino] finish family update workflow

- when creating or updating a family, store the family.code_interne value into
the user object for later retrieval,
- add web service API to retrieve person to contact for children

View differences:

extra/modules/abelium_domino_ui.ptl
1
from quixote import get_publisher, redirect
1
from quixote import get_publisher, redirect, get_request
2 2
from quixote.directory import Directory, AccessControlled
3 3

  
4 4
from qommon import get_cfg
......
7 7

  
8 8
from payments import Regie
9 9

  
10

  
10 11
# constants
11 12
ABELIUM_DOMINO = 'abelium_domino'
12 13
ACTIVATED = 'activated'
......
32 33
    cfg = get_abelium_cfg(publisher)
33 34
    return cfg.get(ACTIVATED, False) and abelium_domino_ws is not None
34 35

  
35
_WS_CACHE = None
36

  
37 36
def get_client(publisher=None):
38
    global _WS_CACHE
37
    publisher = publisher or get_publisher()
39 38

  
40 39
    cfg = get_abelium_cfg(publisher)
41
    if _WS_CACHE is None:
42
        _WS_CACHE = abelium_domino_ws.DominoWs(
43
            url=cfg.get(WSDL_URL, ''),
44
            domain=cfg.get(DOMAIN,''),
45
            login=cfg.get(LOGIN, ''),
46
            password=cfg.get(PASSWORD, ''),
47
            location=cfg.get(SERVICE_URL))
48
    return _WS_CACHE
40
    publisher._ws_cache = abelium_domino_ws.DominoWs(
41
        url=cfg.get(WSDL_URL, ''),
42
        domain=cfg.get(DOMAIN,''),
43
        login=cfg.get(LOGIN, ''),
44
        password=cfg.get(PASSWORD, ''),
45
        location=cfg.get(SERVICE_URL))
46
    return publisher._ws_cache
47

  
48
def get_family(user, publisher=None):
49
    family = None
50
    if user is None:
51
        return None
52
    client = get_client(publisher)
53
    if hasattr(user, 'abelium_domino_code_famille'):
54
        family = client.get_family_by_code_interne(
55
            user.abelium_domino_code_famille)
56
    if family is None and user.email:
57
        family = client.get_family_by_mail(user.email)
58
    return family
49 59

  
50 60
def get_invoice_regie(publisher=None):
51 61
    cfg = get_abelium_cfg(publisher)
......
59 69
    label = N_('Domino')
60 70

  
61 71
    def debug [html] (self):
72
        from abelium_domino_vars import SESSION_CACHE
62 73
        html_top(ABELIUM_DOMINO)
74
        '<p>code interne: %s</p>' % getattr(get_request().user, str('abelium_domino_code_famille'), None)
63 75
        '<dl>'
64 76
        context = get_publisher().substitutions.get_context_variables()
65 77
        for var in sorted(context.keys()):
66 78
            value = context[var]
67 79
            if value:
68 80
                '<dt>%s</dt>' % var
69
                '<dd>%s</dt>' % unicode(value).encode(get_publisher().site_charset)
81
                '<dd>%s</dt>' % value
70 82
        '</dl>'
71

  
83
        delattr(get_request().session, SESSION_CACHE)
72 84

  
73 85
    def _q_index [html] (self):
74 86
        publisher = get_publisher()
......
98 110
                    'activated because of this error when '
99 111
                    'loading it: %r') % import_error
100 112
            '<p class="errornotice">%s</p>' % message
113
        '<dl>'
114
        context = get_publisher().substitutions.get_context_variables()
115
        for var in sorted(context.keys()):
116
            value = context[var]
117
            if value:
118
                '<dt>%s</dt>' % var
119
                '<dd>%s</dt>' % unicode(value).encode(get_publisher().site_charset)
120
        '</dl>'
101 121

  
102 122
    form_desc = (
103 123
            # name, required, title, kind
......
129 149
        form.add_submit('cancel', _('Cancel'))
130 150

  
131 151
        return form
132

  

Also available in: Unified diff