#63 Replacing vote expiration with vote accuarcy

This commit is contained in:
Leonhard Strohmidel
2022-09-20 09:56:23 +02:00
parent d213b51a59
commit 8597e53599
5 changed files with 57 additions and 16 deletions

View File

@@ -74,7 +74,8 @@ class PlaceDetailView(IsAuthenticatedMixin, IsEligibleToSeePlaceMixin, View):
},
'placevoting': {
'users_vote': PlaceVoting.objects.filter(place=place, submitted_by=explorer).first(),
'all_choices': reversed(PLACE_LEVELS)
'all_choices': reversed(PLACE_LEVELS),
'accuracy': place.calculate_voting_accuracy()
}
}
return render(request, 'place/place_detail.html', context)
@@ -204,8 +205,11 @@ class PlaceVisitDeleteView(IsAuthenticatedMixin, View):
class PlaceVoteView(IsEligibleToSeePlaceMixin, View):
delta = timedelta(weeks=24)
def get_place(self):
return get_object_or_404(Place, pk=self.kwargs['place_id'])
def get(self, request, place_id, vote):
place = get_object_or_404(Place, id=place_id)
place = self.get_place()
explorer = request.user.explorer
voting = PlaceVoting.objects.filter(