Skip to content

Commit

Permalink
[#659] Updated comment.time to comment.created_at in templates and views
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Aug 6, 2014
1 parent 35b2724 commit 912ec71
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions akvo/rsr/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def projectupdates(request, project_id):
'''
project = get_object_or_404(Project, pk=project_id)
updates = project.project_updates.all().order_by('-created_at')
comments = project.comments.all().order_by('-time')[:3]
comments = project.comments.all().order_by('-created_at')[:3]
can_add_update = project.connected_to_user(request.user)
return {
'project': project,
Expand All @@ -650,7 +650,7 @@ def projectupdate(request, project_id, update_id):
can_add_update = project.connected_to_user(request.user)
can_edit_update = (update.user == request.user and can_add_update and
not update.edit_window_has_expired())
comments = project.comments.all().order_by('-time')[:3]
comments = project.comments.all().order_by('-created_at')[:3]
edit_timeout = settings.PROJECT_UPDATE_TIMEOUT
return {
'project': project,
Expand All @@ -673,7 +673,7 @@ def projectcomments(request, project_id):
updates: list of updates, ordered by time in reverse
'''
project = get_object_or_404(Project, pk=project_id)
comments = Project.objects.get(id=project_id).comments.all().order_by('-time')
comments = Project.objects.get(id=project_id).comments.all().order_by('-created_at')
form = CommentForm()
updates = project.project_updates.all().order_by('-created_at')[:3]
can_add_update = project.connected_to_user(request.user)
Expand Down Expand Up @@ -776,7 +776,6 @@ def commentform(request, project_id):
if form.is_valid():
comment = form.save(commit=False)
comment.project = p
comment.time = datetime.now()
comment.user = request.user
comment.save()
return HttpResponseRedirect(reverse('project_comments', args=[project_id]))
Expand Down Expand Up @@ -812,7 +811,7 @@ def projectmain(request, project, draft=False, can_add_update=False):
'''
all_updates = project.project_updates.all().order_by('-created_at')
updates_with_images = all_updates.exclude(photo__exact='').order_by('-created_at')
comments = project.comments.all().order_by('-time')[:3]
comments = project.comments.all().order_by('-created_at')[:3]
# comprehensions are fun! here we use it to get the categories that
# don't contain only 0 value benchmarks
benchmarks = project.benchmarks.filter(
Expand Down Expand Up @@ -846,7 +845,7 @@ def projectdetails(request, project_id):
@render_to('rsr/project/project_partners.html')
def projectpartners(request, project, draft=False, can_add_update=False):
updates = project.project_updates.all().order_by('-created_at')[:3]
comments = project.comments.all().order_by('-time')[:3]
comments = project.comments.all().order_by('-created_at')[:3]
can_add_update = project.connected_to_user(request.user)
return {
'can_add_update': can_add_update,
Expand All @@ -864,7 +863,7 @@ def projectpartners(request, project, draft=False, can_add_update=False):
def projectfunding(request, project, draft=False, can_add_update=False):
public_donations = project.public_donations()
updates = project.project_updates.all().order_by('-created_at')[:3]
comments = project.comments.all().order_by('-time')[:3]
comments = project.comments.all().order_by('-created_at')[:3]
can_add_update = project.connected_to_user(request.user)
return {
'can_add_update': can_add_update,
Expand Down Expand Up @@ -927,7 +926,7 @@ def templatedev(request, template_name):
SAMPLE_ORG_ID = 42
p = Project.objects.get(pk=SAMPLE_PROJECT_ID)
updates = Project.objects.get(id=SAMPLE_PROJECT_ID).project_updates.all().order_by('-created_at')[:3]
comments = Project.objects.get(id=SAMPLE_PROJECT_ID).comments.all().order_by('-time')[:3]
comments = Project.objects.get(id=SAMPLE_PROJECT_ID).comments.all().order_by('-created_at')[:3]
grid_projects = Project.objects.filter(current_image__startswith='img').order_by('?')[:12]

projects = Project.objects.published()
Expand Down
2 changes: 1 addition & 1 deletion akvo/templates/rsr/project/project_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ <h2>{% trans 'Comments' %}</h2>
<p style="padding:5px; margin-bottom:5px;">
{{ c.comment|capfirst }}<br />
<span class="grey small">
{{c.user.get_full_name}}, {{c.time|date:"Y-m-d H:i"}}
{{c.user.get_full_name}}, {{c.created_at|date:"Y-m-d H:i"}}
</span>
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion akvo/templates/rsr/project/project_comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2>{% trans 'All comments' %}</h2>
<p style="margin:0;">
{{c.comment|capfirst}}<br />
<span class="grey small">
{{c.user.get_full_name}}, {{c.time|date:"Y-m-d H:i"}},
{{c.user.get_full_name}}, {{c.created_at|date:"Y-m-d H:i"}},
<a href="mailto:[email protected]?subject={% blocktrans with project.id as p_id and c.id as c_id %}Comment%20abuse%20in%20project%20%23{{p_id}}%2C%20comment%20#{{c_id}}{% endblocktrans %}">{% trans 'Report abuse' %}</a>
</span>
</p>
Expand Down

0 comments on commit 912ec71

Please sign in to comment.