Skip to content

Commit

Permalink
Merge branch 'master' into issue-3907-profile-header-update
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu authored Jul 17, 2019
2 parents 099e5ed + 0ba380b commit 2b5845e
Show file tree
Hide file tree
Showing 28 changed files with 292 additions and 169 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
2 changes: 2 additions & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,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
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
2 changes: 1 addition & 1 deletion app/assets/v2/js/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ratingModal = (bountyId, receiver, elem) => {
}).done(function(result) {
$('body').append(result);
$('#modalRating').bootstrapModal('show');
$('[data-toggle="tooltip"]').runTooltip();
$('[data-toggle="tooltip"]').bootstrapTooltip();
$('input[name="review[rating]"]').filter('[value="' + elem.val() + '"]').prop('checked', true);

$('#ratingForm').on('submit', function(e) {
Expand Down
53 changes: 0 additions & 53 deletions app/assets/v2/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,6 @@ var loading_button = function(button) {
button.prepend('<img src=' + static_url + 'v2/images/loading_white.gif style="max-width:20px; max-height: 20px">');
};

var 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 {
var new_top = (index * 66) + 'px';

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


var update_metamask_conf_time_and_cost_estimate = function() {
var confTime = 'unknown';
var ethAmount = 'unknown';
Expand Down Expand Up @@ -224,43 +209,6 @@ var normalizeURL = function(url) {
return url.replace(/\/$/, '');
};

var _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);
};

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

return html;
};

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

return html;
};

var timestamp = function() {
return Math.floor(Date.now() / 1000);
};
Expand Down Expand Up @@ -1043,7 +991,6 @@ attach_change_element_type();

window.addEventListener('load', function() {
setInterval(listen_for_web3_changes, 1000);
attach_close_button();
});

var promptForAuth = function(event) {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/v2/js/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Vue.mixin({
let postInvite = fetchData(
apiUrlInvite,
'POST',
{ 'url': bounty.github_url, 'usersId': [user], 'bountyId': bounty.id},
{ 'usersId': [user], 'bountyId': bounty.id},
{'X-CSRFToken': csrftoken}
);

Expand Down
10 changes: 1 addition & 9 deletions app/dashboard/templates/bounty/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,8 @@ <h5 class="bounty-heading">{% trans "Funder" %}</h5>
<script src="/dynamic/js/tokens_dynamic.js"></script>
<script src="{% static "v2/js/tokens.js" %}"></script>
<script src="{% static "v2/js/amounts.js" %}"></script>
<script src="{% static "v2/js/lib/popper.min.js" %}"></script>
<script src="{% static "v2/js/lib/bootstrap.min.js" %}" crossorigin="anonymous"></script>
<script src="{% static "v2/js/clipboard.js" %}"></script>
<script src="{% static "v2/js/clipboard.js" %}"></script>>
<script>
let bootstrapTooltip = $.fn.tooltip.noConflict()
let bootstrapModal = $.fn.modal.noConflict()
$.fn.bootstrapModal = bootstrapModal
</script>
<script>
$.fn.runTooltip = bootstrapTooltip
$('[data-toggle="popover"]').popover()

$("body").on("mouseover", "[data-username] img", function(e) {
Expand Down
11 changes: 1 addition & 10 deletions app/dashboard/templates/bounty/fulfill.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,9 @@ <h1 class="text-center title">{% trans "Submit Work" %}</h1>
{% include 'shared/footer.html' %}
{% include 'shared/messages.html' %}
</body>

<!-- jQuery -->
<script src="{% static "v2/js/lib/popper.min.js" %}"></script>
<script src="{% static "v2/js/lib/bootstrap.min.js" %}" crossorigin="anonymous"></script>
<script>
var bootstrapTooltip = $.fn.tooltip.noConflict()
var bootstrapModal = $.fn.modal.noConflict()
$.fn.runTooltip = bootstrapTooltip
$.fn.bootstrapModal = bootstrapModal
$('[data-toggle="popover"]').popover()
$('[data-toggle="tooltip"]').runTooltip();

$('[data-toggle="tooltip"]').bootstrapTooltip();
</script>
<script src="{% static "v2/js/pages/wallet_estimate.js" %}"></script>
<script src="{% static "v2/js/rating.js" %}"></script>
Expand Down
Loading

0 comments on commit 2b5845e

Please sign in to comment.