From bad8c050d1c91deae9043a08da86a180e5005757 Mon Sep 17 00:00:00 2001 From: Kevin Seagraves Date: Mon, 19 Nov 2018 09:28:27 -0700 Subject: [PATCH 01/10] make default required periodSeconds 0 instead of 30 days and remove yapf from pre-commit hooks --- .pre-commit-config.yaml | 8 --- app/grants/models.py | 129 +++++++++++++++++++++++++++++++--------- app/grants/views.py | 8 +-- 3 files changed, 103 insertions(+), 42 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8b24d350cb2..2f2aa090055 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,14 +13,6 @@ repos: language: system entry: sh -c 'npm run stylelint:fix' files: .css$ -- repo: local - hooks: - - id: yapf - name: yapf - language: python - entry: yapf - files: \.py$ - args: ["-i", "-r", "-e", "app/**/migrations/", "-e", "app/app/settings.py", "-p", "app/avatar/", "app/credits/", "app/dataviz/", "app/enssubdomain/", "app/ethos/", "app/github/"] - repo: git://github.com/pre-commit/mirrors-isort sha: 'v4.3.4' hooks: diff --git a/app/grants/models.py b/app/grants/models.py index bbcf851bbcd..9a7e53aa532 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -30,6 +30,7 @@ class GrantQuerySet(models.QuerySet): pass + class Grant(SuperModel): """Define the structure of a Grant.""" @@ -38,40 +39,70 @@ class Grant(SuperModel): description = models.TextField(default='', blank=True, help_text=_('The description of the Grant.')) reference_url = models.URLField(blank=True, help_text=_('The associated reference URL of the Grant.')) logo = models.ImageField( - upload_to=get_upload_filename, null=True, blank=True, help_text=_('The Grant logo image.'), + upload_to=get_upload_filename, + null=True, + blank=True, + help_text=_('The Grant logo image.'), ) logo_svg = models.FileField( - upload_to=get_upload_filename, null=True, blank=True, help_text=_('The Grant logo SVG.'), + upload_to=get_upload_filename, + null=True, + blank=True, + help_text=_('The Grant logo SVG.'), ) admin_address = models.CharField( - max_length=255, default='0x0', help_text=_('The wallet address for the administrator of this Grant.'), + max_length=255, + default='0x0', + help_text=_('The wallet address for the administrator of this Grant.'), ) frequency = models.DecimalField( - default=2592000, decimal_places=0, max_digits=50, help_text=_('The payout frequency of the Grant.'), + 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, max_digits=50, help_text=_('The contribution goal amount for the Grant.'), + default=1, + decimal_places=4, + max_digits=50, + help_text=_('The contribution goal amount for the Grant.'), ) amount_received = models.DecimalField( - default=0, decimal_places=4, max_digits=50, help_text=_('The total amount received for the Grant.'), + default=0, + decimal_places=4, + max_digits=50, + help_text=_('The total amount received for the Grant.'), ) token_address = models.CharField( - max_length=255, default='0x0', help_text=_('The token address to be used with the Grant.'), + max_length=255, + default='0x0', + help_text=_('The token address to be used with the Grant.'), ) contract_address = models.CharField( - max_length=255, default='0x0', help_text=_('The contract address of the Grant.'), + max_length=255, + default='0x0', + help_text=_('The contract address of the Grant.'), ) transaction_hash = models.CharField( - max_length=255, default='0x0', help_text=_('The transaction hash of the Grant.'), + max_length=255, + default='0x0', + help_text=_('The transaction hash of the Grant.'), ) metadata = JSONField( - default=dict, blank=True, help_text=_('The Grant metadata. Includes creation and last synced block numbers.'), + default=dict, + blank=True, + help_text=_('The Grant metadata. Includes creation and last synced block numbers.'), ) network = models.CharField( - max_length=8, default='mainnet', help_text=_('The network in which the Grant contract resides.'), + max_length=8, + default='mainnet', + help_text=_('The network in which the Grant contract resides.'), ) required_gas_price = models.DecimalField( - default='0', decimal_places=0, max_digits=50, help_text=_('The required gas price for the Grant.'), + default='0', + decimal_places=0, + max_digits=50, + help_text=_('The required gas price for the Grant.'), ) admin_profile = models.ForeignKey( 'dashboard.Profile', @@ -108,10 +139,17 @@ class Milestone(SuperModel): description = models.TextField(help_text=_('The Milestone description.')) due_date = models.DateField(help_text=_('The requested Milestone completion date.')) completion_date = models.DateField( - default=None, blank=True, null=True, help_text=_('The Milestone completion date.'), + default=None, + blank=True, + null=True, + help_text=_('The Milestone completion date.'), ) grant = models.ForeignKey( - 'Grant', related_name='milestones', on_delete=models.CASCADE, null=True, help_text=_('The associated Grant.'), + 'Grant', + related_name='milestones', + on_delete=models.CASCADE, + null=True, + help_text=_('The associated Grant.'), ) def __str__(self): @@ -127,26 +165,43 @@ class Subscription(SuperModel): active = models.BooleanField(default=True, help_text=_('Whether or not the Subscription is active.')) subscription_hash = models.CharField( - default='', max_length=255, help_text=_('The contributor\'s Subscription hash.'), + default='', + max_length=255, + help_text=_('The contributor\'s Subscription hash.'), ) contributor_signature = models.CharField(default='', max_length=255, help_text=_('The contributor\'s signature.')) contributor_address = models.CharField( - default='', max_length=255, help_text=_('The contributor\'s wallet address of the Subscription.'), + default='', + max_length=255, + help_text=_('The contributor\'s wallet address of the Subscription.'), ) amount_per_period = models.DecimalField( - default=1, decimal_places=4, max_digits=50, help_text=_('The promised contribution amount per period.'), + default=1, + decimal_places=4, + max_digits=50, + help_text=_('The promised contribution amount per period.'), ) period_seconds = models.DecimalField( - default=2592000, decimal_places=0, max_digits=50, help_text=_('The subscription period length.'), + default=2592000, + decimal_places=0, + max_digits=50, + help_text=_('The subscription period length.'), ) token_address = models.CharField( - max_length=255, default='0x0', help_text=_('The token address to be used with the Subscription.'), + max_length=255, + default='0x0', + help_text=_('The token address to be used with the Subscription.'), ) gas_price = models.DecimalField( - default=1, decimal_places=4, max_digits=50, help_text=_('The required gas price for the Subscription.'), + default=1, + decimal_places=4, + max_digits=50, + help_text=_('The required gas price for the Subscription.'), ) network = models.CharField( - max_length=8, default='mainnet', help_text=_('The network in which the Subscription resides.'), + max_length=8, + default='mainnet', + help_text=_('The network in which the Subscription resides.'), ) grant = models.ForeignKey( 'grants.Grant', @@ -179,25 +234,43 @@ class Contribution(SuperModel): tx_id = models.CharField(max_length=255, default='0x0', help_text=_('The transaction ID of the Contribution.')) from_address = models.CharField( - max_length=255, default='0x0', help_text=_('The wallet address tokens are sent from.'), + max_length=255, + default='0x0', + help_text=_('The wallet address tokens are sent from.'), ) to_address = models.CharField( - max_length=255, default='0x0', help_text=_('The wallet address tokens are sent to.'), + max_length=255, + default='0x0', + help_text=_('The wallet address tokens are sent to.'), ) token_address = models.CharField( - max_length=255, default='0x0', help_text=_('The token address to be used with the Subscription.'), + max_length=255, + default='0x0', + help_text=_('The token address to be used with the Subscription.'), ) token_amount = models.DecimalField( - default=1, decimal_places=4, max_digits=50, help_text=_('The promised contribution amount per period.'), + default=1, + decimal_places=4, + max_digits=50, + help_text=_('The promised contribution amount per period.'), ) period_seconds = models.DecimalField( - default=0, decimal_places=0, max_digits=50, help_text=_('The number of seconds thats constitues a period.'), + default=0, + decimal_places=0, + max_digits=50, + help_text=_('The number of seconds thats constitues a period.'), ) gas_price = models.DecimalField( - default=0, decimal_places=4, max_digits=50, help_text=_('The amount of token used to incentivize subminers.'), + default=0, + decimal_places=4, + max_digits=50, + help_text=_('The amount of token used to incentivize subminers.'), ) nonce = models.DecimalField( - default=0, decimal_places=0, max_digits=50, help_text=_('The of the subscription metaTx.'), + default=0, + decimal_places=0, + max_digits=50, + help_text=_('The of the subscription metaTx.'), ) subscription = models.ForeignKey( 'grants.Subscription', diff --git a/app/grants/views.py b/app/grants/views.py index f372bc1ffb7..aa8583fa7c8 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -34,11 +34,7 @@ from grants.forms import MilestoneForm from grants.models import Grant, Milestone, Subscription from marketing.mails import ( - grant_cancellation, - new_grant, - new_supporter, - subscription_terminated, - support_cancellation, + grant_cancellation, new_grant, new_supporter, subscription_terminated, support_cancellation, thank_you_for_supporting, ) from marketing.models import Keyword @@ -186,7 +182,7 @@ 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', 2592000), + 'frequency': request.POST.get('frequency', 0), 'token_address': request.POST.get('denomination', ''), 'amount_goal': request.POST.get('amount_goal', 0), 'transaction_hash': request.POST.get('transaction_hash', ''), From bc398213eb7d202400415e1ab001678611624400 Mon Sep 17 00:00:00 2001 From: Kevin Seagraves Date: Mon, 19 Nov 2018 11:10:21 -0700 Subject: [PATCH 02/10] cancel_subscription functionality working --- app/assets/v2/js/grants/cancel_subscription.js | 3 ++- app/assets/v2/js/grants/fund_grant.js | 15 ++++++++++++--- .../migrations/0002_auto_20181119_1728.py | 18 ++++++++++++++++++ app/grants/templates/grants/fund.html | 1 + 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 app/grants/migrations/0002_auto_20181119_1728.py diff --git a/app/assets/v2/js/grants/cancel_subscription.js b/app/assets/v2/js/grants/cancel_subscription.js index f5450018aaa..13cb64f228d 100644 --- a/app/assets/v2/js/grants/cancel_subscription.js +++ b/app/assets/v2/js/grants/cancel_subscription.js @@ -26,7 +26,8 @@ window.onload = function() { console.log('realTokenAmount', realTokenAmount); - let realGasPrice = Number(data.gas_price * 10 ** decimals); + // gas price in gwei + let realGasPrice = Number(data.gas_price * 10 ** 9); console.log('realGasPrice', realGasPrice); diff --git a/app/assets/v2/js/grants/fund_grant.js b/app/assets/v2/js/grants/fund_grant.js index 50c2bfc9147..dcbccebc664 100644 --- a/app/assets/v2/js/grants/fund_grant.js +++ b/app/assets/v2/js/grants/fund_grant.js @@ -44,7 +44,11 @@ $(document).ready(function() { let realTokenAmount = Number(data.amount_per_period * 10 ** decimals); - let realGasPrice = Number(4 * 10 ** decimals); + // gas price in gwei + let realGasPrice = Number(4 * 10 ** 9); + + $('#gas_price').val(4); + web3.eth.getAccounts(function(err, accounts) { @@ -75,6 +79,11 @@ $(document).ready(function() { web3.utils.toTwosComplement(nonce) ]; + console.log('realTokenAmount', realTokenAmount); + console.log('realPeriodSeconds', realPeriodSeconds); + console.log('realGasPrice', realGasPrice); + console.log('parts', parts); + deployedSubscription.methods.getSubscriptionHash(...parts).call(function(err, subscriptionHash) { $('#subscription_hash').val(subscriptionHash); @@ -93,12 +102,12 @@ $(document).ready(function() { console.log('postData', postData); + $('#frequency_count').val(realPeriodSeconds); + $.each($(form).serializeArray(), function() { data[this.name] = this.value; }); - data.frequency = realPeriodSeconds; - console.log('data', data); form.submit(); diff --git a/app/grants/migrations/0002_auto_20181119_1728.py b/app/grants/migrations/0002_auto_20181119_1728.py new file mode 100644 index 00000000000..99e53c087e2 --- /dev/null +++ b/app/grants/migrations/0002_auto_20181119_1728.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.2 on 2018-11-19 17:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('grants', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='grant', + name='frequency', + field=models.DecimalField(decimal_places=0, default=0, help_text='The payout frequency of the Grant.', max_digits=50), + ), + ] diff --git a/app/grants/templates/grants/fund.html b/app/grants/templates/grants/fund.html index 9d20be0b44b..4bde1a04c81 100644 --- a/app/grants/templates/grants/fund.html +++ b/app/grants/templates/grants/fund.html @@ -170,6 +170,7 @@

