Skip to content
Snippets Groups Projects
Commit 994a3c8c authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Removed deprecated data requests

parent 131f83ee
No related branches found
No related tags found
1 merge request!50Upgraded to CKAN 2.10
Showing
with 133 additions and 722 deletions
{% extends "page.html" %}
{% block styles %}
{{ super() }}
<link rel="stylesheet" href="/datarequests.css" />
{% endblock %}
{% block subtitle %}
{% endblock %}
{% block breadcrumb_content %}
<li class="active">{% link_for _('Data Proposal'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.index' %}</li>
{% endblock %}
{% block main_content %}
{% block flash %}
{{ super() }}
{% endblock %}
{% block toolbar %}
{{ super() }}
{% endblock %}
<div class="datarequest row wrapper{% block wrapper_class %}{% endblock %}{% if self.secondary()|trim == '' %} no-nav{% endif %} is-table-row">
{#
The pre_primary block can be used to add content to before the
rendering of the main content columns of the page.
#}
{% block pre_primary %}
{% endblock %}
{% block primary %}
<div class="primary span9">
{% block primary_content %}
{{ super() }}
{% endblock %}
</div>
{% endblock %}
{% block secondary %}
<aside class="secondary span3">
{% block secondary_content %}
{{ super() }}
{% endblock %}
</aside>
{% endblock %}
</div>
{% block pre_wrap %}
{% endblock %}
{% endblock %}
</div>
</div>
{% extends "datarequests/base.html" %}
{% block subtitle %}{{ _('Close Data Proposal') }}{% endblock %}
{% block breadcrumb_content %}
<li>{% link_for _('Data Proposal'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.index' %}</li>
<li>{% link_for c.datarequest.get('title')|truncate(30), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.show', id=c.datarequest.get('id') %}</li>
<li class="active"><a href="">{{ _('Close Data Proposal') }}</a></li>
{% endblock %}
{% block primary_content_inner %}
<h1 class="{% block page_heading_class %}page-heading{% endblock %}">{% block page_heading %}{{ _('Close Data Proposal') }}{% endblock %}</h1>
{% snippet "datarequests/snippets/close_datarequest_form.html", datarequest=c.datarequest, datasets=c.datasets, errors=c.errors, errors_summary=c.errors_summary %}
{% endblock %}
{% block page_header %}{% endblock %}
\ No newline at end of file
{% extends "datarequests/show.html" %}
{% block breadcrumb_content %}
{{ super() }}
{% endblock %}
{% block content_action %}
{% endblock %}
{% block content_primary_nav %}
{% endblock %}
{% block subtitle %}
{% endblock %}
{% block primary_content_inner %}
{% if h.check_access('update_datarequest', {'id':datarequest_id }) %}
{% link_for _('Manage'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.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 %}
{% link_for _('Close'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.close', id=datarequest_id, class_='btn btn-danger', icon='lock' %}
{% endif %}
<h2 class="page-heading">
{% block page_heading %}
{{c.datarequest.title}}
{% endblock %}
</h2>
<div class='datarequest-primary'>
{{ h.render_markdown(h.get_translated(c.datarequest, 'description')) }}
{% snippet "datarequests/snippets/comments.html", comments=c.comments, datarequest=c.datarequest, errors=c.errors, errors_summary=c.errors_summary, updated_comment=c.updated_comment %}
{% if h.check_access('comment_datarequest', {'id':c.datarequest.id }) %}
<h2 class='comments-heading'>{{_('Add New Comment')}}:</h2>
<div >
{% set create_comment_error = c.updated_comment is defined and c.updated_comment.id == '' %}
{% if create_comment_error %}
<a name="comment_focus"></a>
{% endif %}
{% snippet "datarequests/snippets/comment_form.html", datarequest=c.datarequest, errors=c.errors, errors_summary=c.errors_summary, offering=c.offering, initial_text=c.updated_comment.comment if create_comment_error, focus=create_comment_error, current_user=c.userobj %}
</div>
{% endif %}
</div>
<section class="additional-info">
{% block package_additional_info %}
<div>{{ _('Released') }}: {{ h.odsh_render_datetime(c.datarequest.open_time) }}</div>
<div>{{ _('Suggester') }}: {{ c.datarequest.user['display_name'] if c.datarequest.user else _('None') }}</div>
{#<td class="dataset-details" title="{{ c.datarequest.close_time }}">{{ h.time_ago_from_timestamp(c.datarequest.close_time) if c.datarequest.close_time else _('Not closed yet') }}</td>#}
<div >{{ _('Status') }}:
<div class="dataset-details">
{% if c.datarequest.get('closed', False) %}
<div class="badge label-closed">
{% trans %}Done{% endtrans %}
</div>
{% else %}
<div class="badge label-open">
{% trans %}Open{% endtrans %}
</div>
{% endif %}
</div>
{#{% if c.datarequest.closed %}
<tr>
<th scope="row" class="dataset-label">{{ _('Accepted Dataset') }}</th>
<td class="dataset-details">
{% if c.datarequest.accepted_dataset %}
{% link_for c.datarequest.accepted_dataset['title'], named_route='dataset.read', id=c.datarequest.accepted_dataset.get('id') %}
{% else %}
{{ _('None') }}
{% endif %}
</td>
</tr>
{% endif %}
#}
<div class='comment-count-wrapper'><i class="icon-comment fa fa-comment"></i> {{ h.get_comments_number(c.datarequest.get('id', '')) }}</span> </div>
{% endblock %}
</section>
{% endblock %}
\ No newline at end of file
{% extends "datarequests/base.html" %}
{% block subtitle %}{{ _('Edit Data Proposal') }}{% endblock %}
{% block breadcrumb_content %}
<li>{% link_for _('Data Proposal'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.index' %}</li>
<li>{% link_for c.original_title|truncate(30), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.show', id=c.datarequest.get('id') %}</li>
<li class="active"><a href="">{{ _('Edit Data Proposal') }}</a></li>
{% endblock %}
{% block primary_content_inner %}
<h1 class="{% block page_heading_class %}page-heading{% endblock %}">{% block page_heading %}{{ _('Edit Data Proposal') }}{% endblock %}</h1>
{% snippet "datarequests/snippets/edit_datarequest_form.html", data=c.datarequest, errors=c.errors, errors_summary=c.errors_summary, offering=c.offering %}
{% endblock %}
{% block page_header %}{% endblock %}
\ No newline at end of file
{% extends "datarequests/base.html" %}
{% block primary_content %}
<section class="module">
<div class="module-content">
{% block page_primary_action %}
<form id='datarequest-search-form' method="get" data-module="select-switch">
{% snippet 'snippets/custom_search_form.html', form_id='datarequest-search-form', query=c.q, fields=(('organization', c.organization), ('state', c.state)), sorting=c.filters, sorting_selected=c.sort, placeholder=_('Search Data Requests...'), no_bottom_border=false, count=c.datarequest_count, no_title=True, type='datarequest' %}
{{ h.snippet('datarequests/snippets/datarequest_list.html', datarequest_count=c.datarequest_count, datarequests=c.datarequests, page=c.page, q=c.q)}}
{% if h.check_access('create_datarequest') %}
<div class="add_request_container">
{% link_for _('Add Request'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.new', class_='btn btn-primary', icon=h.get_plus_icon() %}
</div>
{% endif %}
{% endblock %}
</div>
</section>
{% endblock %}
{% block secondary%}
{% endblock %}
{#{% block secondary_content %}
{{ super() }}
{% for facet in c.facet_titles %}
{{ h.snippet('snippets/facet_list.html', title=c.facet_titles[facet], name=facet) }}
{% endfor %}
{% endblock %}#}
{% block pre_wrap %}
</form>
{% endblock %}
\ No newline at end of file
{% extends "datarequests/base.html" %}
{% block subtitle %}{{ _('Create Data Request') }}{% endblock %}
{% block breadcrumb_content %}
<li>{% link_for _('Data Proposal'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.index' %}</li>
<li class="active"><a href="">{{ _('Create Data Proposal') }}</a></li>
{% endblock %}
{% block primary_content_inner %}
<h1 class="{% block page_heading_class %}page-heading{% endblock %}">{% block page_heading %}{{ _('Create New 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 %}
{% endblock %}
{% block secondary %}
{% endblock %}
{% block page_header %}{% endblock %}
\ No newline at end of file
{% extends "datarequests/base.html" %}
{% block title %}{{_('Data Request')}} {{c.datarequest.get('title', '')}}{% endblock %}
{% set datarequest_id = c.datarequest.get('id') %}
{% block breadcrumb_content %}
<li>{% link_for _('Data Requests'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.index' %}</li>
<li>{% link_for c.datarequest.get('title'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.show', id=datarequest_id %}</li>
{% endblock %}
{% block content_action %}
{% if h.check_access('update_datarequest', {'id':datarequest_id }) %}
{% link_for _('Manage'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.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 %}
{% link_for _('Close'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.close', id=datarequest_id, class_='btn btn-danger', icon='lock' %}
{% endif %}
{% endblock %}
{% block content_primary_nav %}
{{ h.build_nav_icon('show_datarequest', _('Data Request'), id=datarequest_id) }}
{% endblock %}
{% block secondary %}
{% endblock %}
{% block primary_content_inner %}
{% if c.datarequest.closed %}
<span class="uppercase badge label-closed pull-right">
<i class="icon-lock fa fa-lock"></i>
{{ _('Closed') }}
</span>
{% else %}
<span class="uppercase badge label-open pull-right">
<i class="icon-unlock fa fa-unlock"></i>
{{ _('Open') }}
</span>
{% endif %}
<h1 class="{% block page_heading_class %}page-heading{% endblock %}">{% block page_heading %}{{ c.datarequest.get('title') }}{% endblock %}</h1>
{% block datarequest_description %}
{% if c.datarequest.get('description') %}
<div class="notes embedded-content">
{{ h.render_markdown(c.datarequest.get('description')) }}
</div>
{% endif %}
{% endblock %}
{% block datarequest_additional_info %}
{% snippet "datarequests/snippets/additional_info.html", datarequest=c.datarequest %}
{% endblock %}
{% if c.comments %}
{% for comment in c.comments %}
{% snippet "datarequests/snippets/comment_item.html", comment=c.comment, datarequest=c.datarequest, errors=c.errors, errors_summary=c.errors_summary, updated_comment=c.updated_comment %}
{% endfor %}
{% else %}
<p class="empty">
{{ _('This data request has not been commented yet') }}
</p>
{% endif %}
{% endblock %}
{% import 'macros/form.html' as form %}
<form class="dataset-form {{ 'comment-edit-form' if comment_id else 'odsh-comment-wrapper' }} {{ 'hide' if comment_id and not (focus and errors) }} form-horizontal" id="comment-form{{ '-' + comment_id if comment_id }}" method="post" data-module="basic-form" action enctype="multipart/form-data">
{% if focus %}
{% block errors %}{{ form.errors(errors_summary) }}{% endblock %}
{% endif %}
<input type="hidden" name="datarequest-id" value="{{ datarequest.get('id', '') }}" />
<input type="hidden" name="comment-id" value="{{ comment_id if comment_id }}" />
<div class="controls control-full control-large control-group {{ 'error' if errors and errors.get('Comment') and focus }} editor">
{% set markdown_tooltip = "<pre><p>__Bold text__ or _italic text_</p><p># title<br>## secondary title<br>### etc</p><p>* list<br>* of<br>* items</p><p>http://auto.link.ed/</p></pre><p><b><a href='http://daringfireball.net/projects/markdown/syntax' target='_blank'>Full markdown syntax</a></b></p><p class='muted'><b>Please note:</b> HTML tags are stripped out for security reasons</p>" %}
<textarea name="comment" cols="20" rows="9" placeholder="{{ _('Add a new Comment') if not comment_id }}">{{ initial_text }}</textarea>
</div>
<div class="comment-form-actions">
{% if comment_id %}
<button id="comment-discard-{{ comment_id }}" class="btn btn-danger" name="discard">{{ _('Cancel') }}</button>
<button class="btn btn-primary" type="submit" name="update">{{ _('Update Comment') }}</button>
{% else %}
<button class="btn btn-primary btn-arrow-right" type="submit" name="add">{{ _('Add New Comment') }}</button>
{% endif %}
</div>
</form>
{% set focus = updated_comment is not none and updated_comment.id == comment.id %}
{% set can_update = h.check_access('update_datarequest_comment', {'id':comment.id }) %}
{% if focus %}
<a name="comment_focus"></a>
{% endif %}
<div class="odsh-comment-wrapper">
{# <a href="{{ h.url_for('user.read', id=comment.user.get('name')) }}"
class="comment-avatar">
{{ h.gravatar(comment.user.get('email_hash'), 48) }}
</a>
#}
<div class="">
<div class="odsh-comment-header">
<div class="comment-actions">
{#
{% if h.check_access('delete_datarequest_comment', {'id':comment.id }) %}
<div class="comment-action">
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this comment?')}) %}
<a class="subtle-btn" id="delete-comment-{{ comment.id }}" href="{% url_for 'ckanext.datarequests.controllers.ui_controller:DataRequestsUI.delete_comment', datarequest_id=datarequest.id, comment_id=comment.id %}" data-module="confirm-action" data-module-i18n="{{ locale }}"><i class="icon-remove fa fa-times"></i></a>
</div>
{% endif %}
{% if can_update %}
<div class="comment-action" id="edit-button">
<button class="subtle-btn" id="update-comment-{{ comment.id }}" href=""><i class="icon-pencil fa fa-pencil"></i></button>
</div>
{% endif %}
#}
<div class="comment-header-text">
<i class="icon-comment fa fa-comment"></i>
<a href="{{ h.url_for('user.read', id=comment.user.get('name')) }}" class="comment-author">{{ comment.user.get('display_name') }}</a>
<span class='comment-date' title="{{comment.time}}">{{ h.odsh_render_datetime(comment.time).lower() }}</span>
</div>
</div>
</div>
<div class="odsh-comment-content {{ 'hide' if focus and errors }}" id="comment-{{ comment.id }}">
{{ h.render_markdown(comment.comment|safe) }}
</div>
{% if can_update %}
{% snippet "datarequests/snippets/comment_form.html", comment_id=comment.id, datarequest=datarequest, errors=errors, errors_summary=errors_summary, initial_text=updated_comment.comment if focus else comment.comment, focus=focus %}
{% endif %}
</div>
</div>
\ No newline at end of file
<h2 class='comments-heading'>{{_('Comments')}}:</h2>
{% if comments %}
{% for comment in comments %}
{% snippet "datarequests/snippets/comment_item.html", comment=comment, datarequest=datarequest, errors=errors, errors_summary=errors_summary, updated_comment=updated_comment %}
{% endfor %}
{% else %}
<p class="empty">
{{ _('This data request has not been commented yet') }}
</p>
{% endif %}
{% import 'macros/form.html' as form %}
{% set title = data.get('title', '') %}
{% set description = data.get('description', '') %}
{% set organization_id = data.get('organization_id', h.get_request_param('organization')) %}
{% set organizations_available = h.organizations_available('read') %}
{# This provides a full page that renders a form for publishing a dataset. It can
then itself be extended to add/remove blocks of functionality. #}
<form class="dataset-form" method="post" data-module="basic-form" action enctype="multipart/form-data">
<input type="hidden" id="id" name="id" value="{{ data.get('id', '') }}" />
{% block errors %}{{ form.errors(errors_summary) }}{% endblock %}
{% block offering_title %}
{{ form.input('title', id='field-title', label=_('Title'), placeholder=_('eg. Data Request Name'), value=title, error=errors['Title'], classes=['control-full'], is_required=true) }}
{% endblock %}
{% block offering_description %}
{{ form.markdown('description', id='field-description', label=_('Description'), placeholder=_('eg. Data Request description'), value=description, error=errors['Description'], is_required=true) }}
{% endblock %}
{% block form_actions %}
<div class="form-actions">
{% block delete_button %}
{% if h.check_access('delete_datarequest', {'id': data.get('id', '')}) and not data.state == 'deleted' %}
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this data request?')}) %}
<a class="btn btn-danger pull-left" href="{% url_for 'ckanext.datarequests.controllers.ui_controller:DataRequestsUI.delete', id=data.get('id') %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endblock %}
<button class="btn btn-primary btn-arrow-right" type="submit" name="save">{% block save_button_text %}{{ _('Create Data Request') }}{% endblock %}</button>
</div>
{% endblock %}
</form>
\ No newline at end of file
{% set truncate = truncate or 180 %}
{% set truncate_title = truncate_title or 80 %}
{% set title = datarequest.get('title', '') %}
{% set description = h.markdown_extract(datarequest.get('description', ''), extract_length=truncate) %}
<div class="container-fluid odsh-dataset-item">
{% block package_item_content %}
<div class="dataset-content">
<div class="dataset-heading ">
<div class="span1">
{% if datarequest.get('closed', False) %}
<div class="badge label-closed">
{% trans %}Done{% endtrans %}
</div>
{% else %}
<div class="badge label-open">
{% trans %}Open{% endtrans %}
</div>
{% endif %}
</div>
<div class='span9'>
<div class='datarequest-subtitle'>
<span class="datarequest-item-open-time">{{h.odsh_render_datetime(datarequest.open_time)}}</span>
<span class="datarequest-item-autor-name">{{datarequest.user['display_name']}}</span>
</div>
{{ h.link_to(h.truncate(title, truncate_title), h.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='show', id=datarequest.get('id', ''))) }}
</div>
</div>
{% if description %}
<div>{{ description }}</div>
{% endif %}
{% if h.show_comments_tab() %}
<i class="icon-comment fa fa-comment"></i> {{ h.get_comments_number(datarequest.get('id', '')) }}</span>
{% endif %}
</div>
<div class="dataset-meta">
{% if h.show_comments_tab() %}
{% link_for _('Add New Comment'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='comment', id=datarequest.get('id',''), class_='btn btn-primary btn-arrow-right' %}
{% endif %}
</div>
{% endblock %}
</div>
\ No newline at end of file
{% block datarequest_search_results_list %}
{% if datarequests %}
<div class="dataset-list unstyled">
{% for datarequest in datarequests %}
{{ h.snippet('datarequests/snippets/datarequest_item.html', datarequest=datarequest, facet_titles=facet_titles) }}
{% endfor %}
</div>
{% else %}
<p class="empty">
{{ _('No Data Requests found with the given criteria') }}.
{% if h.check_access('create_datarequest') %}
{% link_for _('How about creating one?'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.new' %}</a>
{% endif %}
</p>
{% endif %}
{% endblock %}
{% block page_pagination %}
{{ page.pager(q=q) }}
{% endblock %}
\ No newline at end of file
{% extends "datarequests/snippets/datarequest_form.html" %}
{% block delete_button %}
{% endblock %}
{% block save_button_text %}
{{ _('Suggest New Data Request') }}
{% endblock %}
\ No newline at end of file
......@@ -4,8 +4,6 @@
{% set sorting_label_prefix = _('Order by') %}
{% if type=='organization' %}
{% set sorting = sorting if sorting else [(_('Name Ascending'), 'name asc'), (_('Name Descending'), 'name desc')] %}
{% elif type=='datarequest' %}
{% set sorting = [(_('Date Ascending'), 'asc'), (_('Date Descending'), 'desc')] %}
{% else %}
{% set sorting = [
(_('Relevance'), 'score desc, metadata_modified desc'),
......@@ -48,7 +46,7 @@
{%- endif -%}
{% endif %}
{% else %}
<h2>Error</h2>
<h2>{{ _('Error') }}</h2>
{% endif %}
{% endblock %}
......
from ckanext.odsh.tests_wip.test_helpers import AppProxy
import ckanext.odsh.tests_wip.test_helpers as testhelpers
import ckan.tests.factories as factories
import uuid
import pdb
from ckanext.odsh.tests_wip.harvest_sever_mock import HarvestServerMock
import ckanext.odsh.tests_wip.harvest_sever_mock as harvest_sever_mock
import subprocess
import re
markdown = \
"""
Lorem markdownum supplex iniquis, nec nostram nam conde tympana, deae Mutinae
regna sepulcro; morae arces quae, pia? Rates Circe, quandoquidem Ausoniae, me,
cacumine apta, saevus abductas navigiis. Sacri ostendit *ad anas* amores nostras
[currebam celeres], milia gaudet eripitur superest circumque auras, [nec]. Si
haurit geminis agendum profana lacertis infamis?
> Dedit potuit perenni nesciet flumine. Et sui **ibis** mihi supponat, flamina
> mihi rogos, deus manum ora tenebras. Acta nec dominus aenum, haud de ripa
> instabilemque amnis erat nam Patraeque parabat quod membra quamquam.
"""
class TestDatarequest:
def test_nologin_cannot_create_request(self):
pass
def _create_request(self):
guid = str(uuid.uuid4())
self._get_app().login()
response = self.app.get('/datarequest/new')
form = response.forms[0]
title = 'datarequest_' + guid
form['title'] = title
form['description'] = markdown
final_response = self.app.submit_form(form)
id = re.search(
'/datarequest/edit/([a-zA-Z0-9\-]*)">', final_response.body).group(1)
return id
def test_create_datarequest(self):
# Act
id = self._create_request()
# Assert
response = self.app.get('/datarequest')
assert id in response
def test_edit_datarequest(self):
# Arrange
id = self._create_request()
# Act
response = self.app.get('/datarequest/edit/'+id)
form = response.forms[0]
form['title'] = id+'edit_title'
form['description'] = id+'edit_desc'
final_response = self.app.submit_form(form)
# Assert
response = self.app.get('/datarequest/'+id)
assert id+'edit_title' in response
assert id+'edit_desc' in response
def test_comment_datarequest(self):
# Arrange
id = self._create_request()
guid = str(uuid.uuid4())
# Act
response = self.app.get('/datarequest/comment/'+id)
form = response.forms[0]
form['comment'] = markdown + guid
final_response = self.app.submit_form(form)
# Assert
assert guid in final_response
def test_close_datarequest(self):
# Arrange
id = self._create_request()
# Act
response = self.app.get('/datarequest/close/'+id)
form = response.forms[0]
final_response = self.app.submit_form(form)
# Assert
response = self.app.get('/datarequest/'+id)
assert 'label-closed' in response
def _get_app(self):
if not hasattr(self, 'app'):
app = AppProxy()
self.app = app
return self.app
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment