Skip to content

Commit

Permalink
Merge pull request #31 from davidbgk/30-fix-followers-displayed
Browse files Browse the repository at this point in the history
Fix the number of followers displayed on org pages, fix #30
  • Loading branch information
noirbizarre committed May 26, 2015
2 parents 8c9cab2 + 5d244cd commit 9471dda
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
3 changes: 1 addition & 2 deletions udata/core/organization/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def can(self, *args, **kwargs):
@blueprint.route('/<org:org>/', endpoint='show')
class OrganizationDetailView(OrgView, DetailView):
template_name = 'organization/display.html'
nb_followers = 16
page_size = 9

def get_context(self):
Expand All @@ -94,7 +93,7 @@ def get_context(self):
'reuses': reuses.paginate(1, self.page_size),
'datasets': datasets.paginate(1, self.page_size),
'supplied_datasets': supplied_datasets[:self.page_size],
'followers': followers[:self.nb_followers],
'followers': followers,
'can_edit': can_edit,
'can_view': can_view,
'private_reuses': list(Reuse.objects(organization=self.object).hidden()) if can_view else [],
Expand Down
8 changes: 4 additions & 4 deletions udata/static/js/dataset/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ define([
// Prevent default click on link
$this.find('a[itemprop="url"]').click(function(e) {
e.preventDefault();
})
});

// Ensure toolbar links does not interfere
$this.find('.tools a').click(function(e) {
e.stopPropagation();
})
});

// Display detailled informations in a modal
$this.click(function() {
Expand Down Expand Up @@ -137,7 +137,7 @@ define([
} else if ($el.data('zones')) {
$.get($el.data('zones'), function(data) {
loadJson(map, layer, data);
})
});
}
}

Expand Down Expand Up @@ -170,5 +170,5 @@ define([
prepare_resources();
fetch_reuses();
}
}
};
});
14 changes: 12 additions & 2 deletions udata/static/js/organization/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ define([
return false;
});


function displayFollowers(e) {
e.preventDefault();
var $parent = $(this).parent();
$parent.siblings('.col-md-4').removeClass('hidden');
$parent.remove();
}
$('.display-followers').click(displayFollowers);

return {
start: function() {
log.debug('Organization display page');
Expand All @@ -61,8 +70,9 @@ define([
$('a[href="' + location.hash + '"]').tab('show');
}
$('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
return location.hash = $(e.target).attr('href').substr(1);
e.preventDefault();
location.hash = $(e.target).attr('href').substr(1);
});
}
}
};
});
14 changes: 12 additions & 2 deletions udata/templates/organization/display.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,20 @@ <h1>
<div id="followers" class="tab-pane">
<div class="row card-list">
{% for follow in followers %}
<div class="col-md-4">
{% include theme('follow/follower-card.html') %}
<div class="col-md-4{% if loop.index > 15 %} hidden{% endif %}">
{% include theme('follow/follower-card.html') %}
</div>
{% endfor %}
{% if followers|length > 15 %}
<div class="clearfix"></div>
<p class="text-center">
<a class="btn btn-default display-followers"
href="#">
<span class="glyphicon glyphicon-list" ></span>
{{ _('Display all followers') }}
</a>
</p>
{% endif %}
</div>
</div>
{% endif %}
Expand Down

0 comments on commit 9471dda

Please sign in to comment.