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

Commit 922900c

Browse files
committed
Updating group id for blockchain
1 parent 27b66b4 commit 922900c

File tree

4 files changed

+52
-20
lines changed

4 files changed

+52
-20
lines changed

app/services/group.service.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import angular from 'angular'
2+
3+
(function () {
4+
'use strict'
5+
6+
angular.module('tc.services').factory('GroupService', GroupService)
7+
8+
GroupService.$inject = ['ApiService']
9+
10+
function GroupService(ApiService) {
11+
var service = ApiService.restangularV3
12+
13+
// Retrieves the registration status of the member for the given program
14+
service.getMemberRegistration = function(userId, programId) {
15+
return service.one('groups').get({'memberId': userId,'membershipType':'user'})
16+
}
17+
18+
// Registers the given member for the given program.
19+
service.rm = function(userId, programId) {
20+
return service.one('groups', programId).one('members').post({
21+
memberId : userId +'', membershipType : 'user'
22+
})
23+
}
24+
25+
return service
26+
}
27+
})()

app/skill-picker/skill-picker.controller.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import _ from 'lodash'
66

77
angular.module('tc.skill-picker').controller('SkillPickerController', SkillPickerController)
88

9-
SkillPickerController.$inject = ['$scope', 'CONSTANTS', 'ProfileService', '$state', 'userProfile', 'featuredSkills', 'logger', 'toaster', 'MemberCertService', '$q']
9+
SkillPickerController.$inject = ['$scope', 'CONSTANTS', 'ProfileService', '$state', 'userProfile', 'featuredSkills', 'logger', 'toaster', 'MemberCertService','GroupService', '$q']
1010

11-
function SkillPickerController($scope, CONSTANTS, ProfileService, $state, userProfile, featuredSkills, logger, toaster, MemberCertService, $q) {
11+
function SkillPickerController($scope, CONSTANTS, ProfileService, $state, userProfile, featuredSkills, logger, toaster, MemberCertService, GroupService, $q) {
1212
var vm = this
1313
vm.ASSET_PREFIX = CONSTANTS.ASSET_PREFIX
1414
vm.IOS_PROGRAM_ID = parseInt(CONSTANTS.SWIFT_PROGRAM_ID)
@@ -80,6 +80,13 @@ import _ from 'lodash'
8080
dirty: true,
8181
display: true
8282
}
83+
vm.communities['blockchain'] = {
84+
displayName: 'Blockchain',
85+
programId: vm.BLOCKCHAIN_PROGRAM_ID,
86+
status: false,
87+
dirty: false,
88+
display: true
89+
}
8390
vm.communities['ios'] = {
8491
displayName: 'iOS',
8592
programId: vm.IOS_PROGRAM_ID,
@@ -93,18 +100,11 @@ import _ from 'lodash'
93100
status: false,
94101
dirty: false,
95102
display: true
96-
}
97-
vm.communities['blockchain'] = {
98-
displayName: 'Blockchain',
99-
programId: vm.PREDIX_PROGRAM_ID,
100-
status: false,
101-
dirty: false,
102-
display: true
103-
}
103+
}
104104
_addWatchToCommunity(vm.communities['ios'])
105-
_addWatchToCommunity(vm.communities['predix'])
106-
_addWatchToCommunity(vm.communities['ibm_cognitive'])
107105
_addWatchToCommunity(vm.communities['blockchain'])
106+
_addWatchToCommunity(vm.communities['predix'])
107+
_addWatchToCommunity(vm.communities['ibm_cognitive'])
108108
}
109109

