Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu authored Jul 17, 2019
2 parents d1b52ce + 6077f2d commit 1c4d201
Show file tree
Hide file tree
Showing 73 changed files with 20,931 additions and 350 deletions.
3 changes: 3 additions & 0 deletions app/app/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ def preprocess(request):
'access_token': profile.access_token if profile else '',
'is_staff': request.user.is_staff if user_is_authenticated else False,
'is_moderator': profile.is_moderator if profile else False,
'persona_is_funder': profile.persona_is_funder if profile else False,
'persona_is_hunter': profile.persona_is_hunter if profile else False,

}
context['json_context'] = json.dumps(context)

Expand Down
4 changes: 4 additions & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@

# api views
url(r'^api/v0.1/profile/(.*)?/keywords', dashboard.views.profile_keywords, name='profile_keywords'),
url(r'^api/v0.1/profile/banner', dashboard.views.change_user_profile_banner, name='change_user_profile_banner'),
url(
r'^api/v0.1/profile/(.*)?/jobopportunity',
dashboard.views.profile_job_opportunity,
name='profile_job_opportunity'
),
url(r'^api/v0.1/profile/(?P<handle>.*)', dashboard.views.profile_details, name='profile_details'),
url(r'^api/v0.1/banners', dashboard.views.load_banners, name='load_banners'),
url(
r'^api/v0.1/get_suggested_contributors',
dashboard.views.get_suggested_contributors,
Expand All @@ -116,6 +118,8 @@
url(r'^actions/api/v0.1/', include(dbrouter.urls)), # same as active
url(r'^api/v0.1/users_search/', dashboard.views.get_users, name='users_search'),
url(r'^api/v0.1/kudos_search/', dashboard.views.get_kudos, name='kudos_search'),
url(r'^api/v0.1/choose_persona/', dashboard.views.choose_persona, name='choose_persona'),

# Health check endpoint
re_path(r'^health/', include('health_check.urls')),
re_path(r'^lbcheck/?', healthcheck.views.lbcheck, name='lbcheck'),
Expand Down
28 changes: 28 additions & 0 deletions app/assets/v2/css/profile.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ a:hover .avatar_edit .avatar_edit_text {
top: 40%;
}

.picky img {
width: 100%;
height: auto;
vertical-align: middle;
}


.profile-organizations .organization {
display: inline-block;
}
Expand Down Expand Up @@ -365,3 +372,24 @@ a:hover .avatar_edit .avatar_edit_text {
.no-profile-textcolor {
color: #666666;
}

.profile-banner {
top: 25vh;
color: #ffffff;
z-index: 99;
width: 100vw;
visibility: hidden;
cursor: pointer;
}

.picky {
cursor: pointer;
}

.picky:active, .picky:focus {
border: 2px solid #007bff;
}

.selected {
border: 5px solid #007bff;
}
60 changes: 60 additions & 0 deletions app/assets/v2/images/modals/persona-choose.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
142 changes: 141 additions & 1 deletion app/assets/v2/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,60 @@ $(document).ready(function() {
}
}
});
attach_close_button();
});

const attach_close_button = function() {
$('body').delegate('.alert .closebtn', 'click', function(e) {
$(this).parents('.alert').remove();
$('.alert').each(function(index) {
if (index == 0) $(this).css('top', 0);
else {
let new_top = (index * 66) + 'px';

$(this).css('top', new_top);
}
});
});
};

const closeButton = function(msg) {
var html = (msg['closeButton'] === false ? '' : '<span class="closebtn" >&times;</span>');

return html;
};

const alertMessage = function(msg) {
var html = `<strong>${typeof msg['title'] !== 'undefined' ? msg['title'] : ''}</strong>${msg['message']}`;

return html;
};

const _alert = function(msg, _class) {
if (typeof msg == 'string') {
msg = {
'message': msg
};
}
var numAlertsAlready = $('.alert:visible').length;
var top = numAlertsAlready * 44;

var html = function() {
return (
`<div class="alert ${_class} g-font-muli" style="top: ${top}px">
<div class="message">
<div class="content">
${alertMessage(msg)}
</div>
</div>
${closeButton(msg)}
</div>`
);
};

$('body').append(html);
};


