summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--static/website/css/main.css65
-rw-r--r--static/website/templates/ajax-duration.html2
-rw-r--r--static/website/templates/index.html41
-rw-r--r--website/models.py6
-rw-r--r--website/urls.py8
-rw-r--r--website/views.py37
6 files changed, 97 insertions, 62 deletions
diff --git a/static/website/css/main.css b/static/website/css/main.css
index 9e68e7f..315845d 100644
--- a/static/website/css/main.css
+++ b/static/website/css/main.css
@@ -8,32 +8,63 @@
padding: 0 0 25px 0;
}
#content-inner {
-
+ min-height: 600px;
}
#content{
- min-height: 600px;
}
-#content .category {
- min-height: 50px;
+#content .question {
+ padding: 15px 0 15px 0;
border-bottom: 1px solid #f5f5f5;
}
-#content .category .questions {
- color: #7395d9;
+#content .question .title {
+ padding: 0 0 7px 0;
+ font-size: 1.3em;
+ color: #424242;
}
-#content .category .replies {
- color: #a26dc8;
+#content .question .title a {
+ color: #424242;
}
-#content .category .helper {
- position: absolute;
- right: 20px;
- top: 5px;
- font-size: 1.5em;
- color: #cccccc;
+#content .question .category {
+ padding: 2px 5px;
+ margin: 0 10px 0 0;
+ background: #a26dc8;
+ color: #ffffff;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ -o-border-radius: 3px;
+ border-radius: 3px;
}
-#content .tutorial {
- min-height: 50px;
- border-bottom: 1px solid #f5f5f5;
+#content .question .tutorial {
+ padding: 2px 5px;
+ margin: 0 10px 0 0;
+ background: #424242;
+ color: #ffffff;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ -o-border-radius: 3px;
+ border-radius: 3px;
}
+#content .question .minute_range {
+ padding: 2px 5px;
+ margin: 0 10px 0 0;
+ background: #f5f5f5;
+ color: #424242;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ -o-border-radius: 3px;
+ border-radius: 3px;
+}
+#content .question .second_range {
+ padding: 2px 5px;
+ margin: 0 10px 0 0;
+ background: #f5f5f5;
+ color: #424242;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ -o-border-radius: 3px;
+ border-radius: 3px;
+}
+
#footer-wrapper {
background-color: #2d2d2d;
min-height: 60px;
diff --git a/static/website/templates/ajax-duration.html b/static/website/templates/ajax-duration.html
index f89927b..22fe04f 100644
--- a/static/website/templates/ajax-duration.html
+++ b/static/website/templates/ajax-duration.html
@@ -10,7 +10,7 @@
<div id="seconds">
<option value="None">sec</option>
{% for i in seconds|get_range:"0,10" %}
- <option value="{{ i }}">{{ i }}-{{ i|add:"10" }} </option>
+ <option value="{{ i }}-{{ i|add:"10" }}">{{ i }}-{{ i|add:"10" }}</option>
{% endfor %}
</div> <!-- /#seconds -->
</div> <!-- /required for ajax -->
diff --git a/static/website/templates/index.html b/static/website/templates/index.html
index 471fb48..c54b637 100644
--- a/static/website/templates/index.html
+++ b/static/website/templates/index.html
@@ -1,20 +1,27 @@
{% extends 'website/templates/base.html' %}
{% block content %}
-{% for category in categories %}
- <div class="category col-lg-4">
- <a href="{% url 'website:fetch_tutorials' category %}">{{ category }}</a>
- <br>
- {% load count_tags %}
- <span class="questions">
- {% category_question_count category %} questions,
- </span>
- <span class="replies">
- {% category_question_count category %} replies
- </span>
- <span class="helper">
- A
- </span>
- </div>
-{% endfor %}
-<div class="clear"></div>
+<h4>Recent Questions</h4>
+ {% for question in questions %}
+ <div class="question">
+ <div class="title">
+ <a href="">{{ question.title }}</a>
+ </div>
+
+ <span class="category">
+ <small>{{ question.category }}</small>
+ </span>
+
+ <span class="tutorial">
+ <small>{{ question.tutorial}}</small>
+ </span>
+
+ <span class="minute_range">
+ <small>{{ question.minute_range }} min</small>
+ </span>
+
+ <span class="second_range">
+ <small>{{ question.second_range }} sec</small>
+ </span>
+ </div>
+ {% endfor %}
{% endblock %}
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()