8000 comment authorization partialy done! · moktadirul-raju/DjangoBlog@c1e2f9b · GitHub
[go: up one dir, main page]

Skip to content

Commit c1e2f9b

Browse files
committed
comment authorization partialy done!
1 parent 78a128a commit c1e2f9b

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

blog/__pycache__/views.cpython-37.pyc

4 Bytes
Binary file not shown.

blog/views.py

Lines changed: 1 addition & 0 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def search_view(request):
8282
context = {'posts':post_list}
8383
return render(request, 'blog/archeive.html', context)
8484

85+
@login_required
8586
def submit_comment(request):
8687

8788
if request.method == 'POST' :

db.sqlite3

0 Bytes
Binary file not shown.

static/js/script.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
$(document).ready(function (){
2-
3-
//Social Share
4-
$("#share").jsSocials({
5-
shares: ["email", "twitter", "facebook", "googleplus", "linkedin", "pinterest", "stumbleupon", "whatsapp"]
6-
});
7-
8-
//Form Validation
9-
$("#signup").validate();
10-
11-
});
1+
function login_alert(){
2+
alert("Login to Continue!")
3+
}

templates/blog/single.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ <h2>{{post.title}}</h2>
3232
</div>
3333
<div class="card-body">
3434

35+
{% if user.is_authenticated %}
3536
<form action="{% url 'blog:submit_comment'%}" method="POST">
3637
{% csrf_token %}
3738

@@ -46,6 +47,22 @@ <h2>{{post.title}}</h2>
4647
<button type="submit" class="btn btn-primary" >Submit</button>
4748

4849
</form>
50+
{% else %}
51+
<form method="POST">
52+
53+
54+
<div class="form-group">
55+
56+
<input type="text" name='comment_title'>
57+
<input type="hidden" name='post_id' value="{{post.id}}">
58+
<textarea class="form-control" id="comment-box" rows="3" name="comment_content"></textarea>
59+
60+
</div>
61+
62+
<button type="submit" class="btn btn-primary" onclick="alert("helloWorld!");">Submit</button> <!-- have to work here -->
63+
64+
65+
{% endif %}
4966

5067
</div>
5168

0 commit comments

Comments
 (0)
0