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

More QA fixes #2896

Merged
merged 11 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 20 additions & 1 deletion app/assets/v2/css/grants/milestones.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,23 @@ ul.milestones-list .button {

ul.milestones-list .button:hover {
color: #fff;
}
}

input[type="date"]:before {
content: attr(placeholder) !important;
color: #aaa;
margin-right: 0.5em;
}

input[type="date"]:focus:before,
input[type="date"]:valid:before {
content: "";
}

#completed_label {
display: flex;
}

#due_label {
margin: 0px;
}
2 changes: 1 addition & 1 deletion app/assets/v2/js/grants/cancel_subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ window.onload = function() {
// data.amount_per_period
web3.utils.toTwosComplement(realTokenAmount),
// data.period_seconds
web3.utils.toTwosComplement(data.period_seconds),
web3.utils.toTwosComplement(data.real_period_seconds),
// data.gas_price
web3.utils.toTwosComplement(realGasPrice),
// nonce
Expand Down
4 changes: 3 additions & 1 deletion app/assets/v2/js/grants/fund_grant.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ $(document).ready(function() {
data[this.name] = this.value;
});

$('#token_symbol').val($('#js-token option:selected').text());

let realPeriodSeconds = 0;

if (data.frequency) {
Expand Down Expand Up @@ -102,7 +104,7 @@ $(document).ready(function() {

console.log('postData', postData);

$('#frequency_count').val(realPeriodSeconds);
$('#real_period_seconds').val(realPeriodSeconds);

$.each($(form).serializeArray(), function() {
data[this.name] = this.value;
Expand Down
4 changes: 2 additions & 2 deletions app/grants/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Meta:

model = Grant
fields = (
'title', 'description', 'reference_url', 'logo', 'logo_svg', 'admin_address', 'frequency', 'amount_goal',
'title', 'description', 'reference_url', 'logo', 'logo_svg', 'admin_address', 'amount_goal',
'amount_received', 'token_address', 'contract_address', 'transaction_hash', 'metadata', 'network',
'required_gas_price', 'admin_profile', 'team_members'
)
Expand Down Expand Up @@ -60,7 +60,7 @@ class Meta:
attrs={
'type': 'date',
'class': 'form__input form__input-lg',
'placeholder': _('Date')
'placeholder': _('Due Date')
}
)
}
46 changes: 46 additions & 0 deletions app/grants/migrations/0003_auto_20181120_0011.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 2.1.2 on 2018-11-20 00:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('grants', '0002_auto_20181119_1728'),
]

operations = [
migrations.RemoveField(
model_name='grant',
name='frequency',
),
migrations.RemoveField(
model_name='subscription',
name='period_seconds',
),
migrations.AddField(
model_name='grant',
name='token_symbol',
field=models.CharField(default='0x0', help_text='The token symbol to be used with the Grant.', max_length=255),
),
migrations.AddField(
model_name='subscription',
name='frequency',
field=models.DecimalField(decimal_places=0, default=0, help_text='The real payout frequency of the Subscription in seconds.', max_digits=50),
),
migrations.AddField(
model_name='subscription',
name='frequency_uint',
field=models.CharField(default='', help_text='The text version of frequency units e.g. days, months', max_length=255),
),
migrations.AddField(
model_name='subscription',
name='real_period_seconds',
field=models.DecimalField(decimal_places=0, default=2592000, help_text='The real payout frequency of the Subscription in seconds.', max_digits=50),
),
migrations.AddField(
model_name='subscription',
name='token_symbol',
field=models.CharField(default='0x0', help_text='The token symbol to be used with the Subscription.', max_length=255),
),
]
18 changes: 18 additions & 0 deletions app/grants/migrations/0004_auto_20181120_0027.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.2 on 2018-11-20 00:27

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('grants', '0003_auto_20181120_0011'),
]

operations = [
migrations.RenameField(
model_name='subscription',
old_name='frequency_uint',
new_name='frequency_unit',
),
]
31 changes: 23 additions & 8 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ class Grant(SuperModel):
default='0x0',
help_text=_('The wallet address for the administrator of this Grant.'),
)
frequency = models.DecimalField(
default=0,
decimal_places=0,
max_digits=50,
help_text=_('The payout frequency of the Grant.'),
)
amount_goal = models.DecimalField(
default=1,
decimal_places=4,
Expand All @@ -78,6 +72,11 @@ class Grant(SuperModel):
default='0x0',
help_text=_('The token address to be used with the Grant.'),
)
token_symbol = models.CharField(
max_length=255,
default='0x0',
help_text=_('The token symbol to be used with the Grant.'),
)
contract_address = models.CharField(
max_length=255,
default='0x0',
Expand Down Expand Up @@ -181,17 +180,33 @@ class Subscription(SuperModel):
max_digits=50,
help_text=_('The promised contribution amount per period.'),
)
period_seconds = models.DecimalField(
real_period_seconds = models.DecimalField(
default=2592000,
decimal_places=0,
max_digits=50,
help_text=_('The subscription period length.'),
help_text=_('The real payout frequency of the Subscription in seconds.'),
)
frequency_unit = models.CharField(
max_length=255,
default='',
help_text=_('The text version of frequency units e.g. days, months'),
)
frequency = models.DecimalField(
default=0,
decimal_places=0,
max_digits=50,
help_text=_('The real payout frequency of the Subscription in seconds.'),
)
token_address = models.CharField(
max_length=255,
default='0x0',
help_text=_('The token address to be used with the Subscription.'),
)
token_symbol = models.CharField(
max_length=255,
default='0x0',
help_text=_('The token symbol to be used with the Subscription.'),
)
gas_price = models.DecimalField(
default=1,
decimal_places=4,
Expand Down
2 changes: 1 addition & 1 deletion app/grants/templates/grants/cancel.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h2 class="my-5 text-center">
<input type="hidden" id="admin_address" name="admin_address" value="{{ grant.admin_address }}">
<input type="hidden" id="token_address" name="token_address" value="{{ subscription.token_address }}">
<input type="hidden" id="amount_per_period" name="amount_per_period" value="{{ subscription.amount_per_period }}">
<input type="hidden" id="period_seconds" name="period_seconds" value="{{ subscription.period_seconds }}">
<input type="hidden" id="real_period_seconds" name="real_period_seconds" value="{{ subscription.real_period_seconds }}">
<input type="hidden" id="signature" name="signature" value="{{ subscription.contributor_signature }}">
<input type="hidden" id="gas_price" name="gas_price" value="{{ subscription.gas_price }}">
</form>
Expand Down
21 changes: 12 additions & 9 deletions app/grants/templates/grants/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,14 @@ <h1 class="grant__title font-title-lg">
</div>
</div>
</div>
{% if user_subscription %}
<h5>
{% trans 'You have agreed to contribute' %} {{ user_subscription.amount_per_period|floatformat:2|intcomma }} {{ user_subscription.token_symbol }} every {{ user_subscription.frequency }} {{ user_subscription.frequency_unit }}
</h5>
{% endif %}
</div>
{% if grant_is_inactive %}
<h4>{% trans "This grant has ended. You can find all active grants" %}
<h4 class="my-4" >{% trans "This grant has ended. You can find all active grants" %}
<a href="{% url 'grants:grants' %}">
{% trans "here." %}
</a>
Expand All @@ -112,8 +117,8 @@ <h4>{% trans "This grant has ended. You can find all active grants" %}
</button>
<input type="hidden" id="contract_address" name="contract_address" value="{{ grant.contract_address }}">
</form>
{% elif subscription %}
<a href="{% url 'grants:subscription_cancel' grant.id subscription.id %}">
{% elif user_subscription %}
<a href="{% url 'grants:subscription_cancel' grant.id user_subscription.id %}">
<button class="button button--primary button--warning button--full">{% trans "Cancel Your Funding" %}</button>
</a>
{% else %}
Expand Down Expand Up @@ -187,9 +192,9 @@ <h4>{% trans "This grant has ended. You can find all active grants" %}
{% endif %}
</div>
<div class="font-body">
<p class="sub-title">{% trans "Supported By" %} ({{ grant.subscriptions.all|length }})</p>
<p class="sub-title">{% trans "Supported By" %} ({{ subscriptions|length }})</p>
<div class="grant__stakeholders-list">
{% for subscriber in grant.subscriptions.all %}
{% for subscriber in subscriptions %}
<a class="grant__stakeholders-item mr-2" href="{% url 'profile' subscriber.contributor_profile.handle %}">
<img src="{{ subscriber.contributor_profile.avatar_url }}" />
</a>
Expand Down Expand Up @@ -219,11 +224,9 @@ <h4>{% trans "This grant has ended. You can find all active grants" %}
<li>
<div class="milestone-title">{{ milestone.title }}</div>
<div class="milestone-date">
{{ milestone.due_date }} -
<p>{% trans 'Due Date - ' %}{{ milestone.due_date }}</p>
{% if milestone.completion_date %}
{{ milestone.completion_date }}
{% else %}
{% trans "Present" %}
<p>{% trans 'Date Completed - ' %}{{ milestone.completion_date }}</p>
{% endif %}
</div>
<p class="milestone-description">{{ milestone.description }}</p>
Expand Down
6 changes: 4 additions & 2 deletions app/grants/templates/grants/fund.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ <h2 class="my-5 text-center">
<div class="progress-text mt-2">
<div class="row">
<div class="col-6">
<span>{{ grant.amount_received }} DAI</span>
<span>{{ grant.amount_received|floatformat:2|intcomma }} DAI</span>
<p>Current</p>
</div>
<div class="col-6 text-right">
<span>{{ grant.amount_goal }} DAI</span>
<span>{{ grant.amount_goal|floatformat:2|intcomma }} DAI</span>
<p>Goal</p>
</div>
</div>
Expand Down Expand Up @@ -171,6 +171,8 @@ <h2 class="my-5 text-center">
<input type="hidden" id="signature" name="signature" value="">
<input type="hidden" id="contributor_address" name="contributor_address" value="">
<input type="hidden" id="gas_price" name="gas_price" value="">
<input type="hidden" id="token_symbol" name="token_symbol" value="">
<input type="hidden" id="real_period_seconds" name="real_period_seconds" value="">
</div>
</form>
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/grants/templates/grants/milestones.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ <h1 class="font-title-xl">{% trans "Create Milestones for " %}{{ grant.title }}<
<li>
<div class="milestone-title">{{ milestone.title }}</div>
<div class="milestone-date">
{{ milestone.due_date }} -
<p id="due_label">{% trans 'Due Date - ' %}{{ milestone.due_date }}</p>
{% if milestone.completion_date %}
{{ milestone.completion_date }}
{% trans 'Date Completed - ' %}{{ milestone.completion_date }}
{% else %}
<form method="POST" action="{% url 'grants:milestones' grant.id %}">
{% csrf_token %}
<input type="hidden" name="method" value="">
<input type="hidden" name="milestone_id" value="{{milestone.id}}">
<input type="date" placeholder="Date" name="completion_date" required />
<p id="completed_label">{% trans 'Date Completed - ' %}<input type="date" name="completion_date" id="completion_date" required/></p>
<a data-form-method="DELETE" class="button button--warning">{% trans "Delete" %}</a>
<a data-form-method="PUT" class="button button--primary">{% trans "Complete" %}</a>
</form>
Expand Down
16 changes: 10 additions & 6 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ def grant_details(request, grant_id):
try:
grant = Grant.objects.prefetch_related('subscriptions', 'milestones').get(pk=grant_id)
milestones = grant.milestones.order_by('due_date')
subscriptions = grant.subscriptions.all()
active_subscription = grant.subscriptions.filter(contributor_profile=profile, active=True).first()
subscriptions = grant.subscriptions.filter(active=True)
user_subscription = grant.subscriptions.filter(contributor_profile=profile, active=True).first()
except Grant.DoesNotExist:
raise Http404

if request.method == 'POST':
grant.active = False
grant.save()
grant_cancellation(grant, active_subscription)
grant_cancellation(grant, user_subscription)
for sub in subscriptions:
subscription_terminated(grant, sub)

Expand Down Expand Up @@ -156,7 +156,8 @@ def grant_details(request, grant_id):
'active': 'grant_details',
'title': _('Grant Details'),
'grant': grant,
'subscription': active_subscription,
'subscriptions': subscriptions,
'user_subscription': user_subscription,
'is_admin': (grant.admin_profile.id == profile.id) if profile and grant.admin_profile else False,
'grant_is_inactive': not grant.active,
'activity': activity_data,
Expand All @@ -182,8 +183,8 @@ def grant_new(request):
'description': request.POST.get('description', ''),
'reference_url': request.POST.get('reference_url', ''),
'admin_address': request.POST.get('admin_address', ''),
'frequency': request.POST.get('frequency', 0),
'token_address': request.POST.get('denomination', ''),
'token_symbol': request.POST.get('token_symbol', ''),
'amount_goal': request.POST.get('amount_goal', 1),
'transaction_hash': request.POST.get('transaction_hash', ''),
'contract_address': request.POST.get('contract_address', ''),
Expand Down Expand Up @@ -272,8 +273,11 @@ def grant_fund(request, grant_id):
subscription.contributor_signature = request.POST.get('signature', '')
subscription.contributor_address = request.POST.get('contributor_address', '')
subscription.amount_per_period = request.POST.get('amount_per_period', 0)
subscription.period_seconds = request.POST.get('frequency', 2592000)
subscription.real_period_seconds = request.POST.get('real_period_seconds', 2592000)
subscription.frequency = request.POST.get('frequency', 30)
subscription.frequency_unit = request.POST.get('frequency_unit', 'days')
subscription.token_address = request.POST.get('denomination', '')
subscription.token_symbol = request.POST.get('token_symbol', '')
subscription.gas_price = request.POST.get('gas_price', 0)
subscription.network = request.POST.get('network', '')
subscription.contributor_profile = profile
Expand Down