Free assets: Assets should not be advertised as free if the user is a logged in subscriber.
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
/* How many nodes to load initially, and when clicked on the 'Load Next' link. */
|
/* How many nodes to load initially, and when clicked on the 'Load Next' link. */
|
||||||
const LOAD_INITIAL_COUNT = 8;
|
const LOAD_INITIAL_COUNT = 8;
|
||||||
const LOAD_NEXT_COUNT = 8;
|
const LOAD_NEXT_COUNT = 8;
|
||||||
|
var mark_if_public = true;
|
||||||
|
|
||||||
/* Renders a node as an asset card, returns a jQuery object. */
|
/* Renders a node as an asset card, returns a jQuery object. */
|
||||||
function renderAsset(node) {
|
function renderAsset(node) {
|
||||||
@@ -97,7 +98,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 'Free' ribbon for public assets. */
|
/* 'Free' ribbon for public assets. */
|
||||||
if (node.permissions && node.permissions.world){
|
if (mark_if_public && node.permissions && node.permissions.world){
|
||||||
card.addClass('free');
|
card.addClass('free');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +124,8 @@
|
|||||||
load_next.remove();
|
load_next.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
$.fn.loadTaggedAssets = function(LOAD_INITIAL_COUNT, LOAD_NEXT_COUNT) {
|
$.fn.loadTaggedAssets = function(LOAD_INITIAL_COUNT, LOAD_NEXT_COUNT, has_subscription) {
|
||||||
|
mark_if_public = !has_subscription;
|
||||||
this.each(function(index, card_deck_element) {
|
this.each(function(index, card_deck_element) {
|
||||||
// TODO(Sybren): show a 'loading' animation.
|
// TODO(Sybren): show a 'loading' animation.
|
||||||
$.get('/api/nodes/tagged/' + card_deck_element.dataset.assetTag)
|
$.get('/api/nodes/tagged/' + card_deck_element.dataset.assetTag)
|
||||||
|
@@ -23,7 +23,8 @@ script(src="{{ url_for('static_cloud', filename='assets/js/tagged_assets.min.js'
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
$(function() {
|
$(function() {
|
||||||
$('.js-asset-list').loadTaggedAssets(8, 8);
|
let is_subscriber = {{ current_user.has_cap('subscriber')|string|lower }};
|
||||||
|
$('.js-asset-list').loadTaggedAssets(8, 8, is_subscriber);
|
||||||
});
|
});
|
||||||
| {% endblock %}
|
| {% endblock %}
|
||||||
| {% block body %}
|
| {% block body %}
|
||||||
|
Reference in New Issue
Block a user