Show last person to act on a rrequest on dashboard

This commit is contained in:
Sebastian Lohff 2017-04-15 16:58:00 +02:00
parent 648be3ef83
commit 370bbe58af
2 changed files with 10 additions and 0 deletions

View File

@ -33,6 +33,14 @@ class Request(models.Model):
def __str__(self): def __str__(self):
return "(%s -> %s) [%s] %s" % (self.applicant, self.provider, self.status, self.subject) return "(%s -> %s) [%s] %s" % (self.applicant, self.provider, self.status, self.subject)
def getLastActionBy(self):
msgs = self.requestmessage_set.order_by("-created")
if msgs.count() > 0:
return msgs[0].creator
else:
return None
class RequestMessage(models.Model): class RequestMessage(models.Model):
request = models.ForeignKey(Request) request = models.ForeignKey(Request)

View File

@ -96,11 +96,13 @@
<tr> <tr>
<th>From</th> <th>From</th>
<th>Subject</th> <th>Subject</th>
<th>Last</th>
</tr> </tr>
{% for rrequest in rrequests %} {% for rrequest in rrequests %}
<tr> <tr>
<td>{{ rrequest.applicant }} <span class="glyphicon glyphicon-arrow-right"></span> {{ rrequest.provider }}</td> <td>{{ rrequest.applicant }} <span class="glyphicon glyphicon-arrow-right"></span> {{ rrequest.provider }}</td>
<td><a href="{{ rrequest.get_absolute_url }}">{{ rrequest.subject }}</a></td> <td><a href="{{ rrequest.get_absolute_url }}">{{ rrequest.subject }}</a></td>
<td>{{ rrequest.getLastActionBy }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>