Skip to content

Commit 68d0b73

Browse files
authored
Merge pull request #71 from topcoder-platform/issues-663
Support self-service flag
2 parents 66a79e0 + b2088c8 commit 68d0b73

File tree

2 files changed

+66
-7
lines changed

2 files changed

+66
-7
lines changed

config/template.json

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"categories": [
2222
{
2323
"name": "Code Documents",
24+
"selfservice": false,
2425
"urlcode": "${ challenge.id }-documents",
2526
"discussions": [
2627
{
@@ -39,6 +40,20 @@
3940
},
4041
{
4142
"name": "Code Questions",
43+
"selfservice": false,
44+
"urlcode": "${ challenge.id }-questions",
45+
"discussions": [
46+
{
47+
"title": "Welcome!",
48+
"body": "Please read the requirements carefully. If you have questions, please let me know, I'll be glad to help you.",
49+
"announce": 0,
50+
"closed": 0
51+
}
52+
]
53+
},
54+
{
55+
"name": "General Questions",
56+
"selfservice": true,
4257
"urlcode": "${ challenge.id }-questions",
4358
"discussions": [
4459
{
@@ -64,6 +79,7 @@
6479
"categories": [
6580
{
6681
"name": "Code Documents",
82+
"selfservice": false,
6783
"urlcode": "${ challenge.id }-documents",
6884
"discussions": [
6985
{
@@ -82,6 +98,20 @@
8298
},
8399
{
84100
"name": "Code Questions",
101+
"selfservice": false,
102+
"urlcode": "${ challenge.id }-questions",
103+
"discussions": [
104+
{
105+
"title": "Welcome!",
106+
"body": "Please read the requirements carefully. If you have questions, please let me know, I'll be glad to help you.",
107+
"announce": 0,
108+
"closed": 0
109+
}
110+
]
111+
},
112+
{
113+
"name": "General Questions",
114+
"selfservice": true,
85115
"urlcode": "${ challenge.id }-questions",
86116
"discussions": [
87117
{
@@ -115,25 +145,36 @@
115145
"title": "Spec Review Discussion",
116146
"body": "Spec Review Discussion",
117147
"announce": 0,
118-
"closed": 0
148+
"closed": 0,
149+
"selfservice": false
119150
},
120151
{
121152
"title": "Please give us feedback on this challenge!",
122153
"body": "Hi Competitors,\n\nAt topcoder, we are always trying to continuously improve how we are running competitions and tasks for our competitors. Part of this involves getting feedback from you on how well our tasks and challenges are being managed.\n\nPlease take 2-3 minutes to fill out this survey. The results will be used to identify areas of improvement, follow on training, procedural changes, etc. \n\n https://www.surveymonkey.com/r/3SYYTHP?Challenge_ID=<%- challenge.id %>",
123154
"announce": 0,
124-
"closed": 0
155+
"closed": 0,
156+
"selfservice": false
125157
},
126158
{
127159
"title": "Welcome!",
128160
"body": "Please read the requirements carefully. If you have questions, please let me know, I'll be glad to help you.",
129161
"announce": 0,
130-
"closed": 0
162+
"closed": 0,
163+
"selfservice": false
131164
},
132165
{
133166
"title": "Challenge Overview",
134167
"body": "[Back to Challenge Details page](<%- challenge.url %>)\n<% _.forEach(challenge.prizeSets, function(prizeSet) { %>* <%- prizeSet.type %>: <% _.forEach(prizeSet.prizes, function(prize) { %><%- prize.value %>$ <% }) %>\n<% }); %>",
135168
"announce": 1,
136-
"closed": 1
169+
"closed": 1,
170+
"selfservice": false
171+
},
172+
{
173+
"title": "Welcome!",
174+
"body": "Please read the requirements carefully. If you have questions, please let me know, I'll be glad to help you.",
175+
"announce": 0,
176+
"closed": 0,
177+
"selfservice": true
137178
}
138179
]
139180
}
@@ -156,6 +197,7 @@
156197
"categories": [
157198
{
158199
"name": "Code Documents",
200+
"selfservice": false,
159201
"urlcode": "${ challenge.id }-documents",
160202
"discussions": [
161203
{
@@ -174,6 +216,20 @@
174216
},
175217
{
176218
"name": "Code Questions",
219+
"selfservice": false,
220+
"urlcode": "${ challenge.id }-questions",
221+
"discussions": [
222+
{
223+
"title": "Welcome!",
224+
"body": "Please read the requirements carefully. If you have questions, please let me know, I'll be glad to help you.",
225+
"announce": 0,
226+
"closed": 0
227+
}
228+
]
229+
},
230+
{
231+
"name": "General Questions",
232+
"selfservice": true,
177233
"urlcode": "${ challenge.id }-questions",
178234
"discussions": [
179235
{

src/services/vanilla.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,12 @@ async function createVanillaGroup (challenge) {
237237
archived: true
238238
})
239239

240-
logger.info(`The '${challengeCategory.name}' category was created`)
240+
logger.info(`The '${challengeCategory.name}' category was created.`)
241241

242+
const isSelfService = challenge.legacy.selfService;
242243
if (groupTemplate.categories) {
243-
for (const item of groupTemplate.categories) {
244+
const categories = _.filter(groupTemplate.categories, ['selfservice', isSelfService] )
245+
for (const item of categories) {
244246
const urlCodeTemplate = _.template(item.urlcode)
245247
const { body: childCategory } = await vanillaClient.createCategory({
246248
name: item.name,
@@ -255,7 +257,8 @@ async function createVanillaGroup (challenge) {
255257
}
256258

257259
if (groupTemplate.discussions) {
258-
await createDiscussions(group, challenge, groupTemplate.discussions, challengeCategory)
260+
const groupDiscussions = _.filter(groupTemplate.discussions, ['selfservice', isSelfService] )
261+
await createDiscussions(group, challenge, groupDiscussions, challengeCategory)
259262
}
260263

261264
for (const member of members) {

0 commit comments

Comments
 (0)