Skip to content
This repository

Feature #89: Auto link key terms #15

Merged
merged 19 commits into from over 2 years ago

4 participants

Arun S A G Evgeny Fadeev Hrishi Rag Sagar.V
Arun S A G

Completed this feature http://askbot.org/en/question/607/auto-linking-of-key-terms. Please verify and merge

Hrishi

So we have to change the django.po file also right?

Evgeny Fadeev

Arun, thanks, I will look through the pull requests by Monday.

Arun S A G

Sure , Thanks!

Arun S A G

Hi,

You can test it by using the following pattern and link:

#rhbz\s(\d+) <- pattern

https://bugzilla.redhat.com/show_bug.cgi?id=\\1 <- Link

Evgeny Fadeev evgenyfadeev merged commit 10ff7a3 into from September 26, 2011
Evgeny Fadeev evgenyfadeev closed this September 26, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
1  MANIFEST.in
@@ -4,6 +4,7 @@ include LICENSE
4 4
 include AUTHORS
5 5
 include COPYING
6 6
 include README.rst
  7
+include askbot_requirements.txt
7 8
 recursive-include askbot *
8 9
 recursive-exclude askbot *.pyc
9 10
 recursive-exclude .git
2  askbot/__init__.py
@@ -9,7 +9,7 @@
9 9
 import sys
10 10
 import logging
11 11
 
12  
-VERSION = (0, 7, 22)
  12
+VERSION = (0, 7, 23)
13 13
 
14 14
 #necessary for interoperability of django and coffin
15 15
 try:
27  askbot/conf/markup.py
@@ -113,12 +113,12 @@ def regex_settings_validation(*args):
113 113
         'PATTERN',
114 114
         description=_('Regex to detect the pattern'),
115 115
         help_text=_(
116  
-            'Enter a valid regular expression to '
117  
-            'detect the pattern. For example to'
118  
-            'detect something like #rhbz 637402 '
119  
-            'use a regular expression like #rhbz\s(\d+)'
120  
-            'If you want to process multiple regex enter'
121  
-            ' them line by line'
  116
+            ' Enter valid regular expressions to'
  117
+            ' detect patterns. If you want to auto'
  118
+            ' link more than one key terms enter them'
  119
+            ' line by line. For example to'
  120
+            ' detect a bug pattern like #rhbz 637402'
  121
+            ' you will have use the following regex  #rhbz\s(\d+)'
122 122
             ),
123 123
         update_callback=regex_settings_validation,
124 124
         default = ''
@@ -131,13 +131,14 @@ def regex_settings_validation(*args):
131 131
         'AUTO_LINK_URL',
132 132
         description=_('URL for autolinking'),
133 133
         help_text=_(
134  
-            'Let us assume that to detect a pattern  #rhbz 637402'
135  
-            ' the regex is  #rhbz\s(\d+) '
136  
-            'then the autolink URL should be https://bugzilla.redhat.com/show_bug.cgi?id=\1'
137  
-            ' Where \1 is the saved match (bugid) from the regular expression'
138  
-            ' If you want to process multiple regex enter'
139  
-            ' them line by line. The URL in first line will be used to link the'
140  
-            ' pattern on the first line'
  134
+            ' The regex to  detect pattern  #rhbz 637402'
  135
+            ' is  #rhbz\s(\d+), If you want to auto link it to the actual bug'
  136
+            ' then the autolink URL should be entered here. Example URL can be'
  137
+            ' https://bugzilla.redhat.com/show_bug.cgi?id=\\1'
  138
+            ' where \\1 is the saved match (bugid) from the regular expression.'
  139
+            ' Multiple URLs should be entered in separate lines.'
  140
+            ' The URL entered in first line'
  141
+            ' will be used to auto link the first pattern or key term'
141 142
             ),
142 143
         default = ''
143 144
         )
19  askbot/conf/site_settings.py
@@ -5,8 +5,6 @@
5 5
 from askbot.conf.settings_wrapper import settings
