Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 4dac26b

Browse files
committed
Add default groups for trial
1 parent 5521687 commit 4dac26b

File tree

11 files changed

+67
-18
lines changed

11 files changed

+67
-18
lines changed

conf/Direct.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ JWT_V3_SECRET = @JWT_V3_SECRET@
2222

2323
#Parameter whether we use login processor or not
2424
USE_LOGIN_PROCESSOR = @useLoginProcessor@
25+
TRIAL_BILLING_ID = @trialBillingId@

src/java/main/com/topcoder/direct/services/view/action/contest/launch/SaveDraftContestAction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.topcoder.direct.services.view.dto.contest.TermOfUse;
1919
import com.topcoder.direct.services.view.dto.contest.ContestType;
2020
import com.topcoder.direct.services.view.util.DataProvider;
21+
import com.topcoder.direct.services.view.util.DirectProperties;
2122
import com.topcoder.direct.services.view.util.DirectUtils;
2223
import com.topcoder.direct.services.view.util.SessionFileStore;
2324
import com.topcoder.management.project.FileType;
@@ -828,6 +829,12 @@ protected void executeAction() throws Exception {
828829
checkpointDate = null;
829830
}
830831

832+
if (DirectProperties.TRIAL_BILLING_ID.equals(
833+
projectHeader.getProperty(ProjectPropertyType.BILLING_PROJECT_PROJECT_PROPERTY_KEY)) &&
834+
groups.size() < 1) {
835+
addFieldError("Group", "Group is required for Trial Billing Account");
836+
return;
837+
}
831838

