diff --git a/app/assets/v2/css/grants/milestones.css b/app/assets/v2/css/grants/milestones.css index 508b0b2ed41..2f7e7e89365 100644 --- a/app/assets/v2/css/grants/milestones.css +++ b/app/assets/v2/css/grants/milestones.css @@ -99,4 +99,23 @@ ul.milestones-list .button { ul.milestones-list .button:hover { color: #fff; -} \ No newline at end of file +} + +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; +} diff --git a/app/assets/v2/js/grants/cancel_subscription.js b/app/assets/v2/js/grants/cancel_subscription.js index 13cb64f228d..d23ebde156b 100644 --- a/app/assets/v2/js/grants/cancel_subscription.js +++ b/app/assets/v2/js/grants/cancel_subscription.js @@ -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 diff --git a/app/assets/v2/js/grants/fund_grant.js b/app/assets/v2/js/grants/fund_grant.js index dcbccebc664..e4703151d4a 100644 --- a/app/assets/v2/js/grants/fund_grant.js +++ b/app/assets/v2/js/grants/fund_grant.js @@ -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) { @@ -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; diff --git a/app/grants/forms.py b/app/grants/forms.py index 6788bedadef..f8c317f2227 100644 --- a/app/grants/forms.py +++ b/app/grants/forms.py @@ -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' ) @@ -60,7 +60,7 @@ class Meta: attrs={ 'type': 'date', 'class': 'form__input form__input-lg', - 'placeholder': _('Date') + 'placeholder': _('Due Date') } ) } diff --git a/app/grants/migrations/0003_auto_20181120_0011.py b/app/grants/migrations/0003_auto_20181120_0011.py new file mode 100644 index 00000000000..d5d296f8d67 --- /dev/null +++ b/app/grants/migrations/0003_auto_20181120_0011.py @@ -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), + ), + ] diff --git a/app/grants/migrations/0004_auto_20181120_0027.py b/app/grants/migrations/0004_auto_20181120_0027.py new file mode 100644 index 00000000000..ca2c090c9fe --- /dev/null +++ b/app/grants/migrations/0004_auto_20181120_0027.py @@ -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', + ), + ] diff --git a/app/grants/models.py b/app/grants/models.py index 9a7e53aa532..dd0b41b897c 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -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, @@ -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', @@ -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, diff --git a/app/grants/templates/grants/cancel.html b/app/grants/templates/grants/cancel.html index 5b1789186f9..40607fdf0e5 100644 --- a/app/grants/templates/grants/cancel.html +++ b/app/grants/templates/grants/cancel.html @@ -100,7 +100,7 @@

- + diff --git a/app/grants/templates/grants/detail.html b/app/grants/templates/grants/detail.html index 2b649ead0d7..e1b1afd69fb 100644 --- a/app/grants/templates/grants/detail.html +++ b/app/grants/templates/grants/detail.html @@ -98,9 +98,14 @@

+ {% if user_subscription %} +

+ {% 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 }} +
+ {% endif %} {% if grant_is_inactive %} -

{% trans "This grant has ended. You can find all active grants" %} +

{% trans "This grant has ended. You can find all active grants" %} {% trans "here." %} @@ -112,8 +117,8 @@

{% trans "This grant has ended. You can find all active grants" %} - {% elif subscription %} - + {% elif user_subscription %} + {% else %} @@ -187,9 +192,9 @@

{% trans "This grant has ended. You can find all active grants" %} {% endif %}
-

{% trans "Supported By" %} ({{ grant.subscriptions.all|length }})

+

{% trans "Supported By" %} ({{ subscriptions|length }})

- {% for subscriber in grant.subscriptions.all %} + {% for subscriber in subscriptions %} @@ -219,11 +224,9 @@

{% trans "This grant has ended. You can find all active grants" %}
  • {{ milestone.title }}
    - {{ milestone.due_date }} - +

    {% trans 'Due Date - ' %}{{ milestone.due_date }}

    {% if milestone.completion_date %} - {{ milestone.completion_date }} - {% else %} - {% trans "Present" %} +

    {% trans 'Date Completed - ' %}{{ milestone.completion_date }}

    {% endif %}

    {{ milestone.description }}

    diff --git a/app/grants/templates/grants/fund.html b/app/grants/templates/grants/fund.html index 4bde1a04c81..a2b508dde7d 100644 --- a/app/grants/templates/grants/fund.html +++ b/app/grants/templates/grants/fund.html @@ -86,11 +86,11 @@

    - {{ grant.amount_received }} DAI + {{ grant.amount_received|floatformat:2|intcomma }} DAI

    Current

    - {{ grant.amount_goal }} DAI + {{ grant.amount_goal|floatformat:2|intcomma }} DAI

    Goal

    @@ -171,6 +171,8 @@

    + +

  • diff --git a/app/grants/templates/grants/milestones.html b/app/grants/templates/grants/milestones.html index 16fa2428adb..44e7c83fa09 100644 --- a/app/grants/templates/grants/milestones.html +++ b/app/grants/templates/grants/milestones.html @@ -49,15 +49,15 @@

    {% trans "Create Milestones for " %}{{ grant.title }}<
  • {{ milestone.title }}
    - {{ milestone.due_date }} - +

    {% trans 'Due Date - ' %}{{ milestone.due_date }}

    {% if milestone.completion_date %} - {{ milestone.completion_date }} + {% trans 'Date Completed - ' %}{{ milestone.completion_date }} {% else %}
    {% csrf_token %} - +

    {% trans 'Date Completed - ' %}

    {% trans "Delete" %} {% trans "Complete" %}
    diff --git a/app/grants/views.py b/app/grants/views.py index eb43434dcc6..011a40c79db 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -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) @@ -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, @@ -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', ''), @@ -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