Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1315 from philanthropy-u/zahid/LP-1756
Browse files Browse the repository at this point in the history
Zahid/lp 1756 Hot fix: Allow G2A-tagged learners to skip "Org Details" step
  • Loading branch information
ahmed-faraz46 authored Jan 8, 2020
2 parents 800d960 + e4e06b8 commit f0c80c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 0 additions & 2 deletions openedx/features/partners/give2asia/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
G2A_EXTENDED_PROFILE_DEFAULT_DATA = {
ENGLISH_PROFICIENCY_KEY: 'IWRNS', # I'd rather not say
HOURS_PER_WEEK_KEY: 1,
IS_FIRST_LEARNER: True, # mark user is first learner
IS_INTERESTS_DATA_SUBMITTED_KEY: True, # Flag required for by-passing interests form
IS_ORGANIZATION_METRICS_SUBMITTED: True, # mark user has completed organization details
ROLE_IN_ORG_KEY: 'IWRNS', # I'd rather not say
}

Expand Down
13 changes: 10 additions & 3 deletions openedx/features/partners/give2asia/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import analytics
import json
from copy import deepcopy
from datetime import datetime
from logging import getLogger

Expand Down Expand Up @@ -103,10 +104,10 @@ def create_account_with_params_custom(request, params, partner):
log.exception("User creation failed for user {username}".format(username=params['username']), repr(err))
raise

extended_profile_data = g2a_constants.G2A_EXTENDED_PROFILE_DEFAULT_DATA
extended_profile_data = deepcopy(g2a_constants.G2A_EXTENDED_PROFILE_DEFAULT_DATA)
extended_profile_data[g2a_constants.START_MONTH_YEAR_KEY] = datetime.now().strftime('%m/%Y')

user_profile_data = g2a_constants.G2A_USER_PROFILE_DEFAULT_DATA
user_profile_data = deepcopy(g2a_constants.G2A_USER_PROFILE_DEFAULT_DATA)
user_profile_data['name'] = '{} {}'.format(first_name, last_name)
user_profile_data['country'] = params['country']

Expand All @@ -124,12 +125,18 @@ def create_account_with_params_custom(request, params, partner):
raise

try:
organization_data = g2a_constants.G2A_ORGANIZATION_DEFAULT_DATA
organization_data = deepcopy(g2a_constants.G2A_ORGANIZATION_DEFAULT_DATA)
organization_data[g2a_constants.ORG_TYPE_KEY] = PartnerNetwork.NON_PROFIT_ORG_TYPE_CODE

organization_name = params['organization_name']
organization_to_assign = Organization.objects.filter(label__iexact=organization_name).first()

if not organization_to_assign:

# making user first learner
extended_profile_data[g2a_constants.IS_FIRST_LEARNER] = True
extended_profile_data[g2a_constants.IS_ORGANIZATION_METRICS_SUBMITTED] = True

# Create organization if not already exists and make user first learner
organization_to_assign = Organization.objects.create(label=organization_name, **organization_data)
organization_to_assign.save()
Expand Down

0 comments on commit f0c80c7

Please # to comment.