Skip to content

Commit

Permalink
Merge branch 'master' into fixes/grant-edit_info
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickGT authored Jul 30, 2019
2 parents 162ee56 + f190cdf commit cb76e6d
Show file tree
Hide file tree
Showing 17 changed files with 302 additions and 101 deletions.
4 changes: 2 additions & 2 deletions app/app/sitemaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class ResultsSitemap(Sitemap):
priority = 0.6

def items(self):
from retail.utils import programming_languages_full
return programming_languages_full
from retail.utils import programming_languages
return programming_languages

def lastmod(self, obj):
from django.utils import timezone
Expand Down
2 changes: 1 addition & 1 deletion app/assets/v2/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ if (document.contxt.github_handle && !document.contxt.persona_is_funder && !docu
</button>
</div>
<div class="col-12 pt-2 pb-2 text-center">
<img src="${static_url}/v2/images/modals/persona-choose.svg" width="160" height="137">
<img src="${static_url}v2/images/modals/persona-choose.svg" width="160" height="137">
<h2 class="font-title mt-4">${gettext('Are you a Funder or a Contributor?')}</h2>
</div>
<div class="col-12 pt-2 text-center">
Expand Down
17 changes: 9 additions & 8 deletions app/assets/v2/js/pages/bounty_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,31 +125,32 @@ var callbacks = {
},
'status': function(key, val, result) {
let ui_status = val;
let ui_status_raw = val;

if (ui_status === 'open') {
if (ui_status_raw === 'open') {
ui_status = '<span>' + gettext('OPEN ISSUE') + '</span>';

let can_submit = result['can_submit_after_expiration_date'];

if (!isBountyOwner && can_submit && is_bounty_expired(result)) {
if (!isBountyOwner() && can_submit && is_bounty_expired(result)) {
ui_status += '<p class="text-highlight-light-blue font-weight-light font-body" style="text-transform: none;">' +
gettext('This issue is past its expiration date, but it is still active.') +
'<br>' +
gettext('Check with the submitter to see if they still want to see it fulfilled.') +
'</p>';
}
} else if (ui_status === 'started') {
} else if (ui_status_raw === 'started') {
ui_status = '<span>' + gettext('work started') + '</span>';
} else if (ui_status === 'submitted') {
} else if (ui_status_raw === 'submitted') {
ui_status = '<span>' + gettext('work submitted') + '</span>';
} else if (ui_status === 'done') {
} else if (ui_status_raw === 'done') {
ui_status = '<span>' + gettext('done') + '</span>';
} else if (ui_status === 'cancelled') {
} else if (ui_status_raw === 'cancelled') {
ui_status = '<span style="color: #f9006c;">' + gettext('cancelled') + '</span>';
}

if (isBountyOwner && is_bounty_expired(result) &&
ui_status !== 'done' && ui_status !== 'cancelled') {
if (isBountyOwner() && is_bounty_expired(result) &&
ui_status_raw !== 'done' && ui_status_raw !== 'cancelled') {

ui_status += '<p class="font-weight-light font-body" style="color: black; text-transform: none;">' +
'This issue has expired. Click <a class="text-highlight-light-blue font-weight-semibold" href="/extend-deadlines">here to extend expiration</a> ' +
Expand Down
10 changes: 10 additions & 0 deletions app/avatar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from django.core.files import File
from django.core.files.base import ContentFile
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils.translation import gettext_lazy as _

from economy.models import SuperModel
Expand Down Expand Up @@ -208,3 +210,11 @@ def github_avatar(cls, profile, avatar_img):
avatar.png.save(f'{profile.handle}.png', ContentFile(get_temp_image_file(avatar_img).getvalue()), save=True)
avatar.svg = avatar.convert_field(avatar.png, 'png', 'svg')
return avatar


@receiver(post_save, sender=SocialAvatar, dispatch_uid="psave_avatar")
@receiver(post_save, sender=CustomAvatar, dispatch_uid="psave_avatar2")
def psave_avatar(sender, instance, **kwargs):
from dashboard.models import Activity
metadata = {'url': instance.png.url if getattr(instance, 'png', False) else None, }
Activity.objects.create(profile=instance.profile, activity_type='updated_avatar', metadata=metadata)
18 changes: 18 additions & 0 deletions app/dashboard/migrations/0044_auto_20190729_1817.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.3 on 2019-07-29 18:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0043_auto_20190724_1507'),
]

operations = [
migrations.AlterField(
model_name='activity',
name='activity_type',
field=models.CharField(blank=True, choices=[('new_bounty', 'New Bounty'), ('start_work', 'Work Started'), ('stop_work', 'Work Stopped'), ('work_submitted', 'Work Submitted'), ('work_done', 'Work Done'), ('worker_approved', 'Worker Approved'), ('worker_rejected', 'Worker Rejected'), ('worker_applied', 'Worker Applied'), ('increased_bounty', 'Increased Funding'), ('killed_bounty', 'Canceled Bounty'), ('new_tip', 'New Tip'), ('receive_tip', 'Tip Received'), ('bounty_abandonment_escalation_to_mods', 'Escalated for Abandonment of Bounty'), ('bounty_abandonment_warning', 'Warning for Abandonment of Bounty'), ('bounty_removed_slashed_by_staff', 'Dinged and Removed from Bounty by Staff'), ('bounty_removed_by_staff', 'Removed from Bounty by Staff'), ('bounty_removed_by_funder', 'Removed from Bounty by Funder'), ('new_crowdfund', 'New Crowdfund Contribution'), ('new_grant', 'New Grant'), ('update_grant', 'Updated Grant'), ('killed_grant', 'Cancelled Grant'), ('new_grant_contribution', 'Contributed to Grant'), ('new_grant_subscription', 'Subscribed to Grant'), ('killed_grant_contribution', 'Cancelled Grant Contribution'), ('new_milestone', 'New Milestone'), ('update_milestone', 'Updated Milestone'), ('new_kudos', 'New Kudos'), ('joined', 'Joined Gitcoin'), ('updated_avatar', 'Updated Avatar')], db_index=True, max_length=50),
),
]
1 change: 1 addition & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,7 @@ class Activity(SuperModel):
('update_milestone', 'Updated Milestone'),
('new_kudos', 'New Kudos'),
('joined', 'Joined Gitcoin'),
('updated_avatar', 'Updated Avatar'),
]

profile = models.ForeignKey(
Expand Down
8 changes: 6 additions & 2 deletions app/dashboard/templates/shared/profile_activities_misc.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
{% elif activity.subscription.grant.reference_url %} href="{{ activity.subscription.grant.reference_url }}"
{% endif %}>
<div class="avatar-container col-1 justify-content-center special_tag hide_min_viewport">
<img class="avatar" src="/dynamic/avatar/{{ activity.profile.handle }}">
{% if activity.metadata.url %}
<img class="avatar" src="{{ activity.metadata.url }}">
{% else %}
<img class="avatar" src="/dynamic/avatar/{{ activity.profile.handle }}">
{% endif %}
</div>
<div class="col-12 col-md-7 d-flex flex-column">
<div class="bounty-detail">
Expand All @@ -13,7 +17,7 @@
{{activity.humanized_activity_type}}
<div class="bounty-summary col-12">
<div class="info font-caption">
&bull; {{ activity.created_on | naturaltime }}
{{ activity.created_on | naturaltime }}
</div>
</div>
</div>
Expand Down
9 changes: 6 additions & 3 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ def profile(request, handle):
handle = handle[:-1]
profile = profile_helper(handle, current_user=request.user)

all_activities = ['all', 'new_bounty', 'start_work', 'work_submitted', 'work_done', 'new_tip', 'receive_tip', 'new_grant', 'update_grant', 'killed_grant', 'new_grant_contribution', 'new_grant_subscription', 'killed_grant_contribution', 'receive_kudos', 'new_kudos']
all_activities = ['all', 'new_bounty', 'start_work', 'work_submitted', 'work_done', 'new_tip', 'receive_tip', 'new_grant', 'update_grant', 'killed_grant', 'new_grant_contribution', 'new_grant_subscription', 'killed_grant_contribution', 'receive_kudos', 'new_kudos', 'joined', 'updated_avatar']
activity_tabs = [
(_('All Activity'), all_activities),
(_('Bounties'), ['new_bounty', 'start_work', 'work_submitted', 'work_done']),
Expand Down Expand Up @@ -2041,7 +2041,7 @@ def profile(request, handle):
context['sent_kudos_count'] = sent_kudos.count()
context['verification'] = profile.get_my_verified_check
context['avg_rating'] = profile.get_average_star_rating

context['suppress_sumo'] = True
context['unrated_funded_bounties'] = Bounty.objects.current().prefetch_related('fulfillments', 'interested', 'interested__profile', 'feedbacks') \
.filter(
bounty_owner_github_username__iexact=profile.handle,
Expand Down Expand Up @@ -2864,7 +2864,10 @@ def change_user_profile_banner(request):

try:
profile = profile_helper(handle, True)
if request.user.profile.id != profile.id:
is_valid = request.user.profile.id == profile.id
if filename[0:7] != '/static' or filename.split('/')[-1] not in load_files_in_directory('wallpapers'):
is_valid = False
if not is_valid:
return JsonResponse(
{'error': 'Bad request'},
status=401)
Expand Down
39 changes: 39 additions & 0 deletions app/grants/migrations/0025_donation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 2.1.7 on 2019-07-22 13:10

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


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0041_auto_20190718_1222'),
('grants', '0024_auto_20190612_1645'),
]

operations = [
migrations.CreateModel(
name='Donation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_on', models.DateTimeField(db_index=True, default=economy.models.get_time)),
('modified_on', models.DateTimeField(default=economy.models.get_time)),
('from_address', models.CharField(default='0x0', help_text="The sender's address.", max_length=255)),
('to_address', models.CharField(default='0x0', help_text='The destination address.', max_length=255)),
('token_address', models.CharField(default='0x0', help_text='The token address to be used with the Grant.', max_length=255)),
('token_symbol', models.CharField(default='', help_text="The donation token's symbol.", max_length=255)),
('token_amount', models.DecimalField(decimal_places=18, default=0, help_text='The donation amount in tokens.', max_digits=64)),
('token_amount_usdt', models.DecimalField(decimal_places=4, default=0, help_text='The donation amount converted to USDT/DAI at the moment of donation.', max_digits=50)),
('tx_id', models.CharField(default='0x0', help_text='The transaction ID of the Contribution.', max_length=255)),
('network', models.CharField(default='mainnet', help_text='The network in which the Subscription resides.', max_length=8)),
('donation_percentage', models.DecimalField(decimal_places=2, default=0, help_text='The additional percentage selected when the donation is made', max_digits=5)),
('contribution', models.ForeignKey(help_text='The contribution that this donation was a part of.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='donation', to='grants.Contribution')),
('profile', models.ForeignKey(help_text="The donator's profile.", null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='donations', to='dashboard.Profile')),
('subscription', models.ForeignKey(help_text='The recurring subscription that this donation originated from.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='donations', to='grants.Subscription')),
],
options={
'abstract': False,
},
),
]
88 changes: 88 additions & 0 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,94 @@ def psave_grant(sender, instance, **kwargs):
#print("-", subscription.id, value_usdt, instance.monthly_amount_subscribed )


class DonationQuerySet(models.QuerySet):
"""Define the Contribution default queryset and manager."""

pass


class Donation(SuperModel):
"""Define the structure of an optional donation. These donations are
additional funds sent to Gitcoin as part of contributing or subscribing
to a grant."""

from_address = models.CharField(
max_length=255,
default='0x0',
help_text=_("The sender's address."),
)
to_address = models.CharField(
max_length=255,
default='0x0',
help_text=_("The destination address."),
)
profile = models.ForeignKey(
'dashboard.Profile',
related_name='donations',
on_delete=models.SET_NULL,
help_text=_("The donator's profile."),
null=True,
)
token_address = models.CharField(
max_length=255,
default='0x0',
help_text=_('The token address to be used with the Grant.'),
)
token_symbol = models.CharField(
max_length=255,
default='',
help_text=_("The donation token's symbol."),
)
token_amount = models.DecimalField(
default=0,
decimal_places=18,
max_digits=64,
help_text=_('The donation amount in tokens.'),
)
token_amount_usdt = models.DecimalField(
default=0,
decimal_places=4,
max_digits=50,
help_text=_('The donation amount converted to USDT/DAI at the moment of donation.'),
)
tx_id = models.CharField(
max_length=255,
default='0x0',
help_text=_('The transaction ID of the Contribution.'),
)
network = models.CharField(
max_length=8,
default='mainnet',
help_text=_('The network in which the Subscription resides.'),
)
donation_percentage = models.DecimalField(
default=0,
decimal_places=2,
max_digits=5,
help_text=_('The additional percentage selected when the donation is made'),
)
subscription = models.ForeignKey(
'grants.subscription',
related_name='donations',
on_delete=models.SET_NULL,
help_text=_("The recurring subscription that this donation originated from."),
null=True,
)
contribution = models.ForeignKey(
'grants.contribution',
related_name='donation',
on_delete=models.SET_NULL,
help_text=_("The contribution that this donation was a part of."),
null=True,
)


def __str__(self):
"""Return the string representation of this object."""
from django.contrib.humanize.templatetags.humanize import naturaltime
return f"id: {self.pk}; from:{profile.handle}; {tx_id} => ${token_amount_usdt}; {naturaltime(self.created_on)}"


class ContributionQuerySet(models.QuerySet):
"""Define the Contribution default queryset and manager."""

Expand Down
Loading

0 comments on commit cb76e6d

Please sign in to comment.