diff options
author | Jayaram Pai | 2013-12-01 20:50:56 +0530 |
---|---|---|
committer | Jayaram Pai | 2013-12-01 20:50:56 +0530 |
commit | 5e3c305f49becd0db41f63bc1c69b1a72c3119ea (patch) | |
tree | 572d50d199ce07073695c3eb2e2344b92e72bf2c /website | |
parent | 8533d61eb93ecb4c943ec3c3b83dfef87b20a916 (diff) | |
download | FOSSEE-Forum-5e3c305f49becd0db41f63bc1c69b1a72c3119ea.tar.gz FOSSEE-Forum-5e3c305f49becd0db41f63bc1c69b1a72c3119ea.tar.bz2 FOSSEE-Forum-5e3c305f49becd0db41f63bc1c69b1a72c3119ea.zip |
basic filter structure, recent question display
Diffstat (limited to 'website')
-rw-r--r-- | website/models.py | 6 | ||||
-rw-r--r-- | website/urls.py | 8 | ||||
-rw-r--r-- | website/views.py | 37 |
3 files changed, 24 insertions, 27 deletions
diff --git a/website/models.py b/website/models.py index ce8d4dc..7a3072a 100644 --- a/website/models.py +++ b/website/models.py @@ -5,10 +5,8 @@ class Question(models.Model): user = models.ForeignKey(User) category = models.CharField(max_length=200) tutorial = models.CharField(max_length=200) - minute_start = models.IntegerField() - minute_end = models.IntegerField() - second_start = models.IntegerField() - second_end = models.IntegerField() + minute_range = models.CharField(max_length=10) + second_range = models.CharField(max_length=10) title = models.CharField(max_length=200) body = models.TextField() date_created = models.DateTimeField(auto_now_add=True) diff --git a/website/urls.py b/website/urls.py index 9d1b048..bad4e34 100644 --- a/website/urls.py +++ b/website/urls.py @@ -2,9 +2,11 @@ from django.conf.urls import patterns, include, url urlpatterns = patterns('', url(r'^$', 'website.views.home', name='home'), - url(r'^category/(?P<category>.+)/$', 'website.views.fetch_tutorials', name='fetch_tutorials'), - url(r'^tutorial/(?P<category>.+)/(?P<tutorial>.+)/$', 'website.views.fetch_questions', name='fetch_questions'), - url(r'^question/(?P<question_id>\d+)$', 'website.views.get_question', name='get_question'), + url(r'^question/(?P<question_id>\d+)/$', 'website.views.get_question', name='get_question'), + url(r'^filter/(?P<category>[^/]+)/$', 'website.views.filter', name='filter'), + url(r'^filter/(?P<category>[^/]+)/(?P<tutorial>[^/]+)/$', 'website.views.filter', name='filter'), + url(r'^filter/(?P<category>[^/]+)/(?P<tutorial>[^/]+)/(?P<minute_range>[^/]+)/$', 'website.views.filter', name='filter'), + url(r'^filter/(?P<category>[^/]+)/(?P<tutorial>[^/]+)/(?P<minute_range>[^/]+)/(?P<second_range>[^/]+)/$', 'website.views.filter', name='filter'), url(r'^new-question/$', 'website.views.new_question', name='new_question'), # Ajax helpers diff --git a/website/views.py b/website/views.py index c5b71af..fea9855 100644 --- a/website/views.py +++ b/website/views.py @@ -26,28 +26,11 @@ categories = [ ] def home(request): + questions = Question.objects.all() context = { - 'categories': categories - } - return render_to_response('website/templates/index.html', context) - -def fetch_tutorials(request, category=None): - tutorials = TutorialDetails.objects.using('spoken').filter(foss_category=category) - context = { - 'category': category, - 'tutorials': tutorials - } - return render_to_response('website/templates/fetch_tutorials.html', context) - -def fetch_questions(request, category=None, tutorial=None): - questions = Question.objects.filter(category=category).filter(tutorial=tutorial) - context = { - 'category': category, - 'tutorial': tutorial, 'questions': questions } - return render_to_response('website/templates/fetch_questions.html', context) - + return render_to_response('website/templates/index.html', context) def get_question(request, question_id=None): question = get_object_or_404(Question, id=question_id) @@ -58,12 +41,26 @@ def get_question(request, question_id=None): } return render_to_response('website/templates/get_question.html', context) +def filter(request, category='', tutorial='', minute_range='', second_range=''): + res = category + '<br>' + tutorial + '<br>' + minute_range + '<br>' + second_range + return HttpResponse(res) + @login_required def new_question(request): if request.method == 'POST': form = NewQuestionForm(request.POST) if form.is_valid(): - return HttpResponse("valid") + cleaned_data = form.cleaned_data + question = Question() + question.user = request.user + question.category = cleaned_data['category'] + question.tutorial = cleaned_data['tutorial'] + question.minute_range = cleaned_data['minute_range'] + question.second_range = cleaned_data['second_range'] + question.title = cleaned_data['title'] + question.body = cleaned_data['body'] + question.save() + return HttpResponse('atlast :>') else: form = NewQuestionForm() |