Skip to content

Commit

Permalink
#255 Last actions pagw now show the last tasks, not only comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yn-coder committed Nov 12, 2020
1 parent b05df7b commit 974d0ed
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
17 changes: 10 additions & 7 deletions project/templates/project/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,23 @@ <h2>{% trans "Recent project activity" %}</h2>
<table class="table table-striped">
<thead>
<tr>
<th>Type</th>
<th>Date time</th>
<th>Action</th>
<th>User</th>
<th>Comment</th>
<th>Task</th>
</tr>
</thead>

<tbody>
{% for c in last_actions %}
{% for la in last_actions %}
<tr>
<td>{{c.modified_at}}</td>
<td>{{c.modified_user}}</td>
<td>{{c.comment|safe|truncatewords_html:12}}</td>
<td><a href="{{c.parenttask.get_absolute_url}}">{{c.parenttask}}</a></td>
<td>{{la.type}}</td>
<td>{{la.modified_at}}</td>
<td>
{{la.title|safe|truncatewords_html:12}}
<a href="{{la.url}}">{{la.url_title}}</a>
</td>
<td>{{la.modified_user}}</td>
</tr>
{%endfor%}
</tbody>
Expand Down
20 changes: 19 additions & 1 deletion project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,24 @@ def project_create_repo(request, project_id):
else:
raise Http404() # хотя такого быть не должно

def get_last_action_content( arg_project ):
def mySort(e):
return e['modified_at']

depth = 10
res = []
comments = TaskComment.objects.filter( parenttask__project = arg_project ).order_by('-modified_at')[:depth]
for c in comments:
res.append( { 'modified_at' : c.modified_at, 'type' : 'comment', 'modified_user' : c.modified_user, 'title' : c.comment, 'url' : c.parenttask.get_absolute_url, 'url_title' : c.parenttask, } )

tasks = Task.objects.filter( project = arg_project ).order_by('-modified_at')[:depth]
for t in tasks:
res.append( { 'modified_at' : t.modified_at, 'type' : 'task', 'modified_user' : t.modified_user, 'title' : t.fullname, 'url' : t.get_absolute_url, 'url_title' : t, } )

res.sort(reverse=True, key=mySort)

return res

def get_project_view(request, project_id, arg_task_filter = TASK_FILTER_OPEN, arg_page = PROJECT_PAGE_TITLE, arg_domain_id = None ):
# Получить контекст запроса
context = RequestContext(request)
Expand Down Expand Up @@ -393,7 +411,7 @@ def get_project_view(request, project_id, arg_task_filter = TASK_FILTER_OPEN, ar
members = project.GetMemberList()

if arg_page == PROJECT_PAGE_LAST_ACTIONS:
last_actions = TaskComment.objects.filter( parenttask__project = project ).order_by('-modified_at')[:10]
last_actions = get_last_action_content( project )

if arg_page == PROJECT_PAGE_REPORTS:
pass
Expand Down

0 comments on commit 974d0ed

Please sign in to comment.