summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo Fitoria <adolfo.fitoria@gmail.com>2012-08-17 10:15:24 -0600
committerAdolfo Fitoria <adolfo.fitoria@gmail.com>2012-08-17 10:15:24 -0600
commit0d2c4b77710a765e5f720cb7833649af18f61605 (patch)
treebe976b114af073dd0876c2bdc2a17e2995cdc4d0
parent8bd941573e226b990edb2737e362397c7526e4fb (diff)
downloadaskbot-0d2c4b77710a765e5f720cb7833649af18f61605.tar.gz
askbot-0d2c4b77710a765e5f720cb7833649af18f61605.tar.bz2
askbot-0d2c4b77710a765e5f720cb7833649af18f61605.zip
Moved question widget from views.readers to views.widgets
-rw-r--r--askbot/urls.py10
-rw-r--r--askbot/views/readers.py19
-rw-r--r--askbot/views/widgets.py26
3 files changed, 27 insertions, 28 deletions
diff --git a/askbot/urls.py b/askbot/urls.py
index f6499845..a614c84d 100644
--- a/askbot/urls.py
+++ b/askbot/urls.py
@@ -144,11 +144,6 @@ urlpatterns = patterns('',
kwargs = {'post_type': 'question'},
name='question_revisions'
),
- url(
- r'^%s%s$' % (_('widgets/'), _('questions/')),
- views.readers.widget_questions,
- name='widget_questions'
- ),
url(#ajax only
r'^comment/upvote/$',
views.commands.upvote_comment,
@@ -430,6 +425,11 @@ urlpatterns = patterns('',
name = 'list_ask_widgets'
),
url(
+ r'^%s%s$' % (_('widgets/'), _('questions/')),
+ views.widgets.widget_questions,
+ name='widget_questions'
+ ),
+ url(
r'^feeds/(?P<url>.*)/$',
'django.contrib.syndication.views.feed',
{'feed_dict': feeds},
diff --git a/askbot/views/readers.py b/askbot/views/readers.py
index 578e4ad8..ba331a83 100644
--- a/askbot/views/readers.py
+++ b/askbot/views/readers.py
@@ -424,7 +424,7 @@ def question(request, id):#refactor - long subroutine. display question body, an
return HttpResponseRedirect(reverse('index'))
elif show_answer:
- #if the url calls to view a particular answer to
+ #if the url calls to view a particular answer to
#question - we must check whether the question exists
#whether answer is actually corresponding to the current question
#and that the visitor is allowed to see it
@@ -631,20 +631,3 @@ def get_comment(request):
comment = models.Post.objects.get(post_type='comment', id=id)
request.user.assert_can_edit_comment(comment)
return {'text': comment.text}
-
-def widget_questions(request):
- """Returns the first x questions based on certain tags.
- @returns template with those questions listed."""
- # make sure this is a GET request with the correct parameters.
- if request.method != 'GET':
- raise Http404
- threads = models.Thread.objects.all()
- tags_input = request.GET.get('tags','').strip()
- if len(tags_input) > 0:
- tags = [tag.strip() for tag in tags_input.split(',')]
- threads = threads.filter(tags__name__in=tags)
- data = {
- 'threads': threads[:askbot_settings.QUESTIONS_WIDGET_MAX_QUESTIONS]
- }
- return render_into_skin('question_widget.html', data, request)
-
diff --git a/askbot/views/widgets.py b/askbot/views/widgets.py
index 1940eedd..5710a179 100644
--- a/askbot/views/widgets.py
+++ b/askbot/views/widgets.py
@@ -1,17 +1,16 @@
from datetime import datetime
from django.core import exceptions
-from django.utils import simplejson
from django.template import Context
from django.http import HttpResponse
from django.views.decorators import csrf
-from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.shortcuts import redirect, get_object_or_404
from django.contrib.auth.decorators import login_required
from askbot.skins.loaders import render_into_skin, get_template
+from askbot.conf import settings as askbot_settings
from askbot.utils import decorators
from askbot import models
from askbot import forms
@@ -119,7 +118,7 @@ def list_ask_widget(request):
@decorators.admins_only
def create_ask_widget(request):
- if request.method=='POST':
+ if request.method == 'POST':
form = models.widgets.CreateAskWidgetForm(request.POST)
if form.is_valid():
form.save()
@@ -133,7 +132,7 @@ def create_ask_widget(request):
@decorators.admins_only
def edit_ask_widget(request, widget_id):
widget = get_object_or_404(models.AskWidget, pk=widget_id)
- if request.method=='POST':
+ if request.method == 'POST':
form = models.widgets.CreateAskWidgetForm(request.POST,
instance=widget)
if form.is_valid():
@@ -148,7 +147,7 @@ def edit_ask_widget(request, widget_id):
@decorators.admins_only
def delete_ask_widget(request, widget_id):
widget = get_object_or_404(models.AskWidget, pk=widget_id)
- if request.method=="POST":
+ if request.method == "POST":
widget.delete()
return redirect('list_ask_widgets')
else:
@@ -176,3 +175,20 @@ def render_ask_widget_css(request, widget_id):
'variable_name': variable_name}
content = content_tpl.render(Context(context_dict))
return HttpResponse(content, mimetype='text/css')
+
+#search widget
+def widget_questions(request):
+ """Returns the first x questions based on certain tags.
+ @returns template with those questions listed."""
+ # make sure this is a GET request with the correct parameters.
+ if request.method != 'GET':
+ raise Http404
+ threads = models.Thread.objects.all()
+ tags_input = request.GET.get('tags','').strip()
+ if len(tags_input) > 0:
+ tags = [tag.strip() for tag in tags_input.split(',')]
+ threads = threads.filter(tags__name__in=tags)
+ data = {
+ 'threads': threads[:askbot_settings.QUESTIONS_WIDGET_MAX_QUESTIONS]
+ }
+ return render_into_skin('question_widget.html', data, request)