Skip to content

Commit

Permalink
Merge branch 'master' into kevin/action_urls
Browse files Browse the repository at this point in the history
  • Loading branch information
owocki committed Apr 26, 2018
2 parents 9432928 + 2102eb8 commit 5363f7b
Show file tree
Hide file tree
Showing 18 changed files with 202 additions and 51 deletions.
4 changes: 2 additions & 2 deletions app/app/tests/test_app_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def test_sitemap_resolve(self):
def test_email_settings_reverse(self):
"""Test the email_settings url and check the reverse."""
priv_key = token_hex(16)[:29]
self.assertEqual(reverse('email_settings', args=(priv_key, )), f'/email/settings/{priv_key}')
self.assertEqual(reverse('email_settings', args=(priv_key, )), f'/settings/email/{priv_key}')

def test_email_settings_resolve(self):
"""Test the email_settings url and check the resolution."""
self.assertEqual(resolve('/email/settings/').view_name, 'email_settings')
self.assertEqual(resolve('/settings/email/').view_name, 'email_settings')

def test_leaderboard_reverse(self):
"""Test the leaderboard url and check the reverse."""
Expand Down
11 changes: 5 additions & 6 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,11 @@
url(r'^_administration/process_faucet_request/(.*)$', faucet.views.process_faucet_request, name='process_faucet_request'),

# settings
url(r'^email/settings/(.*)', marketing.views.email_settings, name='email_settings'),
url(r'^settings/email/(.*)', marketing.views.email_settings, name='settings_email'),
url(r'^settings/privacy/?', marketing.views.privacy_settings, name='privacy_settings'),
url(r'^settings/matching/?', marketing.views.matching_settings, name='matching_settings'),
url(r'^settings/feedback/?', marketing.views.feedback_settings, name='feedback_settings'),
url(r'^settings/(.*)?', marketing.views.email_settings, name='feedback_settings'),
re_path(r'^settings/email/(.*)', marketing.views.email_settings, name='email_settings'),
re_path(r'^settings/privacy/?', marketing.views.privacy_settings, name='privacy_settings'),
re_path(r'^settings/matching/?', marketing.views.matching_settings, name='matching_settings'),
re_path(r'^settings/feedback/?', marketing.views.feedback_settings, name='feedback_settings'),
re_path(r'^settings/(.*)?', marketing.views.email_settings, name='feedback_settings'),

# marketing views
url(r'^leaderboard/(.*)', marketing.views.leaderboard, name='leaderboard'),
Expand Down
9 changes: 5 additions & 4 deletions app/assets/v2/css/forms/input.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@
font-size: 12px;
font-family: 'Muli', sans-serif;
}

.form__input-help--dynamic {
position: absolute;
bottom: -20px;
left: 0;
margin-top: 5px;
display: block;
}
.amount_container{
height: 100px;
}
33 changes: 31 additions & 2 deletions app/assets/v2/js/amounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ var estimate = function(amount, conv_rate) {
return gettext('Approx: Unknown amount');
};

var get_rates_estimate = function(usd_amount) {
if (!usd_amount) {
return '';
}
var rates_addon = [];
var rates = [ 40, 80, 120 ];

for (var i = 0; i < rates.length; i++) {
var rate = rates[i];
var hours = usd_amount / rate;
var round_decimals = hours < 1 ? 2 : 1;

hours = Math.round(hours, round_decimals);
rates_addon.push('' + hours + ' hrs at $' + rate + '/hr');
}
rates_addon = rates_addon.join(', ');
return rates_addon;
};

