diff options
author | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-05-15 15:25:07 -0600 |
---|---|---|
committer | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-05-15 15:25:07 -0600 |
commit | fe2bd64fcf4767c3801af4451e347365d288b15d (patch) | |
tree | b61e513ee6bc0ff06a4a85e4d8f02f42941121b3 /askbot/management | |
parent | 32a4a5ddf93f2bc605706ecc3eafbc63dc923acf (diff) | |
parent | 4cf3ec3998b1f067a7f0c76eae4a90c274024986 (diff) | |
download | askbot-fe2bd64fcf4767c3801af4451e347365d288b15d.tar.gz askbot-fe2bd64fcf4767c3801af4451e347365d288b15d.tar.bz2 askbot-fe2bd64fcf4767c3801af4451e347365d288b15d.zip |
Merge branch 'master' into livesettings_fix
Diffstat (limited to 'askbot/management')
-rw-r--r-- | askbot/management/commands/get_tag_stats.py | 50 | ||||
-rw-r--r-- | askbot/management/commands/send_email_alerts.py | 3 |
2 files changed, 43 insertions, 10 deletions
diff --git a/askbot/management/commands/get_tag_stats.py b/askbot/management/commands/get_tag_stats.py index c30643b3..b065a6a1 100644 --- a/askbot/management/commands/get_tag_stats.py +++ b/askbot/management/commands/get_tag_stats.py @@ -2,6 +2,7 @@ import sys import optparse from django.core.management.base import BaseCommand, CommandError from askbot import models +from askbot import const def get_tag_lines(tag_marks, width = 25): output = list() @@ -120,15 +121,30 @@ class Command(BaseCommand): for bad_tag in user.ignored_tags.split(): ignored_tags.append(bad_tag) + subscribed_tags = list() + subscribed_tags.extend( + tag_marks.filter( + reason='subscribed' + ).values_list( + 'tag__name', flat = True + ) + ) + + for subscribed_tag in user.subscribed_tags.split(): + subscribed_tags.append(subscribed_tag) + followed_count = len(followed_tags) ignored_count = len(ignored_tags) - if followed_count == 0 and ignored_count == 0 and print_empty == False: + subscribed_count = len(subscribed_tags) + total_count = followed_count + ignored_count + subscribed_count + if total_count == 0 and print_empty == False: continue if item_count == 0: - print '%-28s %25s %25s' % ('User (id)', 'Interesting tags', 'Ignored tags') - print '%-28s %25s %25s' % ('=========', '================', '============') + print '%-28s %25s %25s %25s' % ('User (id)', 'Interesting tags', 'Ignored tags', 'Subscribed tags') + print '%-28s %25s %25s %25s' % ('=========', '================', '============', '===============') followed_lines = get_tag_lines(followed_tags, width = 25) ignored_lines = get_tag_lines(ignored_tags, width = 25) + subscribed_lines = get_tag_lines(subscribed_tags, width = 25) follow = '*' if user.email_tag_filter_strategy == const.INCLUDE_INTERESTING: @@ -138,7 +154,8 @@ class Command(BaseCommand): [user_string,], followed_lines, ignored_lines, - format_string = '%-28s %25s %25s' + subscribed_lines, + format_string = '%-28s %25s %25s %25s' ) item_count += 1 for line in output_lines: @@ -163,16 +180,23 @@ class Command(BaseCommand): interesting_tags = models.Tag.objects.get_by_wildcards(wk) for tag in interesting_tags: if tag.name not in wild: - wild[tag.name] = [0, 0] + wild[tag.name] = [0, 0, 0] wild[tag.name][0] += 1 wk = user.ignored_tags.strip().split() ignored_tags = models.Tag.objects.get_by_wildcards(wk) for tag in ignored_tags: if tag.name not in wild: - wild[tag.name] = [0, 0] + wild[tag.name] = [0, 0, 0] wild[tag.name][1] += 1 + wk = user.subscribed_tags.strip().split() + subscribed_tags = models.Tag.objects.get_by_wildcards(wk) + for tag in subscribed_tags: + if tag.name not in wild: + wild[tag.name] = [0, 0, 0] + wild[tag.name][2] += 1 + return wild def print_sub_counts(self, print_empty): @@ -185,6 +209,7 @@ class Command(BaseCommand): for tag in tags: wild_follow = 0 wild_ignore = 0 + wild_sub = 0 if tag.name in wild_tags: (wild_follow, wild_ignore) = wild_tags[tag.name] @@ -193,17 +218,22 @@ class Command(BaseCommand): + wild_follow ignore_count = tag_marks.filter(reason='bad').count() \ + wild_ignore + subscribe_count = tag_marks.filter(reason='subscribe').count() \ + + wild_sub follow_str = '%d (%d)' % (follow_count, wild_follow) ignore_str = '%d (%d)' % (ignore_count, wild_ignore) + subscribe_str = '%d (%d)' % (subscribe_count, wild_sub) + counts = (11-len(subscribe_str)) * ' ' + subscribe_str + ' ' counts = (11-len(follow_str)) * ' ' + follow_str + ' ' counts += (11-len(ignore_str)) * ' ' + ignore_str - if follow_count + ignore_count == 0 and print_empty == False: + total_count = follow_count + ignore_count + subscribe_count + if total_count == 0 and print_empty == False: continue if item_count == 0: - print '%-32s %12s %12s' % ('', 'Interesting', 'Ignored ') - print '%-32s %12s %12s' % ('Tag name', 'Total(wild)', 'Total(wild)') - print '%-32s %12s %12s' % ('========', '===========', '===========') + print '%-32s %12s %12s %12s' % ('', 'Subscribed', 'Ignored ', 'Interesting') + print '%-32s %12s %12s %12s' % ('Tag name', 'Total(wild)', 'Total(wild)', 'Total(wild)') + print '%-32s %12s %12s %12s' % ('========', '===========', '===========', '===========') print '%-32s %s' % (tag.name, counts) item_count += 1 diff --git a/askbot/management/commands/send_email_alerts.py b/askbot/management/commands/send_email_alerts.py index 8002ecbf..b7624e21 100644 --- a/askbot/management/commands/send_email_alerts.py +++ b/askbot/management/commands/send_email_alerts.py @@ -136,6 +136,9 @@ class Command(NoArgsCommand): ).exclude( thread__closed=True ).order_by('-thread__last_activity_at') + + if askbot_settings.ENABLE_CONTENT_MODERATION: + base_qs = base_qs.filter(approved = True) #todo: for some reason filter on did not work as expected ~Q(viewed__who=user) | # Q(viewed__who=user,viewed__when__lt=F('thread__last_activity_at')) #returns way more questions than you might think it should |