Skip to content

Commit

Permalink
Merge pull request #329 from ucsd-ets/develop
Browse files Browse the repository at this point in the history
QA release for Release 2020-03-26
  • Loading branch information
danialmalik authored Mar 25, 2020
2 parents 0c8224c + b70ac46 commit c521ded
Show file tree
Hide file tree
Showing 19 changed files with 389 additions and 192 deletions.
2 changes: 1 addition & 1 deletion common/djangoapps/course_modes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from openedx.features.content_type_gating.models import ContentTypeGatingConfig
from openedx.features.course_duration_limits.models import CourseDurationLimitConfig
from openedx.features.ucsd_features.ecommerce.utils import is_user_eligible_for_discount
from openedx.features.ucsd_features.ecommerce.EcommerceClient import EcommerceRestAPIClient
from openedx.features.ucsd_features.ecommerce.ecommerce_client import EcommerceRestAPIClient
from openedx.features.ucsd_features.ecommerce.constants import IS_DISCOUNT_AVAILABLE_QUERY_PARAM
from student.models import CourseEnrollment
from util.db import outer_atomic
Expand Down
1 change: 0 additions & 1 deletion common/djangoapps/student/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@ def student_dashboard(request):

# Display activation message
activate_account_message = ''
activation_email_support_link = 'http://edtech.ucsd.edu/uc-san-diego-online-help'
if not user.is_active:
activate_account_message = Text(_(
"Check your {email_start}{email}{email_end} inbox for an account activation link from {platform_name}. "
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/views/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
from openedx.core.djangoapps.user_api.models import UserRetirementRequest
from openedx.core.djangoapps.user_api.preferences import api as preferences_api
from openedx.features.ucsd_features.ecommerce.utils import is_user_eligible_for_discount
from openedx.features.ucsd_features.ecommerce.EcommerceClient import EcommerceRestAPIClient
from openedx.features.ucsd_features.ecommerce.ecommerce_client import EcommerceRestAPIClient
from openedx.features.ucsd_features.ecommerce.tasks import assign_course_voucher_to_user
from openedx.features.ucsd_features.ecommerce.constants import IS_DISCOUNT_AVAILABLE_QUERY_PARAM
from openedx.features.ucsd_features.utils import add_to_ga_events_cookie
Expand Down
158 changes: 1 addition & 157 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3492,160 +3492,4 @@ def _make_locale_paths(settings):
FEATURES['DISABLE_REFUND_FAILURE_NOTIFICATION'] = True
FEATURES['ENABLE_GEOGRAPHIC_DISCOUNTS'] = True

COUNTRIES_ELIGIBLE_FOR_DISCOUNTS = {
'AF': 'Afghanistan',
'AL': 'Albania',
'DZ': 'Algeria',
'AO': 'Angola',
'AG': 'Antigua and Barbuda',
'AR': 'Argentina',
'AM': 'Armenia',
'AW': 'Aruba',
'AZ': 'Azerbaijan',
'BS': 'Bahamaz',
'BH': 'Bahrain',
'BD': 'Bangladesh',
'BB': 'Barbados',
'BY': 'Belarus',
'BZ': 'Belize',
'BJ': 'Benin',
'BT': 'Bhutan',
'BO': 'Bolivia',
'BA': 'Bosnia and Herzegovina',
'BW': 'Botswana',
'BR': 'Brazil',
'BN': 'Brunei Darussalam',
'BG': 'Bulgaria',
'BF': 'Burkina Faso',
'BI': 'Burundi',
'CV': 'Cabo Verde',
'KH': 'Cambodia',
'CM': 'Cameroon',
'CF': 'Central African Republic',
'TD': 'Chad',
'CL': 'Chile',
'CN': 'China',
'CO': 'Colombia',
'KM': 'Comoros',
'CD': 'Democratic Republic of the Congo',
'CD': 'Republic of Congo',
'CR': 'Costa Rica',
'CI': 'Côte d\'Ivoire',
'HR': 'Croatia',
'DJ': 'Djibouti',
'DM': 'Dominica',
'DO': 'Dominican Republic',
'EC': 'Ecuador',
'EG': 'Egypt',
'SV': 'El Salvador',
'GQ': 'Equatorial Guinea',
'ER': 'Eritrea',
'SZ': 'Eswatini',
'ET': 'Ethiopia',
'FJ': 'Fiji',
'GA': 'Gabon',
'GM': 'Gambia',
'GE': 'Georgia',
'GH': 'Ghana',
'GD': 'Grenada',
'GT': 'Guatemala',
'GN': 'Guinea',
'GW': 'Guinea-Bissau',
'GY': 'Guyana',
'HT': 'Haiti',
'HN': 'Honduras',
'HU': 'Hungary',
'IN': 'India',
'ID': 'Indonesia',
'IR': 'Iran',
'IQ': 'Iraq',
'JM': 'Jamaica',
'JO': 'Jordan',
'KZ': 'Kazakhstan',
'KE': 'Kenya',
'KI': 'Kiribati',
'RS': 'Kosovo',
'KW': 'Kuwait',
'KG': 'Kyrgyzstan',
'LA': 'Lao People\'s Democratic Republic',
'LB': 'Lebanon',
'LS': 'Lesotho',
'LR': 'Liberia',
'LY': 'Libya',
'MK': 'Macedonia',
'MG': 'Madagascar',
'MW': 'Malawi',
'MY': 'Malaysia',
'MV': 'Maldives',
'ML': 'Mali',
'MH': 'Marshall Islands',
'MR': 'Mauritania',
'MU': 'Mauritius',
'MX': 'Mexico',
'FM': 'Micronesia',
'MD': 'Moldova',
'MN': 'Mongolia',
'ME': 'Montenegro',
'MA': 'Morocco',
'MZ': 'Mozambique',
'MM': 'Myanmar',
'NA': 'Namibia',
'NR': 'Nauru',
'NP': 'Nepal',
'NI': 'Nicaragua',
'NE': 'Niger',
'NG': 'Nigeria',
'OM': 'Oman',
'PK': 'Pakistan',
'PW': 'Palau',
'PA': 'Panama',
'PG': 'Papua New Guinea',
'PY': 'Paraguay',
'PE': 'Peru',
'PH': 'Philippines',
'PL': 'Poland',
'QA': 'Qatar',
'RO': 'Romania',
'RU': 'Russian Federation',
'RW': 'Rwanda',
'WS': 'Samoa',
'ST': 'São Tomé and Príncipe',
'SA': 'Saudi Arabia',
'SN': 'Senegal',
'RS': 'Serbia',
'SC': 'Seychelles',
'SL': 'Sierra Leone',
'SB': 'Solomon Islands',
'SO': 'Somalia',
'ZA': 'South Africa',
'SS': 'South Sudan',
'LK': 'Sri Lanka',
'KN': 'Saint Kitts and Nevis',
'LC': 'Saint Lucia',
'VC': 'Saint Vincent and the Grenadines',
'SD': 'Sudan',
'SR': 'Suriname',
'SY': 'Syrian Arab Republic',
'TJ': 'Tajikistan',
'TZ': 'Tanzania',
'TH': 'Thailand',
'TL': 'Timor-Leste',
'TG': 'Togo',
'TO': 'Tonga',
'TT': 'Trinidad and Tobago',
'TN': 'Tunisia',
'TR': 'Turkey',
'TM': 'Turkmenistan',
'TV': 'Tuvalu',
'UG': 'Uganda',
'UA': 'Ukraine',
'AE': 'United Arab Emirates',
'UY': 'Uruguay',
'UZ': 'Uzbekistan',
'VU': 'Vanuatu',
'VE': 'Venezuela',
'VN': 'Viet nam',
'YE': 'Yemen',
'ZM': 'Zambia',
'ZW': 'Zimbabwe'
}
COUNTRIES_ELIGIBLE_FOR_DISCOUNTS = {}
1 change: 1 addition & 0 deletions lms/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,4 @@
FEATURES['DISABLE_REFUND_FAILURE_NOTIFICATION'] = False
FEATURES['AUTOMATIC_PERMANENT_ACCOUNT_VERIFICATION'] = False
FEATURES['ENABLE_GEOGRAPHIC_DISCOUNTS'] = False
COUNTRIES_ELIGIBLE_FOR_DISCOUNTS = {}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class StudentAccountDeletion extends React.Component {
const changeAcctInfoText = StringUtils.interpolate(
gettext('{htmlStart}Want to change your email, name, or password instead?{htmlEnd}'),
{
htmlStart: '<a href="https://https://edtech.ucsd.edu/uc-san-diego-online-help/account_basics/manage-your-account-settings/index.html#Manage-Your-Account-Settings" target="_blank">',
htmlStart: '<a href="https://edtech.ucsd.edu/uc-san-diego-online-help/account_basics/manage-your-account-settings/index.html#Manage-Your-Account-Settings" target="_blank">',
htmlEnd: '</a>',
},
);
Expand Down
13 changes: 1 addition & 12 deletions lms/static/js/student_account/views/RegisterView.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,7 @@
field.errorMessages = this.escapeStrings(field.errorMessages);
}

if (field.required) {
requiredFields.push(field);
} else {
if (field.type !== 'hidden') {
// For the purporse of displaying the optional field toggle,
// the form should be considered to have optional fields
// only if all of the optional fields are being rendering as
// input elements that are visible on the page.
this.hasOptionalFields = true;
}
optionalFields.push(field);
}
requiredFields.push(field);
}

html = this.renderFields(requiredFields, 'required-fields');
Expand Down
130 changes: 130 additions & 0 deletions openedx/features/ucsd_features/additional_registration_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import csv
from django.conf import settings
from django.contrib import admin
from django.db import models
from django.forms import ModelForm
from django.http import HttpResponse

# Backwards compatible settings.AUTH_USER_MODEL
USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')


# Models
class AdditionalRegistrationFields(models.Model):
"""
This model contains two extra fields that will be saved when a user registers.
The form that wraps this model is in the forms.py file.
"""
user = models.OneToOneField(USER_MODEL, null=True)

gender_nb = models.CharField(blank=False, max_length=32, verbose_name=b'Gender', choices=[
(b'male', b'Male'),
(b'female', b'Female'),
(b'nonbinary', b'Non-Binary'),

(b'decline', b'Decline to State'),
])

ethnicity = models.CharField(blank=False, max_length=128, verbose_name=b'Ethnicity', choices=[
(b'african-american-and-black', b'African American and Black'),
(b'american-indian-alaska-native', b'American Indian / Alaska Native'),
(b'asian', b'Asian'),
(b'hispanic-latinx', b'Hispanic / Latinx'),
(b'native-hawaiian-and-pacific-islander', b'Native Hawaiian and Pacific Islander'),
(b'southwest-asia-north-african', b'Southwest Asia / North African'),
(b'white', b'White'),

(b'decline', b'Decline to State'),
])

age = models.CharField(blank=False, max_length=32, verbose_name=b'Age', choices=[
(b'13-17', b'13 - 17 years old'),
(b'18-22', b'18 - 22 years old'),
(b'23-29', b'23 - 29 years old'),
(b'30-49', b'30 - 49 years old'),
(b'50-plus', b'50+ years old'),

(b'decline', b'Decline to State'),
])

education = models.CharField(blank=False, max_length=64, verbose_name=b'Highest level of education completed', choices=[
(b'graduate', b'Graduate'),
(b'undergraduate', b'Undergraduate'),
(b'up-to-high-school', b'Up to High School'),

(b'decline', b'Decline to State'),
])

howheard = models.CharField(blank=False, max_length=64, verbose_name=b'How did you hear about UC San Diego Online', choices=[
(b'social-media', b'Social Media'),
(b'email', b'Email'),
(b'word-of-mouth', b'Word-of-Mouth'),
(b'print-advertisement', b'Print Advertisement'),
(b'other', b'Other'),
])

class Meta:
verbose_name = "Additional Registration Information"
verbose_name_plural = "Additional Registration Information"


# Form
class AdditionalRegistrationFieldsForm(ModelForm):
"""
The fields on this form are derived from the AdditionalRegistrationFields model in models.py.
"""
def __init__(self, *args, **kwargs):
super(AdditionalRegistrationFieldsForm, self).__init__(*args, **kwargs)

class Meta(object):
model = AdditionalRegistrationFields
fields = ('gender_nb', 'ethnicity', 'age', 'education', 'howheard')


# Admin Customization
class ExportCsvMixin:
def export_as_csv(self, request, queryset):
meta = self.model._meta

response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename={}.csv'.format(meta)
writer = csv.writer(response)

field_map = {field.name: field for field in meta.fields}

header = []
for field in self.list_display:
if field in field_map:
header.append(field_map[field].verbose_name)
else:
header.append(field.title())

writer.writerow(header)
for obj in queryset:
row = []
for field in self.list_display:
if field in field_map:
row.append(getattr(obj, field))
else:
row.append(getattr(self, field)(obj))

writer.writerow(row)

return response

export_as_csv.short_description = "Export Selected"


@admin.register(AdditionalRegistrationFields)
class AdditionalRegistrationFieldsAdmin(admin.ModelAdmin, ExportCsvMixin):
list_display = ('user_id', 'username', 'email', 'gender_nb', 'ethnicity', 'age', 'education', 'howheard')
actions = ["export_as_csv"]

def user_id(self, x):
return x.user.id

def username(self, x):
return x.user.username

def email(self, x):
return x.user.email
1 change: 1 addition & 0 deletions openedx/features/ucsd_features/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ class UcsdFeatures(AppConfig):
def ready(self):
super(UcsdFeatures, self).ready()
from .signals import *
from .additional_registration_fields import *
4 changes: 4 additions & 0 deletions openedx/features/ucsd_features/ecommerce/constants.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
"""
This file contains constants used in the "ecommerce" module of "UCSDFeatures" app
"""

IS_DISCOUNT_AVAILABLE_QUERY_PARAM = 'is_discount_available'
Loading

0 comments on commit c521ded

Please sign in to comment.