Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save es keywords to profile and fix onboarding #5105

Merged
merged 3 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
55 changes: 28 additions & 27 deletions app/assets/v2/js/pages/onboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ onboard.watchMetamask = function() {
}
};

onboard.getFilters = function(savedKeywords) {
onboard.getFilters = function(savedKeywords, currentKeywords) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added parameters because was saving empty when going out of that page

$('.suggested-tag input[type=checkbox]:checked + span i').removeClass('fa-plus').addClass('fa-check');
$('.suggested-tag input[type=checkbox]:not(:checked) + span i').removeClass('fa-check').addClass('fa-plus');

Expand All @@ -120,8 +120,8 @@ onboard.getFilters = function(savedKeywords) {
});
}

if (savedKeywords) {
$.each(savedKeywords, function(k, value) {
if (currentKeywords) {
$.each(currentKeywords, function(k, value) {
if (keywords.includes(value.toLowerCase())) {
$('input[type=checkbox][name=tech-stack][value="' + value.toLowerCase() + '"]').prop('checked', true);
} else {
Expand Down Expand Up @@ -149,24 +149,25 @@ onboard.getFilters = function(savedKeywords) {
$('#selected-skills').css('display', 'inherit');

$('.filter-tags').html(_filters);
words = [...new Set(_words)];
// TODO: Save Preferences
var settings = {
url: '/settings/matching',
method: 'POST',
headers: {'X-CSRFToken': csrftoken},
data: JSON.stringify({
'keywords': 'JavaScript,CCoffeeScript,CSS,HTML',
'submit': 'Go',
'github': 'thelostone-mc'
})
};

$.ajax(settings).done(function(response) {
// TODO : Update keywords for user profile
}).fail(function(error) {
// TODO: Handle Error
});

if (savedKeywords) {

words = [...new Set(_words)];
var settings = {
url: '/settings/matching',
method: 'POST',
headers: {'X-CSRFToken': csrftoken},
data: {
'keywords': words.join(),
'submit': 'Go'
}
};

$.ajax(settings).done(function(response) {
}).fail(function(error) {
// TODO: Handle Error
});
}
};

var changeStep = function(n) {
Expand Down Expand Up @@ -226,21 +227,21 @@ keywords.forEach(function(keyword) {

$('#skills #suggested-tags').html(suggested_tags);

if ($('.navbar #navbarDropdown').html()) {
var url = '/api/v0.1/profile/' + $('.navbar #navbarDropdown').html().trim() + '/keywords';
if (document.contxt.github_handle) {
var url = `/api/v0.1/profile/${document.contxt.github_handle}/keywords`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this because menu changed and now $('.navbar #navbarDropdown') wasn't the user gh, was "Products"


$.get(url, function(response) {
onboard.getFilters(response.keywords);
onboard.getFilters(false, response.keywords);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will just populate the keywords if you already have any

});
}

$('.suggested-tag input[type=checkbox]').change(function(e) {
onboard.getFilters();
onboard.getFilters(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will save the changes

});

$('.search-area input[type=text]').keypress(function(e) {
if (e.which == 13) {
onboard.getFilters();
onboard.getFilters(true);
e.preventDefault();
}
});
Expand All @@ -260,4 +261,4 @@ var redirectURL = function() {
document.location.href = url;
};

localStorage['onboarded_funder'] = true;
localStorage['onboarded_funder'] = true;
5 changes: 3 additions & 2 deletions app/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,21 @@ def matching_settings(request):

"""
# setup
__, es, __, is_logged_in = settings_helper_get_auth(request)
profile, es, __, is_logged_in = settings_helper_get_auth(request)
if not es:
login_redirect = redirect('/login/github?next=' + request.get_full_path())
return login_redirect

msg = ''

if request.POST and request.POST.get('submit'):
github = request.POST.get('github', '')
keywords = request.POST.get('keywords').split(',')
if github:
es.github = github
if keywords:
es.keywords = keywords
profile.keywords = keywords
profile.save()
es = record_form_submission(request, es, 'match')
es.save()
msg = _('Updated your preferences.')
Expand Down