diff options
-rw-r--r-- | askbot/askbot | 0 | ||||
-rw-r--r-- | askbot/deps/django_authopenid/util.py | 5 | ||||
-rw-r--r-- | askbot/management/commands/find_bodyless_questions.py | 44 | ||||
-rw-r--r-- | askbot/management/commands/init_postgresql_full_text_search.py | 8 | ||||
-rw-r--r-- | askbot/models/question.py | 2 |
5 files changed, 54 insertions, 5 deletions
diff --git a/askbot/askbot b/askbot/askbot deleted file mode 100644 index e69de29b..00000000 --- a/askbot/askbot +++ /dev/null diff --git a/askbot/deps/django_authopenid/util.py b/askbot/deps/django_authopenid/util.py index 9f02050d..8d37b9e5 100644 --- a/askbot/deps/django_authopenid/util.py +++ b/askbot/deps/django_authopenid/util.py @@ -127,9 +127,6 @@ class DjangoOpenIDStore(OpenIDStore): return False - def cleanupNonce(self): - Nonce.objects.filter(timestamp<int(time.time()) - nonce.SKEW).delete() - def cleanupAssociations(self): Association.objects.extra(where=['issued + lifetimeint<(%s)' % time.time()]).delete() @@ -414,7 +411,7 @@ def get_enabled_major_login_providers(): token = oauth.Token(data['oauth_token'], data['oauth_token_secret']) client = oauth.Client(consumer, token=token) url = 'https://identi.ca/api/account/verify_credentials.json' - content = urllib2.urlopen(url).read() + response, content = client.request(url, 'GET') json = simplejson.loads(content) return json['id'] if askbot_settings.IDENTICA_KEY and askbot_settings.IDENTICA_SECRET: diff --git a/askbot/management/commands/find_bodyless_questions.py b/askbot/management/commands/find_bodyless_questions.py new file mode 100644 index 00000000..75312620 --- /dev/null +++ b/askbot/management/commands/find_bodyless_questions.py @@ -0,0 +1,44 @@ +"""this management commands will fix corrupted posts +that do not have revisions by creating a fake initial revision +based on the content stored in the post itself +""" +from django.core.management.base import NoArgsCommand +from askbot import models +from askbot import const +from askbot.utils.console import ProgressBar + +def print_results(items): + template = 'id=%d, title=%s' + for thread in items: + print template % (thread.id, thread.title.encode('utf8')) + +class Command(NoArgsCommand): + """Command class for "fix_bodyless_questions" + """ + def handle(self, *arguments, **options): + """function that handles the command job + """ + threads = models.Thread.objects.all() + count = threads.count() + message = 'Looking for body-less questions' + bodyless = list() + multi_body = list() + for thread in ProgressBar(threads.iterator(), count, message): + body_count = models.Post.objects.filter( + thread=thread, + post_type='question', + ).count() + if body_count == 0: + bodyless.append(thread) + elif body_count > 1: + multi_body.append(thread) + + if len(bodyless) + len(multi_body) == 0: + print 'None found.' + else: + if len(bodyless): + print '\nQuestions without body text:' + print_results(bodyless) + if len(multi_body): + print '\nQuestions with >1 instances of body text' + print_results(multi_body) diff --git a/askbot/management/commands/init_postgresql_full_text_search.py b/askbot/management/commands/init_postgresql_full_text_search.py index cd709be0..3cf4b03c 100644 --- a/askbot/management/commands/init_postgresql_full_text_search.py +++ b/askbot/management/commands/init_postgresql_full_text_search.py @@ -14,3 +14,11 @@ class Command(NoArgsCommand): 'thread_and_post_models_01162012.plsql' ) setup_full_text_search(script_path) + + script_path = os.path.join( + askbot.get_install_directory(), + 'search', + 'postgresql', + 'user_profile_search_16102012.plsql' + ) + setup_full_text_search(script_path) diff --git a/askbot/models/question.py b/askbot/models/question.py index 44653dd0..f94265b0 100644 --- a/askbot/models/question.py +++ b/askbot/models/question.py @@ -30,7 +30,7 @@ from askbot.models.user import Group, PERSONAL_GROUP_NAME_PREFIX from askbot.models import signals from askbot import const from askbot.utils.lists import LazyList -from askbot.utils import mysql +from askbot.search import mysql from askbot.utils.slug import slugify from askbot.skins.loaders import get_template #jinja2 template loading enviroment from askbot.search.state_manager import DummySearchState |