Skip to content

Commit

Permalink
Add approved_visits to opportunity detail
Browse files Browse the repository at this point in the history
  • Loading branch information
pxwxnvermx committed Oct 6, 2023
1 parent 185cf1c commit 3fbe259
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions commcare_connect/opportunity/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ def utilised_budget(self):
)
return user_visits

@property
def approved_visits(self):
approved_user_visits = (
UserVisit.objects.filter(opportunity=self, status=VisitValidationStatus.approved)
.exclude(status=VisitValidationStatus.over_limit)
.count()
)
return approved_user_visits


class DeliverForm(models.Model):
app = models.ForeignKey(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ <h1 class="display-5 mb-0">{{ object.name }}</h1>
<th scope="row">Budget Utilised</th>
<td>{{ object.utilised_budget }}</td>
</tr>
<tr>
<th scope="row">Approved Visits</th>
<td>{{ object.approved_visits }}</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 3fbe259

Please sign in to comment.