Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix delete URL for custom organizations#374

Merged
wardi merged 1 commit into
ckan:masterfrom
avdata99:fix_delete_url
Jul 6, 2023
Merged

Fix delete URL for custom organizations#374
wardi merged 1 commit into
ckan:masterfrom
avdata99:fix_delete_url

Conversation

@avdata99
Copy link
Copy Markdown
Member

@avdata99 avdata99 commented Jun 22, 2023

There are an error deleting an organization with datasets (using a custom organization type)

Example
image

After manage -> delete

image

(my custom type is called Data Container)
If I go back to the container again I see Data Container cannot be deleted while it still has datasets

image

Error log

ERROR [ckan.config.middleware.flask_app] 'organization' 
 Traceback (most recent call last): 
 File "/usr/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request |
 rv = self.dispatch_request() |
 File "/usr/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request 
 return self.view_functions[rule.endpoint](**req.view_args) 
 File "/srv/app/src/ckan/ckan/config/middleware/../../views/group.py", line 450, in read 
 extra_vars = _read(id, limit, group_type) |
 File "/srv/app/src/ckan/ckan/config/middleware/../../views/group.py", line 371, in _read 
 _setup_template_variables(context, {u'id': id}, group_type=group_type) |
 File "/srv/app/src/ckan/ckan/config/middleware/../../views/group.py", line 66, in _setup_template_variables 
 return lookup_group_plugin(group_type).\ 
 File "/srv/app/src/ckanext-scheming/ckanext/scheming/plugins.py", line 167, in setup_template_variables 
 c.scheming_schema = self._schemas[group_type] 
 KeyError: 'organization' 
INFO [ckan.config.middleware.flask_app] 500 /organization/container_test render time 0.294 seconds 

This is because the delete button for organization goes to a bad URL

CKAN core generates the delete button URL this way: group_type + '.delete'

<div class="form-actions">
    {% block delete_button %}
      {% if h.check_access('organization_delete', {'id': data.id})  %}

        <a class="btn btn-danger pull-left" href="{% url_for group_type+'.delete', id=data.id %}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this Organization? Note*: Deleting cannot be performed while public or private datasets belong to this organization.') }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>

      {% endif %}
    {% endblock %}
    <button class="btn btn-primary" name="save" type="submit">{% block save_text %}{{ _('Save Organization') }}{% endblock %}</button>
  </div>

https://github.com/ckan/ckan/blob/master/ckan/templates/organization/snippets/organization_form.html#L40

We need to generate the delete URL in the same way in this extension

@amercader
Copy link
Copy Markdown
Member

This looks good to me @avdata99, maybe you can update the description to include a description / screenshot of the error so it's easier to understand the context

@avdata99
Copy link
Copy Markdown
Member Author

I updated the description here @amercader

@amercader
Copy link
Copy Markdown
Member

@wardi any objections to merge this?

@wardi wardi merged commit a92778b into ckan:master Jul 6, 2023
@wardi
Copy link
Copy Markdown
Contributor

wardi commented Jul 6, 2023

@amercader thank you for reviewing

@avdata99 avdata99 deleted the fix_delete_url branch July 6, 2023 12:50
@avdata99
Copy link
Copy Markdown
Member Author

avdata99 commented Jul 6, 2023

@amercader @wardi, If you think it's appropriate, could you please create the release-3.0.1 tag?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants