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

Fix for Issue: Do not allow a member to register for challenge if country is not set #473

Merged
merged 1 commit into from
Jul 26, 2016
Merged
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
6 changes: 6 additions & 0 deletions initializers/challengeHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ exports.challengeHelper = function (api, next) {
return;
}

// Do not allow a member to register for challenge if country is not set
if (rows[0].comp_country_is_null) {
cb(new ForbiddenError('You cannot participate in this challenge as your country is not set.'));
return;
}

if (rows[0].project_category_id === COPILOT_POSTING_PROJECT_TYPE) {
if (!rows[0].user_is_copilot && rows[0].copilot_type && rows[0].copilot_type.indexOf("Marathon Match") < 0) {
cb(new ForbiddenError('You cannot participate in this challenge because you are not an active member of the copilot pool.'));
Expand Down
3 changes: 3 additions & 0 deletions queries/challenge_registration_validations
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ select
(ce.contest_eligibility_id IS NULL) as no_elgibility_req,
(ugx.login_id IS NOT NULL) as user_in_eligible_group,
(uax.user_id IS NOT NULL OR coder.coder_id IS NOT NULL) as user_country_banned,
(coder2.comp_country_code IS NULL) as comp_country_is_null,
(cop.copilot_profile_id IS NOT NULL) as user_is_copilot,
(pctl.name) as copilot_type
from project p
Expand Down Expand Up @@ -50,6 +51,8 @@ left outer join (
on coder.comp_country_code=country.country_code
and country.country_name in ( "Iran", "North Korea", "Cuba", "Sudan", "Syria" )
) on coder.coder_id = @userId@
-- Get coder to check comp_country_code
left outer join informixoltp:coder coder2 on coder2.coder_id = @userId@
-- Get the copilot type
left join (
project_copilot_type pct join project_copilot_type_lu pctl
Expand Down