This repository was archived by the owner on Sep 3, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 10 files changed +36
-6
lines changed Expand file tree Collapse file tree 10 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class UserProfile(models.Model):
2727
2828 # The additional attributes we wish to include.
2929 website = models .URLField (blank = True )
30- picture = models .ImageField (upload_to = 'profile_images' , blank = True )
30+ picture = models .ImageField (upload_to = 'static/ profile_images' , blank = True )
3131
3232 # Override the __unicode__() method to return out something meaningful!
3333 def __unicode__ (self ):
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ <h1><a href="/">Simple QA </a><small>Add Question</small></h1>
1818 {% csrf_token %}
1919 < input class ="input-lg " style ="width:100% " placeholder ="Enter your question..... " type ="text " name ="question "/> < br /> < br />
2020
21+ < input class ="input-lg " style ="width:100% " placeholder ="Enter tags separates by comma! " type ="text " name ="tags "/> < br /> < br />
22+
2123 < input class ="btn pull-right btn-success " type ="submit " value ="Submit Question " />
2224 </ form >
2325 < p > Note. Question cannot be empty!</ p >
Original file line number Diff line number Diff line change @@ -50,7 +50,16 @@ <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 "> < 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 > </ div >
53+ < div class ="col-md-3 ">
54+
55+ {% if answer.user_data.picture %}
56+ < img class ="pull-right " src ="{{ answer.user_data.picture }} ">
57+ {% else %}
58+ < img class ="pull-right " width ="50px " height ="50px " src ="{% static "qa /user.png" %}">
59+ {% endif %}
60+
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 >
62+ </ div >
5463 </ div >
5564
5665 {% endfor %}
@@ -60,15 +69,15 @@ <h3 class="panel-title">Answers</h3>
6069< div class ="pagination ">
6170 < span class ="step-links ">
6271 {% if answers.has_previous %}
63- < a href ="?page={{ answers.previous_page_number }} "> previous </ a >
72+ < a href ="?page={{ answers.previous_page_number }} "> < Previous | </ a >
6473 {% endif %}
6574
6675 < span class ="current ">
6776 Page {{ answers.number }} of {{ answers.paginator.num_pages }}.
6877 </ span >
6978
7079 {% if answers.has_next %}
71- < a href ="?page={{ answers.next_page_number }} "> next </ a >
80+ < a href ="?page={{ answers.next_page_number }} "> | Next > </ a >
7281 {% endif %}
7382 </ span >
7483</ div >
Original file line number Diff line number Diff line change 1010 font-family : 'Roboto' , sans-serif;
1111 font-size : 25px ;
1212}
13+ tag {
14+ background-color : # E0E0E0 ;
15+ color : # 500000 ;
16+ }
1317</ style >
1418
1519< div class ="container ">
2226 {% for question in questions %}
2327 < 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 >
2428 < small > {{ question.answer_set.count }} Answers | {{ question.views }} Views</ small >
29+ {% for tag in question.tags.all %}
30+ < tag > {{ tag.slug }}</ tag >
31+ {% endfor %}
2532 {% endfor %}
2633</ ul >
2734
2835< div class ="pagination ">
2936 < span class ="step-links ">
3037 {% if questions.has_previous %}
31- < a href ="?page={{ questions.previous_page_number }} "> previous </ a >
38+ < a href ="?page={{ questions.previous_page_number }} "> < Previous | </ a >
3239 {% endif %}
3340
3441 < span class ="current ">
3542 Page {{ questions.number }} of {{ questions.paginator.num_pages }}.
3643 </ span >
3744
3845 {% if questions.has_next %}
39- < a href ="?page={{ questions.next_page_number }} "> next </ a >
46+ < a href ="?page={{ questions.next_page_number }} "> | Next > </ a >
4047 {% endif %}
4148 </ span >
4249</ div >
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ def add(request):
3737
3838 if request .method == 'POST' :
3939 question_text = request .POST ['question' ]
40+ tags_text = request .POST ['tags' ]
4041
4142 if question_text .strip () == '' :
4243 return render (request , 'qa/add.html' , {'message' : 'Empty' })
@@ -46,6 +47,17 @@ def add(request):
4647 q .question_text = question_text
4748 q .pub_date = pub_date
4849 q .save ()
50+
51+ tags = tags_text .split (',' )
52+ for tag in tags :
53+ try :
54+ t = Tag .objects .get (slug = tag )
55+ q .tags .add (t )
56+ except Tag .DoesNotExist :
57+ t = Tag ()
58+ t .slug = tag
59+ t .save ()
60+ q .tags .add (t )
4961 return HttpResponseRedirect ('/' )
5062 return HttpResponse (template .render (context ))
5163
You can’t perform that action at this time.
0 commit comments