110110
/**
@@ -128,9 +128,10 @@ import _ from 'lodash'
128128
function checkCommunityStatus() {
129129
var promises = []
130130
for (var name in vm.communities) {
131-
var community = vm.communities[name]
132-
promises.push(MemberCertService.getMemberRegistration(vm.userId, community.programId))
131+
var community = vm.communities[name]
132+
promises.push(MemberCertService.getMemberRegistration(vm.userId, community.programId))
133133
}
134+
134135
vm.loadingCommunities = true
135136

136137
$q.all(promises)
@@ -211,7 +212,11 @@ import _ from 'lodash'
211212
var community = vm.communities[communityName]
212213
if (community.dirty === true) {
213214
if (community.status === true) {
214-
promises.push(MemberCertService.registerMember(vm.userId, community.programId))
215+
if(community.programId === vm.BLOCKCHAIN_PROGRAM_ID){
216+
promises.push(GroupService.rm(vm.userId, community.programId))
217+
}else{
218+
promises.push(MemberCertService.registerMember(vm.userId, community.programId))
219+
}
215220
}
216221
}
217222
}

app/skill-picker/skill-picker.jade

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
.community__icon(ng-class="{'community__icon--disabled': !community.status}")
1313
img(ng-if="communityKey == 'ibm_cognitive' && community.status", src=require("../../assets/images/ico-ibm_cognitive-community.svg"))
1414
img(ng-if="communityKey == 'ibm_cognitive' && !community.status", src=require("../../assets/images/ico-ibm_cognitive-community-grey.svg"))
15+
img(ng-if="communityKey == 'blockchain' && community.status", src=require("../../assets/images/ico-predix-community.svg"))
16+
img(ng-if="communityKey == 'blockchain' && !community.status", src=require("../../assets/images/ico-predix-community-grey.svg"))
1517
img(ng-if="communityKey == 'ios' && community.status", src=require("../../assets/images/ico-ios-community.svg"))
1618
img(ng-if="communityKey == 'ios' && !community.status", src=require("../../assets/images/ico-ios-community-grey.svg"))
1719
img(ng-if="communityKey == 'predix' && community.status", src=require("../../assets/images/ico-predix-community.svg"))
1820
img(ng-if="communityKey == 'predix' && !community.status", src=require("../../assets/images/ico-predix-community-grey.svg"))
19-
img(ng-if="communityKey == 'blockchain' && community.status", src=require("../../assets/images/ico-predix-community.svg"))
20-
img(ng-if="communityKey == 'blockchain' && !community.status", src=require("../../assets/images/ico-predix-community-grey.svg"))
2121

2222
.community__text
2323
span.community__title(class="{{!community.status && 'disabled'}}") {{community.displayName}}
2424
.community__description
2525
span(ng-if="communityKey == 'ibm_cognitive'") Cognitive Community
26+
span(ng-if="communityKey == 'blockchain'") Help create the future of Blockchain-based applications
2627
span(ng-if="communityKey == 'ios'") Mobile app design and development for iOS, with Swift emphasis
2728
span(ng-if="communityKey == 'predix'") Design and development on GE’s platform for the Industrial Internet of Things
28-
span(ng-if="communityKey == 'blockchain'") Help create the future of Blockchain-based applications
2929

3030
onoff-switch(model="community.status", unique-id="'community-' + communityKey")
3131

app/topcoder.constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ angular.module('CONSTANTS', []).constant('CONSTANTS', {
2929
'NEW_CHALLENGES_URL' : 'https://www.topcoder.com/challenges/develop/upcoming/',
3030
'SWIFT_PROGRAM_ID' : 3445,
3131
'PREDIX_PROGRAM_ID' : process.env.PREDIX_PROGRAM_ID || 3448,
32-
'IBM_COGNITIVE_PROGRAM_ID' : process.env.IBM_COGNITIVE_PROGRAM_ID || 3449,
33-
'BLOCKCHAIN_PROGRAM_ID' : process.env.BLOCKCHAIN_PROGRAM_ID || 111111,
32+
'IBM_COGNITIVE_PROGRAM_ID' : process.env.IBM_COGNITIVE_PROGRAM_ID || 3449,
33+
'BLOCKCHAIN_PROGRAM_ID' : process.env.BLOCKCHAIN_PROGRAM_ID || 20000010,
3434
'UPCOMING_SRMS_URL' : 'https://www.topcoder.com/challenges/data/upcoming/',
3535
'EVENT_USER_LOGGED_IN' : 'user_logged_in',
3636
'EVENT_USER_LOGGED_OUT' : 'user_logged_out',

0 commit comments

Comments
 (0)