summaryrefslogtreecommitdiff
path: root/comments
diff options
context:
space:
mode:
authorJayaram R Pai2014-07-08 08:57:48 +0530
committerJayaram R Pai2014-07-08 08:57:48 +0530
commitfd765dab5eab149535ec01540562e8100f582307 (patch)
treeca9d33a6ce421e9454953b2bb6152854574e5c3f /comments
parentca738ba0953ab950a16c9b89085c9aab5473e7a5 (diff)
downloadPython-TBC-Interface-fd765dab5eab149535ec01540562e8100f582307.tar.gz
Python-TBC-Interface-fd765dab5eab149535ec01540562e8100f582307.tar.bz2
Python-TBC-Interface-fd765dab5eab149535ec01540562e8100f582307.zip
added emails field for comment and reply
Diffstat (limited to 'comments')
-rw-r--r--comments/forms.py2
-rw-r--r--comments/models.py2
-rw-r--r--comments/templates/comments/get_comments.html9
-rw-r--r--comments/templates/comments/new_comment.html4
-rw-r--r--comments/templates/comments/new_reply.html4
-rw-r--r--comments/views.py2
6 files changed, 21 insertions, 2 deletions
diff --git a/comments/forms.py b/comments/forms.py
index a5fb326..b944a49 100644
--- a/comments/forms.py
+++ b/comments/forms.py
@@ -7,6 +7,7 @@ class CommentForm(forms.Form):
page = forms.CharField(widget=forms.HiddenInput())
title = forms.CharField()
body = forms.CharField(widget=forms.Textarea)
+ email = forms.CharField()
def clean(self):
cleaned_data = self.cleaned_data
@@ -19,6 +20,7 @@ class CommentForm(forms.Form):
class ReplyForm(forms.Form):
comment_id = forms.CharField(widget=forms.HiddenInput())
body = forms.CharField(widget=forms.Textarea)
+ email = forms.CharField()
def clean(self):
return self.cleaned_data
diff --git a/comments/models.py b/comments/models.py
index 390b274..0c7f70f 100644
--- a/comments/models.py
+++ b/comments/models.py
@@ -7,12 +7,14 @@ class Comment(models.Model):
chapter = models.CharField(max_length=10)
example = models.CharField(max_length=10)
page = models.CharField(max_length=10)
+ email = models.CharField(max_length=100)
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
class Reply(models.Model):
comment = models.ForeignKey(Comment)
body = models.CharField(max_length=200)
+ email = models.CharField(max_length=100)
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
diff --git a/comments/templates/comments/get_comments.html b/comments/templates/comments/get_comments.html
index 5dcc84a..71443db 100644
--- a/comments/templates/comments/get_comments.html
+++ b/comments/templates/comments/get_comments.html
@@ -22,6 +22,7 @@
<div class="accordion-inner">
<blockquote>
{{ comment.body }}
+ <small>{{ comment.email }}</small>
</blockquote>
<div class="replies">
{% if comment.reply_set.all %}
@@ -30,6 +31,7 @@
{% for reply in comment.reply_set.all %}
<div class="reply">
<p>{{ reply.body }}</p>
+ <small> - {{ comment.email }}</small>
</div>
{% endfor %}
<a class="btn btn-success btn-small" href="/comments/new-reply/?comment_id={{ comment.id }}">+ Reply</a>
@@ -41,8 +43,11 @@
</div> <!-- /.accordion -->
{% else %}
<center>
- <p> No comments for this example... </p>
- <a class="btn btn-primary" href="/comments/new/?book={{ book }}&chapter={{ chapter }}&example={{ example }}&page={{ page }}">Create a new comment</a>
+ <div class="well">
+ <h5>Book: {{ book }} / Chapter: {{ chapter }} / Example: {{ example }}</h5>
+ <p> <em>Be the first one to create a comment for this example.</em> </p>
+ <a class="btn btn-primary" href="/comments/new/?book={{ book }}&chapter={{ chapter }}&example={{ example }}&page={{ page }}">+ Create a new comment</a>
+ </div>
</center>
{% endif %}
</div> <!-- /#recent-comments-form -->
diff --git a/comments/templates/comments/new_comment.html b/comments/templates/comments/new_comment.html
index d16aa15..64c4ab0 100644
--- a/comments/templates/comments/new_comment.html
+++ b/comments/templates/comments/new_comment.html
@@ -9,8 +9,12 @@
{{ form.chapter }}
{{ form.example }}
{{ form.page }}
+ <label>Comment Title:</label>
{{ form.title }}<br>
+ <label>Comment Description:</label>
{{ form.body }} <br>
+ <label>Email:</label>
+ {{ form.email }} <br>
<input class="btn btn-primary" type="submit" value="Submit">
<a class="btn btn-default" href="/comments/get/?book={{ book }}&chapter={{ chapter }}&example={{ example }}&page={{ page }}">Cancel</a>
</form>
diff --git a/comments/templates/comments/new_reply.html b/comments/templates/comments/new_reply.html
index eac5a06..56c97f5 100644
--- a/comments/templates/comments/new_reply.html
+++ b/comments/templates/comments/new_reply.html
@@ -5,6 +5,7 @@
<div class="well" style="width: 78%">
<blockquote>
{{ comment.body }}
+ <small>{{ comment.email }}</small>
</blockquote>
<div class="replies">
{% if comment.reply_set.all %}
@@ -13,6 +14,7 @@
{% for reply in comment.reply_set.all %}
<div class="reply">
<p>{{ reply.body }}</p>
+ <small> - {{ reply.email }}</small>
</div>
{% endfor %}
</div>
@@ -23,6 +25,8 @@
{{ form.comment_id }}
<label>Description:</label>
{{ form.body }} <br>
+ <label>Email:</label>
+ {{ form.email }} <br>
<input class="btn btn-primary" type="submit" value="Submit">
<a class="btn btn-default" href="/comments/get/?book={{ comment.book }}&chapter={{ comment.chapter }}&example={{ comment.example }}&page={{ comment.page }}">Cancel</a>
</form>
diff --git a/comments/views.py b/comments/views.py
index a095727..15a174b 100644
--- a/comments/views.py
+++ b/comments/views.py
@@ -36,6 +36,7 @@ def new_comment(request):
comment.page = form.cleaned_data.get("page")
comment.title = form.cleaned_data.get("title")
comment.body = form.cleaned_data.get("body")
+ comment.email = form.cleaned_data.get("email")
comment.save()
return HttpResponseRedirect(
'/comments/get/?book={0}&chapter={1}&example={2}&page={3}'.format(
@@ -84,6 +85,7 @@ def new_reply(request):
reply = Reply()
reply.comment = comment
reply.body = form.cleaned_data.get('body')
+ reply.email = form.cleaned_data.get('email')
reply.save()
return HttpResponseRedirect(
'/comments/get/?book={0}&chapter={1}&example={2}&page={3}'.format(