Skip to content
This repository was archived by the owner on Sep 3, 2020. It is now read-only.

Commit 36bd01b

Browse files
author
Arjun
committed
v0.5
New looks!
1 parent 00d0b30 commit 36bd01b

File tree

6 files changed

+92
-10
lines changed

6 files changed

+92
-10
lines changed

db.sqlite3

0 Bytes
Binary file not shown.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import models, migrations
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('qa', '0012_auto_20150120_1239'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='userprofile',
16+
name='picture',
17+
field=models.ImageField(upload_to=b'static/profile_images', blank=True),
18+
preserve_default=True,
19+
),
20+
]

qa/templates/qa/detail.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ <h1><a href="/">Simple QA </a><small>Open Questions</small></h1>
2020

2121
<div class="jumbotron">
2222
<p class="pull-right">{{ question.pub_date }}</p>
23-
<h2><cool>Q: {{ question.question_text }}</cool></h2>
23+
<h3><cool>Q: </cool>{{ question.question_text }}</h3>
2424
<p><a class="btn btn-primary btn-sm pull-right" href="/answer/{{ question.id }}" role="button">Answer this Question!</a></p>
2525
</div>
2626

@@ -35,7 +35,7 @@ <h3 class="panel-title">Answers</h3>
3535
{% if user.is_authenticated %}
3636
<div class ="col-md-1"><h3><a href="/vote/{{ answer.id }}/{{ question.id }}/0/"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a> {{ answer.votes }} <a href="/vote/{{ answer.id }}/{{ question.id }}/1/"><span class="glyphicon glyphicon-minus" aria-hidden="true"></span></a></h3></div>
3737
{% endif %}
38-
<div class ="col-md-8">
38+
<div class ="col-md-9">
3939
<a href="/comment/{{ answer.id }}/" class="pull-right"><small><span class="glyphicon glyphicon-comment" aria-hidden="true"></span> Comment &nbsp;</small></a>
4040

4141
{% if answer.votes > 0 %}
@@ -50,15 +50,15 @@ <h3 class="panel-title">Answers</h3>
5050
<p>-<b>{{ comment.comment_text }}</b><small>, <a href="/profile/{{ comment.user_data.user.id }}">{{ comment.user_data.user.username }}</a> at {{ comment.pub_date }}</small></p>
5151
{% endfor %}
5252
</div>
53-
<div class ="col-md-3">
53+
<div class ="col-md-2">
5454

5555
{% if answer.user_data.picture %}
5656
<img class="pull-right" src="{{ answer.user_data.picture }}">
5757
{% else %}
5858
<img class="pull-right" width="50px" height="50px" src="{% static "qa/user.png" %}">
5959
{% endif %}
6060

61-
<p class="pull-right">- <b><a href="/profile/{{ answer.user_data.user.id }}">{{ answer.user_data.user.username }}</a> ({{ answer.user_data.points }})</b> ({{ answer.pub_date }})</p>
61+
<p class="pull-right">- <b><a href="/profile/{{ answer.user_data.user.id }}">{{ answer.user_data.user.username }}</a> ({{ answer.user_data.points }})</b></p>
6262
</div>
6363
</div>
6464

qa/templates/qa/index.html

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@
99
<link href='http://fonts.googleapis.com/css?family=Roboto:300' rel='stylesheet' type='text/css'>
1010

