Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 37 additions & 14 deletions frontend/src/components/Round/RoundNew.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@
weight="primary"
@click="submitRound()"
>
<check class="icon-small" /> {{ $t('montage-round-add') }}
<check class="icon-small" />
{{
createdRoundId
? $t('montage-round-retry-import') || 'Retry Import'
: $t('montage-round-add')
}}
</cdx-button>
<cdx-button
action="destructive"
Expand Down Expand Up @@ -263,6 +268,8 @@ const thresholds = ref(null)
const thresholdOptions = ref(null)
const isLoading = ref(false)

const createdRoundId = ref(null)

const formData = ref({
name: `Round ${roundIndex + 1}`,
vote_method: roundIndex !== 0 && roundIndex < 3 ? voteMethods[roundIndex] : 'yesno',
Expand Down Expand Up @@ -307,7 +314,19 @@ function searchCategory(name) {
}

const cancelRound = () => {
emit('update:showAddRoundForm', false)
if (createdRoundId.value) {
adminService
.cancelRound(createdRoundId.value)
.then(() => {
emit('reload-campaign-state')
emit('update:showAddRoundForm', false)
})
.catch(() => {
emit('update:showAddRoundForm', false)
})
} else {
emit('update:showAddRoundForm', false)
}
}

const submitRound = () => {
Expand All @@ -327,6 +346,17 @@ const submitRound = () => {

// Check if the round is the first round
if (roundIndex === 0) {
if (selectedImportSource.value === 'selected') {
importSourceValue.value.file_names = importSourceValue.value.file_names
.split('\n')
.filter((elem) => elem)
}

if (createdRoundId.value) {
importCategory(createdRoundId.value)
return
}

const payload = {
name: formData.value.name,
vote_method: formData.value.vote_method,
Expand All @@ -343,13 +373,6 @@ const submitRound = () => {
.addRound(campaignId, payload)
.then((resp) => {
alertService.success($t('montage-round-added'))

if (selectedImportSource.value === 'selected') {
importSourceValue.value.file_names = importSourceValue.value.file_names
.split('\n')
.filter((elem) => elem)
}

importCategory(resp.data.id)
})
.catch(alertService.error)
Expand Down Expand Up @@ -415,19 +438,19 @@ const importCategory = (id) => {

const text = `${warningsList.join('\n\n')}\n\n${filesList}`

createdRoundId.value = id

dialogService().show({
title: 'Import Warning',
content: text,
primaryAction: {
label: 'OK',
label: 'Fix Import',
actionType: 'progressive'
},
onPrimary: () => {
emit('reload-campaign-state')
emit('update:showAddRoundForm', false)
}
onPrimary: () => {}
})
} else {
createdRoundId.value = null
emit('reload-campaign-state')
emit('update:showAddRoundForm', false)
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"montage-latest-round": "Latest round",
"montage-coordinators": "Coordinators",
"montage-voting-deadline": "Voting deadline",
"montage-round-retry-import": "Retry Import",
"montage-directions": "Directions",
"montage-your-progress": "Your progress",
"montage-vote": "Vote",
Expand Down
8 changes: 4 additions & 4 deletions montage/admin_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,17 +379,17 @@ def import_entries(user_dao, round_id, request_dict):

if not entries:
new_entry_stats['warnings'].append({'empty import':
'no entries imported'})
'No entries were imported. Please fix your import source and try again, or click "Cancel" to delete the empty round.'})
elif not new_entry_stats.get('new_entry_count'):
new_entry_stats['warnings'].append({'duplicate import':
'no new entries imported'})
'No new entries were imported.'})


# automatically disqualify entries based on round config
auto_dq = autodisqualify(user_dao, round_id, request_dict={})
new_entry_stats['disqualified'] = auto_dq['data']
if len(new_entry_stats['disqualified']) >= len(entries):
new_entry_stats['warnings'].append({'all disqualified':
'all entries disqualified by round settings'})
'All entries were disqualified by round settings.'})

return {'data': new_entry_stats}

Expand Down