Commit 9635c2b0 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt

at time of last vote to poll voter

parent a820284f
......@@ -31,6 +31,14 @@ class VoterSerializer(serializers.ModelSerializer):
class PollSerializer(serializers.ModelSerializer):
options = OptionSerializer(many=True, read_only=True)
last_voted = serializers.SerializerMethodField()
def get_last_voted(self, instance: models.WorkaroundPoll):
last_vote = models.Vote.objects\
.filter(option__poll=instance)\
.order_by('time_updated')\
.last()
return last_vote.time_updated if last_vote else None
def to_representation(self, instance):
representation = super().to_representation(instance)
......@@ -79,7 +87,7 @@ class PollSerializer(serializers.ModelSerializer):
class Meta:
model = models.WorkaroundPoll
fields = ('id', 'options',)
fields = ('id', 'options', 'last_voted',)
class EndorsementsSerializer(serializers.Serializer):
......
......@@ -4,7 +4,10 @@
<i class="poll-header-icon fa fa-lightbulb-o" v-if="isVoting"></i>
<slot name="header">
<div class="poll-info">
{{ headerText }}
<div>{{ headerText }}</div>
<small class="content-mute" v-if="lastVoted">
Letztes Votum {{ lastVoted.from(new Date()) }}
</small>
</div>
<div class="poll-header-actions">
<div class="spinner" v-if="!poll"></div>
......@@ -30,6 +33,7 @@
<script>
import { get } from 'lodash'
import moment from 'moment'
import { poll } from '../../adapters/api'
import { danger, success } from '../../util/notify'
......@@ -46,6 +50,11 @@
}
},
computed: {
lastVoted () {
return this.poll && this.poll.last_voted
? moment(this.poll.last_voted)
: null
},
allowVote () {
return this.canVote && !this.hasGestaltVoted
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment