diff --git a/app/assets/v2/js/grants/_detail-component.js b/app/assets/v2/js/grants/_detail-component.js index 4a9f648e6ef..3c24d02efac 100644 --- a/app/assets/v2/js/grants/_detail-component.js +++ b/app/assets/v2/js/grants/_detail-component.js @@ -78,7 +78,8 @@ Vue.mixin({ 'polkadot_payout_address': vm.grant.polkadot_payout_address, 'kusama_payout_address': vm.grant.kusama_payout_address, 'rsk_payout_address': vm.grant.rsk_payout_address, - 'region': vm.grant.region?.name || undefined + 'region': vm.grant.region?.name || undefined, + 'has_external_funding': vm.grant.has_external_funding }; if (vm.logo) { @@ -349,6 +350,9 @@ Vue.mixin({ if (vm.grant.description_rich_edited.length < 10) { vm.$set(vm.errors, 'description', 'Please enter description for the grant'); } + if (vm.grant.has_external_funding == 'unknown') { + vm.$set(vm.errors, 'has_external_funding', 'Please select if your grant has had external funding'); + } if (!vm.$refs.formEditGrant.reportValidity()) { return false; @@ -536,6 +540,10 @@ Vue.component('grant-details', { { 'name': 'india', 'label': 'India'}, { 'name': 'east_asia', 'label': 'East Asia'}, { 'name': 'southeast_asia', 'label': 'Southeast Asia'} + ], + externalFundingOptions: [ + {'key': 'yes', 'value': 'Yes, this project has raised external funding.'}, + {'key': 'no', 'value': 'No, this project has not raised external funding.'} ] }; }, diff --git a/app/assets/v2/js/grants/_new.js b/app/assets/v2/js/grants/_new.js index 734f8939e84..379d87dd8af 100644 --- a/app/assets/v2/js/grants/_new.js +++ b/app/assets/v2/js/grants/_new.js @@ -138,6 +138,9 @@ Vue.mixin({ if (vm.form.description_rich.length < 10) { vm.$set(vm.errors, 'description', 'Please enter description for the grant'); } + if (!vm.form.has_external_funding) { + vm.$set(vm.errors, 'has_external_funding', 'Please select if grant has external funding'); + } if (Object.keys(vm.errors).length) { return false; // there are errors the user must correct @@ -176,7 +179,8 @@ Vue.mixin({ 'grant_type': form.grant_type, 'categories[]': form.grant_categories, 'network': form.network, - 'region': form.region + 'region': form.region, + 'has_external_funding': form.has_external_funding }; console.log(params); @@ -312,6 +316,11 @@ const grant_regions = [ { 'name': 'southeast_asia', 'label': 'Southeast Asia'} ]; +const externalFundingOptions = [ + {'key': 'yes', 'value': 'Yes, this project has raised external funding.'}, + {'key': 'no', 'value': 'No, this project has not raised external funding.'} +]; + if (document.getElementById('gc-new-grant')) { appFormBounty = new Vue({ delimiters: [ '[[', ']]' ], @@ -324,6 +333,7 @@ if (document.getElementById('gc-new-grant')) { chainId: '', grant_types: document.grant_types, grant_regions: grant_regions, + externalFundingOptions: externalFundingOptions, usersOptions: [], network: 'mainnet', logo: null, diff --git a/app/assets/v2/js/grants/detail.js b/app/assets/v2/js/grants/detail.js deleted file mode 100644 index 74a12b2342d..00000000000 --- a/app/assets/v2/js/grants/detail.js +++ /dev/null @@ -1,261 +0,0 @@ -const editableFields = [ - '#form--input__title', - '#form--input__github-project-url', - '#form--twitter__account', - '#form--input__reference-url', - '#contract_owner_address', - '#grant-members', - '#grant-categories' -]; - -function getCategoryIndex(categoryName, categories) { - const resultSet = categories.filter(category => { - const name = category[0]; - - return name === categoryName; - }); - - if (resultSet.length === 1) { - const matchingCategory = resultSet[0]; - - const index = matchingCategory[1]; - - return index.toString(); - } - - return '-1'; -} - -function initGrantCategoriesInput() { - const grant_type = $('#grant-type').html(); - - if (grant_type && grant_type.length > 0) { - grantCategoriesSelection( - '#grant-categories', - `/grants/categories?type=${grant_type.toLowerCase()}` - ); - } -} - -$(document).ready(function() { - showMore(); - addGrantLogo(); - initGrantCategoriesInput(); - - - var lgi = localStorage.getItem('last_grants_index'); - var lgt = localStorage.getItem('last_grants_title'); - - if (lgi) { - $('#backgrants').attr('href', lgi); - $('#backgrants').html(' Back to ' + lgt); - } - - var algi = localStorage.getItem('last_all_grants_index'); - var algt = localStorage.getItem('last_all_grants_title'); - - if (algi) { - $('#cart_backgrants').attr('href', algi); - $('#cart_backgrants').html(' Back to ' + algt); - } - - setInterval (() => { - if ($('#cancel_grant').attr('disabled')) { - $('#cancel_grant').addClass('disable-btn').addClass('disable-tooltip'); - $('#cancel_grant_tooltip').attr( - 'data-original-title', 'switch to below contract owner address to cancel grant.' - ); - } else { - $('#cancel_grant').removeClass('disable-btn').removeClass('disable-tooltip'); - $('#cancel_grant_tooltip').attr('data-original-title', ''); - } - }, 1000); - - $('#flag').click(function(e) { - e.preventDefault(); - const comment = prompt('What is your reason for flagging this Grant?'); - - if (!comment) { - return; - } - const data = { - 'csrfmiddlewaretoken': $('input[name=csrfmiddlewaretoken]').val(), - 'comment': comment - }; - - if (!document.contxt.github_handle) { - _alert({ message: gettext('Please login.') }, 'danger', 1000); - return; - } - $.ajax({ - type: 'post', - url: $(this).data('href'), - data, - success: function(json) { - _alert({ message: gettext('Your flag has been sent to Gitcoin.') }, 'success', 1000); - }, - error: function() { - _alert({ message: gettext('Your report failed to save Please try again.') }, 'danger', 1000); - } - }); - - }); - - userSearch('#grant-members', false, undefined, false, false, true); - $('.select2-selection__rendered').removeAttr('title'); - $('#form--input__title').height($('#form--input__title').prop('scrollHeight')); - $('#form--input__reference-url').height($('#form--input__reference-url').prop('scrollHeight')); - $('#form--twitter__account').height($('#form--twitter__account').prop('scrollHeight')); - - $('#edit-details').on('click', (event) => { - event.preventDefault(); - - if (grant_description !== undefined) { - grant_description.enable(true); - grant_description.getContents(); - } - - $('#edit-details').addClass('hidden'); - $('#save-details').removeClass('hidden'); - $('#cancel-details').removeClass('hidden'); - $('.grant__progress').addClass('hidden'); - - $('#section-nav-description .ql-toolbar').css('display', 'inherit'); - $('#section-nav-description .ql-container').css('border-color', '#ccc'); - - copyDuplicateDetails(); - - editableFields.forEach(field => { - makeEditable(field); - }); - }); - - $('#save-details').on('click', event => { - $('#edit-details').removeClass('hidden'); - $('#save-details').addClass('hidden'); - $('#cancel-details').addClass('hidden'); - $('.grant__progress').removeClass('hidden'); - - $('#section-nav-description .ql-toolbar').css('display', 'none'); - $('#section-nav-description .ql-container').css('border-color', 'transparent'); - - let edit_title = $('#form--input__title').val(); - let edit_github_project_url = $('#form--input__github-project-url').val(); - let edit_reference_url = $('#form--input__reference-url').val(); - let twitter_account = $('#form--twitter__account').val().replace('@', ''); - let edit_grant_members = $('#grant-members').val(); - let edit_categories = $('#grant-categories').val(); - - let data = { - 'edit-title': edit_title, - 'edit-github_project_url': edit_github_project_url, - 'edit-reference_url': edit_reference_url, - 'edit-twitter_account': twitter_account, - 'edit-grant_members[]': edit_grant_members, - 'edit-categories[]': edit_categories - }; - - if (grant_description !== undefined) { - const edit_description = grant_description.getText(); - const edit_description_rich = JSON.stringify(grant_description.getContents()); - - grant_description.enable(false); - data = Object.assign({}, data, { - 'edit-description': edit_description, - 'edit-description_rich': edit_description_rich - }); - } - - $.ajax({ - type: 'post', - url: '', - data, - success: function(json) { - window.location.reload(false); - }, - error: function() { - _alert({ message: gettext('Your edits failed to save. Please try again.') }, 'danger'); - } - }); - - editableFields.forEach(field => disableEdit(field)); - }); - - $('#cancel-details').on('click', event => { - if (grant_description !== undefined) { - grant_description.enable(false); - grant_description.setContents(grant_description.getContents()); - } - $('#edit-details').removeClass('hidden'); - $('#save-details').addClass('hidden'); - $('#cancel-details').addClass('hidden'); - $('.grant__progress').removeClass('hidden'); - - $('#section-nav-description .ql-toolbar').css('display', 'none'); - $('#section-nav-description .ql-container').css('border-color', 'transparent'); - - editableFields.forEach(field => disableEdit(field)); - }); - - $('#cancel_grant').on('click', function(e) { - $('.modal-cancel-grants').on('click', function(e) { - $.ajax({ - type: 'post', - url: '', - data: { - 'grant_cancel_tx_id': '0x0' - }, - success: function(json) { - window.location.reload(false); - }, - error: function() { - _alert({ message: gettext('Canceling your grant failed to save. Please try again.') }, 'danger'); - } - }); - }); - }); -}); - -const makeEditable = (input) => { - $(input).addClass('editable'); - $(input).prop('readonly', false); - $(input).prop('disabled', false); - if (input === '#form--input__github-project-url') { - $(input).attr('type', 'text'); - $('#form--a__github-project-url').hide(); - } -}; - -const disableEdit = (input) => { - $(input).removeClass('editable'); - $(input).prop('readonly', true); - $(input).prop('disabled', true); - if (input === '#form--input__github-project-url') { - $(input).attr('type', 'hidden'); - $('#form--a__github-project-url').show(); - } -}; - -const copyDuplicateDetails = () => { - let obj = {}; - - editableFields.forEach(field => { - obj[field] = $(field).val() ? $(field).val() : $(field).last().text(); - }); - - $('#cancel-details').on('click', () => { - editableFields.forEach(field => { - if ([ '#grant-members', '#grant-categories' ].includes(field)) - $(field).val(obj[field]).trigger('change'); - else - $(field).val(obj[field]); - }); - }); -}; - -$(document).ready(() => { - $('#grant-profile-tabs button').click(function() { - document.location = $(this).attr('href'); - }); - $('.select2-selection__choice').removeAttr('title'); -}); diff --git a/app/dashboard/views.py b/app/dashboard/views.py index e12bba287b6..64fb04426d2 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -2231,11 +2231,6 @@ def user_card(request, handle): except (ProfileNotFoundException, ProfileHiddenException): raise Http404 - if not settings.DEBUG: - network = 'mainnet' - else: - network = 'rinkeby' - if request.user.is_authenticated: is_following = True if TribeMember.objects.filter(profile=request.user.profile, org=profile).count() else False else: diff --git a/app/grants/admin.py b/app/grants/admin.py index 354bc25ab9a..bd161d82253 100644 --- a/app/grants/admin.py +++ b/app/grants/admin.py @@ -113,7 +113,7 @@ class GrantAdmin(GeneralAdmin): 'metadata', 'twitter_handle_1', 'twitter_handle_2', 'view_count', 'in_active_clrs', 'last_update', 'funding_info', 'twitter_verified', 'twitter_verified_by', 'twitter_verified_at', 'stats_history', 'zcash_payout_address', 'celo_payout_address','zil_payout_address', 'harmony_payout_address', 'binance_payout_address', - 'polkadot_payout_address', 'kusama_payout_address', 'rsk_payout_address', 'emails', 'admin_message' + 'polkadot_payout_address', 'kusama_payout_address', 'rsk_payout_address', 'emails', 'admin_message', 'has_external_funding' ] readonly_fields = [ 'logo_svg_asset', 'logo_asset', diff --git a/app/grants/migrations/0118_grant_has_external_funding.py b/app/grants/migrations/0118_grant_has_external_funding.py new file mode 100644 index 00000000000..9677c7f5263 --- /dev/null +++ b/app/grants/migrations/0118_grant_has_external_funding.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.20 on 2021-05-31 07:46 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('grants', '0117_subscription_visitorid'), + ] + + operations = [ + migrations.AddField( + model_name='grant', + name='has_external_funding', + field=models.CharField(choices=[('yes', 'Yes'), ('no', 'No'), ('unknown', 'Unknown')], default='unknown', help_text='Does this grant have external funding', max_length=8), + ), + ] diff --git a/app/grants/models.py b/app/grants/models.py index 66863eb2d41..8b18c7ca43d 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -306,6 +306,12 @@ class Meta: ('southeast_asia', 'Southeast Asia') ] + EXTERNAL_FUNDING = [ + ('yes', 'Yes'), + ('no', 'No'), + ('unknown', 'Unknown') + ] + active = models.BooleanField(default=True, help_text=_('Whether or not the Grant is active.'), db_index=True) grant_type = models.ForeignKey(GrantType, on_delete=models.CASCADE, null=True, help_text="Grant Type") title = models.CharField(default='', max_length=255, help_text=_('The title of the Grant.')) @@ -552,7 +558,14 @@ class Meta: help_text=_('The Grants Sybil Score'), ) + # TODO-GRANTS: remove funding_info funding_info = models.CharField(default='', blank=True, null=True, max_length=255, help_text=_('Is this grant VC funded?')) + has_external_funding = models.CharField( + max_length=8, + default='unknown', + choices=EXTERNAL_FUNDING, + help_text="Does this grant have external funding" + ) clr_prediction_curve = ArrayField( ArrayField( @@ -952,7 +965,8 @@ def repr(self, user, build_absolute_uri): 'funding_info': self.funding_info, 'admin_message': self.admin_message, 'link_to_new_grant': self.link_to_new_grant.url if self.link_to_new_grant else self.link_to_new_grant, - 'region': {'name':self.region, 'label':self.get_region_display()} if self.region and self.region != 'null' else None + 'region': {'name':self.region, 'label':self.get_region_display()} if self.region and self.region != 'null' else None, + 'has_external_funding': self.has_external_funding } def favorite(self, user): diff --git a/app/grants/templates/grants/_new.html b/app/grants/templates/grants/_new.html index 4e972859aac..83d0cc2bebc 100644 --- a/app/grants/templates/grants/_new.html +++ b/app/grants/templates/grants/_new.html @@ -402,6 +402,22 @@
Funding Information
+ +
+ + Required + + + + + +
+ [[errors.has_external_funding]] +
+
+
Categorization Information
diff --git a/app/grants/templates/grants/detail/template-grant-details.html b/app/grants/templates/grants/detail/template-grant-details.html index 15dfd5b78ee..a84fd99adab 100644 --- a/app/grants/templates/grants/detail/template-grant-details.html +++ b/app/grants/templates/grants/detail/template-grant-details.html @@ -4,177 +4,216 @@
-
-

- [[grant.title]] -

- -
-
+
+ +

[[grant.title]]

+ + +
+ +
+ + + [[item.fields.label]] + + + + + [[item.fields.category]] + - -
- -
- @[[grant.twitter_handle_1]] - - -

- Verified Ownership - -

-

Grant owner has verified ownership of their twitter account.

-
- -
-
- - - - +
- +
- +
- + + - + +
+ + + - + + - + + - + + -
-
-
-
- -
+ + - -
-