6 6
 from askbot.deps import livesettings
7 7
 from django.utils.translation import ugettext as _
8  
-from django.utils.html import escape
9  
-from askbot import const
10 8
 
11 9
 QA_SITE_SETTINGS = livesettings.ConfigurationGroup(
12 10
                     'QA_SITE_SETTINGS',
@@ -74,19 +72,16 @@
74 72
 settings.register(
75 73
     livesettings.StringValue(
76 74
         QA_SITE_SETTINGS,
77  
-        'GREETING_URL',
78  
-        default='/' + _('faq/'),#cannot reverse url here, must be absolute also
79  
-        hidden=True,
  75
+        'GREETING_FOR_ANONYMOUS_USER',
  76
+        default='First time here? Check out the FAQ!',
  77
+        hidden=False,
80 78
         description=_(
81  
-                'Link shown in the greeting message '
  79
+                'Text shown in the greeting message '
82 80
                 'shown to the anonymous user'
83 81
             ),
84  
-        help_text=_('If you change this url from the default - '
85  
-                    'then you will also probably want to adjust translation of '
86  
-                    'the following string: ') + '"' 
87  
-                    + escape(const.GREETING_FOR_ANONYMOUS_USER + '"'
88  
-                    ' You can find this string in your locale django.po file'
89  
-                    )
  82
+        help_text=_(
  83
+                'Use HTML to format the message '
  84
+            )
90 85
     )
91 86
 )
92 87
 
1  askbot/const/__init__.py
@@ -263,6 +263,7 @@
263 263
     'facebook-apps': 'http://www.facebook.com/developers/createapp.php',
264 264
     'google-webmaster-tools': 'https://www.google.com/webmasters/tools/home',
265 265
     'identica-apps': 'http://identi.ca/settings/oauthapps',
  266
+    'noscript': 'https://www.google.com/support/bin/answer.py?answer=23852',
266 267
     'linkedin-apps': 'https://www.linkedin.com/secure/developer',
267 268
     'mathjax': 'http://www.mathjax.org/resources/docs/?installation.html',
268 269
     'recaptcha': 'http://google.com/recaptcha',
9  askbot/const/message_keys.py
@@ -9,14 +9,7 @@
9 9
 
10 10
 #NOTE: all strings must be explicitly put into this dictionary,
11 11
 #because you don't want to import _ from here with import *
12  
-__all__ = ['GREETING_FOR_ANONYMOUS_USER', ]
13  
-
14  
-#this variable is shown in settings, because
15  
-#the url within is configurable, the default is reverse('faq')
16  
-#if user changes url they will have to be able to fix the
17  
-#message translation too
18  
-GREETING_FOR_ANONYMOUS_USER = \
19  
-    _('First time here? Check out the <a href="%s">FAQ</a>!')
  12
+__all__ = []
20 13
 
21 14
 #messages loaded in the templates via direct _ calls
22 15
 _('most relevant questions')
4  askbot/context.py
@@ -5,6 +5,7 @@
5 5
 from django.conf import settings
6 6
 import askbot
7 7
 from askbot import api
  8
+from askbot import const
8 9
 from askbot.conf import settings as askbot_settings
9 10
 from askbot.skins.loaders import get_skin
10 11
 from askbot.utils import url_utils
@@ -22,5 +23,6 @@ def application_settings(request):
22 23
     return {
23 24
         'settings': my_settings,
24 25
         'skin': get_skin(request),
25  
-        'moderation_items': api.get_info_on_moderation_items(request.user)
  26
+        'moderation_items': api.get_info_on_moderation_items(request.user),
  27
+        'noscript_url': const.DEPENDENCY_URLS['noscript'],
26 28
     }
8  askbot/doc/source/changelog.rst
Source Rendered
... ...
@@ -1,16 +1,18 @@
1 1
 Changes in Askbot
2 2
 =================
3 3
 
4  
-Development version
  4
+0.7.23 (Current Version)
5 5
 -------------------
  6
+* Greeting for anonymuos users can be changed from live settings (Hrishi)
  7
+* Greeting for anonymous users is shown only once (Rag Sagar)
6 8
 * Added support for Akismet spam detection service (Adolfo Fitoria)
7 9
 * Added noscript message (Arun SAG)
8 10
 * Support for url shortening with TinyUrl on link sharing (Rtnpro)
9 11
 * Allowed logging in with password and email in the place of login name (Evgeny)
10 12
 * Added config settings allowing adjust license information (Evgeny)
11 13
 
12  
-0.7.22 (Current Version)
13  
-------------------------
  14
+0.7.22
  15
+------
14 16
 * Media resource revision is now incremented 
15 17
   automatically any time when media is updated (Adolfo Fitoria, Evgeny Fadeev)
16 18
 * First user automatically becomes site administrator (Adolfo Fitoria)
2  askbot/doc/source/contributors.rst
Source Rendered
@@ -15,10 +15,12 @@ Programming and documentation
15 15
 * Andy Knotts
16 16
 * Benoit Lavine (with Windriver Software, Inc.)
17 17
 * Jeff Madynski
  18
+* `Hrishi <https://github.com/stultus>`_
18 19
 * Andrei Mamoutkine
19 20
 * Ramiro Morales (with Machinalis)
20 21
 * `NoahY <https://github.com/NoahY>`_
21 22
 * `Gael Pasgrimaud <http://www.gawel.org/>`_ (bearstech)
  23
+* `Rag Sagar <https://github.com/ragsagar>`_
22 24
 * Alex Robbins (celery support)
23 25
 * `Tomasz Szynalski <http://antimoon.com>`_
24 26
 
31  askbot/forms.py
@@ -968,19 +968,26 @@ def __init__(self, *arg, **kwarg):
968 968
 
969 969
 class EditUserEmailFeedsForm(forms.Form):
970 970
     FORM_TO_MODEL_MAP = {
971  
-                    'all_questions':'q_all',
972  
-                    'asked_by_me':'q_ask',
973  
-                    'answered_by_me':'q_ans',
974  
-                    'individually_selected':'q_sel',
975  
-                    'mentions_and_comments':'m_and_c',
976  
-                }
  971
+        'all_questions':'q_all',
  972
+        'asked_by_me':'q_ask',
  973
+        'answered_by_me':'q_ans',
  974
+        'individually_selected':'q_sel',
  975
+        'mentions_and_comments':'m_and_c',
  976
+    }
977 977
     NO_EMAIL_INITIAL = {
978  
-                    'all_questions':'n',
979  
-                    'asked_by_me':'n',
980  
-                    'answered_by_me':'n',
981  
-                    'individually_selected':'n',
982  
-                    'mentions_and_comments':'n',
983  
-                }
  978
