Projet

Général

Profil

0001-utils-add-is_portal_agent-function-58851.patch

Frédéric Péters, 11 février 2022 11:08

Télécharger (1,94 ko)

Voir les différences:

Subject: [PATCH 1/2] utils: add is_portal_agent function (#58851)

 combo/manager/views.py | 10 +++-------
 combo/utils/misc.py    |  8 ++++++++
 2 files changed, 11 insertions(+), 7 deletions(-)
combo/manager/views.py
57 57
    import_site_tar,
58 58
)
59 59
from combo.urls_utils import staff_required
60
from combo.utils.misc import is_portal_agent
60 61

  
61 62
from .forms import (
62 63
    CellVisibilityForm,
......
862 863
    else:
863 864
        label = _('Content Management')
864 865

  
865
    slug = 'portal'
866
    if getattr(settings, 'KNOWN_SERVICES') and 'combo' in settings.KNOWN_SERVICES:
867
        # switch to custom slug if the site is the portal agent.
868
        for service in settings.KNOWN_SERVICES['combo'].values():
869
            if service.get('is-portal-agent') and not service.get('secret'):
870
                slug = 'portal-agent'
871
                break
866
    # use a custom slug if the site is the portal agent.
867
    slug = 'portal-agent' if is_portal_agent() else 'portal'
872 868

  
873 869
    json_str = json.dumps(
874 870
        [
combo/utils/misc.py
56 56
    if not netloc:
57 57
        return True
58 58
    return bool(get_known_service_for_url(url))
59

  
60

  
61
def is_portal_agent():
62
    if getattr(settings, 'KNOWN_SERVICES') and 'combo' in settings.KNOWN_SERVICES:
63
        for service in settings.KNOWN_SERVICES['combo'].values():
64
            if service.get('is-portal-agent') and not service.get('secret'):
65
                return True
66
    return False
59
-