1111
<style>
12+
1213
.ques {
1314
font-family: 'Roboto', sans-serif;
14-
font-size: 25px;
15+
font-size: 20px;
1516
}
17+
18+
.ans {
19+
height: 40px;
20+
width: 75px;
21+
color:#500000;
22+
text-align: center;
23+
text-align: center;
24+
vertical-align: middle;
25+
}
26+
1627
tag {
1728
background-color:#E0E0E0;
1829
color:#500000;
@@ -109,16 +120,23 @@
109120
<a class="btn btn-lg btn-warning pull-right" href="#search"><span class="glyphicon glyphicon-search" aria-hidden="true"></span> Find</a><a class="btn btn-lg btn-danger pull-right" href="/add/">Ask Question</a><h1><a href="/">Simple QA </a><small>Open Questions</small></h1>
110121
</div>
111122

123+
<div class="col-md-8">
112124
{% if questions %}
113-
<ul>
114125
{% for question in questions %}
115-
<li>{% if question.answer_set.count %}<span class="glyphicon glyphicon-fire" aria-hidden="true"></span>{% endif %} <a class="ques" href="/q/{{ question.id }}/">{{ question.question_text }}</a><small class="pull-right"> {{ question.pub_date}}</small></li>
116-
<small>{{ question.answer_set.count }} Answers | {{ question.views }} Views</small>
126+
<div class="row">
127+
<div class="col-sm-1 ans"><small><div class="ques">{{ question.answer_set.count }}</div>Answers</small></div>
128+
<div class="col-sm-1 ans"><small><div class="ques">{{ question.views }}</div>Views</small></div>
129+
<p>
130+
{% if question.answer_set.count %}<span class="glyphicon glyphicon-fire" aria-hidden="true"></span>{% endif %} <a class="ques" href="/q/{{ question.id }}/">{{ question.question_text }}</a>
131+
<br/>
117132
{% for tag in question.tags.all %}
118-
<tag>{{ tag.slug }}</tag>
133+
<tag>{{ tag.slug }}</tag>
119134
{% endfor %}
135+
<small> {{ question.pub_date}}</small>
136+
</p>
137+
</div>
138+
<hr>
120139
{% endfor %}
121-
</ul>
122140

123141
<div class="pagination">
124142
<span class="step-links">
@@ -142,6 +160,42 @@
142160

143161
</div>
144162

163+
<div class="col-md-4">
164+
<div class="panel panel-default">
165+
<div class="panel-body">
166+
<h4>Total Questions: {{ totalcount }}</h4>
167+
<h4>Total Answers: {{ anscount }}</h4>
168+
</div>
169+
</div>
170+
171+
<div class="panel panel-default">
172+
<div class="panel-heading">
173+
<h3 class="panel-title">Recent Tags</h3>
174+
</div>
175+
<div class="panel-body">
176+
{% for question in questions %}
177+
{% for tag in question.tags.all %}
178+
<tag>{{ tag.slug }}</tag>
179+
{% endfor %}
180+
{% endfor %}
181+
</div>
182+
</div>
183+
184+
<div class="panel panel-warning">
185+
<div class="panel-heading">
186+
<h3 class="panel-title">Unanswered Questions</h3>
187+
</div>
188+
<div class="panel-body">
189+
<ul>
190+
{% for question in noans %}
191+
<li><a href="/q/{{ question.id }}/">{{ question.question_text }}</a></li>
192+
{% endfor %}
193+
</ul>
194+
</div>
195+
</div>
196+
197+
</div>
198+
</div>
145199
<hr>
146200
<center>
147201
{% if user.is_authenticated %}

qa/views.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ def search(request):
3030

3131
def index(request):
3232
latest_question_list = Question.objects.order_by('-pub_date')
33+
latest_noans_list = Question.objects.order_by('-pub_date').filter(answer__isnull=True)[:10]
34+
count = Question.objects.count
35+
count_a = Answer.objects.count
3336
paginator = Paginator(latest_question_list, 10)
3437
page = request.GET.get('page')
3538
try:
@@ -43,6 +46,9 @@ def index(request):
4346
template = loader.get_template('qa/index.html')
4447
context = RequestContext(request, {
4548
'questions': questions,
49+
'totalcount': count,
50+
'anscount': count_a,
51+
'noans': latest_noans_list,
4652
})
4753
return HttpResponse(template.render(context))
4854

simpleqa/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'django.contrib.sessions',
3737
'django.contrib.messages',
3838
'django.contrib.staticfiles',
39+
'django.contrib.sites',
3940
'qa',
4041
'bootstrap3',
4142
'django_markdown',
@@ -79,6 +80,7 @@
7980

8081
USE_TZ = True
8182

83+
SITE_ID = 1
8284

8385
# Static files (CSS, JavaScript, Images)
8486
# https://docs.djangoproject.com/en/1.7/howto/static-files/

0 commit comments

Comments
 (0)