+        'all_questions':'n',
  979
+        'asked_by_me':'n',
  980
+        'answered_by_me':'n',
  981
+        'individually_selected':'n',
  982
+        'mentions_and_comments':'n',
  983
+    }
  984
+    INSTANT_EMAIL_INITIAL = {
  985
+        'all_questions':'i',
  986
+        'asked_by_me':'i',
  987
+        'answered_by_me':'i',
  988
+        'individually_selected':'i',
  989
+        'mentions_and_comments':'i',
  990
+    }
984 991
 
985 992
     asked_by_me = EmailFeedSettingField(
986 993
                             label=_('Asked by me')
10  askbot/locale/en/LC_MESSAGES/django.po
@@ -499,7 +499,7 @@ msgstr ""
499 499
 
500 500
 #: conf/email.py:22
501 501
 msgid "Prefix for the email subject line"
502  
-msgstr "Welcome to the Q&A forum"
  502
+msgstr ""
503 503
 
504 504
 #: conf/email.py:24
505 505
 msgid ""
@@ -1600,10 +1600,10 @@ msgstr ""
1600 1600
 msgid "bronze"
1601 1601
 msgstr ""
1602 1602
 
1603  
-#: const/message_keys.py:19
1604  
-#, python-format
1605  
-msgid "First time here? Check out the <a href=\"%s\">FAQ</a>!"
1606  
-msgstr ""
  1603
+
  1604
+
  1605
+
  1606
+
1607 1607
 
1608 1608
 #: const/message_keys.py:22 skins/default/templates/main_page/tab_bar.html:27
1609 1609
 msgid "most relevant questions"
42  askbot/middleware/anon_user.py
... ...
@@ -1,13 +1,25 @@
1  
-from django.utils.translation import ugettext as _
  1
+"""middleware that allows anonymous users
  2
+receive messages using the now deprecated `message_set()`
  3
+interface of the user objects.
  4
+
  5
+To allow anonymous users accept messages, a special
  6
+message manager is defined here, and :meth:`__deepcopy__()` method
  7
+added to the :class:`AnonymousUser` so that user could be pickled.
  8
+
  9
+Secondly, it sends greeting message to anonymous users.
  10
+"""
2 11
 from askbot.user_messages import create_message, get_and_delete_messages
3 12
 from askbot.conf import settings as askbot_settings
4  
-from askbot import const
5 13
 
6 14
 class AnonymousMessageManager(object):
  15
+    """message manager for the anonymous user"""
7 16
     def __init__(self, request):
8 17
         self.request = request
  18
+
9 19
     def create(self, message=''):
  20
+        """send message to anonymous user"""
10 21
         create_message(self.request, message)  
  22
+
11 23
     def get_and_delete(self):
12 24
         messages = get_and_delete_messages(self.request)
13 25
         return messages
@@ -19,18 +31,34 @@ def dummy_deepcopy(*arg):
19 31
     return None
20 32
 
21 33
 class ConnectToSessionMessagesMiddleware(object):
  34
+    """middleware that attaches messages to anonymous users"""
22 35
     def process_request(self, request):
23 36
         if not request.user.is_authenticated():
24 37
             #plug on deepcopy which may be called by django db "driver"
25  
-            request.user.__deepcopy__ = dummy_deepcopy 
  38
+            request.user.__deepcopy__ = dummy_deepcopy
26 39
             #here request is linked to anon user
27  
-            request.user.message_set = AnonymousMessageManager(request) 
  40
+            request.user.message_set = AnonymousMessageManager(request)
28 41
             request.user.get_and_delete_messages = \
29 42
                             request.user.message_set.get_and_delete
30 43
 
31 44
             #also set the first greeting one time per session only
32  
-            if 'greeting_set' not in request.session:
  45
+            if 'greeting_set' not in request.session and \
  46
+                    'askbot_visitor' not in request.COOKIES:
33 47
                 request.session['greeting_set'] = True
34  
-                msg = _(const.GREETING_FOR_ANONYMOUS_USER) \
35  
-                            % askbot_settings.GREETING_URL
  48
+                msg = askbot_settings.GREETING_FOR_ANONYMOUS_USER
36 49
                 request.user.message_set.create(message=msg)
  50
+
  51
+    def process_response(self, request, response):
  52
+        """ Adds the ``'askbot_visitor'``key to cookie if user ever authenticates so
  53
+        that the anonymous user message won't be shown. """
  54
+        if request.user.is_authenticated() and \
  55
+                'askbot_visitor' not in request.COOKIES :
  56
+            #import datetime
  57
+            #max_age = 365*24*60*60
  58
+            #expires = datetime.datetime.strftime\
  59
+            #        (datetime.datetime.utcnow() +
  60
+            #                datetime.timedelta(seconds=max_age),\
  61
+            #                        "%a, %d-%b-%Y %H:%M:%S GMT")
  62
+            response.set_cookie('askbot_visitor', False)
  63
+        return response
  64
+
3  askbot/models/__init__.py
@@ -1202,6 +1202,8 @@ def user_post_question(
1202 1202
                     is_anonymous = False,
1203 1203
                     timestamp = None
1204 1204
                 ):
  1205
+    """makes an assertion whether user can post the question
  1206
+    then posts it and returns the question object"""
1205 1207
 
1206 1208
     self.assert_can_post_question()
1207 1209
 
@@ -2230,7 +2232,6 @@ def format_instant_notification_email(
2230 2232
         'origin_post_title': origin_post.title,
2231 2233
         'user_subscriptions_url': user_subscriptions_url,
2232 2234
     }
2233  
-    subject_line = mail.prefix_the_subject_line(subject_line)
2234 2235
     return subject_line, template.render(Context(update_data))
2235 2236
 
2236 2237
 #todo: action
4  askbot/models/meta.py
@@ -159,9 +159,9 @@ def get_owner(self):
159 159
         return self.user
160 160
 
161 161
     def get_updated_activity_data(self, created = False):
162  
-        if self.content_object.__class__.__name__ == 'Question':
  162
+        if self.content_object.post_type == 'question':
163 163
             return const.TYPE_ACTIVITY_COMMENT_QUESTION, self
164  
-        elif self.content_object.__class__.__name__ == 'Answer':
  164
+        elif self.content_object.post_type == 'answer':
165 165
             return const.TYPE_ACTIVITY_COMMENT_ANSWER, self
166 166
 
167 167
     def get_response_receivers(self, exclude_list = None):
2  askbot/skins/default/templates/blocks/bottom_scripts.html
@@ -4,7 +4,7 @@
4 4
 #}
5 5
 <div id="no-javascript">
6 6
   <noscript class="noscript">
7  
-    {% trans app_name = settings.APP_SHORT_NAME %}Please note: {{app_name}} requires javascript to work properly, please enable javascript in your browser{% endtrans %}
  7
+    {% 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 %}
8 8
   </noscript>
9 9
 </div>
10 10
 <script type="text/javascript">
14  askbot/skins/default/templates/macros.html
@@ -246,9 +246,9 @@
246 246
     <div class='post-update-info'>
247 247
     {% if is_wiki %}
248 248
         <p>
249  
-           {%- if post.__class__.__name__ == 'Question' -%}
  249
+           {%- if post.post_type == 'question' -%}
250 250
                 {%- trans %}asked{% endtrans %}
251  
-           {% elif post.__class__.__name__ == 'Answer' %}
  251
+           {% elif post.post_type == 'answer' %}
252 252
                 {%- trans %}answered{% endtrans %}
253 253
            {% else %}
254 254
                 {%- trans %}posted{% endtrans %}
@@ -265,9 +265,9 @@
265 265
     {% else %}
266 266
         <p style="line-height:12px;">
267 267
             {# todo: access to class names needs to be removed here #}
268  
-            {% if post.__class__.__name__=="Question" %}
  268
+            {% if post.post_type == 'question' %}
269 269
                 {% trans %}asked{% endtrans %}
270  
-            {% elif post.__class__.name__=="Answer" %}
  270
+            {% elif post.post_type == 'answer' %}
271 271
                 {% trans %}answered{% endtrans %}
272 272
             {% else %}
273 273
                 {% trans %}posted{% endtrans %}
@@ -282,11 +282,11 @@
282 282
     {% endif %}
283 283
     </div>
284 284
 {% elif contributor_type=="last_updater" %}
285  
-    {% if post.__class__.__name__ in ('Question', 'Answer') %}
  285
+    {% if post.post_type in ('Question', 'Answer') %}
286 286
         {% set last_edited_at = post.last_edited_at %}
287 287
         {% set original_author = post.author %}
288 288
         {% set update_author = post.last_edited_by %}
289  
-    {% elif post.__class__.__name__ in ('QuestionRevision', 'AnswerRevision') %}
  289
+    {% elif post.post_type in ('QuestionRevision', 'AnswerRevision') %}
290 290
         {% set last_edited_at = post.revised_at %}
291 291
         {% set original_author = None %}{# fake value to force display widget in the revision views #}
292 292
         {% set update_author = post.author %}
@@ -295,7 +295,7 @@
295 295
     <div class='post-update-info'>
296 296
         <p style="line-height:12px;">
297 297
             <a 
298  
-        {% if post.__class__.__name__ == 'Question' %}
  298
+        {% if post.post_type == 'Question' %}
299 299
             href="{% url question_revisions post.id %}"
300 300
         {% else %}
301 301
             href="{% url answer_revisions post.id %}"
4  askbot/skins/default/templates/user_profile/user_inbox.html
@@ -70,7 +70,7 @@
70 70
                 <a style="font-size:12px" href="{{ response.user.get_absolute_url() }}">{{ response.user.username }}</a>
71 71
                 <a style="text-decoration:none;" href="{{ response.response_url }}">
72 72
                     {{ response.response_type }}
73  
-                    ({{ response.timestamp|diff_date(3, True) }}):<br/>
  73
+                    ({{ response.timestamp|diff_date(True) }}):<br/>
74 74
                     {{ response.response_snippet}}
75 75
                 </a>
76 76
                 </div>
@@ -84,7 +84,7 @@
84 84
                 <a style="font-size:12px" href="{{ nested_response.user.get_absolute_url() }}">{{ nested_response.user.username }}</a>
85 85
                 <a style="text-decoration:none;" href="{{ nested_response.response_url }}">
86 86
                     {{ nested_response.response_type }}
87  
-                    ({{ nested_response.timestamp|diff_date(3, True) }}):<br/>
  87
+                    ({{ nested_response.timestamp|diff_date(True) }}):<br/>
88 88
                     {{ nested_response.response_snippet}}
89 89
                 </a>
90 90
                 </div>
2  askbot/skins/default/templates/user_profile/user_recent.html
@@ -7,7 +7,7 @@
7 7
         <div style="padding-top:5px;font-size:13px;">
8 8
         {% for act in activities %}
9 9
             <div style="clear:both;line-height:20px" >
10  
-                <div style="width:180px;float:left">{{ act.time|diff_date(3) }}</div>
  10
+                <div style="width:180px;float:left">{{ act.time|diff_date(True) }}</div>
11 11
                 <div style="width:150px;float:left">
12 12
                 <span class="user-action-{{ act.type_id }}">{{ act.type }}</span>
13 13
                 </div>
2  askbot/skins/default/templates/user_profile/user_votes.html
@@ -7,7 +7,7 @@
7 7
         <div style="padding-top:5px;font-size:13px;">
8 8
         {% for vote in votes %}
9 9
             <div style="clear:both;line-height:20px" >
10  
-                <div style="width:150px;float:left">{{vote.voted_at|diff_date(3)}}</div>
  10
+                <div style="width:150px;float:left">{{vote.voted_at|diff_date(True)}}</div>
11 11
                 <div style="width:30px;float:left">
12 12
                 {% if vote.vote==1 %}
13 13
                     <img src="{{"/images/vote-arrow-up-on.png"|media}}" title="{% trans %}upvote{% endtrans %}">
33  askbot/tests/page_load_tests.py
@@ -49,11 +49,22 @@ def try_url(
49 49
         if template:
50 50
             if isinstance(r.template, coffin.template.Template):
51 51
                 self.assertEqual(r.template.name, template)
52  
-            else:
  52
+            elif isinstance(r.template, list):
53 53
                 #asuming that there is more than one template
54 54
                 template_names = ','.join([t.name for t in r.template])
55 55
                 print 'templates are %s' % template_names
  56
+                if follow == False:
  57
+                    self.fail(
  58
+                        ('Have issue accessing %s. '
  59
+                        'This should not have happened, '
  60
+                        'since you are not expecting a redirect '
  61
+                        'i.e. follow == False, there should be only '
  62
+                        'one template') % url
  63
+                    )
  64
+
56 65
                 self.assertEqual(r.template[0].name, template)
  66
+            else:
  67
+                raise Exception('unexpected error while runnig test')
57 68
 
58 69
 class PageLoadTests(PageLoadTestCase):
59 70
     fixtures = ['tmp/fixture2.json', ]
@@ -313,6 +324,26 @@ def test_user_urls_logged_in(self):
313 324
         )
314 325
         self.client.logout()
315 326
 
  327
+    def test_inbox_page(self):
  328
+        asker = models.User.objects.get(id = 2)
  329
+        question = asker.post_question(
  330
+            title = 'How can this happen?',
  331
+            body_text = 'This is the body of my question',
  332
+            tags = 'question answer test',
  333
+        )
  334
+        responder = models.User.objects.get(id = 3)
  335
+        responder.post_answer(
  336
+            question = question,
  337
+            body_text = 'this is the answer text'
  338
+        )
  339
+        self.client.login(method = 'force', user_id = asker.id)
  340
+        self.try_url(
  341
+            'user_profile', 
  342
+            kwargs={'id': asker.id, 'slug': slugify(asker.username)},
  343
+            data={'sort':'inbox'}, 
  344
+            template='user_profile/user_inbox.html',
  345
+        )
  346
+
316 347
 class AvatarTests(AskbotTestCase):
317 348
 
318 349
     def test_avatar_for_two_word_user_works(self):
7  askbot/utils/mail.py
@@ -15,9 +15,9 @@ def prefix_the_subject_line(subject):
15 15
     EMAIL_SUBJECT_LINE_PREFIX either from
16 16
     from live settings, which take default from django
17 17
     """
18  
-    prefix = askbot_settings.EMAIL_SUBJECT_PREFIX.strip()
  18
+    prefix = askbot_settings.EMAIL_SUBJECT_PREFIX
19 19
     if prefix != '':
20  
-        subject = prefix + ' ' + subject
  20
+        subject = prefix.strip() + ' ' + subject.strip()
21 21
     return subject
22 22
 
23 23
 def extract_first_email_address(text):
@@ -89,10 +89,9 @@ def send_mail(
89 89
 
90 90
     if raise_on_failure is True, exceptions.EmailNotSent is raised
91 91
     """
92  
-    prefix = askbot_settings.EMAIL_SUBJECT_PREFIX.strip() + ' '
93 92
     try:
94 93
         assert(subject_line is not None)
95  
-        subject_line = prefix + subject_line
  94
+        subject_line = prefix_the_subject_line(subject_line)
96 95
         msg = mail.EmailMessage(
97 96
                         subject_line, 
98 97
                         body_text, 
8  askbot/utils/markup.py
... ...
@@ -1,4 +1,5 @@
1 1
 import re
  2
+import logging
2 3
 from askbot import const
3 4
 from askbot.conf import settings as askbot_settings
4 5
 from markdown2 import Markdown
@@ -27,10 +28,15 @@ def get_parser():
27 28
         pattern_list = askbot_settings.PATTERN.split('\n')
28 29
         url_list = askbot_settings.AUTO_LINK_URL.split('\n')
29 30
         
30  
-        #  Check whether  we have matching links for all key terms, Other wise we ignore the key terms
  31
+        # Check whether  we have matching links for all key terms, Other wise we ignore the key terms
  32
+        # May be we should do this test in update_callback?
31 33
         if len(pattern_list) == len(url_list):
32 34
             for i in range(0,len(pattern_list)):
33 35
                 LINK_PATTERNS.append((re.compile(pattern_list[i].strip()),url_list[i].strip()))
  36
+        else:
  37
+            settings_url = askbot_settings.APP_URL+'/settings/AUTOLINK/'
  38
+            logging.debug("Number of keyterms didn't match the number of links, fix this by visiting" + settings_url) 
  39
+            
34 40
             
35 41
     return Markdown(
36 42
                 html4tags=True,
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.