+ From d68ea0c6fb814799216c866b4b50bc7a3863f002 Mon Sep 17 00:00:00 2001 From: Kevin Seagraves Date: Mon, 19 Nov 2018 11:19:28 -0700 Subject: [PATCH 03/10] min value of amount_goal in grants/new validation implemented --- app/grants/templates/grants/new.html | 2 +- app/grants/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/grants/templates/grants/new.html b/app/grants/templates/grants/new.html index 1b7af5e3803..7197d5d8575 100644 --- a/app/grants/templates/grants/new.html +++ b/app/grants/templates/grants/new.html @@ -106,7 +106,7 @@

{% trans "Create a Grant" %}

- +
diff --git a/app/grants/views.py b/app/grants/views.py index aa8583fa7c8..9976fe1cdb4 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -184,7 +184,7 @@ def grant_new(request): 'admin_address': request.POST.get('admin_address', ''), 'frequency': request.POST.get('frequency', 0), 'token_address': request.POST.get('denomination', ''), - 'amount_goal': request.POST.get('amount_goal', 0), + 'amount_goal': request.POST.get('amount_goal', 1), 'transaction_hash': request.POST.get('transaction_hash', ''), 'contract_address': request.POST.get('contract_address', ''), 'network': request.POST.get('network', 'mainnet'), From 338aa16611e31af6e27b90d8738851befffdb8a6 Mon Sep 17 00:00:00 2001 From: Kevin Seagraves Date: Mon, 19 Nov 2018 11:25:03 -0700 Subject: [PATCH 04/10] rename input_name to input_title in grants/new to prevent chrome user name autofill --- app/grants/templates/grants/new.html | 4 ++-- app/grants/views.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/grants/templates/grants/new.html b/app/grants/templates/grants/new.html index 7197d5d8575..1f5810380e1 100644 --- a/app/grants/templates/grants/new.html +++ b/app/grants/templates/grants/new.html @@ -80,8 +80,8 @@

