diff --git a/lms/djangoapps/onboarding/forms.py b/lms/djangoapps/onboarding/forms.py index 294f57276469..64d4ae4536c6 100644 --- a/lms/djangoapps/onboarding/forms.py +++ b/lms/djangoapps/onboarding/forms.py @@ -130,6 +130,11 @@ def __init__(self, *args, **kwargs): self.fields['country_of_employment'].required = False self.fields['city_of_employment'].required = False + if not self.instance.organization: + self.fields['role_in_org'].required = False + self.fields['start_month_year'].required = False + self.fields['hours_per_week'].required = False + focus_area_choices = ((field_name, label) for field_name, label in UserExtendedProfile.FUNCTIONS_LABELS.items()) @@ -174,12 +179,13 @@ def clean_language(self): raise forms.ValidationError(ugettext_noop('Please select language.')) def clean_start_month_year(self): - start_month_year = datetime.strptime( - self.cleaned_data['start_month_year'], - '%m/%Y') + if self.instance.organization: + start_month_year = datetime.strptime( + self.cleaned_data['start_month_year'], + '%m/%Y') - if start_month_year > datetime.now(): - raise forms.ValidationError(ugettext_noop("Please enter a valid start month/year")) + if start_month_year > datetime.now(): + raise forms.ValidationError(ugettext_noop("Please enter a valid start month/year")) return self.cleaned_data['start_month_year'] @@ -711,7 +717,10 @@ def save(self, user=None, commit=True): prev_org = extended_profile.organization extended_profile.organization = organization_to_assign - # Reset organizations under my administrations if i updated my organization + ask for org details + if organization_to_assign.users_count() == 0: + extended_profile.is_first_learner = True + + # Reset organizations under my administrations if i updated my organization & ask for org details if not prev_org == organization_to_assign: Organization.objects.filter(admin=user).update(admin=None) extended_profile.is_organization_metrics_submitted = False @@ -731,6 +740,13 @@ def save(self, user=None, commit=True): extended_profile.organization.admin = None extended_profile.organization.save() + if extended_profile.is_first_learner: + extended_profile.is_first_learner = False + + extended_profile.role_in_org = None + extended_profile.start_month_year = None + extended_profile.hours_per_week = 0 + extended_profile.organization = None extended_profile.is_organization_metrics_submitted = False diff --git a/lms/djangoapps/onboarding/models.py b/lms/djangoapps/onboarding/models.py index e753a3ffd538..4444036c377d 100644 --- a/lms/djangoapps/onboarding/models.py +++ b/lms/djangoapps/onboarding/models.py @@ -541,7 +541,9 @@ def get_normal_user_attend_surveys(self): """ attended_list = [] - if self.user.profile.level_of_education and self.start_month_year and self.english_proficiency: + if (not self.organization and self.user.profile.level_of_education and self.english_proficiency) or ( + self.organization and self.user.profile.level_of_education and self.start_month_year and + self.english_proficiency): attended_list.append(self.SURVEYS_LIST[0]) if self.is_interests_data_submitted: attended_list.append(self.SURVEYS_LIST[1]) diff --git a/lms/djangoapps/onboarding/views.py b/lms/djangoapps/onboarding/views.py index 1b1046769b80..ac51e2fe908b 100644 --- a/lms/djangoapps/onboarding/views.py +++ b/lms/djangoapps/onboarding/views.py @@ -59,7 +59,6 @@ def user_info(request): is_under_age = False template = 'onboarding/tell_us_more_survey.html' - next_page_url = reverse('interests') redirect_to_next = True if request.path == reverse('additional_information'): @@ -98,11 +97,16 @@ def user_info(request): if form.is_valid() and not is_under_age: form.save(request) - - are_forms_complete = not (bool(user_extended_profile.unattended_surveys(_type='list'))) + unattended_surveys = user_extended_profile.unattended_surveys(_type='list') + are_forms_complete = not (bool(unattended_surveys)) if not are_forms_complete and redirect_to_next: - return redirect(next_page_url) + return redirect(unattended_surveys[0]) + + # this will only executed if user updated his/her employed status from account settings page + # redirect user to account settings page where he come from + if not request.path == "/myaccount/additional_information/": + return redirect(reverse("update_account_settings")) else: form = forms.UserInfoModelForm(instance=user_extended_profile, initial=initial) @@ -386,10 +390,11 @@ def update_account_settings(request): form = forms.UpdateRegModelForm(request.POST, instance=user_extended_profile) if form.is_valid(): user_extended_profile = form.save(user=user_extended_profile.user, commit=True) - are_forms_complete = not (bool(user_extended_profile.unattended_surveys(_type='list'))) + unattended_surveys = user_extended_profile.unattended_surveys(_type='list') + are_forms_complete = not (bool(unattended_surveys)) if not are_forms_complete : - return redirect(reverse('organization')) + return redirect(reverse(unattended_surveys[0])) return redirect(reverse('update_account_settings')) diff --git a/lms/djangoapps/philu_overrides/branding/api.py b/lms/djangoapps/philu_overrides/branding/api.py index a47e8b723df2..0372a5e674fc 100644 --- a/lms/djangoapps/philu_overrides/branding/api.py +++ b/lms/djangoapps/philu_overrides/branding/api.py @@ -138,9 +138,10 @@ def _auth_footer_navigation_links(): "name": link_name, "title": link_title, "url": link_url, + "target": link_target, } - for link_name, link_url, link_title in [ - ("about", "https://philanthropyu.org/about-us/", _("About Philanthropy University")) + for link_name, link_url, link_title, link_target in [ + ("about", "https://philanthropyu.org/about-us/our-story/", _("About Philanthropy University"), "_blank") ] if link_url and link_url != "#" ] @@ -154,10 +155,11 @@ def _auth_footer_courses_communities_links(): "name": link_name, "title": link_title, "url": link_url, + "target": link_target, } - for link_name, link_url, link_title in [ - ("explore_course", "/courses", _("Explore our Courses")), - ("communities", settings.NODEBB_ENDPOINT, _("Be part of our Communities")), + for link_name, link_url, link_title, link_target in [ + ("explore_course", "/courses", _("Explore our Courses"), "_self"), + ("communities", settings.NODEBB_ENDPOINT, _("Be part of our Communities"), "_self"), ] if link_url and link_url != "#" ] @@ -172,11 +174,12 @@ def _footer_navigation_links(): "name": link_name, "title": link_title, "url": link_url, + "target": link_target, } - for link_name, link_url, link_title in [ - ("about", "https://philanthropyu.org/about-us/", _("About Philanthropy University")), - ("explore_course", "/courses", _("Explore our Courses")), - ("communities", settings.NODEBB_ENDPOINT, _("Be part of our Communities")), + for link_name, link_url, link_title, link_target in [ + ("about", "https://philanthropyu.org/about-us/our-story/", _("About Philanthropy University"), "_blank"), + ("explore_course", "/courses", _("Explore our Courses"), "_self"), + ("communities", settings.NODEBB_ENDPOINT, _("Be part of our Communities"), "_self"), ] if link_url and link_url != "#" ] @@ -185,10 +188,9 @@ def _footer_navigation_links(): def _auth_footer_legal_links(): """Return the legal footer links (e.g. terms of service). """ links = [ - ("terms_of_service_and_honor_code", "https://philanthropyu.org/terms-of-use/", _("Terms of Use")), - ("privacy_policy", "https://philanthropyu.org/privacy-policy/", _("Privacy Policy")), - ("faq", "/faq", _("FAQ")), - ("disclaimir", "/disclaimer", _("Disclaimer")) + ("terms_of_service_and_honor_code", "https://philanthropyu.org/terms-of-use/", _("Terms of Use"), "_blank"), + ("privacy_policy", "https://philanthropyu.org/privacy-policy/", _("Privacy Policy"), "_blank"), + ("faq", "https://philanthropyu.org/faq/", _("FAQ"), "_blank") ] return [ @@ -196,8 +198,9 @@ def _auth_footer_legal_links(): "name": link_name, "title": link_title, "url": link_url, + "target": link_target, } - for link_name, link_url, link_title in links + for link_name, link_url, link_title, link_target in links if link_url and link_url != "#" ] @@ -206,10 +209,9 @@ def my_footer_legal_links(): """Return the legal footer links (e.g. terms of service). """ links = [ - ("terms_of_service_and_honor_code", "https://philanthropyu.org/terms-of-use/", _("Terms of Use")), - ("privacy_policy", "https://philanthropyu.org/privacy-policy/", _("Privacy Policy")), - ("faq", "/faq", _("FAQ")), - ("disclaimir", "/disclaimer", _("Disclaimer")) + ("terms_of_service_and_honor_code", "https://philanthropyu.org/terms-of-use/", _("Terms of Use"), "_blank"), + ("privacy_policy", "https://philanthropyu.org/privacy-policy/", _("Privacy Policy"), "_blank"), + ("faq", "https://philanthropyu.org/faq/", _("FAQ"), "_blank") ] return [ @@ -217,8 +219,9 @@ def my_footer_legal_links(): "name": link_name, "title": link_title, "url": link_url, + "target": link_target, } - for link_name, link_url, link_title in links + for link_name, link_url, link_title, link_target in links if link_url and link_url != "#" ]