Skip to content

Commit

Permalink
[QOLDEV-1011] drop Pylons 'c' object from data request handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ThrawnCA committed Dec 4, 2024
1 parent f01e611 commit 271a40b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
8 changes: 4 additions & 4 deletions ckanext/data_qld/controller_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ def open_datarequest(id):
context = _get_context()

# Basic initialization
c.datarequest = {}
datarequest = {}
try:
check_access(OPEN_DATAREQUEST, context, data_dict)
c.datarequest = get_action(SHOW_DATAREQUEST)(context, data_dict)
datarequest = get_action(SHOW_DATAREQUEST)(context, data_dict)

if c.datarequest.get('closed', False) is False:
if datarequest.get('closed', False) is False:
return abort(403, _('This data request is already open'))
else:
data_dict = {}
data_dict['id'] = id
data_dict['organization_id'] = c.datarequest.get('organization_id')
data_dict['organization_id'] = datarequest.get('organization_id')

get_action(OPEN_DATAREQUEST)(context, data_dict)
return redirect_to(url_for('datarequest.show', id=data_dict['id']))
Expand Down
8 changes: 6 additions & 2 deletions ckanext/data_qld/templates/datarequests/close.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{% ckan_extends %}
{% set datasets = datasets or c.datasets %}
{% set datarequest = datarequest or c.datarequest %}
{% set errors = errors or c.errors %}
{% set errors_summary = errors_summary or c.errors_summary %}

{% block subtitle %}{{ _('Close data request') }}{% endblock %}

{% block breadcrumb_content %}
<li>{% link_for _('Data requests'), named_route='datarequest.index' %}</li>
<li>{% link_for c.datarequest.get('title')|truncate(30), named_route='datarequest.show', id=c.datarequest.get('id') %}</li>
<li>{% link_for datarequest.get('title')|truncate(30), named_route='datarequest.show', id=datarequest.get('id') %}</li>
<li class="active"><a href="">{{ _('Close data request') }}</a></li>
{% endblock %}

{% block primary_content_inner %}
<h1 class="{% block page_heading_class %}page-heading{% endblock %}">{% block page_heading %}{{ _('Close data request') }}{% endblock %}</h1>
{% snippet "datarequests/snippets/close_datarequest_form.html", datarequest=c.datarequest, datasets=c.datasets, errors=c.errors, errors_summary=c.errors_summary %}
{% snippet "datarequests/snippets/close_datarequest_form.html", datarequest=datarequest, datasets=datasets, errors=errors, errors_summary=errors_summary %}
{% endblock %}

{% block page_header %}{% endblock %}
5 changes: 3 additions & 2 deletions ckanext/data_qld/templates/datarequests/comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@


{% block primary_content_inner %}

{% snippet "package/comment_list.html", content_type='datarequest', pkg_id=c.datarequest.id, pkg_name=c.datarequest.id, userobj=c.userobj %}
{% set datarequest = datarequest or c.datarequest %}
{% set userobj = userobj or c.userobj %}
{% snippet "package/comment_list.html", content_type='datarequest', pkg_id=datarequest.id, pkg_name=datarequest.id, userobj=userobj %}

{% endblock %}
8 changes: 6 additions & 2 deletions ckanext/data_qld/templates/datarequests/edit.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{% ckan_extends %}
{% set datarequest = datarequest or c.datarequest %}
{% set errors = errors or c.errors %}
{% set errors_summary = errors_summary or c.errors_summary %}
{% set original_title = original_title or c.original_title %}

{% block subtitle %}{{ _('Edit data request') }}{% endblock %}

{% block breadcrumb_content %}
<li>{% link_for _('Data requests'), named_route='datarequest.index' %}</li>
<li>{% link_for c.original_title|truncate(30), named_route='datarequest.show', id=c.datarequest.get('id') %}</li>
<li>{% link_for original_title|truncate(30), named_route='datarequest.show', id=datarequest.get('id') %}</li>
<li class="active"><a href="">{{ _('Edit data request') }}</a></li>
{% endblock %}

{% block primary_content_inner %}
<h1 class="{% block page_heading_class %}page-heading{% endblock %}">{% block page_heading %}{{ _('Edit data request') }}{% endblock %}</h1>
{% snippet "datarequests/snippets/edit_datarequest_form.html", data=c.datarequest, errors=c.errors, errors_summary=c.errors_summary, offering=c.offering %}
{% snippet "datarequests/snippets/edit_datarequest_form.html", data=datarequest, errors=errors, errors_summary=errors_summary %}
{% endblock %}

{% block page_header %}{% endblock %}
5 changes: 4 additions & 1 deletion ckanext/data_qld/templates/datarequests/new.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{% ckan_extends %}
{% set datarequest = datarequest or c.datarequest %}
{% set errors = errors or c.errors %}
{% set errors_summary = errors_summary or c.errors_summary %}

{% block subtitle %}{{ _('Create data request') }}{% endblock %}

Expand All @@ -9,7 +12,7 @@

{% block primary_content_inner %}
<h1 class="{% block page_heading_class %}page-heading{% endblock %}">{% block page_heading %}{{ _('Create data request') }}{% endblock %}</h1>
{% snippet "datarequests/snippets/new_datarequest_form.html", data=c.datarequest, errors=c.errors, errors_summary=c.errors_summary, offering=c.offering %}
{% snippet "datarequests/snippets/new_datarequest_form.html", data=datarequest, errors=errors, errors_summary=errors_summary %}
{% endblock %}

{% block secondary_content_additional_info %}
Expand Down
9 changes: 5 additions & 4 deletions ckanext/data_qld/templates/datarequests/show.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{% ckan_extends %}
{% set datarequest = datarequest or c.datarequest %}

{% block title %}Data request {{c.datarequest.get('title', '')}}{% endblock %}
{% block title %}Data request {{datarequest.get('title', '')}}{% endblock %}

{% block breadcrumb_content %}
<li>{% link_for _('Data requests'), named_route='datarequest.index' %}</li>
<li>{% link_for c.datarequest.get('title'), named_route='datarequest.show', id=datarequest_id %}</li>
<li>{% link_for datarequest.get('title'), named_route='datarequest.show', id=datarequest_id %}</li>
{% endblock %}

{% block content_action %}
Expand All @@ -13,11 +14,11 @@
{% link_for _('Manage'), named_route='datarequest.update', id=datarequest_id, class_='btn btn-default', icon='wrench' %}
{% endif %}

{% if h.check_access('close_datarequest', {'id':datarequest_id }) and not c.datarequest.closed %}
{% if h.check_access('close_datarequest', {'id':datarequest_id }) and not datarequest.closed %}
{% link_for _('Close'), named_route='datarequest.close', id=datarequest_id, class_='btn btn-danger', icon='lock' %}
{% endif %}

{% if h.check_access('open_datarequest', {'id':datarequest_id }) and c.datarequest.closed %}
{% if h.check_access('open_datarequest', {'id':datarequest_id }) and datarequest.closed %}
{% link_for _('Re-open'), named_route='data_qld.open_datarequest', id=datarequest_id, class_='btn btn-success', icon='unlock' %}
{% endif %}

Expand Down

0 comments on commit 271a40b

Please sign in to comment.