{% trans "Create a Grant" %}

{% csrf_token %}
- - + +
diff --git a/app/grants/views.py b/app/grants/views.py index 9976fe1cdb4..eb43434dcc6 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -178,7 +178,7 @@ def grant_new(request): team_members = request.POST.getlist('team_members[]') grant_kwargs = { - 'title': request.POST.get('input_name', ''), + 'title': request.POST.get('input_title', ''), 'description': request.POST.get('description', ''), 'reference_url': request.POST.get('reference_url', ''), 'admin_address': request.POST.get('admin_address', ''), From bbebbe3bb43f549ee56a4f2a836fbf8f2d265a64 Mon Sep 17 00:00:00 2001 From: Kevin Seagraves Date: Mon, 19 Nov 2018 12:35:14 -0700 Subject: [PATCH 05/10] grants/details display long titles and urls, while remaining editable --- app/assets/v2/css/grants/detail.css | 5 +---- app/assets/v2/js/grants/detail.js | 6 +++--- app/grants/templates/grants/detail.html | 20 +++++++++++--------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/assets/v2/css/grants/detail.css b/app/assets/v2/css/grants/detail.css index a11bc0afe87..e66af7b7d90 100644 --- a/app/assets/v2/css/grants/detail.css +++ b/app/assets/v2/css/grants/detail.css @@ -94,9 +94,6 @@ textarea.editable { #form--input__reference-url, #form--input__title { width: 100%; -} - -#form--input__description { text-align: justify; resize: none; } @@ -236,4 +233,4 @@ textarea.editable { display: flex; justify-content: center; } -} \ No newline at end of file +} diff --git a/app/assets/v2/js/grants/detail.js b/app/assets/v2/js/grants/detail.js index 11b0159a8d5..8bb88829d09 100644 --- a/app/assets/v2/js/grants/detail.js +++ b/app/assets/v2/js/grants/detail.js @@ -9,13 +9,13 @@ const editableFields = [ $(document).ready(function() { $('#tabs').tabs(); - $('#form--input__description').height($('#form--input__description').prop('scrollHeight')); - userSearch('#grant-admin'); userSearch('#grant-members'); $('.select2-selection__rendered').removeAttr('title'); $('#form--input__description').height($('#form--input__description').prop('scrollHeight')); + $('#form--input__title').height($('#form--input__title').prop('scrollHeight')); + $('#form--input__reference-url').height($('#form--input__reference-url').prop('scrollHeight')); $('#edit-details').on('click', (event) => { event.preventDefault(); @@ -84,4 +84,4 @@ const disableEdit = (input) => { $(input).removeClass('editable'); $(input).prop('readonly', true); $(input).prop('disabled', true); -}; \ No newline at end of file +}; diff --git a/app/grants/templates/grants/detail.html b/app/grants/templates/grants/detail.html index a0438a7f96b..2b649ead0d7 100644 --- a/app/grants/templates/grants/detail.html +++ b/app/grants/templates/grants/detail.html @@ -41,12 +41,16 @@

- -

+ {% if is_admin %} + + {% else %} + {{ grant.title }} + {% endif %} +

{% if is_admin %}
- +
{% else %} @@ -85,12 +89,12 @@

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

Current

- {{ grant.amount_goal }} DAI -

Goal

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

Monthly Goal

@@ -142,9 +146,7 @@

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

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

+

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

- {% for subscriber in grant.subscriptions.all %} + {% for subscriber in subscriptions %} diff --git a/app/grants/views.py b/app/grants/views.py index eb43434dcc6..f2e8f2b5ceb 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -84,8 +84,8 @@ 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 @@ -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, From f9ca1a22d0e07d74c88c379062e87ccd5891506d Mon Sep 17 00:00:00 2001 From: Kevin Seagraves Date: Mon, 19 Nov 2018 14:55:59 -0700 Subject: [PATCH 07/10] milestones now refer to due dates and completion dates, instead of start/finish dates --- app/assets/v2/css/grants/milestones.css | 21 ++++++++++++++++++++- app/grants/forms.py | 2 +- app/grants/templates/grants/detail.html | 6 ++---- app/grants/templates/grants/milestones.html | 6 +++--- 4 files changed, 26 insertions(+), 9 deletions(-) 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/grants/forms.py b/app/grants/forms.py index 6788bedadef..72df67889f6 100644 --- a/app/grants/forms.py +++ b/app/grants/forms.py @@ -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/templates/grants/detail.html b/app/grants/templates/grants/detail.html index 174a0661b97..822feabc745 100644 --- a/app/grants/templates/grants/detail.html +++ b/app/grants/templates/grants/detail.html @@ -219,11 +219,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/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" %}
    From e3ae0a9af722d8cb8a06ecef5e82bdc51e67dfec Mon Sep 17 00:00:00 2001 From: Kevin Seagraves Date: Mon, 19 Nov 2018 17:04:29 -0700 Subject: [PATCH 08/10] saving raw frequency, frequency_unit, real_period_seconds, and token_symbol data. --- .../v2/js/grants/cancel_subscription.js | 2 +- app/assets/v2/js/grants/fund_grant.js | 4 ++- app/grants/forms.py | 4 +-- app/grants/models.py | 31 ++++++++++++++----- app/grants/templates/grants/cancel.html | 2 +- app/grants/templates/grants/detail.html | 11 +++++-- app/grants/templates/grants/fund.html | 6 ++-- app/grants/views.py | 9 ++++-- 8 files changed, 47 insertions(+), 22 deletions(-) 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 72df67889f6..5d4e50da616 100644 --- a/app/grants/forms.py +++ b/app/grants/forms.py @@ -31,9 +31,7 @@ class Meta: model = Grant fields = ( - 'title', 'description', 'reference_url', 'logo', 'logo_svg', 'admin_address', 'frequency', 'amount_goal', - 'amount_received', 'token_address', 'contract_address', 'transaction_hash', 'metadata', 'network', - 'required_gas_price', 'admin_profile', 'team_members' + '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' ) diff --git a/app/grants/models.py b/app/grants/models.py index 9a7e53aa532..547174e70f5 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_uint = 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 822feabc745..c041f8dba94 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 give' %} {{ user_subscription.amount_per_period|floatformat:2|intcomma }} DAI {{ user_subscription.token_name }} every {{ user_subscription.period_second }} 30 days {{ 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 active_subscription %} - + {% elif user_subscription %} + {% else %} 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/views.py b/app/grants/views.py index f2e8f2b5ceb..011a40c79db 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -92,7 +92,7 @@ def grant_details(request, grant_id): 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) @@ -183,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', ''), @@ -273,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 From b756d3b777baff333ccb3d9466f2e7fcf4af5cb7 Mon Sep 17 00:00:00 2001 From: Kevin Seagraves Date: Mon, 19 Nov 2018 17:33:15 -0700 Subject: [PATCH 09/10] smooth out typos in models and templates for previous commit. All working. --- .../migrations/0003_auto_20181120_0011.py | 46 +++++++++++++++++++ .../migrations/0004_auto_20181120_0027.py | 18 ++++++++ app/grants/models.py | 2 +- app/grants/templates/grants/detail.html | 2 +- 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 app/grants/migrations/0003_auto_20181120_0011.py create mode 100644 app/grants/migrations/0004_auto_20181120_0027.py 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 547174e70f5..dd0b41b897c 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -186,7 +186,7 @@ class Subscription(SuperModel): max_digits=50, help_text=_('The real payout frequency of the Subscription in seconds.'), ) - frequency_uint = models.CharField( + frequency_unit = models.CharField( max_length=255, default='', help_text=_('The text version of frequency units e.g. days, months'), diff --git a/app/grants/templates/grants/detail.html b/app/grants/templates/grants/detail.html index c041f8dba94..e8e031810a9 100644 --- a/app/grants/templates/grants/detail.html +++ b/app/grants/templates/grants/detail.html @@ -100,7 +100,7 @@

    {% if user_subscription %}

    - {% trans 'You have agreed to give' %} {{ user_subscription.amount_per_period|floatformat:2|intcomma }} DAI {{ user_subscription.token_name }} every {{ user_subscription.period_second }} 30 days {{ frequency_unit }} + {% trans 'You have agreed to give' %} {{ user_subscription.amount_per_period|floatformat:2|intcomma }} {{ user_subscription.token_symbol }} every {{ user_subscription.frequency }} {{ user_subscription.frequency_unit }}
    {% endif %} From aba8e118397a7584ee2c50b68b37ec6bfe907d88 Mon Sep 17 00:00:00 2001 From: Kevin Seagraves Date: Tue, 20 Nov 2018 11:21:06 -0700 Subject: [PATCH 10/10] changed line length in forms.py and copy in details --- app/grants/forms.py | 4 +++- app/grants/templates/grants/detail.html | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/grants/forms.py b/app/grants/forms.py index 5d4e50da616..f8c317f2227 100644 --- a/app/grants/forms.py +++ b/app/grants/forms.py @@ -31,7 +31,9 @@ class Meta: model = Grant fields = ( - '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' + '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' ) diff --git a/app/grants/templates/grants/detail.html b/app/grants/templates/grants/detail.html index e8e031810a9..e1b1afd69fb 100644 --- a/app/grants/templates/grants/detail.html +++ b/app/grants/templates/grants/detail.html @@ -100,7 +100,7 @@

    {% if user_subscription %}

    - {% trans 'You have agreed to give' %} {{ user_subscription.amount_per_period|floatformat:2|intcomma }} {{ user_subscription.token_symbol }} every {{ user_subscription.frequency }} {{ user_subscription.frequency_unit }} + {% 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 %}