832839
if (projectId > 0) {
833840
// **** update of the software competition ***

src/java/main/com/topcoder/direct/services/view/ajax/SoftwareCompetitionBeanProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public Object transform(Object object) {
320320
// group api v5 use ProjectGroup.newId as id
321321
result.put("groupIds", CollectionUtils.collect(bean.getProjectHeader().getGroups(), new Transformer() {
322322
public Object transform(Object object) {
323-
return ((ProjectGroup) object).getNewId();
323+
return ((ProjectGroup) object).getId();
324324
}
325325
}));
326326

src/java/main/com/topcoder/direct/services/view/util/DirectProperties.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ public final class DirectProperties {
143143
*/
144144
public static String JWT_VALID_ISSUERS;
145145

146+
/**
147+
* Trial Billing Account Id
148+
*/
149+
public static String TRIAL_BILLING_ID;
150+
146151
/**
147152
* <p>
148153
* Initializes non-final static fields for this class with values for the same-named properties from the resource

src/web/WEB-INF/includes/jq_1_11_1.jsp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@
1717
var jQuery_1_11_1 = $.noConflict(true);
1818
var member_api_url = "@memberSearchApiUrl@";
1919
var group_member_api_url = "@groupMemberSearchApiUrl@";
20+
var TRIAL_BILLING_ID = "@trialBillingId@";
21+
var DEFAULT_GROUP_ID_FOR_TRIAL = "@defaultGroupIdForTrial@";
2022
</script>

src/web/scripts/launch/contestDetailSoftware.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,13 @@ function validateFieldsTypeSection() {
15961596
if (categoryId == ALGORITHM_CATEGORY_ID_MARATHON && $('#mmType').val() === '0') {
15971597
errors.push('Marathon match type is required');
15981598
}
1599+
1600+
// trial billing selected: groups should exist
1601+
if ($('#billingProjects').val() === TRIAL_BILLING_ID &&
1602+
jQuery_1_11_1("#groups").magicSuggest().getValue().length < 1) {
1603+
errors.push('For trial billing account, at least one group should be selected');
1604+
}
1605+
15991606
if (errors.length > 0) {
16001607
showErrors(errors);
16011608
return false;
@@ -3657,7 +3664,12 @@ function handleProjectDropDownChange() {
36573664
}else{
36583665
$("#chkboxCCA").removeAttr('disabled');
36593666
}
3660-
3667+
if ($('#billingProjects').val() === TRIAL_BILLING_ID) {
3668+
// trial billing selected: if no group been selected then add default group
3669+
if (jQuery_1_11_1("#groups").magicSuggest().getValue().length < 1) {
3670+
jQuery_1_11_1("#groups").magicSuggest().setValue([DEFAULT_GROUP_ID_FOR_TRIAL])
3671+
}
3672+
}
36613673
if($(this).find(":selected").data("enableEffortDays")) {
36623674
$('.effortEstimateRow').show();
36633675
} else {

src/web/scripts/launch/main.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ $(document).ready(function() {
337337
url = group_member_api_url;
338338
data = setupTokenRequest(
339339
{
340-
groupIds: jQuery_1_11_1('#groups')
341-
.magicSuggest()
342-
.getValue()
340+
groupIds: jQuery_1_11_1('#groups')
341+
.magicSuggest()
342+
.getValue()
343343
},
344344
getStruts2TokenName()
345345
);
@@ -1358,12 +1358,7 @@ function saveAsDraftRequest() {
13581358
request['cmcBillingId'] = $('input[name=CMCBillingID]').val();
13591359
}
13601360

1361-
var selectedGroups = jQuery_1_11_1('#groups')
1362-
.magicSuggest()
1363-
.getSelection();
1364-
request['groups'] = $.map(selectedGroups, function(val, i) {
1365-
return val.id.toString();
1366-
});
1361+
request['groups'] = jQuery_1_11_1('#groups').magicSuggest().getValue();
13671362

13681363
var copilotCost = parseFloat(mainWidget.softwareCompetition.copilotCost);
13691364
if (copilotCost > 0 && copilotCost != parseFloat(copilotFees[getContestType(true)[1]]['copilotFee'])) {

src/web/scripts/launch/pages/selection.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ function onBillingProjectChange() {
9292
//reset as medium prize
9393
resetSoftwarePrizes();
9494
}
95+
9596
}
9697

9798
function validateFieldsContestSelection() {
@@ -189,6 +190,12 @@ function validateFieldsContestSelectionAlgorithm() {
189190
errors.push('The registration end date should be before or equal the end date.');
190191
}
191192

193+
// trial billing selected: groups should exist
194+
if ($('#billingProjects').val() === TRIAL_BILLING_ID &&
195+
jQuery_1_11_1("#groups").magicSuggest().getValue().length < 1) {
196+
errors.push('For trial billing account, at least one group should be selected');
197+
}
198+
192199
if(errors.length > 0) {
193200
showErrors(errors);
194201
return false;
@@ -294,7 +301,11 @@ function validateFieldsContestSelectionSoftware() {
294301
errors.push('Submission end date/time should be larger than Start date/time.');
295302
}
296303
}
297-
304+
// trial billing selected: groups should exist
305+
if ($('#billingProjects').val() === TRIAL_BILLING_ID &&
306+
jQuery_1_11_1("#groups").magicSuggest().getValue().length < 1) {
307+
errors.push('For trial billing account, at least one group should be selected');
308+
}
298309
if (errors.length > 0) {
299310
showErrors(errors);
300311
return false;
@@ -468,7 +479,11 @@ function validateFieldsContestSelectionStudio() {
468479
if(startDate.getTime() - getServerTime().getTime() < 4 * 60 * 60 * 1000 ) {
469480
errors.push('Start time can\'t be less than within 4 hours');
470481
}
471-
482+
// trial billing selected: groups should exist
483+
if ($('#billingProjects').val() === TRIAL_BILLING_ID &&
484+
jQuery_1_11_1("#groups").magicSuggest().getValue().length < 1) {
485+
errors.push('For trial billing account, at least one group should be selected');
486+
}
472487
if(errors.length > 0) {
473488
showErrors(errors);
474489
return false;

src/web/scripts/launchcontest.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,13 @@ function handleProjectDropDownChange() {
684684

685685
updateContestFee();
686686
updateBillingGroups();
687+
688+
if ($('#billingProjects').val() === TRIAL_BILLING_ID) {
689+
// trial billing selected: if no group been selected then add default group
690+
if (jQuery_1_11_1("#groups").magicSuggest().getValue().length < 1) {
691+
jQuery_1_11_1("#groups").magicSuggest().setValue([DEFAULT_GROUP_ID_FOR_TRIAL])
692+
}
693+
}
687694
});
688695

689696
if(hasCMCBilling) {

token.properties.docker

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@
320320
# Auth0 #
321321
#####################################
322322
@DOMAIN_AUTH0@ = sma.auth0.com
323-
@CLIENT_ID_AUTH0@ =
324-
@CLIENT_SECRET_AUTH0@ =
325-
@JWT_V3_SECRET@ =
323+
@CLIENT_ID_AUTH0@ =
324+
@CLIENT_SECRET_AUTH0@ =
325+
@JWT_V3_SECRET@ =
326326
@REG_SERVER_NAME@= tc.cloud.topcoder.com
327327
@LDAP_AUTH0_CONNECTION_NAME@=vm-ldap-connection
328-
@JWT_VALID_ISSUERS@ = https://sma.auth0.com, https://newtc.auth0.com, https://topcoder-newauth.auth0.com/
328+
@JWT_VALID_ISSUERS@ = https://api.topcoder.com, https://sma.auth0.com, https://newtc.auth0.com, https://topcoder-newauth.auth0.com/
329329

330330
@ApplicationServer.SSO_COOKIE_KEY@=tcsso_vm
331331
@ApplicationServer.SSO_HASH_SECRET@=GKDKJF80dbdc541fe829898aa01d9e30118bab5d6b9fe94fd052a40069385f5628
@@ -342,8 +342,11 @@
342342
@groupMemberApiUrl@=http://tc-api.cloud.topcoder.com:8080/v3/groups/%d/members
343343
@directChallengeServicesApiUrl@=http://api.topcoder-dev.com/v3/direct/challenges
344344
@authorizationUrl@=https://api.topcoder-dev.com/v3/authorizations
345-
@userGroupsApiEndpoint@=http://tc-api.cloud.topcoder.com:8080/v3/groups
345+
@userGroupsApiEndpoint@=http://tc-api.cloud.topcoder.com:3000/api/v5/groups
346346

347347
@aws_s3_bucket@=topcoder-dev-submissions
348348
@aws_s3_access_key@=
349349
@aws_s3_secret_key@=
350+
351+
@trialBillingId@ =
352+
@defaultGroupIdForTrial@ =

0 commit comments

Comments
 (0)