var getUSDEstimate = function(amount, denomination, callback) {
var conv_rate;
var eth_usd;
Expand All @@ -25,7 +44,12 @@ var getUSDEstimate = function(amount, denomination, callback) {
}
if (document.conversion_rates && document.conversion_rates[denomination]) {
conv_rate = document.conversion_rates[denomination];
return callback(estimate(amount, conv_rate));
var usd_estimate = estimate(amount, conv_rate);

rate_estimate = get_rates_estimate(amount * conv_rate);
var return_text = usd_estimate + '<br>' + rate_estimate;

return callback(return_text);
}
var request_url = '/sync/get_amount?amount=' + amount + '&denomination=' + denomination;

Expand All @@ -38,7 +62,12 @@ var getUSDEstimate = function(amount, denomination, callback) {
document.conversion_rates = {};
}
document.conversion_rates[denomination] = conv_rate;
return callback(estimate(amount, conv_rate));
var usd_estimate = estimate(amount, conv_rate);

rate_estimate = get_rates_estimate(amount * conv_rate);
var return_text = usd_estimate + '<br>' + rate_estimate;

return callback(return_text);
}).fail(function() {
return callback(new Error(gettext('Approx: Unknown amount')));
});
Expand Down
7 changes: 7 additions & 0 deletions app/assets/v2/js/pages/fulfill_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ window.onload = function() {

$('#submitBounty').validate({
submitHandler: function(form) {
try {
bounty_address();
} catch (exception) {
_alert(gettext('You are on an unsupported network. Please change your network to a supported network.'));
return;
}

var data = {};
var disabled = $(form)
.find(':input:disabled')
Expand Down
7 changes: 7 additions & 0 deletions app/assets/v2/js/pages/increase_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ $(document).ready(function() {

// submit bounty button click
$('#submitBounty').click(function(e) {
try {
bounty_address();
} catch (exception) {
_alert(gettext('You are on an unsupported network. Please change your network to a supported network.'));
return;
}

mixpanel.track('Increase Bounty Clicked (funder)', {});

// setup
Expand Down
7 changes: 7 additions & 0 deletions app/assets/v2/js/pages/kill_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ window.onload = function() {

$('#submitBounty').validate({
submitHandler: function(form) {
try {
bounty_address();
} catch (exception) {
_alert(gettext('You are on an unsupported network. Please change your network to a supported network.'));
return;
}

var data = {};
var disabled = $(form)
.find(':input:disabled')
Expand Down
8 changes: 8 additions & 0 deletions app/assets/v2/js/pages/new_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ $(document).ready(function() {
$('input[name=amount]').blur(setUsdAmount);
$('select[name=deonomination]').change(setUsdAmount);
$('input[name=issueURL]').blur(retrieveIssueDetails);
setTimeout(setUsdAmount, 1000);

if ($('input[name=issueURL]').val() != '') {
retrieveIssueDetails();
Expand All @@ -73,6 +74,13 @@ $(document).ready(function() {

$('#submitBounty').validate({
submitHandler: function(form) {
try {
bounty_address();
} catch (exception) {
_alert(gettext('You are on an unsupported network. Please change your network to a supported network.'));
return;
}

var data = {};
var disabled = $(form)
.find(':input:disabled')
Expand Down
7 changes: 7 additions & 0 deletions app/assets/v2/js/pages/process_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ window.onload = function() {
});

$('#acceptBounty').click(function(e) {
try {
bounty_address();
} catch (exception) {
_alert(gettext('You are on an unsupported network. Please change your network to a supported network.'));
return;
}

mixpanel.track('Process Bounty Clicked', {});
e.preventDefault();
var whatAction = $(this).html().trim();
Expand Down
4 changes: 2 additions & 2 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ def get_access_token(self, save=True):
return access_token

def get_profile_preferred_language(self):
return settings.LANGUAGE_CODE if self.pref_lang_code is None else self.pref_lang_code
return settings.LANGUAGE_CODE if not self.pref_lang_code else self.pref_lang_code

@receiver(user_logged_in)
def post_login(sender, request, user, **kwargs):
Expand Down Expand Up @@ -1283,7 +1283,7 @@ class ToolVote(models.Model):
value = models.IntegerField(default=0)

@property
def tool(self):
def tool(self):
try:
return Tool.objects.filter(votes__in=[self.pk]).first()
except:
Expand Down
6 changes: 3 additions & 3 deletions app/dashboard/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def get_status_header(bounty):
else:
statuses.append('**Done**')


#1. Open | **2. Started** | 3. Submitted | 4. Done
status_bar = ""
for x, status in enumerate(statuses):
Expand Down Expand Up @@ -699,11 +699,11 @@ def maybe_warn_user_removed_github(bounty, username, last_heard_from_user_days):
return False

first_warning = 'x'
second_warning = 'x' if last_heard_from_user_days > num_days_back_to_warn else ''
second_warning = 'x' if last_heard_from_user_days > num_days_back_to_warn else ' '
msg = f"""@{username} are you still working on this issue?
* [{first_warning}] warning 1 ({num_days_back_to_warn} days)
* [{second_warning}] warning 2 ({num_days_back_to_warn * 2} days)
* [x] auto removal ({num_days_back_to_delete_interest} days)
* [ ] auto removal ({num_days_back_to_delete_interest} days)
"""

post_issue_comment(bounty.org_name, bounty.github_repo_name, bounty.github_issue_number, msg)
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/templates/increase_bounty.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ <h3>Increase Funding</h3>
<div class="form__select2">
<select name='deonomination' id='token' data-token-address='{{bounty.token_address}}' disabled></select>
</div>
<small class="form__input-help form__input-help--dynamic" id="usd_amount"></small>
</div>
</div>
<small class="form__input-help form__input-help--dynamic" id="usd_amount"></small>
</div>
<div class="w-100 mt-2 terms_container" style="padding-top:5px;">
<div class="form__checkbox">
Expand Down
4 changes: 2 additions & 2 deletions app/dashboard/templates/submit_bounty.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h3>{% trans "Fund an Issue" %}</h3>
<label class="form__label" for=issueURL>{% trans "Issue URL" %}</label>
<input required name='issueURL' id="issueURL" class="w-100 form__input" type="url" placeholder="https://github.com/user/repo/pull/n" value="{% if bounty %}{{bounty.github_url}}{%endif%}" />
</div>
<div class="w-100 mt-2">
<div class="w-100 mt-2 amount_container">
<label class="form__label" for="amount">{% trans "Amount" %}</label>
<div class="form__flex-group">
<div class="form__amount-wrapper">
Expand All @@ -60,9 +60,9 @@ <h3>{% trans "Fund an Issue" %}</h3>
<div class="form__select2">
<select name='deonomination' id='token'></select>
</div>
<small class="form__input-help form__input-help--dynamic" id="usd_amount"></small>
</div>
</div>
<small class="form__input-help form__input-help--dynamic" id="usd_amount"></small>
</div>
{% include 'shared/github_username.html' %}
{% include 'shared/notification_email.html' %}
Expand Down
8 changes: 4 additions & 4 deletions app/dashboard/tests/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@ def setUp(self):
def test_build_github_notification_new_bounty(self):
"""Test the dashboard helper build_github_notification method with new_bounty."""
message = build_github_notification(self.bounty, 'new_bounty')
assert message.startswith(f'__This issue now has a funding of {self.natural_value} {self.bounty.token_name}')
assert f'__This issue now has a funding of {self.natural_value} {self.bounty.token_name}' in message
assert self.usdt_value in message
assert f'[here]({self.absolute_url})' in message
assert f'${self.amount_open_work}' in message

def test_build_github_notification_killed_bounty(self):
"""Test the dashboard helper build_github_notification method with killed_bounty."""
message = build_github_notification(self.bounty, 'killed_bounty')
assert message.startswith(f"__The funding of {self.natural_value} {self.bounty.token_name} {self.usdt_value}")
assert f"__The funding of {self.natural_value} {self.bounty.token_name} {self.usdt_value}" in message
assert 'Questions?' in message
assert f'${self.amount_open_work}' in message

def test_build_github_notification_increased_bounty(self):
"""Test the dashboard helper build_github_notification method with new_bounty."""
message = build_github_notification(self.bounty, 'increased_bounty')
assert message.startswith(f'__The funding of this issue was increased to {self.natural_value} {self.bounty.token_name}')
assert f'__The funding of this issue was increased to {self.natural_value} {self.bounty.token_name}' in message
assert self.usdt_value in message
assert f'[here]({self.absolute_url})' in message
assert f'This issue now has a funding of' in message
assert f'${self.amount_open_work}' in message

def tearDown(self):
Expand Down
Loading

0 comments on commit 5363f7b

Please sign in to comment.