Projet

Général

Profil

« Précédent | Suivant » 

Révision d443ceb7

Ajouté par Serghei Mihai il y a environ 9 ans

services parameters updated.
Default 64x64 icon added automatically on group creation

Voir les différences:

ckanext/ozwillo_organization_api/plugin.py
2 2
import hmac
3 3
import requests
4 4
import logging
5
import json
5 6

  
6 7
import ckan.plugins as plugins
7 8
import ckan.plugins.toolkit as toolkit
......
87 88
                                           action='read',
88 89
                                           id=org_dict['name'],
89 90
                                           qualified=True)
91
        default_icon_url = toolkit.url_for(host=request.host,
92
                                           qualified=True,
93
                                           controller='home',
94
                                           action='index') + 'organization_icon.png'
90 95

  
91 96

  
92 97
        group_or_org_create(context, org_dict, is_org=True)
......
94 99
        # setting organization as active explicitely
95 100
        group = model.Group.get(org_dict['name'])
96 101
        group.state = 'active'
102
        group.image_url = default_icon_url
97 103
        group.save()
98 104

  
99 105
        # notify about organization creation
100 106
        services = {'services': [{
101 107
            'local_id': 'organization',
102
            'name': 'Organization ' + org_dict['name'] + ' on CKAN',
108
            'name': , org_dict['name'],
103 109
            'service_uri': organization_uri,
110
            'description': 'Organization ' + org_dict['name'] + ' on CKAN',
111
            'tos_uri': organization_uri,
112
            'policy_uri': organization_uri,
113
            'icon': group.image_url,
114
            'payment_option': 'FREE',
115
            'target_audience': ['PUBLIC_BODIES'],
116
            'contacts': [organization_uri],
117
            'redirect_uris': [organization_uri],
104 118
            'visible': True}],
105 119
            'instance_id': instance_id,
106 120
            'destruction_uri': delete_uri,
......
113 127
        headers = {'Content-type': 'application/json',
114 128
                   'Accept': 'application/json'}
115 129
        requests.post(registration_uri,
116
                      data = services,
130
                      data=json.dumps(services),
117 131
                      auth=(client_id, client_secret),
118 132
                      headers=headers
119 133
                  )
......
134 148
    API for OASIS to create and delete an organization
135 149
    """
136 150
    plugins.implements(plugins.IActions)
151
    plugins.implements(plugins.IConfigurer)
152

  
153
    def update_config(self, config):
154
        toolkit.add_public_directory(config, 'public')
137 155

  
138 156
    def get_actions(self):
139 157
        return {

Formats disponibles : Unified diff