summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-03-01 02:00:02 -0500
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-03-01 02:00:02 -0500
commitf2e66263f9b55e704cd89e444758fc65724cdff4 (patch)
tree962c802e5f9fb210ac90fd076aa40cdd151a646b
parenteb0b4b964e87c62541812235b8527a258b816158 (diff)
downloadaskbot-f2e66263f9b55e704cd89e444758fc65724cdff4.tar.gz
askbot-f2e66263f9b55e704cd89e444758fc65724cdff4.tar.bz2
askbot-f2e66263f9b55e704cd89e444758fc65724cdff4.zip
fixed small issues in the wilcard tag feature
-rw-r--r--askbot/models/question.py13
-rw-r--r--askbot/skins/default/media/js/tag_selector.js33
2 files changed, 39 insertions, 7 deletions
diff --git a/askbot/models/question.py b/askbot/models/question.py
index 6931dd3b..431505a3 100644
--- a/askbot/models/question.py
+++ b/askbot/models/question.py
@@ -212,10 +212,21 @@ class QuestionManager(models.Manager):
)
# get the list of interesting and ignored tags (interesting_tag_names, ignored_tag_names) = (None, None)
- if ignored_tags:
+ have_ignored_wildcards = (
+ askbot_settings.USE_WILDCARD_TAGS \
+ and request_user.ignored_tags != ''
+ )
+
+ if ignored_tags or have_ignored_wildcards:
if request_user.hide_ignored_questions:
#exclude ignored tags if the user wants to
qs = qs.exclude(tags__in=ignored_tags)
+ if have_ignored_wildcards:
+ ignored_wildcards = request_user.ignored_tags.split()
+ extra_ignored_tags = Tag.objects.get_by_wildcards(
+ ignored_wildcards
+ )
+ qs = qs.exclude(tags__in = extra_ignored_tags)
else:
#annotate questions tagged with ignored tags
#expensive query
diff --git a/askbot/skins/default/media/js/tag_selector.js b/askbot/skins/default/media/js/tag_selector.js
index 9ee8a6e7..979e3c3a 100644
--- a/askbot/skins/default/media/js/tag_selector.js
+++ b/askbot/skins/default/media/js/tag_selector.js
@@ -12,12 +12,16 @@ TagDetailBox.prototype.createDom = function(){
this._element = this.makeElement('div');
this._element.addClass('wildcard-tags');
this._headline = this.makeElement('p');
+ this._headline.html(gettext('Tag "<span></span>" matches:'));
this._element.append(this._headline);
- this._headline.html($.i18n._('Tag "<span></span>" matches:'));
this._tag_list_element = this.makeElement('ul');
this._tag_list_element.addClass('tags');
this._element.append(this._tag_list_element);
-}
+ this._footer = this.makeElement('p');
+ this._footer.css('clear', 'left');
+ this._element.append(this._footer);
+ this._element.hide();
+};
TagDetailBox.prototype.belongsTo = function(wildcard){
return (this.wildcard === wildcard);
@@ -41,37 +45,54 @@ TagDetailBox.prototype.clear = function(){
};
TagDetailBox.prototype.loadTags = function(wildcard, callback){
+ var me = this;
$.ajax({
type: 'GET',
dataType: 'json',
cache: false,
url: askbot['urls']['get_tags_by_wildcard'],
data: { wildcard: wildcard },
- success: callback
+ success: callback,
+ failure: function(){ me._loading = false; }
});
};
TagDetailBox.prototype.renderFor = function(wildcard){
var me = this;
+ if (this._loading === true){
+ return;
+ }
+ this._loading = true;
this.loadTags(
wildcard,
function(data, text_status, xhr){
me._tag_names = data['tag_names'];
if (data['tag_count'] > 0){
- me._element.show();
- me._headline.find('span').html(wildcard.replace(/\*$/, '&#10045;'));
+ var wildcard_display = wildcard.replace(/\*$/, '&#10045;');
+ me._headline.find('span').html(wildcard_display);
$.each(me._tag_names, function(idx, name){
var tag = new Tag();
tag.setName(name);
- tag.setLinkable(false);
+ //tag.setLinkable(false);
me._tags.push(tag);
me._tag_list_element.append(tag.getElement());
});
me._is_blank = false;
me.wildcard = wildcard;
+ var tag_count = data['tag_count'];
+ if (tag_count > 10){
+ var fmts = gettext('and %s more, not shown...');
+ var footer_text = interpolate(fmts, [tag_count - 10]);
+ me._footer.html(footer_text);
+ me._footer.show();
+ } else {
+ me._footer.hide();
+ }
+ me._element.show();
} else {
me.clear();
}
+ me._loading = false;
}
);
}