summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--tbc/static/css/comments.css9
7 files changed, 30 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(
diff --git a/tbc/static/css/comments.css b/tbc/static/css/comments.css
index 5d7f393..552422b 100644
--- a/tbc/static/css/comments.css
+++ b/tbc/static/css/comments.css
@@ -12,6 +12,7 @@
min-height: 300px;
}
#new-comment-form input[type=text],
+#new-reply-form input[type=text],
#new-comment-form textarea,
#new-reply-form textarea {
width: 80%;
@@ -29,3 +30,11 @@
background: #ffffff;
border-left: 2px solid #1dccaa;
}
+.replies .reply small {
+ display: block;
+ line-height: 20px;
+ color: #b4bcc2;
+}
+.replies .reply p {
+ margin-bottom: .6em;
+}