]> git.openstreetmap.org Git - osqa.git/commitdiff
Merge pull request #46 from udacity/subfolder_fixes
authorJavyer Der Derian <javier@tribalo.net>
Thu, 17 Apr 2014 21:59:05 +0000 (18:59 -0300)
committerJavyer Der Derian <javier@tribalo.net>
Thu, 17 Apr 2014 21:59:05 +0000 (18:59 -0300)
Fix OSQA-819: Link to profile in message is wrong if OSQA is installed in a subfolder

forum/views/meta.py
forum/views/readers.py
forum_modules/akismet/startup.py
forum_modules/robotstxt/urls.py
requirements.txt
settings_local.py.dist

index a47cf1d8bbc5f04ffbae53c942c41d4e0842e414..e7d151588a8402a6e0c2b73c19cf03b9005e91c0 100644 (file)
@@ -37,7 +37,7 @@ def static(request, title, content):
 def media(request, skin, path):
     response = serve(request, "%s/media/%s" % (skin, path),
                  document_root=os.path.join(os.path.dirname(os.path.dirname(__file__)), 'skins').replace('\\', '/'))
-    content_type = response['Content-Type']
+    content_type = response.get('Content-Type', '')
     if ('charset=' not in content_type):
         if (content_type.startswith('text') or content_type=='application/x-javascript'):
             content_type += '; charset=utf-8'
index 669eaf3006a849aefdaf84d40e3adf72d6089742..fc819bf164b77f5ed5a2ff36c78d57f8f3956223 100644 (file)
@@ -8,6 +8,7 @@ from django.core.paginator import Paginator, EmptyPage, InvalidPage
 from django.template import RequestContext
 from django import template
 from django.utils.html import *
+from django.utils.http import urlquote
 from django.db.models import Q, Count
 from django.utils.translation import ugettext as _
 from django.core.urlresolvers import reverse
@@ -29,9 +30,28 @@ import decorators
 
 class HottestQuestionsSort(pagination.SortBase):
     def apply(self, questions):
-        return questions.annotate(new_child_count=Count('all_children')).filter(
-                all_children__added_at__gt=datetime.datetime.now() - datetime.timedelta(days=1)).order_by('-new_child_count')
-
+        return questions.extra(select={'new_child_count': '''
+            SELECT COUNT(1)
+                FROM forum_node fn1
+                WHERE fn1.abs_parent_id = forum_node.id
+                    AND fn1.id != forum_node.id
+                    AND NOT(fn1.state_string LIKE '%%(deleted)%%')
+                    AND added_at > %s'''
+            },
+            select_params=[ (datetime.datetime.now() - datetime.timedelta(days=2))
+                .strftime('%Y-%m-%d')]
+        ).order_by('-new_child_count', 'last_activity_at')
+
+class UnansweredQuestionsSort(pagination.SortBase):
+    def apply(self, questions):
+        return questions.extra(select={'answer_count': '''
+            SELECT COUNT(1)
+                FROM forum_node fn1
+                WHERE fn1.abs_parent_id = forum_node.id
+                    AND fn1.id != forum_node.id
+                    AND fn1.node_type='answer'
+                    AND NOT(fn1.state_string LIKE '%%(deleted)%%')'''
+            }).order_by('answer_count', 'last_activity_at')
 
 class QuestionListPaginatorContext(pagination.PaginatorContext):
     def __init__(self, id='QUESTIONS_LIST', prefix='', pagesizes=(15, 30, 50), default_pagesize=30):
@@ -40,6 +60,7 @@ class QuestionListPaginatorContext(pagination.PaginatorContext):
             (_('newest'), pagination.SimpleSort(_('newest'), '-added_at', _("most <strong>recently asked</strong> questions"))),
             (_('hottest'), HottestQuestionsSort(_('hottest'), _("most <strong>active</strong> questions in the last 24 hours</strong>"))),
             (_('mostvoted'), pagination.SimpleSort(_('most voted'), '-score', _("most <strong>voted</strong> questions"))),
+            (_('unanswered'), UnansweredQuestionsSort('unanswered', "questions with no answers")),
         ), pagesizes=pagesizes, default_pagesize=default_pagesize, prefix=prefix)
 
 class AnswerSort(pagination.SimpleSort):
@@ -52,6 +73,7 @@ class AnswerSort(pagination.SimpleSort):
 class AnswerPaginatorContext(pagination.PaginatorContext):
     def __init__(self, id='ANSWER_LIST', prefix='', default_pagesize=10):
         super (AnswerPaginatorContext, self).__init__(id, sort_methods=(
+            (_('active'), AnswerSort(_('active answers'), '-last_activity_at', _("most recently updated answers/comments will be shown first"))),
             (_('oldest'), AnswerSort(_('oldest answers'), 'added_at', _("oldest answers will be shown first"))),
             (_('newest'), AnswerSort(_('newest answers'), '-added_at', _("newest answers will be shown first"))),
             (_('votes'), AnswerSort(_('popular answers'), ('-score', 'added_at'), _("most voted answers will be shown first"))),
index 2387e05d620fe5f609a85942b943650fc2b92191..c050754add3acb4ba8ba228383257d1e46d1352d 100644 (file)
@@ -1,5 +1,4 @@
 import json
-import loggin
 
 from django.utils.translation import ugettext as _
 from django.http import HttpResponse, HttpResponseRedirect
index 5f74a0a62dd250268888945cf2614fb33f87415d..ddcac3bccdaa68444ab5f9adf5b9d74e4697ea01 100644 (file)
@@ -3,5 +3,5 @@ from django.http import  HttpResponse
 import settings
 
 urlpatterns = patterns('',
-    (r'^robots.txt$',  lambda r: HttpResponse(settings.ROBOTS_FILE.value)),
+    (r'^robots.txt$',  lambda r: HttpResponse(settings.ROBOTS_FILE.value, content_type='text/plain')),
 )
index fd43d5c442a0609474cf0c23bbf5a0b4bc750e47..826678735ec80538016a3ba9a9c2e414c6eccd3c 100644 (file)
@@ -3,7 +3,7 @@ html5lib
 python-openid
 South
 python-memcached
-django==1.3.7
+django==1.6.0
 django-debug-toolbar
 django-endless-pagination
 pytz
index ad178f6efe05157c70f028ba8899c61efdcac588..e687228a3084c98c9c8ced11f603ad2e9589be6b 100644 (file)
@@ -77,7 +77,6 @@ TIME_ZONE = 'America/New_York'
 USE_I18N = True
 LANGUAGE_CODE = 'en'
 
-DJANGO_VERSION = 1.1
 OSQA_DEFAULT_SKIN = 'default'
 
 DISABLED_MODULES = ['books', 'recaptcha', 'project_badges']