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

Grants - Require login on some views and help_text on all model attrs #2485

Merged
merged 2 commits into from
Oct 17, 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
4 changes: 4 additions & 0 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.templatetags.static import static
from django.urls import reverse
from django.utils import timezone
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -172,6 +173,9 @@ def create_new_interest_helper(bounty, user, issue_message):
@csrf_exempt
def gh_login(request):
"""Attempt to redirect the user to Github for authentication."""
_next = request.GET.get('next')
if _next:
return redirect(reverse('social:begin', args=('github', )) + f'?next={_next}')
return redirect('social:begin', backend='github')


Expand Down
184 changes: 184 additions & 0 deletions app/grants/migrations/0003_auto_20181017_1645.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# Generated by Django 2.1.2 on 2018-10-17 16:45

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

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

operations = [
migrations.AlterField(
model_name='contribution',
name='subscription',
field=models.ForeignKey(help_text='The associated Subscription.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='subscription_contribution', to='grants.Subscription'),
),
migrations.AlterField(
model_name='contribution',
name='tx_id',
field=models.CharField(default='0x0', help_text='The transaction ID of the Contribution.', max_length=255),
),
migrations.AlterField(
model_name='grant',
name='active',
field=models.BooleanField(default=True, help_text='Whether or not the Grant is active.'),
),
migrations.AlterField(
model_name='grant',
name='admin_address',
field=models.CharField(default='0x0', help_text='The wallet address for the administrator of this Grant.', max_length=255),
),
migrations.AlterField(
model_name='grant',
name='admin_profile',
field=models.ForeignKey(help_text="The Grant administrator's profile.", null=True, on_delete=django.db.models.deletion.CASCADE, related_name='grant_admin', to='dashboard.Profile'),
),
migrations.AlterField(
model_name='grant',
name='amount_goal',
field=models.DecimalField(decimal_places=4, default=1, help_text='The contribution goal amount for the Grant.', max_digits=50),
),
migrations.AlterField(
model_name='grant',
name='amount_received',
field=models.DecimalField(decimal_places=4, default=0, help_text='The total amount received for the Grant.', max_digits=50),
),
migrations.AlterField(
model_name='grant',
name='block_number',
field=models.CharField(default=0, help_text='The Ethereum block number during creation of the Grant.', max_length=9),
),
migrations.AlterField(
model_name='grant',
name='contract_address',
field=models.CharField(default='0x0', help_text='The contract address of the Grant.', max_length=255),
),
migrations.AlterField(
model_name='grant',
name='description',
field=models.TextField(blank=True, default='', help_text='The description of the Grant.'),
),
migrations.AlterField(
model_name='grant',
name='frequency',
field=models.DecimalField(decimal_places=0, default=30, help_text='The payout frequency of the Grant.', max_digits=50),
),
migrations.AlterField(
model_name='grant',
name='network',
field=models.CharField(default='mainnet', help_text='The network in which the Grant contract resides.', max_length=8),
),
migrations.AlterField(
model_name='grant',
name='reference_url',
field=models.URLField(blank=True, help_text='The associated reference URL of the Grant.'),
),
migrations.AlterField(
model_name='grant',
name='required_gas_price',
field=models.DecimalField(decimal_places=0, default='0', help_text='The required gas price for the Grant.', max_digits=50),
),
migrations.AlterField(
model_name='grant',
name='team_members',
field=models.ManyToManyField(help_text='The team members contributing to this Grant.', related_name='grant_teams', to='dashboard.Profile'),
),
migrations.AlterField(
model_name='grant',
name='title',
field=models.CharField(default='', help_text='The title of the Grant.', max_length=255),
),
migrations.AlterField(
model_name='grant',
name='token_address',
field=models.CharField(default='0x0', help_text='The token address to be used with the Grant.', max_length=255),
),
migrations.AlterField(
model_name='grant',
name='transaction_hash',
field=models.CharField(default='0x0', help_text='The transaction hash of the Grant.', max_length=255),
),
migrations.AlterField(
model_name='milestone',
name='completion_date',
field=models.DateField(blank=True, default=None, help_text='The Milestone completion date.', null=True),
),
migrations.AlterField(
model_name='milestone',
name='description',
field=models.TextField(help_text='The Milestone description.'),
),
migrations.AlterField(
model_name='milestone',
name='due_date',
field=models.DateField(help_text='The requested Milestone completion date.'),
),
migrations.AlterField(
model_name='milestone',
name='grant',
field=models.ForeignKey(help_text='The associated Grant.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='milestones', to='grants.Grant'),
),
migrations.AlterField(
model_name='milestone',
name='title',
field=models.CharField(help_text='The Milestone title.', max_length=255),
),
migrations.AlterField(
model_name='subscription',
name='active',
field=models.BooleanField(default=True, help_text='Whether or not the Subscription is active.'),
),
migrations.AlterField(
model_name='subscription',
name='amount_per_period',
field=models.DecimalField(decimal_places=4, default=1, help_text='The promised contribution amount per period.', max_digits=50),
),
migrations.AlterField(
model_name='subscription',
name='contributor_address',
field=models.CharField(default='', help_text="The contributor's wallet address of the Subscription.", max_length=255),
),
migrations.AlterField(
model_name='subscription',
name='contributor_profile',
field=models.ForeignKey(help_text="The Subscription contributor's Profile.", null=True, on_delete=django.db.models.deletion.CASCADE, related_name='grant_contributor', to='dashboard.Profile'),
),
migrations.AlterField(
model_name='subscription',
name='contributor_signature',
field=models.CharField(default='', help_text="The contributor's signature.", max_length=255),
),
migrations.AlterField(
model_name='subscription',
name='gas_price',
field=models.DecimalField(decimal_places=4, default=1, help_text='The required gas price for the Subscription.', max_digits=50),
),
migrations.AlterField(
model_name='subscription',
name='grant',
field=models.ForeignKey(help_text='The associated Grant.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='subscriptions', to='grants.Grant'),
),
migrations.AlterField(
model_name='subscription',
name='network',
field=models.CharField(default='mainnet', help_text='The network in which the Subscription resides.', max_length=8),
),
migrations.AlterField(
model_name='subscription',
name='period_seconds',
field=models.DecimalField(decimal_places=0, default=2592000, help_text='The subscription period length.', max_digits=50),
),
migrations.AlterField(
model_name='subscription',
name='subscription_hash',
field=models.CharField(default='', help_text="The contributor's Subscription hash.", max_length=255),
),
migrations.AlterField(
model_name='subscription',
name='token_address',
field=models.CharField(default='0x0', help_text='The token address to be used with the Subscription.', max_length=255),
),
]
133 changes: 96 additions & 37 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,58 @@ class GrantQuerySet(models.QuerySet):
class Grant(SuperModel):
"""Define the structure of a Grant."""

active = models.BooleanField(default=True)
title = models.CharField(default='', max_length=255)
description = models.TextField(default='', blank=True)
reference_url = models.URLField(db_index=True)
active = models.BooleanField(default=True, help_text=_('Whether or not the Grant is active.'))
title = models.CharField(default='', max_length=255, help_text=_('The title of the Grant.'))
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.'),
)
logo_svg = models.FileField(
upload_to=get_upload_filename, null=True, blank=True, help_text=_('The Grant logo SVG.')
)
admin_address = models.CharField(max_length=255, default='0x0')
frequency = models.DecimalField(default=30, decimal_places=0, max_digits=50)
amount_goal = models.DecimalField(default=1, decimal_places=4, max_digits=50)
amount_received = models.DecimalField(default=0, decimal_places=4, max_digits=50)
token_address = models.CharField(max_length=255, default='0x0')
contract_address = models.CharField(max_length=255, default='0x0')
transaction_hash = models.CharField(max_length=255, default='0x0')
block_number = models.CharField(max_length=9, default=0)
network = models.CharField(max_length=8, default='mainnet')
required_gas_price = models.DecimalField(default='0', decimal_places=0, max_digits=50)
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.'),
)
frequency = models.DecimalField(
default=30, 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.'),
)
amount_received = models.DecimalField(
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.'),
)
contract_address = models.CharField(
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.'),
)
block_number = models.CharField(
max_length=9, default=0, help_text=_('The Ethereum block number during creation of the Grant.'),
)
network = models.CharField(
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.'),
)
admin_profile = models.ForeignKey(
'dashboard.Profile', related_name='grant_admin', on_delete=models.CASCADE, null=True
'dashboard.Profile',
related_name='grant_admin',
on_delete=models.CASCADE,
help_text=_('The Grant administrator\'s profile.'),
null=True,
)
team_members = models.ManyToManyField(
'dashboard.Profile',
related_name='grant_teams',
help_text=_('The team members contributing to this Grant.'),
)
team_members = models.ManyToManyField('dashboard.Profile', related_name='grant_teams')

def __str__(self):
"""Return the string representation of a Grant."""
Expand All @@ -76,12 +104,15 @@ class SubscriptionQuerySet(models.QuerySet):
class Milestone(SuperModel):
"""Define the structure of a Grant Milestone"""

title = models.CharField(max_length=255)
description = models.TextField()
due_date = models.DateField()
completion_date = models.DateField(default=None, blank=True, null=True)

grant = models.ForeignKey('Grant', related_name='milestones', on_delete=models.CASCADE, null=True)
title = models.CharField(max_length=255, help_text=_('The Milestone title.'))
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.'),
)
grant = models.ForeignKey(
'Grant', related_name='milestones', on_delete=models.CASCADE, null=True, help_text=_('The associated Grant.'),
)

