From 1bb6b1c8adad4779fcbf5563bd5407406df15cca Mon Sep 17 00:00:00 2001 From: Saptak Sengupta Date: Mon, 24 Sep 2018 18:58:30 +0530 Subject: [PATCH] Adds fund branding organisation information with a bounty (#2039) * Adds fund branding organisation information with a bounty * makes stickler happy * Related to Kevin's comment * Makes changes in the model file * Update migration file * Modifies migrations to prevent conflict --- app/assets/v2/js/pages/bounty_details.js | 3 +++ app/assets/v2/js/pages/new_bounty.js | 2 ++ app/dashboard/helpers.py | 4 +++- .../0107_bounty_funding_organisation.py | 18 ++++++++++++++++++ app/dashboard/models.py | 1 + app/dashboard/notifications.py | 3 ++- app/dashboard/router.py | 2 +- app/dashboard/templates/bounty/new.html | 4 ++++ 8 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 app/dashboard/migrations/0107_bounty_funding_organisation.py diff --git a/app/assets/v2/js/pages/bounty_details.js b/app/assets/v2/js/pages/bounty_details.js index c9a461b68c3..e10649d8a5a 100644 --- a/app/assets/v2/js/pages/bounty_details.js +++ b/app/assets/v2/js/pages/bounty_details.js @@ -166,6 +166,9 @@ var callbacks = { 'bounty_owner_name': function(key, val, result) { return [ 'bounty_owner_name', result.bounty_owner_name ]; }, + 'funding_organisation': function(key, val, result) { + return [ 'funding_organisation', result.funding_organisation ]; + }, 'permission_type': function(key, val, result) { if (val == 'approval') { val = 'Approval Required'; diff --git a/app/assets/v2/js/pages/new_bounty.js b/app/assets/v2/js/pages/new_bounty.js index 9df26cdee9d..7995664f9c5 100644 --- a/app/assets/v2/js/pages/new_bounty.js +++ b/app/assets/v2/js/pages/new_bounty.js @@ -222,6 +222,7 @@ $(document).ready(function() { experienceLevel: data.experience_level, projectLength: data.project_length, bountyType: data.bounty_type, + fundingOrganisation: data.fundingOrganisation, tokenName }; @@ -256,6 +257,7 @@ $(document).ready(function() { hiringRightNow: data.hiringRightNow, jobDescription: data.jobDescription }, + funding_organisation: metadata.fundingOrganisation, privacy_preferences: privacy_preferences, funders: [], categories: metadata.issueKeywords.split(','), diff --git a/app/dashboard/helpers.py b/app/dashboard/helpers.py index d64ec2991c5..5708b18f75e 100644 --- a/app/dashboard/helpers.py +++ b/app/dashboard/helpers.py @@ -410,6 +410,7 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id): 'contract_address': bounty_details.get('token'), 'network': bounty_details.get('network'), 'bounty_type': metadata.get('bountyType', ''), + 'funding_organisation': metadata.get('fundingOrganisation', ''), 'project_length': metadata.get('projectLength', ''), 'experience_level': metadata.get('experienceLevel', ''), 'project_type': bounty_payload.get('schemes', {}).get('project_type', 'traditional'), @@ -428,7 +429,8 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id): 'project_length', 'experience_level', 'project_type', 'permission_type', 'attached_job_description', 'bounty_owner_github_username', 'bounty_owner_address', 'bounty_owner_email', 'bounty_owner_name', 'github_comments', 'override_status', 'last_comment_date', 'snooze_warnings_for_days', - 'admin_override_and_hide', 'admin_override_suspend_auto_approval', 'admin_mark_as_remarket_ready' + 'admin_override_and_hide', 'admin_override_suspend_auto_approval', 'admin_mark_as_remarket_ready', + 'funding_organisation' ], ) bounty_kwargs.update(latest_old_bounty_dict) diff --git a/app/dashboard/migrations/0107_bounty_funding_organisation.py b/app/dashboard/migrations/0107_bounty_funding_organisation.py new file mode 100644 index 00000000000..b234bc34ddb --- /dev/null +++ b/app/dashboard/migrations/0107_bounty_funding_organisation.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1 on 2018-08-24 14:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0106_auto_20180823_1626'), + ] + + operations = [ + migrations.AddField( + model_name='bounty', + name='funding_organisation', + field=models.CharField(blank=True, default='', max_length=255), + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index f6de984e617..3616fdbe2df 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -245,6 +245,7 @@ class Bounty(SuperModel): idx_project_length = models.IntegerField(default=0, db_index=True) idx_status = models.CharField(max_length=9, choices=STATUS_CHOICES, default='open', db_index=True) issue_description = models.TextField(default='', blank=True) + funding_organisation = models.CharField(max_length=255, default='', blank=True) standard_bounties_id = models.IntegerField(default=0) num_fulfillments = models.IntegerField(default=0) balance = models.DecimalField(default=0, decimal_places=2, max_digits=50) diff --git a/app/dashboard/notifications.py b/app/dashboard/notifications.py index f4d424ff0a1..732facf6dfc 100644 --- a/app/dashboard/notifications.py +++ b/app/dashboard/notifications.py @@ -432,11 +432,12 @@ def build_github_notification(bounty, event_name, profile_pairs=None): learn_more_msg = f"* Learn more [on the Gitcoin Issue Details page]({absolute_url})" crowdfund_amount = f"(plus a crowdfund of {bounty.additional_funding_summary_sentence})" if bounty.additional_funding_summary_sentence else "" crowdfund_thx = ", ".join(f"@{tip.from_username}" for tip in bounty.tips.filter(is_for_bounty_fulfiller=True) if tip.from_username) + funding_org = f"__ as part of the {bounty.funding_organisation} fund__" if bounty.funding_organisation else "" if crowdfund_thx: crowdfund_thx = f"Thanks to {crowdfund_thx} for their crowdfunded contributions to this bounty.\n\n" if event_name == 'new_bounty': msg = f"{status_header}__This issue now has a funding of {natural_value} {bounty.token_name} {usdt_value} " \ - f"{crowdfund_amount} attached to it.__\n\n * If you would " \ + f"{crowdfund_amount} attached to it{funding_org}.__\n\n * If you would " \ f"like to work on this issue you can 'start work' [on the Gitcoin Issue Details page]({absolute_url})." \ f"\n{crowdfund_msg}\n{help_msg}\n{openwork_msg}\n" if event_name == 'increased_bounty': diff --git a/app/dashboard/router.py b/app/dashboard/router.py index 1592b8664a5..d206a68ca2c 100644 --- a/app/dashboard/router.py +++ b/app/dashboard/router.py @@ -97,7 +97,7 @@ class Meta: 'github_org_name', 'github_repo_name', 'idx_status', 'token_value_time_peg', 'fulfillment_accepted_on', 'fulfillment_submitted_on', 'fulfillment_started_on', 'canceled_on', 'action_urls', 'project_type', 'permission_type', 'attached_job_description', 'needs_review', 'github_issue_state', 'is_issue_closed', - 'additional_funding_summary', 'paid', + 'additional_funding_summary', 'funding_organisation', 'paid', ) def create(self, validated_data): diff --git a/app/dashboard/templates/bounty/new.html b/app/dashboard/templates/bounty/new.html index f9714ca4248..362dd164500 100644 --- a/app/dashboard/templates/bounty/new.html +++ b/app/dashboard/templates/bounty/new.html @@ -106,6 +106,10 @@
{% trans "Contact" %}
{% include 'shared/pricing.html' %}
+ + +
+