-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
Private repo #3728
Merged
+1,183
−71
Merged
Private repo #3728
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
43cab9d
mackup
octavioamu f8bf7a6
Merge branch 'master' into private-repo
octavioamu 2a42ed0
mackup
octavioamu 6a653ee
change visual fund new
octavioamu 0a28d58
Backend for private repo
SaptakS faeda64
Merge branch 'master' into private-repo
SaptakS 27ed280
add fields
octavioamu b318a3d
Merge branch 'private-repo' of https://github.com/gitcoinco/web into …
octavioamu 29af38f
fix lint
octavioamu d9b97c4
Adds validation for private repo checks in backend
SaptakS 4b2df80
Adds private repo validation in js on frontend submission of form
SaptakS a512329
commented out v2
octavioamu 72638e1
add nda, change modal
octavioamu 233edfd
change validation
octavioamu 75a2ea4
Adds backend for unsigned nda
SaptakS 0dc7df6
Merge branch 'private-repo' of github.com:gitcoinco/web into private-…
SaptakS 58d387b
Adds uploading of signed and unsigned nda
SaptakS 593c0cb
Fixes isort
SaptakS cd4d15d
Fixes foreign key assignment and fetching in DRF
SaptakS f986344
add nda download
octavioamu 5960905
change button when private repo
octavioamu 4a90676
fix send interest
octavioamu b28a4f3
clean code
octavioamu 9d72797
add doc in activity
octavioamu 0d85a44
Merge branch 'master' into private-repo
octavioamu 5e4099a
Merge branch 'master' into private-repo
octavioamu 878e898
add private modal
octavioamu 9ce2fd8
add condition to private instructions
octavioamu 2ac7dd1
Merge branch 'master' into private-repo
octavioamu ec48e03
Merge branch 'master' into private-repo
octavioamu f54a762
add email for private repo
octavioamu a5c9fec
Merge branch 'master' into private-repo
octavioamu b0aba5c
Fix migration conflicts
SaptakS c233280
Merge branch 'master' into private-repo
SaptakS 9eaca2c
Merge branch 'master' into private-repo
octavioamu 4fe2b2f
solve migrations conflict
octavioamu 6a924ce
Merge branch 'private-repo' of https://github.com/gitcoinco/web into …
octavioamu 86942a6
fix isort
octavioamu e564b84
Merge branch 'master' into private-repo
octavioamu 26d6b23
remove dead code
octavioamu 6467e01
Merge branch 'master' into private-repo
octavioamu 831fbfa
fix migrations
octavioamu db79e7d
fix isort
octavioamu b9743b1
Merge branch 'master' into private-repo
octavioamu 0f10872
Fixes migrations related_names
SaptakS 1d5ec38
Merge branch 'master' into private-repo
SaptakS cdf21ac
Merge branch 'master' into private-repo
octavioamu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -633,51 +633,132 @@ var attach_override_status = function() { | |
}); | ||
}; | ||
|
||
|
||
var show_interest_modal = function() { | ||
var self = this; | ||
let modals = $('#modalInterest'); | ||
let modalBody = $('#modalInterest .modal-content'); | ||
let modalUrl = `/interest/modal?redirect=${window.location.pathname}&pk=${document.result['pk']}`; | ||
|
||
modals.on('show.bs.modal', function() { | ||
modalBody.load(modalUrl, ()=> { | ||
if (document.result['repo_type'] === 'private') { | ||
$('#nda-upload').show(); | ||
$('#issueNDA').prop('required', true); | ||
document.result.unsigned_nda ? $('.nda-download-link').attr('href', document.result.unsigned_nda.doc) : $('#nda-upload').hide(); | ||
} | ||
|
||
setTimeout(function() { | ||
var url = '/interest/modal?redirect=' + window.location.pathname + '&pk=' + document.result['pk']; | ||
|
||
$.get(url, function(newHTML) { | ||
var modal = $(newHTML).appendTo('body').modal({ | ||
modalClass: 'modal add-interest-modal' | ||
}); | ||
|
||
var actionPlanForm = modal.find('form#action_plan'); | ||
var issueMessage = actionPlanForm.find('#issue_message'); | ||
let actionPlanForm = $('#action_plan'); | ||
let issueMessage = $('#issue_message'); | ||
|
||
issueMessage.attr('placeholder', gettext('What steps will you take to complete this task? (min 30 chars)')); | ||
|
||
modal.on('submit', function(event) { | ||
actionPlanForm.on('submit', function(event) { | ||
event.preventDefault(); | ||
|
||
var msg = issueMessage.val().trim(); | ||
let msg = issueMessage.val().trim(); | ||
let issueNDA = $('#issueNDA')[0].files; | ||
|
||
if (!msg || msg.length < 30) { | ||
_alert({message: gettext('Please provide an action plan for this ticket. (min 30 chars)')}, 'error'); | ||
return false; | ||
} | ||
|
||
if (typeof issueNDA[0] !== 'undefined') { | ||
const formData = new FormData(); | ||
|
||
formData.append('docs', issueNDA[0]); | ||
formData.append('doc_type', 'signed_nda'); | ||
const ndaSend = { | ||
url: '/api/v0.1/bountydocument', | ||
method: 'POST', | ||
data: formData, | ||
processData: false, | ||
dataType: 'json', | ||
contentType: false | ||
}; | ||
|
||
$.ajax(ndaSend).done(function(response) { | ||
_alert(response.message, 'info'); | ||
add_interest(document.result['pk'], { | ||
issue_message: msg, | ||
signed_nda: response.bounty_doc_id | ||
}).then(success => { | ||
if (success) { | ||
$(self).attr('href', '/uninterested'); | ||
$(self).find('span').text(gettext('Stop Work')); | ||
$(self).parent().attr('title', '<div class="tooltip-info tooltip-sm">' + gettext('Notify the funder that you will not be working on this project') + '</div>'); | ||
$.modal.close(); | ||
} | ||
}).catch((error) => { | ||
if (error.responseJSON.error === 'You may only work on max of 3 issues at once.') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a better way we can check for this error? I worry that in the future we may change this error message and not realize that it will break this. |
||
return; | ||
throw error; | ||
}); | ||
}).fail(function(error) { | ||
_alert(error, 'error'); | ||
}); | ||
} else { | ||
add_interest(document.result['pk'], { | ||
issue_message: msg | ||
}).then(success => { | ||
if (success) { | ||
$(self).attr('href', '/uninterested'); | ||
$(self).find('span').text(gettext('Stop Work')); | ||
$(self).parent().attr('title', '<div class="tooltip-info tooltip-sm">' + gettext('Notify the funder that you will not be working on this project') + '</div>'); | ||
$.modal.close(); | ||
} | ||
}).catch((error) => { | ||
if (error.responseJSON.error === 'You may only work on max of 3 issues at once.') | ||
return; | ||
throw error; | ||
}); | ||
} | ||
|
||
add_interest(document.result['pk'], { | ||
issue_message: msg | ||
}).then(success => { | ||
if (success) { | ||
$(self).attr('href', '/uninterested'); | ||
$(self).find('span').text(gettext('Stop Work')); | ||
$(self).parent().attr('title', '<div class="tooltip-info tooltip-sm">' + gettext('Notify the funder that you will not be working on this project') + '</div>'); | ||
$.modal.close(); | ||
} | ||
}).catch((error) => { | ||
if (error.responseJSON.error === 'You may only work on max of 3 issues at once.') | ||
return; | ||
throw error; | ||
}); | ||
}); | ||
|
||
}); | ||
}); | ||
modals.bootstrapModal('show'); | ||
}; | ||
|
||
const repoInstructions = () => { | ||
let linkToSettings = `https://github.com/${document.result.github_org_name}/${document.result.github_repo_name}/settings/collaboration`; | ||
|
||
|
||
let modalTmp = ` | ||
<div class="modal fade g-modal" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true"> | ||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body text-center center-block w-75"> | ||
<h5> | ||
You have successfully approved the contributor to work on your bounty! | ||
</h5> | ||
<div> | ||
<img src="${document.contxt.STATIC_URL}v2/images/repo-instructions.png" class="mw-100 my-4" alt=""> | ||
</div> | ||
<p class="mb-4">Now you need to invite the contributor to your private repo on GitHub You can find it under <b>GitHub repository > Settings > Collaborators</b></p> | ||
<div> | ||
<img src="${document.contxt.STATIC_URL}v2/images/repo-settings.png" class="mw-100" alt=""> | ||
</div> | ||
</div> | ||
<div class="modal-footer justify-content-center"> | ||
<a href="${linkToSettings}" target="_blank" class="button button--primary"><i class="fab fa-github"></i> Go to Repo Settings</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div>`; | ||
|
||
$(modalTmp).bootstrapModal('show'); | ||
|
||
$(document, modalTmp).on('hidden.bs.modal', function(e) { | ||
$('#exampleModalCenter').remove(); | ||
$(modalTmp).bootstrapModal('dispose'); | ||
}); | ||
}; | ||
|
||
var set_extended_time_html = function(extendedDuration, currentExpires) { | ||
|
@@ -1055,7 +1136,8 @@ var do_actions = function(result) { | |
const _entry = { | ||
enabled: true, | ||
href: github_url, | ||
text: gettext('View On Github') + | ||
text: (result['repo_type'] === 'private' ? '<i class="fas fa-lock"></i> ' + | ||
gettext('Private Repo') : gettext('View On Github')) + | ||
(result['is_issue_closed'] ? gettext(' (Issue is closed)') : ''), | ||
parent: 'right_actions', | ||
title: gettext('View issue details and comments on Github'), | ||
|
@@ -1266,6 +1348,10 @@ var pull_bounty_from_api = function() { | |
render_activity(result, results); | ||
|
||
document.result = result; | ||
|
||
if (typeof promptPrivateInstructions !== 'undefined' && result.repo_type === 'private') { | ||
repoInstructions(); | ||
} | ||
return; | ||
} | ||
} | ||
|
@@ -1324,6 +1410,12 @@ const process_activities = function(result, bounty_activities) { | |
const fulfillment = meta.fulfillment || {}; | ||
const new_bounty = meta.new_bounty || {}; | ||
const old_bounty = meta.old_bounty || {}; | ||
const has_signed_nda = result.interested.map(interest => { | ||
if (interest.profile.handle === _activity.profile.handle && interest.signed_nda) { | ||
return interest.signed_nda.doc; | ||
} | ||
return false; | ||
}); | ||
const has_pending_interest = !!result.interested.find(interest => | ||
interest.profile.handle === _activity.profile.handle && interest.pending); | ||
const has_interest = !!result.interested.find(interest => | ||
|
@@ -1357,6 +1449,7 @@ const process_activities = function(result, bounty_activities) { | |
age: timeDifference(now, new Date(_activity.created)), | ||
activity_type: _activity.activity_type, | ||
status: _activity.activity_type === 'work_started' ? 'started' : 'stopped', | ||
signed_nda: has_signed_nda, | ||
uninterest_possible: uninterest_possible, | ||
slash_possible: slash_possible, | ||
approve_worker_url: meta.approve_worker_url, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you move this import within the function from the top of the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah. This is to avoid recursive import here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How much time do you think it would take to refactor out the recursive import? Imports within a function aren't terribly bad, but I think for webservers they can really affect performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will take a lot of adjustments in a lot of places. If it's not too much bad for the performance, I think we can do it in a later adjustment.