diff options
author | Tomasz Zielinski <tomasz.zielinski@pyconsultant.eu> | 2012-01-10 15:30:24 +0100 |
---|---|---|
committer | Tomasz Zielinski <tomasz.zielinski@pyconsultant.eu> | 2012-01-11 15:18:13 +0100 |
commit | c993c66c8388866bdf472d6a026ea83b2668b60e (patch) | |
tree | 597d84a59fa089918b00624dad7399f78fa2d375 | |
parent | e815a7c7336aff065dc7894d769e9cd5170b790d (diff) | |
download | askbot-c993c66c8388866bdf472d6a026ea83b2668b60e.tar.gz askbot-c993c66c8388866bdf472d6a026ea83b2668b60e.tar.bz2 askbot-c993c66c8388866bdf472d6a026ea83b2668b60e.zip |
Fix attempt for main page URLs
-rw-r--r-- | askbot/urls.py | 201 | ||||
-rw-r--r-- | askbot/views/users.py | 14 |
2 files changed, 25 insertions, 190 deletions
diff --git a/askbot/urls.py b/askbot/urls.py index f39fd785..4382983c 100644 --- a/askbot/urls.py +++ b/askbot/urls.py @@ -60,194 +60,22 @@ urlpatterns = patterns('', # BEGIN Questions (main page) urls. All this urls work both normally and through ajax - url( # section/sort/query/search/tags/author - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/search:search/tags:(?P<tags>[\w\d\-\+\#]+)/author:(?P<author>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/tags/author/page_size Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/tags:(?P<tags>[\w\d\-\+\#]+)/author:(?P<author>\d+)/page_size:(?P<page_size>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/tags/author/page Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/tags:(?P<tags>[\w\d\-\+\#]+)/author:(?P<author>\d+)/page:(?P<page>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/tags/author for use with ajax - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/tags:(?P<tags>[\w\d\-\+\#]+)/author:(?P<author>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/author/page_size Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/author:(?P<author>\d+)/page_size:(?P<page_size>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/author/page Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/author:(?P<author>\d+)/page:(?P<page>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/author for use with ajax - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/author:(?P<author>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/search/author - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/search:search/author:(?P<author>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/tags/page_size Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/tags:(?P<tags>[\w\d\-\+\#]+)/page_size:(?P<page_size>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/tags/page Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/tags:(?P<tags>[\w\d\-\+\#]+)/page:(?P<page>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/search/tags - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/search:search/tags:(?P<tags>[\w\d\-\+\#]+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/tags for use with ajax - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/tags:(?P<tags>[\w\d\-\+\#]+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), + url( + (r'^%s' % _('questions') + + r'(%s)?' % r'/section:(?P<scope>\w+)' + + r'(%s)?' % r'/sort:(?P<sort>[\w\-]+)' + + r'(%s)?' % r'/query:(?P<query>[\w\d\-\+\#]+)' + + r'(%s)?' % r'/search:search' + + r'(%s)?' % r'/tags:(?P<tags>[\w\d\-\+\#]+)' + + r'(%s)?' % r'/author:(?P<author>\d+)' + + r'(%s)?' % r'/page_size:(?P<page_size>\d+)' + + r'(%s)?' % r'/page:(?P<page>\d+)' + + r'/$'), - url( # section/sort/query/search - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/search:search/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/page_size Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/page_size:(?P<page_size>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query/page Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/page:(?P<page>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/query for use with ajax - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/query:(?P<query>[\w\d\-\+\#]+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/tags/author/page_size Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/tags:(?P<tags>[\w\d\-\+\#]+)/author:(?P<author>\d+)/page_size:(?P<page_size>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/tags/author/page Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/tags:(?P<tags>[\w\d\-\+\#]+)/author:(?P<author>\d+)/page:(?P<page>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/tags/author for use with ajax - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/tags:(?P<tags>[\w\d\-\+\#]+)/author:(?P<author>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/author/page_size Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/author:(?P<author>\d+)/page_size:(?P<page_size>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/author/page Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/author:(?P<author>\d+)/page:(?P<page>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/author for use with ajax - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/author:(?P<author>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/tags/page_size Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/tags:(?P<tags>[\w\d\-\+\#]+)/page_size:(?P<page_size>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # section/sort/tags/page Note:issues with default start_over - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/tags:(?P<tags>[\w\d\-\+\#]+)/page:(?P<page>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # include section/sort/tags - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/tags:(?P<tags>[\w\d\-\+\#]+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # tags/author/page_size Note:issues with default start_over - r'^%s/tags:(?P<tags>[\w\d\-\+\#]+)/author:(?P<author>\d+)/page_size:(?P<page_size>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # tags/author/page Note:issues with default start_over - r'^%s/tags:(?P<tags>[\w\d\-\+\#]+)/author:(?P<author>\d+)/page:(?P<page>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # include tags/author - r'^%s/tags:(?P<tags>[\w\d\-\+\#]+)/author:(?P<author>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - - url( # author/page_size Note:issues with default start_over - r'^%s/author:(?P<author>\d+)/page_size:(?P<page_size>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # author/page Note:issues with default start_over - r'^%s/author:(?P<author>\d+)/page:(?P<page>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # include author - r'^%s/author:(?P<author>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - - url( # tags/page_size Note:issues with default start_over - r'^%s/tags:(?P<tags>[\w\d\-\+\#]+)/page_size:(?P<page_size>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # tags/page Note:issues with default start_over - r'^%s/tags:(?P<tags>[\w\d\-\+\#]+)/page:(?P<page>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # include tags - r'^%s/tags:(?P<tags>[\w\d\-\+\#]+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # include section/sort/page_size - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/page_size:(?P<page_size>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # include section/sort/page - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/page:(?P<page>\d+)/$' % _('questions'), - views.readers.questions, - name='questions' - ), - url( # include section/sort - r'^%s/section:(?P<scope>\w+)/sort:(?P<sort>[\w\-]+)/$' % _('questions'), views.readers.questions, name='questions' ), + url( # removes tag, this is used only with ajax and this parameters is always used alone r'^%s/remove_tag:(?P<remove_tag>[\w\d\-\#]+)/$' % _('questions'), views.readers.questions, @@ -260,11 +88,6 @@ urlpatterns = patterns('', {'start_over': (None)}, # this parameter is true by default, so we are making it false here name='questions' ), - url( - r'^%s$' % _('questions/'), - views.readers.questions, - name='questions' - ), # END main page urls diff --git a/askbot/views/users.py b/askbot/views/users.py index bcfbc28d..6b151c62 100644 --- a/askbot/views/users.py +++ b/askbot/views/users.py @@ -310,11 +310,23 @@ def user_stats(request, user, context): # INFO: There's bug in Django that makes the following query kind of broken (GROUP BY clause is problematic): # http://stackoverflow.com/questions/7973461/django-aggregation-does-excessive-group-by-clauses # Fortunately it looks like it returns correct results for the test data - user_tags = models.Tag.objects.filter(threads__posts__author=user).\ + user_tags = models.Tag.objects.filter(threads__posts__author=user).distinct().\ annotate(user_tag_usage_count=Count('threads')).\ order_by('-user_tag_usage_count')[:const.USER_VIEW_DATA_SIZE] user_tags = list(user_tags) # evaluate +# tags = models.Post.objects.filter(author=user).values('id', 'thread', 'thread__tags') +# post_ids = set() +# thread_ids = set() +# tag_ids = set() +# for t in tags: +# post_ids.add(t['id']) +# thread_ids.add(t['thread']) +# tag_ids.add(t['thread__tags']) +# if t['thread__tags'] == 11: +# print t['thread'], t['id'] +# import ipdb; ipdb.set_trace() + # # Badges/Awards (TODO: refactor into Managers/QuerySets when a pattern emerges; Simplify when we get rid of Question&Answer models) # |