Projet

Général

Profil

0001-misc-add-get_admin_url-to-various-objects-45834.patch

Frédéric Péters, 11 août 2020 16:11

Télécharger (2,38 ko)

Voir les différences:

Subject: [PATCH 1/2] misc: add get_admin_url to various objects (#45834)

 wcs/blocks.py       | 4 ++++
 wcs/data_sources.py | 9 +++++++++
 wcs/wscalls.py      | 4 ++++
 3 files changed, 17 insertions(+)
wcs/blocks.py
87 87
    def get_new_field_id(self):
88 88
        return 'bf%s' % str(uuid.uuid4())
89 89

  
90
    def get_admin_url(self):
91
        base_url = get_publisher().get_backoffice_url()
92
        return '%s/forms/blocks/%s/' % (base_url, self.id)
93

  
90 94
    def get_display_value(self, value):
91 95
        if not self.digest_template:
92 96
            return self.name
wcs/data_sources.py
373 373
            new_slug = '%s-%s' % (base_new_slug, suffix_no)
374 374
        return new_slug
375 375

  
376
    def get_admin_url(self):
377
        base_url = get_publisher().get_backoffice_url()
378
        for section in ('settings', 'forms', 'workflows'):
379
            if get_publisher().get_backoffice_root().is_accessible(section):
380
                return '%s/%s/data-sources/%s/' % (base_url, section, self.id)
381
        # fallback to settings section
382
        section = 'settings'
383
        return '%s/%s/data-sources/%s/' % (base_url, section, self.id)
384

  
376 385
    def export_data_source_to_xml(self, element, attribute_name, charset):
377 386
        data_source = getattr(self, attribute_name)
378 387
        ET.SubElement(element, 'type').text = data_source.get('type')
wcs/wscalls.py
142 142
        XmlStorableObject.__init__(self)
143 143
        self.name = name
144 144

  
145
    def get_admin_url(self):
146
        base_url = get_publisher().get_backoffice_url()
147
        return '%s/settings/wscalls/%s/' % (base_url, self.slug)
148

  
145 149
    def export_request_to_xml(self, element, attribute_name, charset):
146 150
        request = getattr(self, attribute_name)
147 151
        for attr in ('url', 'request_signature_key', 'method'):
148
-