This commit is contained in:
Alex committed 2025-01-14 14:20:01 +03:00
1 parent 574875892d
commit 5e831cc6ac
2 files changed
+8 -19

No files matched your search

+1 -1
View File
@@ -68,7 +68,7 @@ class VoteCreate(APIView):
def post(self, request): def post(self, request):
try: try:
vote = self.create_vote(request) vote = self.create_vote(request)
self.create_news(request) # self.create_news(request)
return Response({'status': 'success', 'message': 'Vote and news created successfully.'}, status=200) return Response({'status': 'success', 'message': 'Vote and news created successfully.'}, status=200)
except Exception as e: except Exception as e:
return Response({'status': 'error', 'message': str(e)}, status=400) return Response({'status': 'error', 'message': str(e)}, status=400)
+7 -18
View File
@@ -17,7 +17,7 @@
<v-tabs-window-item value="current"> <v-tabs-window-item value="current">
<v-container> <v-container>
<v-row> <v-row>
<v-col v-for="voting in sortedCurrentVotes" :key="voting.id" cols="12" lg="3" md="4"> <v-col v-for="voting in votes" :key="voting.id" cols="12" lg="3" md="4">
<VoteCardVue :voteCard="voting" @openVoteModal="openVoteModal" @openEditVoteModal="openEditVoteModal" <VoteCardVue :voteCard="voting" @openVoteModal="openVoteModal" @openEditVoteModal="openEditVoteModal"
@deleteVoting="deleteVoting" /> @deleteVoting="deleteVoting" />
</v-col> </v-col>
@@ -29,7 +29,7 @@
<v-tabs-window-item value="completed"> <v-tabs-window-item value="completed">
<v-container> <v-container>
<v-row> <v-row>
<v-col v-for="voting in sortedCompletedVotes" :key="voting.id" cols="12" lg="3" md="4"> <v-col v-for="voting in votes" :key="voting.id" cols="12" lg="3" md="4">
<v-card> <v-card>
<v-card-title>{{ voting.title }}</v-card-title> <v-card-title>{{ voting.title }}</v-card-title>
<v-card-subtitle> <v-card-subtitle>
@@ -102,7 +102,7 @@
</template> </template>
<script> <script>
import { computed, ref } from "vue"; import { ref } from "vue";
import VoteConstructor from "@/components/vote/VoteConstructor.vue"; import VoteConstructor from "@/components/vote/VoteConstructor.vue";
import CurrentVote from "@/components/vote/CurrentVote.vue"; import CurrentVote from "@/components/vote/CurrentVote.vue";
import VoteCardVue from "@/components/vote/VoteCard.vue"; import VoteCardVue from "@/components/vote/VoteCard.vue";
@@ -118,7 +118,8 @@ export default {
function updating(param) { function updating(param) {
getVotes(param) getVotes(param)
.then(data => { .then(data => {
votes.value = data.votes; console.log(data);
votes.value = data;
}) })
} }
@@ -129,17 +130,6 @@ export default {
const resultsModal = ref(false); const resultsModal = ref(false);
const selectedVoting = ref(null); const selectedVoting = ref(null);
const sortedCurrentVotes = computed(() => {
return votes.value
.filter((v) => new Date(v.dateend) > new Date())
.sort((a, b) => new Date(a.dateend) - new Date(b.dateend));
});
const sortedCompletedVotes = computed(() => {
return votes.value
.filter((v) => new Date(v.dateend) <= new Date())
.sort((a, b) => new Date(b.dateend) - new Date(a.dateend));
});
const timeRemaining = (dateend) => { const timeRemaining = (dateend) => {
const now = new Date(); const now = new Date();
@@ -191,8 +181,6 @@ export default {
return { return {
currentTab, currentTab,
votes, votes,
sortedCurrentVotes,
sortedCompletedVotes,
voteModal, voteModal,
resultsModal, resultsModal,
selectedVoting, selectedVoting,
@@ -207,7 +195,8 @@ export default {
editVoteModal, editVoteModal,
openEditVoteModal, openEditVoteModal,
closeEditVoteModal, closeEditVoteModal,
updating updating,
votingData
}; };
}, },
}; };