Skip to content

Commit

Permalink
Merge pull request #1417 from noirbizarre/backport-1.2
Browse files Browse the repository at this point in the history
Backport 1.2
  • Loading branch information
noirbizarre committed Feb 5, 2018
2 parents 43538f6 + 2a07736 commit 15d097d
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 37 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## Current (in progress)

- Translate Flask-Security email subjects [#1413](https://github.com/opendatateam/udata/pull/1413)
- Fix organization admin pagination [#1372](https://github.com/opendatateam/udata/issues/1372)
- Fix missing spinners on loading datatables [#1401](https://github.com/opendatateam/udata/pull/1401)
- Fixes on the search facets [#1410](https://github.com/opendatateam/udata/pull/1410)

## 1.2.10 (2018-01-24)

Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ uData
[![Python Requirements Status][requires-io-badge]][requires-io-url]
[![JavaScript Dependencies Status][david-dm-badge]][david-dm-url]
[![JavaScript Development Dependencies Status][david-dm-dev-badge]][david-dm-dev-url]
[![Translation progress][crowdin-badge]][crowdin-url]
[![Read the documentation][readthedocs-badge]][readthedocs-url]
[![Join the chat at https://gitter.im/opendatateam/udata][gitter-badge]][gitter-url]

Expand All @@ -14,13 +15,15 @@ The [full documentation][readthedocs-url] is hosted on Read the Docs.

[circleci-url]: https://circleci.com/gh/opendatateam/udata
[circleci-badge]: https://circleci.com/gh/opendatateam/udata.svg?style=shield
[requires-io-url]: https://requires.io/github/opendatateam/udata/requirements/?tag=v1.2.10
[requires-io-badge]: https://requires.io/github/opendatateam/udata/requirements.svg?tag=v1.2.10
[requires-io-url]: https://requires.io/github/opendatateam/udata/requirements/?branch=master
[requires-io-badge]: https://requires.io/github/opendatateam/udata/requirements.svg?branch=master
[david-dm-url]: https://david-dm.org/opendatateam/udata
[david-dm-badge]: https://img.shields.io/david/opendatateam/udata/status.svg
[david-dm-dev-url]: https://david-dm.org/opendatateam/udata?type=dev
[david-dm-dev-badge]: https://david-dm.org/opendatateam/udata/dev-status.svg
[gitter-badge]: https://badges.gitter.im/Join%20Chat.svg
[gitter-url]: https://gitter.im/opendatateam/udata
[readthedocs-badge]: https://readthedocs.org/projects/udata/badge/?version=v1.2.10
[readthedocs-url]: https://udata.readthedocs.io/en/v1.2.10/
[readthedocs-badge]: https://readthedocs.org/projects/udata/badge/?version=latest
[readthedocs-url]: https://udata.readthedocs.io/en/latest/
[crowdin-badge]: https://d322cqt584bo4o.cloudfront.net/udata/localized.svg
[crowdin-url]: https://crowdin.com/project/udata
5 changes: 4 additions & 1 deletion js/components/datatable/widget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ export default {
boxclass: String,
tint: String,
empty: String,
loading: Boolean,
loading: {
type: Boolean,
default: undefined
},
track: {
type: null,
default: 'id'
Expand Down
5 changes: 3 additions & 2 deletions js/views/organization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import Followers from 'models/followers';
import Metrics from 'models/metrics';
import Organization from 'models/organization';
import CommunityResources from 'models/communityresources';
import {PageList} from 'models/base';
import {PageList, ModelPage} from 'models/base';
// Widgets
import DatasetList from 'components/dataset/list.vue';
import DiscussionList from 'components/discussions/list.vue';
Expand All @@ -80,7 +80,8 @@ export default {
search: 'title',
mask: ReuseList.MASK
}),
datasets: new PageList({
datasets: new ModelPage({
query: {page_size: 10, sort: '-created'},
ns: 'organizations',
fetch: 'list_organization_datasets',
search: 'title',
Expand Down
29 changes: 28 additions & 1 deletion less/udata/search.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ul.search-results {

.search-result {
position: relative;
background: white;
border-bottom: 1px solid #F0F0F0;
overflow: hidden;
zoom: 1;
Expand Down Expand Up @@ -136,6 +135,34 @@ ul.search-results {
.advanced-search-panel {
.list-group {
margin-bottom: 0;

.list-group-item {
// Fix the badge position on long facet labels
&:not(.more) {
@padding:15px; // Hard coded in bootstrap list-group component
padding-right: @padding + 37px;
position: relative;

.badge {
position: absolute;
top: 50%;
right: @padding;
transform: translateY(-50%);
}
}

// Center the more button
&.more {
text-align: center;
}
}

.list-group-more {
// Fix bootstrap hiding first border
.list-group-item:first-child {
border-top-width: 1px;
}
}
}

.btn-remove:hover {
Expand Down
2 changes: 1 addition & 1 deletion requirements/circleci.pip
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-r test.pip
invoke==0.22.0
invoke==0.22.1
readme-renderer==17.2
2 changes: 1 addition & 1 deletion requirements/develop.pip
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
invoke==0.22.0
invoke==0.22.1
-r install.pip
-r test.pip
-r report.pip
Expand Down
2 changes: 1 addition & 1 deletion requirements/install.pip
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ chardet==3.0.4
CommonMark==0.7.4
elasticsearch==2.4.1
elasticsearch-dsl==2.2.0
factory-boy==2.9.2
factory-boy==2.10.0
Faker==0.8.10
Flask-BabelEx==0.9.3
Flask-Caching==1.3.3
Expand Down
5 changes: 3 additions & 2 deletions udata/api/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from flask import request, url_for
from flask_restplus.fields import * # noqa

from udata.utils import multi_to_dict

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -42,7 +43,7 @@ class NextPageUrl(String):
def output(self, key, obj):
if not getattr(obj, 'has_next', None):
return None
args = request.args.copy()
args = multi_to_dict(request.args)
args.update(request.view_args)
args['page'] = obj.page + 1
return url_for(request.endpoint, _external=True, **args)
Expand All @@ -52,7 +53,7 @@ class PreviousPageUrl(String):
def output(self, key, obj):
if not getattr(obj, 'has_prev', None):
return None
args = request.args.copy()
args = multi_to_dict(request.args)
args.update(request.view_args)
args['page'] = obj.page - 1
return url_for(request.endpoint, _external=True, **args)
Expand Down
15 changes: 9 additions & 6 deletions udata/core/organization/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
refuse_membership_fields,
)

from udata.core.dataset.api_fields import dataset_fields
from udata.core.dataset.api_fields import dataset_page_fields
from udata.core.dataset.models import Dataset
from udata.core.dataset.search import DatasetSearch
from udata.core.discussions.api import discussion_fields
from udata.core.discussions.models import Discussion
from udata.core.issues.api import issue_fields
Expand All @@ -44,6 +45,7 @@

ns = api.namespace('organizations', 'Organization related operations')
search_parser = OrganizationSearch.as_request_parser()
dataset_search_parser = DatasetSearch.as_request_parser()

common_doc = {
'params': {'org': 'The organization ID or slug'}
Expand Down Expand Up @@ -355,24 +357,25 @@ def put(self, org):
return {'image': org.logo}


dataset_parser = api.parser()
dataset_parser = api.page_parser()
dataset_parser.add_argument(
'size', type=int, help='The amount of datasets to fetch',
location='args', default=25)
'sort', type=str, default='-created', location='args',
help='The sorting attribute')


@ns.route('/<org:org>/datasets/', endpoint='org_datasets')
class OrgDatasetsAPI(API):
@api.doc('list_organization_datasets')
@api.marshal_list_with(dataset_fields)
@api.expect(dataset_parser)
@api.marshal_with(dataset_page_fields)
def get(self, org):
'''List organization datasets (including private ones when member)'''
args = dataset_parser.parse_args()
qs = Dataset.objects.owned_by(org)
if not OrganizationPrivatePermission(org).can():
qs = qs(private__ne=True)
return list(qs.limit(args['size']))
return (qs.order_by(args['sort'].replace('created', 'created_at'))
.paginate(args['page'], args['page_size']))


@ns.route('/<org:org>/reuses/', endpoint='org_reuses')
Expand Down
16 changes: 7 additions & 9 deletions udata/templates/macros/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,20 @@ <h3 class="panel-title">
{% for term, count, selected in terms[:nb_displayed_aggregations] %}
<a href="{{ result.query.to_url(url, **{name: term}) }}"
class="list-group-item">
<span class="badge">{{ count }}</span>
{{ result.query.facets[name].labelize(term) }}
<span class="badge pull-right">{{ count }}</span>
</a>
{% endfor %}
{% if terms|length > nb_displayed_aggregations %}
<button class="list-group-item" @click="expandPanel('{{result.class_name}}-{{name}}', $event)">
<button class="list-group-item more" @click="expandPanel('{{result.class_name}}-{{name}}', $event)">
{{ _('More results…') }}
<span class="fa fa-chevron-right pull-right"></span>
</button>
<div id="facet-{{result.class_name}}-{{name}}-more" class="list-group collapse list-group-more">
{% for term, count, selected in terms[nb_displayed_aggregations:] %}
<a href="{{ result.query.to_url(url, **{name: term}) }}"
class="list-group-item">
<span class="badge">{{ count }}</span>
{{ result.query.facets[name].labelize(term) }}
<span class="badge pull-right">{{ count }}</span>
</a>
{% endfor %}
</div>
Expand All @@ -139,21 +138,20 @@ <h3 class="panel-title">
{% for obj, count, selected in objects[:nb_displayed_aggregations] %}
<a href="{{ result.query.to_url(url, **{name: obj.id|string}) }}"
class="list-group-item">
<span class="badge">{{ count }}</span>
{{ result.query.facets[name].labelize(obj) }}
<span class="badge pull-right">{{ count }}</span>
</a>
{% endfor %}
{% if objects|length > nb_displayed_aggregations %}
<button class="list-group-item list-group-more" @click="expandPanel('{{result.class_name}}-{{name}}', $event)">
<button class="list-group-item more" @click="expandPanel('{{result.class_name}}-{{name}}', $event)">
{{ _('More results…') }}
<span class="fa fa-chevron-right pull-right"></span>
</button>
<div id="facet-{{result.class_name}}-{{name}}-more" class="list-group collapse list-group-more">
{% for obj, count, selected in objects[nb_displayed_aggregations:] %}
<a href="{{ result.query.to_url(url, **{name: obj.id|string}) }}"
class="list-group-item">
<span class="badge">{{ count }}</span>
{{ result.query.facets[name].labelize(obj) }}
<span class="badge pull-right">{{ count }}</span>
</a>
{% endfor %}
</div>
Expand All @@ -169,8 +167,8 @@ <h3 class="panel-title">
{% for key, count, selected in ranges %}
<a href="{{ result.query.to_url(url, **{name: key}) }}"
class="list-group-item">
<span class="badge">{{ count }}</span>
{{ result.query.facets[name].labelize(key) }}
<span class="badge pull-right">{{ count }}</span>
</a>
{% endfor %}
{% endcall %}
Expand Down
2 changes: 1 addition & 1 deletion udata/templates/organization/sidebar-producer.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<br/>
{% endif %}
<a href="{{ url_for('organizations.show', org=organization) }}"
class="btn btn-sm btn-block btn-left btn-warning btn-primary">
class="btn btn-sm btn-block btn-left btn-warning">
<span class="fa fa-users"></span>
{{ _('View Profile') }}
</a>
Expand Down
2 changes: 1 addition & 1 deletion udata/templates/reuse/display.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ <h4 class="text-center">{{ reuse.owner.fullname }}</h4>

<a href="{{ url_for('users.show', user=reuse.owner) }}"
title="{{ _('more') }}"
class="btn btn-block btn-sm btn-left btn-warning btn-primary">
class="btn btn-block btn-sm btn-left btn-warning">
<span class="fa fa-user"></span>
{{ _('View Profile') }}
</a>
Expand Down
10 changes: 5 additions & 5 deletions udata/tests/api/test_organizations_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def test_list_org_datasets(self):
response = self.get(url_for('api.org_datasets', org=org))

self.assert200(response)
self.assertEqual(len(response.json), len(datasets))
self.assertEqual(len(response.json['data']), len(datasets))

def test_list_org_datasets_private(self):
'''Should include private datasets when member'''
Expand All @@ -556,7 +556,7 @@ def test_list_org_datasets_private(self):
response = self.get(url_for('api.org_datasets', org=org))

self.assert200(response)
self.assertEqual(len(response.json), len(datasets))
self.assertEqual(len(response.json['data']), len(datasets))

def test_list_org_datasets_hide_private(self):
'''Should not include private datasets when not member'''
Expand All @@ -567,18 +567,18 @@ def test_list_org_datasets_hide_private(self):
response = self.get(url_for('api.org_datasets', org=org))

self.assert200(response)
self.assertEqual(len(response.json), len(datasets))
self.assertEqual(len(response.json['data']), len(datasets))

def test_list_org_datasets_with_size(self):
'''Should list organization datasets'''
org = OrganizationFactory()
DatasetFactory.create_batch(3, organization=org)

response = self.get(
url_for('api.org_datasets', org=org), qs={'size': 2})
url_for('api.org_datasets', org=org), qs={'page_size': 2})

self.assert200(response)
self.assertEqual(len(response.json), 2)
self.assertEqual(len(response.json['data']), 2)


class OrganizationReusesAPITest(APITestCase):
Expand Down
4 changes: 2 additions & 2 deletions udata/translations/fr/LC_MESSAGES/udata.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: udata\n"
"Report-Msgid-Bugs-To: i18n@opendata.team\n"
"POT-Creation-Date: 2017-12-14 11:54+0100\n"
"PO-Revision-Date: 2017-12-14 13:41-0500\n"
"PO-Revision-Date: 2018-02-02 03:54-0500\n"
"Last-Translator: noirbizarre <noirbizarre@gmail.com>\n"
"Language: fr\n"
"Language-Team: French\n"
Expand Down Expand Up @@ -2236,7 +2236,7 @@ msgstr "Si vous lisez ceci, votre configuration fonctionne"
#: udata/templates/mail/security/reset_instructions.html:7
#, python-format
msgid "Someone has requested a password reset for your %(site)s account. If you didn't, please ignore this email."
msgstr "Quelqu'un a demandé une réinitialisation du mot de passe votre compte %(site)s. Si ce n'est pas vous, vueillez ignorer cet email."
msgstr "Quelqu'un a demandé une réinitialisation du mot de passe votre compte %(site)s. Si ce n'est pas vous, veuillez ignorer cet email."

#: udata/templates/mail/security/reset_instructions.html:10
msgid "To reset your password, please confirm your request through the link below:"
Expand Down

0 comments on commit 15d097d

Please sign in to comment.