def __str__(self):
"""Return the string representation of a Milestone."""
Expand All @@ -94,18 +125,42 @@ def __str__(self):
class Subscription(SuperModel):
"""Define the structure of a subscription agreement."""

active = models.BooleanField(default=True)
subscription_hash = models.CharField(default='', max_length=255)
contributor_signature = models.CharField(default='', max_length=255)
contributor_address = models.CharField(default='', max_length=255)
amount_per_period = models.DecimalField(default=1, decimal_places=4, max_digits=50)
period_seconds = models.DecimalField(default=2592000, decimal_places=0, max_digits=50)
token_address = models.CharField(max_length=255, default='0x0')
gas_price = models.DecimalField(default=1, decimal_places=4, max_digits=50)
network = models.CharField(max_length=8, default='mainnet')
grant = models.ForeignKey('grants.Grant', related_name='subscriptions', on_delete=models.CASCADE, null=True)
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.'),
)
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.'),
)
amount_per_period = models.DecimalField(
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.'),
)
token_address = models.CharField(
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.'),
)
network = models.CharField(
max_length=8, default='mainnet', help_text=_('The network in which the Subscription resides.'),
)
grant = models.ForeignKey(
'grants.Grant',
related_name='subscriptions',
on_delete=models.CASCADE,
null=True,
help_text=_('The associated Grant.'),
)
contributor_profile = models.ForeignKey(
'dashboard.Profile', related_name='grant_contributor', on_delete=models.CASCADE, null=True
'dashboard.Profile',
related_name='grant_contributor',
on_delete=models.CASCADE,
null=True,
help_text=_('The Subscription contributor\'s Profile.'),
)

def __str__(self):
Expand All @@ -122,7 +177,11 @@ class ContributionQuerySet(models.QuerySet):
class Contribution(SuperModel):
"""Define the structure of a subscription agreement."""

tx_id = models.CharField(max_length=255, default='0x0')
tx_id = models.CharField(max_length=255, default='0x0', help_text=_('The transaction ID of the Contribution.'))
subscription = models.ForeignKey(
'grants.Subscription', related_name='subscription_contribution', on_delete=models.CASCADE, null=True
'grants.Subscription',
related_name='subscription_contribution',
on_delete=models.CASCADE,
null=True,
help_text=_('The associated Subscription.'),
)
Loading