Enable the "Add comment" action
This commit is contained in:
parent
a35bb5dbda
commit
7565fb0996
|
@ -56,7 +56,9 @@ class Comment(models.Model):
|
|||
story = models.ForeignKey(Story)
|
||||
posted_date = models.DateTimeField(auto_now=True)
|
||||
author = models.ForeignKey(User)
|
||||
content = models.TextField(verbose_name="Add your comment")
|
||||
action = models.CharField(max_length=150, blank=True)
|
||||
comment_type = models.CharField(max_length=20)
|
||||
content = models.TextField(blank=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ['posted_date']
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
{% for tag in story.storytag_set.all %}
|
||||
<span class="label">{{ tag.name }}</span>
|
||||
{% endfor %}
|
||||
<button class="btn btn-micro" type="button"><i class="icon-plus"></i></button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -74,16 +73,18 @@
|
|||
<tbody>
|
||||
{% for comment in story.comment_set.all %}
|
||||
<tr><td colspan=2>
|
||||
<i class="icon-comment"></i>
|
||||
<i class="icon-{{ comment.comment_type }}"></i>
|
||||
by {{ comment.author.username }} on {{ comment.posted_date }}:
|
||||
{% if comment.action %}<br>{{ comment.action }}{% endif %}
|
||||
</td></tr>
|
||||
<tr><td>{{ comment.content|markdown:"safe" }}</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<form>
|
||||
<textarea class="input-block-level" rows="3" placeholder="Add a comment"></textarea>
|
||||
<button class="btn btn-mini" type="button">Add comment</button>
|
||||
<form method="POST" action="/story/{{ story.id }}/comment">
|
||||
{% csrf_token %}
|
||||
<textarea name="content" class="input-block-level" rows="3" placeholder="Add a comment"></textarea>
|
||||
<button class="btn btn-mini" type="submit">Add comment</button>
|
||||
</form>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
|
|
|
@ -19,4 +19,5 @@ from django.conf.urls.defaults import *
|
|||
urlpatterns = patterns('stories.views',
|
||||
(r'^$', 'dashboard'),
|
||||
(r'^(\d+)$', 'view'),
|
||||
(r'^(\d+)/comment$', 'comment'),
|
||||
)
|
||||
|
|
|
@ -14,14 +14,11 @@
|
|||
# under the License.
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import User
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import logout
|
||||
from django.views.decorators.http import require_POST
|
||||
from django.http import HttpResponseRedirect, HttpResponseForbidden
|
||||
from django.shortcuts import render
|
||||
|
||||
from stories.models import Story, Task
|
||||
|
||||
from stories.models import Story, Comment
|
||||
|
||||
def dashboard(request):
|
||||
return render(request, "stories.dashboard.html")
|
||||
|
@ -33,3 +30,15 @@ def view(request, storyid):
|
|||
'story': story,
|
||||
'priorities': Story.STORY_PRIORITIES,
|
||||
})
|
||||
|
||||
@login_required
|
||||
@require_POST
|
||||
def comment(request, storyid):
|
||||
story = Story.objects.get(id=storyid)
|
||||
if 'content' in request.POST:
|
||||
newcomment = Comment(story=story,
|
||||
author=request.user,
|
||||
comment_type="comment",
|
||||
content=request.POST['content'])
|
||||
newcomment.save()
|
||||
return HttpResponseRedirect('/story/%s' % storyid)
|
||||
|
|
Loading…
Reference in New Issue