summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x.gitignore1
-rw-r--r--askbot/deps/django_authopenid/ldap_auth.py2
-rw-r--r--askbot/deps/django_authopenid/views.py2
-rw-r--r--askbot/management/commands/delete_unused_tags.py18
-rw-r--r--askbot/management/commands/rename_tags_id.py16
-rw-r--r--askbot/management/commands/sample_command.py6
-rw-r--r--askbot/models/__init__.py35
-rw-r--r--askbot/models/question.py7
-rw-r--r--askbot/skins/default/templates/help.html28
-rw-r--r--askbot/skins/default/templates/main_page/javascript.html21
-rw-r--r--askbot/skins/default/templates/main_page/tag_search.html1
-rw-r--r--askbot/skins/default/templates/meta/bottom_scripts.html36
-rw-r--r--askbot/views/users.py8
13 files changed, 118 insertions, 63 deletions
diff --git a/.gitignore b/.gitignore
index 08e42e57..425fd569 100755
--- a/.gitignore
+++ b/.gitignore
@@ -48,3 +48,4 @@ recaptcha
/.ve
/db.sq3
*.DS_Store
+htmlcov
diff --git a/askbot/deps/django_authopenid/ldap_auth.py b/askbot/deps/django_authopenid/ldap_auth.py
index 5e650714..a633aa3b 100644
--- a/askbot/deps/django_authopenid/ldap_auth.py
+++ b/askbot/deps/django_authopenid/ldap_auth.py
@@ -176,7 +176,7 @@ def ldap_create_user_default(user_info):
"""
# create new user in local db
user = User()
- user.username = user_info['ldap_username']
+ user.username = user_info.get('django_username', user_info['ldap_username'])
user.set_unusable_password()
user.first_name = user_info['first_name']
user.last_name = user_info['last_name']
diff --git a/askbot/deps/django_authopenid/views.py b/askbot/deps/django_authopenid/views.py
index ba208b85..5498c792 100644
--- a/askbot/deps/django_authopenid/views.py
+++ b/askbot/deps/django_authopenid/views.py
@@ -920,7 +920,7 @@ def register(request, login_provider_name=None, user_identifier=None):
user_info = request.session['ldap_user_info']
#we take this info from the user input where
#they can override the default provided by LDAP
- user_info['ldap_username'] = username
+ user_info['django_username'] = username
user_info['email'] = email
user = ldap_create_user(user_info).user
del request.session['ldap_user_info']
diff --git a/askbot/management/commands/delete_unused_tags.py b/askbot/management/commands/delete_unused_tags.py
index 9b7c3c1b..bc0b7d69 100644
--- a/askbot/management/commands/delete_unused_tags.py
+++ b/askbot/management/commands/delete_unused_tags.py
@@ -1,26 +1,28 @@
from django.core.management.base import NoArgsCommand
from django.db import transaction
from askbot import models
-from askbot.utils import console
+from askbot.utils.console import ProgressBar
+from askbot.conf import settings as askbot_settings
import sys
class Command(NoArgsCommand):
@transaction.commit_manually
def handle_noargs(self, **options):
tags = models.Tag.objects.all()
- count = 0
- print "Searching for unused tags:",
+ message = 'Searching for unused tags:'
total = tags.count()
+ tags = tags.iterator()
deleted_tags = list()
- for tag in tags:
+ for tag in ProgressBar(tags, total, message):
+ if tag.name == askbot_settings.GLOBAL_GROUP_NAME:#todo: temporary
+ continue
+ if tag.name.startswith('_internal_'):
+ continue
+
if not tag.threads.exists():
deleted_tags.append(tag.name)
tag.delete()
transaction.commit()
- count += 1
- progress = 100*float(count)/float(total)
- console.print_progress('%6.2f%%', progress)
- print '%6.2f%%' % 100
if deleted_tags:
found_count = len(deleted_tags)
diff --git a/askbot/management/commands/rename_tags_id.py b/askbot/management/commands/rename_tags_id.py
index 90dc2916..f6fe05ae 100644
--- a/askbot/management/commands/rename_tags_id.py
+++ b/askbot/management/commands/rename_tags_id.py
@@ -27,8 +27,8 @@ def get_similar_tags_from_strings(tag_strings, tag_name):
"""returns a list of tags, similar to tag_name from a set of questions"""
grab_pattern = r'\b([%(ch)s]*%(nm)s[%(ch)s]*)\b' % \
- {'ch': const.TAG_CHARS, 'nm': from_tag.name}
- grab_re = re.compile(grab_pattern, RE.IGNORECASE)
+ {'ch': const.TAG_CHARS, 'nm': tag_name}
+ grab_re = re.compile(grab_pattern, re.IGNORECASE)
similar_tags = set()
for tag_string in tag_strings:
@@ -103,9 +103,9 @@ rename_tags, but using tag id's
to_tags = get_tags_by_ids(to_tag_ids)
admin = get_admin(options['user_id'])
- questions = models.Question.objects.all()
+ questions = models.Thread.objects.all()
for from_tag in from_tags:
- questions = questions.filter(tags = from_tag)
+ questions = questions.filter(tags=from_tag)
#print some feedback here and give a chance to bail out
question_count = questions.count()
@@ -121,7 +121,7 @@ or repost a bug, if that does not help"""
print "%d questions match." % question_count
print "First 10 are:"
for question in questions[:10]:
- print '* %s' % question.thread.title.strip()
+ print '* %s' % question.title.strip()
from_tag_names = format_tag_name_list(from_tags)
to_tag_names = format_tag_name_list(to_tags)
@@ -145,7 +145,7 @@ or repost a bug, if that does not help"""
tag_names.difference_update(from_tag_names)
admin.retag_question(
- question = question,
+ question = question._question_post(),
tags = u' '.join(tag_names),
#silent = True #do we want to timestamp activity on question
)
@@ -159,8 +159,8 @@ or repost a bug, if that does not help"""
#may need to run assertions on that there are
#print 'Searching for similar tags...',
- #leftover_questions = models.Question.objects.filter(
- # icontains = from_tag.name
+ #leftover_questions = models.Thread.objects.filter(
+ # icontains=from_tag.name
# )
#if leftover_questions.count() > 0:
# tag_strings = leftover_questions.values_list('tagnames', flat=True)
diff --git a/askbot/management/commands/sample_command.py b/askbot/management/commands/sample_command.py
index bcdcb58e..40debe63 100644
--- a/askbot/management/commands/sample_command.py
+++ b/askbot/management/commands/sample_command.py
@@ -1,7 +1,7 @@
from django.core.management.base import NoArgsCommand
-from askbot.models import Comment
+from askbot.models import Post
class Command(NoArgsCommand):
def handle_noargs(self, **options):
- objs = Comment.objects.all()
- print objs \ No newline at end of file
+ objs = Post.objects.all()
+ print objs
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py
index e8702ba1..418a5dba 100644
--- a/askbot/models/__init__.py
+++ b/askbot/models/__init__.py
@@ -14,6 +14,7 @@ import datetime
import hashlib
import logging
import urllib
+import uuid
from django.core.urlresolvers import reverse, NoReverseMatch
from django.db.models import signals as django_signals
from django.template import Context
@@ -3058,6 +3059,15 @@ def send_instant_notifications_about_activity_in_post(
origin_post,
update_activity.activity_type
)
+
+ logger = logging.getLogger()
+ if logger.getEffectiveLevel() <= logging.DEBUG:
+ log_id = uuid.uuid1()
+ message = 'email-alert %s, logId=%s' % (post.get_absolute_url(), log_id)
+ logger.debug(message)
+ else:
+ log_id = None
+
#send email for all recipients
for user in recipients:
@@ -3077,14 +3087,23 @@ def send_instant_notifications_about_activity_in_post(
)
headers['Reply-To'] = reply_address
- mail.send_mail(
- subject_line = subject_line,
- body_text = body_text,
- recipient_list = [user.email],
- related_object = origin_post,
- activity_type = const.TYPE_ACTIVITY_EMAIL_UPDATE_SENT,
- headers = headers
- )
+ try:
+ mail.send_mail(
+ subject_line=subject_line,
+ body_text=body_text,
+ recipient_list=[user.email],
+ related_object=origin_post,
+ activity_type=const.TYPE_ACTIVITY_EMAIL_UPDATE_SENT,
+ headers=headers,
+ raise_on_failure=True
+ )
+ except askbot_exceptions.EmailNotSent, error:
+ logger.debug(
+ '%s, error=%s, logId=%s' % (user.email, error, log_id)
+ )
+ else:
+ logger.debug('success %s, logId=%s' % (user.email, log_id))
+
def notify_author_of_published_revision(
revision = None, was_approved = None, **kwargs
diff --git a/askbot/models/question.py b/askbot/models/question.py
index 354655f3..98a38c90 100644
--- a/askbot/models/question.py
+++ b/askbot/models/question.py
@@ -826,9 +826,10 @@ class Thread(models.Model):
if self.has_accepted_answer() and self.accepted_answer.deleted == False:
#Put the accepted answer to front
#the second check is for the case when accepted answer is deleted
- accepted_answer = post_map[self.accepted_answer_id]
- answers.remove(accepted_answer)
- answers.insert(0, accepted_answer)
+ if self.accepted_answer_id in post_map:
+ accepted_answer = post_map[self.accepted_answer_id]
+ answers.remove(accepted_answer)
+ answers.insert(0, accepted_answer)
#if user is not an inquirer, and thread is moderated,
#put published answers first
diff --git a/askbot/skins/default/templates/help.html b/askbot/skins/default/templates/help.html
index 204fc086..6fdecd51 100644
--- a/askbot/skins/default/templates/help.html
+++ b/askbot/skins/default/templates/help.html
@@ -12,6 +12,8 @@
<p>
{% trans %}Thank you for using {{app_name}}, here is how it works.{% endtrans %}
</p>
+<a name="content"></a>
+<h2>{% trans %}How questions, answers and comments work{% endtrans %}</h2>
<p>
{% trans %}This site is for asking and answering questions, not for open-ended discussions.{% endtrans %}
{% trans %}We encourage everyone to use “question” space for asking and “answer” for answering.{% endtrans %}
@@ -20,13 +22,35 @@
{% trans %}Despite that, each question and answer can be commented –
the comments are good for the limited discussions.{% endtrans %}
</p>
+<a name="search"></a>
+<h2>{% trans %}Please search before asking your questions{% endtrans %}</h2>
+<p>{% trans %}Type your question in the search bar and see whether a similar question has been asked before{% endtrans %}.
+</p>
+<p>{% trans %}Search has advanced capabilities:{% endtrans %}</p>
+<ul>
+ <li>{% trans %}to search in title - enter [title: your text]{% endtrans %}</li>
+ <li>{% trans %}to search by tags - enter [tag: sometag] or #sometag{% endtrans %}</li>
+ <li>{% trans %}to search by user - enter [user: somename] or @somename or @"some name"{% endtrans %}</li>
+</ul>
+<p>{% trans %}In addition, it is possible to click on tags to add them to the search query.{% endtrans %}
+{% if settings.TAG_SEARCH_INPUT_ENABLED %}
+ {% trans %}Finally, a separate tag search box is available in the side bar of the main page, where the search tags can be entered as well{% endtrans %}
+{% endif %}
+</p>
+<p>{% trans %}<em>Important!!!</em> All search terms are combined with a logical "AND" expression - to narrow the search by adding new terms.{% endtrans %}</p>
+<a name="voting"></a>
+<h2>{% trans %}Voting{% endtrans %}</h2>
<p>
{% trans %}Voting in {{app_name}} helps to select best answers and thank most helpful users.{% endtrans %}
</p>
+<p>
{% trans %}Please vote when you find helpful information,
it really helps the {{app_name}} community.{% endtrans %}
-
- {% trans %}Besides, you can @mention users anywhere in the text to point their attention,
+</p>
+<a name="other"></a>
+<h2>{% trans %}Other topics{% endtrans %}</h2>
+<p>
+ {% trans %}You can @mention users anywhere in the text to point their attention,
follow users and conversations and report inappropriate content by flagging it.{% endtrans %}
</p>
<p>{% trans %}Enjoy.{% endtrans %}</p>
diff --git a/askbot/skins/default/templates/main_page/javascript.html b/askbot/skins/default/templates/main_page/javascript.html
index 10f8ede2..f1e0fb44 100644
--- a/askbot/skins/default/templates/main_page/javascript.html
+++ b/askbot/skins/default/templates/main_page/javascript.html
@@ -1,4 +1,5 @@
<script type="text/javascript">
+ /*<![CDATA[*/
var sortMethod = '{{sort}}';
var showSortByRelevance = {% if show_sort_by_relevance %}true{% else %}false{% endif %};
var minSearchWordLength = {{settings.MIN_SEARCH_WORD_LENGTH}};
@@ -22,6 +23,26 @@
askbot['urls']['set_tag_filter_strategy'] = '{% url "set_tag_filter_strategy" %}';
askbot['urls']['questions'] = '{% url "questions" %}';
askbot['urls']['question_url_template'] = scriptUrl + '{{'question/'|transurl}}{{ "{{QuestionID}}/" }}';
+
+ if (Modernizr.history) {
+ // history management works!
+ } else {
+ // no history support :(
+ //hash = unescape(window.location.hash).replace('#','').split("?")[0]
+ {# todo: fix this evil code!!! #}
+ var hash = History.unescapeHash(window.location.hash).replace('#','').split("?")[0];
+ var questions_url = askbot['urls']['questions'];
+ if (hash.substring(0, questions_url.length) === questions_url) {
+ var url = hash;
+ } else {
+ var url = questions_url + hash;
+ }
+ if (hash !== '' && hash !== undefined && url !== undefined){
+ {# was this causing strange redirects in IE??? #}
+ window.location = 'http://' + window.location.host + url;
+ }
+ }
+ /*]]>*/
</script>
<script type='text/javascript' src='{{"/js/editor.js"|media}}'></script>
{% if request.user.is_authenticated() %}
diff --git a/askbot/skins/default/templates/main_page/tag_search.html b/askbot/skins/default/templates/main_page/tag_search.html
index 45f12b2f..0d81bf4e 100644
--- a/askbot/skins/default/templates/main_page/tag_search.html
+++ b/askbot/skins/default/templates/main_page/tag_search.html
@@ -1,5 +1,6 @@
<div id="tagSearch" class="box">
<h2>{% trans %}Tag search{% endtrans %}</h2>
+ <label for="ab-tag-search">{% trans %}Please note that tag search is case sensitive!{% endtrans %}</label>
<div class="inputs">
<input id="ab-tag-search" autocomplete="off" type="text"/>
<input id="ab-tag-search-add" type="submit" value="{% trans %}search{% endtrans %}"/>
diff --git a/askbot/skins/default/templates/meta/bottom_scripts.html b/askbot/skins/default/templates/meta/bottom_scripts.html
index 09970468..b3fcd815 100644
--- a/askbot/skins/default/templates/meta/bottom_scripts.html
+++ b/askbot/skins/default/templates/meta/bottom_scripts.html
@@ -3,15 +3,15 @@
main template "base.html"
#}
<div id="no-javascript">
- <noscript class="noscript">
- {% trans app_name = settings.APP_SHORT_NAME %}Please note: {{app_name}} requires javascript to work properly, please enable javascript in your browser, <a href="{{noscript_url}}">here is how</a>{% endtrans %}
- </noscript>
- <script type="text/javascript">
+ <noscript class="noscript">
+ {% trans app_name = settings.APP_SHORT_NAME %}Please note: {{app_name}} requires javascript to work properly, please enable javascript in your browser, <a href="{{noscript_url}}">here is how</a>{% endtrans %}
+ </noscript>
+ <script type="text/javascript">
//IE fix to hide the red margin
- var noscript = document.getElementsByTagName('noscript')[0];
- noscript.style.padding = '0px';
- noscript.style.backgroundColor = 'transparent';
- </script>
+ var noscript = document.getElementsByTagName('noscript')[0];
+ noscript.style.padding = '0px';
+ noscript.style.backgroundColor = 'transparent';
+ </script>
</div>
<script type="text/javascript">
var i18nLang = '{{settings.LANGUAGE_CODE}}';
@@ -51,26 +51,6 @@
<script type="text/javascript">
/*<![CDATA[*/
$(document).ready(function(){
- {% if active_tab == 'questions' %}
- if (Modernizr.history) {
- // history management works!
- } else {
- // no history support :(
- //hash = unescape(window.location.hash).replace('#','').split("?")[0]
- {# todo: fix this evil code!!! #}
- var hash = History.unescapeHash(window.location.hash).replace('#','').split("?")[0];
- var questions_url = askbot['urls']['questions'];
- if (hash.substring(0, questions_url.length) === questions_url) {
- var url = hash;
- } else {
- var url = questions_url + hash;
- }
- if (hash !== '' && hash !== undefined && url !== undefined){
- {# was this causing strange redirects in IE??? #}
- window.location = 'http://' + window.location.host + url;
- }
- }
- {% endif %}
// focus input on the search bar endcomment
{% if active_tab in ('users', 'questions', 'tags') %}
$('#keywords').focus();
diff --git a/askbot/views/users.py b/askbot/views/users.py
index 5bfece8b..b0b0cfbe 100644
--- a/askbot/views/users.py
+++ b/askbot/views/users.py
@@ -40,6 +40,7 @@ from askbot import exceptions
from askbot.models.badges import award_badges_signal
from askbot.models.tag import get_global_group
from askbot.models.tag import get_groups
+from askbot.models.tag import format_personal_group_name
from askbot.skins.loaders import render_into_skin
from askbot.search.state_manager import SearchState
from askbot.utils import url_utils
@@ -321,7 +322,12 @@ def edit_user(request, id):
set_new_email(user, new_email)
if askbot_settings.EDITABLE_SCREEN_NAME:
- user.username = sanitize_html(form.cleaned_data['username'])
+ new_username = sanitize_html(form.cleaned_data['username'])
+ if user.username != new_username:
+ group = user.get_personal_group()
+ user.username = new_username
+ group.name = format_personal_group_name(user)
+ group.save()
user.real_name = sanitize_html(form.cleaned_data['realname'])
user.website = sanitize_html(form.cleaned_data['website'])