if ($('#is-authenticated').val() === 'True' && !localStorage['notify_policy_update']) {
localStorage['notify_policy_update'] = true;
Expand All @@ -171,7 +223,7 @@ if ($('#is-authenticated').val() === 'True' && !localStorage['notify_policy_upda
<a href="/legal/policy" target="_blank">${gettext('Read Our Updated Terms')}</a>
</div>
<div class="col-12 mt-4 mb-2 text-right font-caption">
<a rel="modal:close" href="javascript:void" aria-label="Close dialog" class="button button--primary">Ok</a>
<button type="button" class="button button--primary" data-dismiss="modal">ok</button>
</div>
</div>
</div>
Expand All @@ -180,3 +232,91 @@ if ($('#is-authenticated').val() === 'True' && !localStorage['notify_policy_upda
$(content).appendTo('body');
$('#notify_policy_update').bootstrapModal('show');
}

if (document.contxt.github_handle && !document.contxt.persona_is_funder && !document.contxt.persona_is_hunter) {

const content = $.parseHTML(
`<div id="persona_modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content px-4 py-3">
<div class="col-12">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="col-12 pt-2 pb-2 text-center">
<img src="${static_url}/v2/images/modals/persona-choose.svg" width="160" height="137">
<h2 class="font-title mt-4">${gettext('Are you a Funder or a Contributor?')}</h2>
</div>
<div class="col-12 pt-2 text-center">
<p>${gettext('Let us know so we could optimize the <br>best experience for you!')}</p>
</div>
<div class="col-12 my-4 d-flex justify-content-around">
<button type="button" class="btn btn-gc-blue col-5" data-persona="persona_is_funder">I'm a Funder</button>
<button type="button" class="btn btn-gc-blue col-5" data-persona="persona_is_hunter">I'm a Contributor</button>
</div>
</div>
</div>
</div>`);

$(content).appendTo('body');
$('#persona_modal').bootstrapModal('show');
}

$('body').on('click', '[data-persona]', function(e) {
sendPersonal($(this).data('persona'));
});

const sendPersonal = (persona) => {
let postPersona = fetchData('/api/v0.1/choose_persona/', 'POST',
{persona, 'access_token': document.contxt.access_token}
);

$.when(postPersona).then((response, status, statusCode) => {
if (statusCode.status != 200) {
return _alert(response.msg, 'error');
}

$('#persona_modal').bootstrapModal('hide');
const urls = [
{
url: document.location.href,
redirect: '/onboard/funder'
},
{
url: '/bounties/funder',
redirect: '/onboard/funder'
},
{
url: '/contributor',
redirect: '/onboard/contributor'
}
];

const checkUrl = (arr, val) => {
return arr.some(arrObj => {
if (val.indexOf(arrObj.url) >= 0) {
return true;
}
return false;
});
};

if (response.persona === 'persona_is_funder') {
if (checkUrl(urls, document.location.href)) {
window.location = '/onboard/funder';
} else {
return _alert(gettext('Thanks, you can read the guide <a href="/how/funder">here.</a>'), 'info');
}

} else if (response.persona === 'persona_is_hunter') {
if (checkUrl(urls, document.location.href)) {
window.location = '/onboard/contributor';
} else {
return _alert(gettext('Thanks, you can read the guide <a href="/how/contributor">here.</a>'), 'info');
}
}


});
};
4 changes: 2 additions & 2 deletions app/assets/v2/js/pages/bounty_share.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $('.modal-link').click(function(e) {
const sendInvites = (users) => {
let usersId = [];
let msg = $('#shareText').val();
const url = document.issueURL;
const bountyId = document.result.pk;

$.each(users, function(index, elem) {
usersId.push(elem.id);
Expand All @@ -30,7 +30,7 @@ const sendInvites = (users) => {
var sendEmail = fetchData(
'/api/v0.1/social_contribution_email/',
'POST',
{usersId, msg, url, invite_url},
{usersId, msg, bountyId, invite_url},
{'X-CSRFToken': csrftoken}
);

Expand Down
Loading

0 comments on commit 1c4d201

Please sign in to comment.