From 829586209a85148a1d89b693a5e5ef7759c9ed14 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Thu, 10 Sep 2020 20:00:09 +0530 Subject: [PATCH 01/25] chg create common function for project data - To share the project params with intra view functions --- app/dashboard/views.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index b47ef1a176b..872afdee393 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -4486,10 +4486,17 @@ def hackathon_save_project(request): def get_project(request, project_id): profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None - project = HackathonProject.objects.filter(pk=project_id).nocache().first() - if not project: + params = project(project_id) + if not params: raise Http404("The project doesnt exists.") + return JsonResponse(params) + +def project(project_id): + project = HackathonProject.objects.filter(pk=project_id).nocache().first() + if not project: + return None + hackathon_obj = HackathonEventSerializer(project.hackathon).data, params = { 'project': { @@ -4515,14 +4522,14 @@ def get_project(request, project_id): 'url': member_profile.url, 'handle': member_profile.handle, 'avatar': member_profile.avatar_url - } for member_profile in project.profiles.all()] + } for member_profile in project.profiles.all()], + 'team_members_profile': [member_profile for member_profile in project.profiles.all()] }, 'hackathon': hackathon_obj[0], } + return params - return JsonResponse(params) - - + def hackathon_project_page(request, hackathon, project_id, project_name, tab=''): profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None From 7c82b96f6fbf0bf80ad76f68a3a163c6be04c4f4 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Thu, 10 Sep 2020 20:04:54 +0530 Subject: [PATCH 02/25] new: add convert to grant button - add convert to grant flow with project id param - url send optional param to fetch project data on new_grant - pre-load the project params on new grant page --- .../dashboard/hackathon/project_page.html | 13 ++++++------- app/grants/templates/grants/new.html | 9 ++++++--- app/grants/urls.py | 2 +- app/grants/views.py | 17 ++++++++++++++--- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/dashboard/templates/dashboard/hackathon/project_page.html b/app/dashboard/templates/dashboard/hackathon/project_page.html index 64d7915f4b0..772c181f091 100644 --- a/app/dashboard/templates/dashboard/hackathon/project_page.html +++ b/app/dashboard/templates/dashboard/hackathon/project_page.html @@ -65,18 +65,17 @@ {% endif %}
-
-
+
{% if is_member %} - +
+ Triangles CONVERT TO GRANT + +
{% endif %} -
-
+
{% include 'project/detail/info.html' %}
-
-
{% include 'shared/bottom_notification.html' %} {% include 'shared/analytics.html' %} diff --git a/app/grants/templates/grants/new.html b/app/grants/templates/grants/new.html index c45f5883a71..562a980b5c2 100644 --- a/app/grants/templates/grants/new.html +++ b/app/grants/templates/grants/new.html @@ -77,7 +77,7 @@
Project Information
- +
@@ -88,13 +88,16 @@
Project Information
- +
@@ -111,7 +114,7 @@
Project Information
- +
Categorization Information
diff --git a/app/grants/urls.py b/app/grants/urls.py index 5aa937c5f88..168f5bc4cbd 100644 --- a/app/grants/urls.py +++ b/app/grants/urls.py @@ -44,7 +44,7 @@ path('/', grant_details, name='details'), path('//', grant_details, name='details2'), re_path(r'^matic/new', grant_new_whitelabel, name='new_whitelabel'), - re_path(r'^new', grant_new, name='new'), + re_path(r'^new/(?:(?P\d+)/)?$', grant_new, name='new'), re_path(r'^categories', grant_categories, name='grant_categories'), path('//fund', grant_fund, name='fund'), path('bulk-fund', bulk_fund, name='bulk_fund'), diff --git a/app/grants/views.py b/app/grants/views.py index 589e8ab3317..4e2c9067236 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -58,7 +58,8 @@ from bs4 import BeautifulSoup from cacheops import cached_view from chartit import PivotChart, PivotDataPool -from dashboard.models import Activity, Profile, SearchHistory +from dashboard.models import Activity, Profile, SearchHistory, HackathonProject +from dashboard.views import project from dashboard.tasks import increment_view_count from dashboard.utils import get_web3, has_tx_mined from economy.models import Token as FTokens @@ -1265,7 +1266,7 @@ def grant_new_whitelabel(request): @login_required -def grant_new(request): +def grant_new(request, project_id=None): """Handle new grant.""" from grants.utils import add_grant_to_active_clrs @@ -1336,6 +1337,12 @@ def grant_new(request): + check_profile = None + project_data = None + if project_id is not None: + check_profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None + project_data = project(project_id) + params = { 'active': 'new_grant', 'title': _('New Grant'), @@ -1351,8 +1358,12 @@ def grant_new(request): 'conf_time_spread': conf_time_spread(), 'gas_advisories': gas_advisories(), 'trusted_relayer': settings.GRANTS_OWNER_ACCOUNT, - 'grant_types': GrantType.objects.all() + 'grant_types': GrantType.objects.all(), + 'data': {} } + if check_profile is not None: + params["data"] = project_data + return TemplateResponse(request, 'grants/new.html', params) From e1791c9a271647278c029aa52e36209ba8f20119 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Fri, 11 Sep 2020 21:58:07 +0530 Subject: [PATCH 03/25] Add: project_link optional integerfield in grants - project_link is id of project which is converted to grant. --- app/assets/v2/js/grants/new.js | 3 ++- app/grants/admin.py | 2 +- app/grants/forms.py | 2 +- .../migrations/0077_grant_project_link.py | 18 ++++++++++++++++++ app/grants/models.py | 1 + app/grants/templates/grants/new.html | 1 + app/grants/views.py | 3 +-- 7 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 app/grants/migrations/0077_grant_project_link.py diff --git a/app/assets/v2/js/grants/new.js b/app/assets/v2/js/grants/new.js index 96433285021..494bcfbd831 100644 --- a/app/assets/v2/js/grants/new.js +++ b/app/assets/v2/js/grants/new.js @@ -161,6 +161,7 @@ const init = () => { } formData.append('contract_version', $('#contract_version').val()); formData.append('transaction_hash', $('#transaction_hash').val()); + formData.append('project_link', $('#project_link').val()); if ($('#network').val()) { formData.append('network', $('#network').val()); } else { @@ -206,7 +207,7 @@ function saveGrant(grantData, isFinal) { $.ajax({ type: 'post', - url: '/grants/new', + url: '/grants/new/', processData: false, contentType: false, data: grantData, diff --git a/app/grants/admin.py b/app/grants/admin.py index c092c4b94b8..25c67adc34d 100644 --- a/app/grants/admin.py +++ b/app/grants/admin.py @@ -91,7 +91,7 @@ class GrantAdmin(GeneralAdmin): 'amount_received', 'monthly_amount_subscribed', 'deploy_tx_id', 'cancel_tx_id', 'admin_profile', 'token_symbol', 'token_address', 'contract_address', 'contract_version', 'network', 'required_gas_price', 'logo_svg_asset', - 'logo_asset', 'created_on', 'modified_on', 'team_member_list', + 'logo_asset', 'created_on', 'modified_on', 'team_member_list', 'project_link', 'subscriptions_links', 'contributions_links', 'logo', 'logo_svg', 'image_css', 'link', 'clr_prediction_curve', 'hidden', 'next_clr_calc_date', 'last_clr_calc_date', 'metadata', 'twitter_handle_1', 'twitter_handle_2', 'view_count', 'is_clr_eligible', 'in_active_clrs', diff --git a/app/grants/forms.py b/app/grants/forms.py index 33c0426bbd0..0955d2ecceb 100644 --- a/app/grants/forms.py +++ b/app/grants/forms.py @@ -33,5 +33,5 @@ class Meta: fields = ( 'title', 'description', 'reference_url', 'github_project_url', 'logo', 'logo_svg', 'admin_address', 'deploy_tx_id', 'cancel_tx_id', 'amount_received', 'token_address', 'contract_address', 'metadata', 'network', - 'required_gas_price', 'admin_profile', 'team_members' + 'required_gas_price', 'admin_profile', 'team_members', 'project_link' ) diff --git a/app/grants/migrations/0077_grant_project_link.py b/app/grants/migrations/0077_grant_project_link.py new file mode 100644 index 00000000000..788f3dab25d --- /dev/null +++ b/app/grants/migrations/0077_grant_project_link.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.4 on 2020-09-11 16:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('grants', '0076_matchpledge_data'), + ] + + operations = [ + migrations.AddField( + model_name='grant', + name='project_link', + field=models.PositiveIntegerField(blank=True, help_text='Project Id which is converted to grant', null=True), + ), + ] diff --git a/app/grants/models.py b/app/grants/models.py index 29169dc37f1..ba2bdaa1283 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -196,6 +196,7 @@ class Meta: reference_url = models.URLField(blank=True, help_text=_('The associated reference URL of the Grant.')) github_project_url = models.URLField(blank=True, help_text=_('Grant Github Project URL')) is_clr_eligible = models.BooleanField(default=True, help_text="Is grant eligible for CLR") + project_link = models.PositiveIntegerField(blank=True, null=True, help_text="Project Id which is converted to grant") link_to_new_grant = models.ForeignKey( 'grants.Grant', null=True, diff --git a/app/grants/templates/grants/new.html b/app/grants/templates/grants/new.html index 562a980b5c2..03410069780 100644 --- a/app/grants/templates/grants/new.html +++ b/app/grants/templates/grants/new.html @@ -166,6 +166,7 @@
Funding Information
+ diff --git a/app/grants/views.py b/app/grants/views.py index 4e2c9067236..b9122a42231 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1295,6 +1295,7 @@ def grant_new(request, project_id=None): 'network': request.POST.get('network', 'mainnet'), 'twitter_handle_1': request.POST.get('handle1', ''), 'twitter_handle_2': request.POST.get('handle2', ''), + 'project_link': request.POST.get('project_link', ''), 'metadata': receipt, 'last_update': timezone.now(), 'admin_profile': profile, @@ -1335,8 +1336,6 @@ def grant_new(request, project_id=None): 'url': grant.url, }) - - check_profile = None project_data = None if project_id is not None: From 9c2e79312daac74c28ca8bae209ddf04648c3686 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sat, 12 Sep 2020 14:26:26 +0530 Subject: [PATCH 04/25] Add project_link field to export serializer --- app/dashboard/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dashboard/export.py b/app/dashboard/export.py index 7c1c6287633..8f05a511482 100644 --- a/app/dashboard/export.py +++ b/app/dashboard/export.py @@ -106,7 +106,7 @@ class Meta: 'admin_address', 'contract_owner_address', 'monthly_amount_subscribed', 'amount_received', 'token_address', 'token_symbol', 'contract_address', 'network', - 'org', 'created_at', 'url', 'contribution_count', 'contributor_count' + 'org', 'created_at', 'url', 'contribution_count', 'contributor_count', 'project_link' ) def get_created_at(self, instance): From 186462e83d2b7f28f11acaa696ee48cb77d64ac6 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sat, 12 Sep 2020 14:30:00 +0530 Subject: [PATCH 05/25] Add button to visit and donate to the grant converted - grant_owner can see edit and convert button - project_vistor can see donate to grant button if project grant exists. --- .../dashboard/hackathon/project_page.html | 24 ++++++++++++++----- app/dashboard/views.py | 11 ++++++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/app/dashboard/templates/dashboard/hackathon/project_page.html b/app/dashboard/templates/dashboard/hackathon/project_page.html index 772c181f091..6759da98541 100644 --- a/app/dashboard/templates/dashboard/hackathon/project_page.html +++ b/app/dashboard/templates/dashboard/hackathon/project_page.html @@ -66,15 +66,27 @@ {% endif %}
- {% if is_member %}
- Triangles CONVERT TO GRANT + + {% if project_obj.is_grant %} + {% if is_member %} + Triangles EDIT GRANT + {% else %} + Triangles DONATE TO GRANT + {% endif %} + {% endif %} + + {% if is_member %} + {% if project_obj.is_grant is None %} + Triangles CONVERT TO GRANT + {% endif %} + {% endif %} +
+ +
+ {% include 'project/detail/info.html' %}
- {% endif %} -
- {% include 'project/detail/info.html' %} -
{% include 'shared/bottom_notification.html' %} diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 872afdee393..9142dab5859 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -122,6 +122,7 @@ ProfileSerializer, ProfileVerification, ProfileView, Question, SearchHistory, Sponsor, Subscription, Tool, ToolVote, TribeMember, UserAction, UserDirectory, UserVerificationModel, ) +from grants.models import Grant from .notifications import ( maybe_market_tip_to_email, maybe_market_tip_to_github, maybe_market_tip_to_slack, maybe_market_to_email, maybe_market_to_github, maybe_market_to_slack, maybe_market_to_user_slack, @@ -4534,9 +4535,16 @@ def hackathon_project_page(request, hackathon, project_id, project_name, tab='') profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None project = HackathonProject.objects.filter(pk=project_id).nocache().first() + grant = Grant.objects.filter(project_link=project_id).first() + if not project: raise Http404("No Hackathon Project matches the given query.") + if grant: + grant_url = grant.get_absolute_url() + else: + grant_url = None + active = 0 if tab == 'activity': active = 1 @@ -4580,7 +4588,8 @@ def hackathon_project_page(request, hackathon, project_id, project_name, tab='') 'url': member_profile.url, 'handle': member_profile.handle, 'avatar': member_profile.avatar_url - } for member_profile in project.profiles.all()] + } for member_profile in project.profiles.all()], + 'is_grant': grant_url }, 'hackathon_obj': hackathon_obj[0], 'hackathon': hackathon, From a08f9d77105cda6660996786e380966a1d13acc6 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sat, 12 Sep 2020 23:25:28 +0530 Subject: [PATCH 06/25] Chg: add grant_link field to hackathon project - rmv the grant model field project_link - Add new field to HackathonProject grant_link --- app/assets/v2/js/grants/new.js | 2 +- app/dashboard/admin.py | 2 +- app/dashboard/export.py | 2 +- .../0149_hackathonproject_grant_link.py | 18 ++++++++++++++++++ app/dashboard/models.py | 6 ++++++ .../dashboard/hackathon/project_page.html | 8 ++++---- app/dashboard/views.py | 8 +------- app/grants/admin.py | 2 +- app/grants/forms.py | 2 +- .../0078_remove_grant_project_link.py | 17 +++++++++++++++++ app/grants/models.py | 1 - app/grants/templates/grants/new.html | 2 +- app/grants/views.py | 4 +++- 13 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 app/dashboard/migrations/0149_hackathonproject_grant_link.py create mode 100644 app/grants/migrations/0078_remove_grant_project_link.py diff --git a/app/assets/v2/js/grants/new.js b/app/assets/v2/js/grants/new.js index 494bcfbd831..23d8ebb541d 100644 --- a/app/assets/v2/js/grants/new.js +++ b/app/assets/v2/js/grants/new.js @@ -161,7 +161,7 @@ const init = () => { } formData.append('contract_version', $('#contract_version').val()); formData.append('transaction_hash', $('#transaction_hash').val()); - formData.append('project_link', $('#project_link').val()); + formData.append('project_pk', $('#project_pk').val()); if ($('#network').val()) { formData.append('network', $('#network').val()); } else { diff --git a/app/dashboard/admin.py b/app/dashboard/admin.py index 8520b8961ed..3d187d30c12 100644 --- a/app/dashboard/admin.py +++ b/app/dashboard/admin.py @@ -454,7 +454,7 @@ class HackathonRegistrationAdmin(admin.ModelAdmin): class HackathonProjectAdmin(admin.ModelAdmin): - list_display = ['pk', 'img', 'name', 'bounty', 'hackathon_link', 'usernames', 'status', 'sponsor'] + list_display = ['pk', 'img', 'name', 'bounty', 'hackathon_link', 'grant_link', 'usernames', 'status', 'sponsor'] raw_id_fields = ['profiles', 'bounty', 'hackathon'] search_fields = ['name', 'summary', 'status'] diff --git a/app/dashboard/export.py b/app/dashboard/export.py index 8f05a511482..7c1c6287633 100644 --- a/app/dashboard/export.py +++ b/app/dashboard/export.py @@ -106,7 +106,7 @@ class Meta: 'admin_address', 'contract_owner_address', 'monthly_amount_subscribed', 'amount_received', 'token_address', 'token_symbol', 'contract_address', 'network', - 'org', 'created_at', 'url', 'contribution_count', 'contributor_count', 'project_link' + 'org', 'created_at', 'url', 'contribution_count', 'contributor_count' ) def get_created_at(self, instance): diff --git a/app/dashboard/migrations/0149_hackathonproject_grant_link.py b/app/dashboard/migrations/0149_hackathonproject_grant_link.py new file mode 100644 index 00000000000..d956be49ed5 --- /dev/null +++ b/app/dashboard/migrations/0149_hackathonproject_grant_link.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.4 on 2020-09-12 16:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0148_add_brightid_status'), + ] + + operations = [ + migrations.AddField( + model_name='hackathonproject', + name='grant_link', + field=models.URLField(blank=True, db_index=True, help_text='Grant Link', null=True), + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 82f55b5d218..50b70622957 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -5120,6 +5120,12 @@ class HackathonProject(SuperModel): chat_channel_id = models.CharField(max_length=255, blank=True, null=True) winner = models.BooleanField(default=False) extra = JSONField(default=dict, blank=True, null=True) + grant_link = models.URLField( + blank=True, + null=True, + db_index=True, + help_text='Grant Link' + ) class Meta: ordering = ['-name'] diff --git a/app/dashboard/templates/dashboard/hackathon/project_page.html b/app/dashboard/templates/dashboard/hackathon/project_page.html index 6759da98541..0851594cd00 100644 --- a/app/dashboard/templates/dashboard/hackathon/project_page.html +++ b/app/dashboard/templates/dashboard/hackathon/project_page.html @@ -68,16 +68,16 @@
- {% if project_obj.is_grant %} + {% if project_obj.grant_link %} {% if is_member %} - Triangles EDIT GRANT + Triangles EDIT GRANT {% else %} - Triangles DONATE TO GRANT + Triangles DONATE TO GRANT {% endif %} {% endif %} {% if is_member %} - {% if project_obj.is_grant is None %} + {% if project_obj.grant_link is None %} Triangles CONVERT TO GRANT {% endif %} diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 9142dab5859..1382e689371 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -4535,16 +4535,10 @@ def hackathon_project_page(request, hackathon, project_id, project_name, tab='') profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None project = HackathonProject.objects.filter(pk=project_id).nocache().first() - grant = Grant.objects.filter(project_link=project_id).first() if not project: raise Http404("No Hackathon Project matches the given query.") - if grant: - grant_url = grant.get_absolute_url() - else: - grant_url = None - active = 0 if tab == 'activity': active = 1 @@ -4589,7 +4583,7 @@ def hackathon_project_page(request, hackathon, project_id, project_name, tab='') 'handle': member_profile.handle, 'avatar': member_profile.avatar_url } for member_profile in project.profiles.all()], - 'is_grant': grant_url + 'grant_link': project.grant_link }, 'hackathon_obj': hackathon_obj[0], 'hackathon': hackathon, diff --git a/app/grants/admin.py b/app/grants/admin.py index 25c67adc34d..c092c4b94b8 100644 --- a/app/grants/admin.py +++ b/app/grants/admin.py @@ -91,7 +91,7 @@ class GrantAdmin(GeneralAdmin): 'amount_received', 'monthly_amount_subscribed', 'deploy_tx_id', 'cancel_tx_id', 'admin_profile', 'token_symbol', 'token_address', 'contract_address', 'contract_version', 'network', 'required_gas_price', 'logo_svg_asset', - 'logo_asset', 'created_on', 'modified_on', 'team_member_list', 'project_link', + 'logo_asset', 'created_on', 'modified_on', 'team_member_list', 'subscriptions_links', 'contributions_links', 'logo', 'logo_svg', 'image_css', 'link', 'clr_prediction_curve', 'hidden', 'next_clr_calc_date', 'last_clr_calc_date', 'metadata', 'twitter_handle_1', 'twitter_handle_2', 'view_count', 'is_clr_eligible', 'in_active_clrs', diff --git a/app/grants/forms.py b/app/grants/forms.py index 0955d2ecceb..33c0426bbd0 100644 --- a/app/grants/forms.py +++ b/app/grants/forms.py @@ -33,5 +33,5 @@ class Meta: fields = ( 'title', 'description', 'reference_url', 'github_project_url', 'logo', 'logo_svg', 'admin_address', 'deploy_tx_id', 'cancel_tx_id', 'amount_received', 'token_address', 'contract_address', 'metadata', 'network', - 'required_gas_price', 'admin_profile', 'team_members', 'project_link' + 'required_gas_price', 'admin_profile', 'team_members' ) diff --git a/app/grants/migrations/0078_remove_grant_project_link.py b/app/grants/migrations/0078_remove_grant_project_link.py new file mode 100644 index 00000000000..c4f6680c23e --- /dev/null +++ b/app/grants/migrations/0078_remove_grant_project_link.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.4 on 2020-09-12 16:26 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('grants', '0077_grant_project_link'), + ] + + operations = [ + migrations.RemoveField( + model_name='grant', + name='project_link', + ), + ] diff --git a/app/grants/models.py b/app/grants/models.py index ba2bdaa1283..29169dc37f1 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -196,7 +196,6 @@ class Meta: reference_url = models.URLField(blank=True, help_text=_('The associated reference URL of the Grant.')) github_project_url = models.URLField(blank=True, help_text=_('Grant Github Project URL')) is_clr_eligible = models.BooleanField(default=True, help_text="Is grant eligible for CLR") - project_link = models.PositiveIntegerField(blank=True, null=True, help_text="Project Id which is converted to grant") link_to_new_grant = models.ForeignKey( 'grants.Grant', null=True, diff --git a/app/grants/templates/grants/new.html b/app/grants/templates/grants/new.html index 03410069780..edd79492f87 100644 --- a/app/grants/templates/grants/new.html +++ b/app/grants/templates/grants/new.html @@ -166,7 +166,7 @@
Funding Information
- + diff --git a/app/grants/views.py b/app/grants/views.py index b9122a42231..3e12eb1de4a 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1295,7 +1295,6 @@ def grant_new(request, project_id=None): 'network': request.POST.get('network', 'mainnet'), 'twitter_handle_1': request.POST.get('handle1', ''), 'twitter_handle_2': request.POST.get('handle2', ''), - 'project_link': request.POST.get('project_link', ''), 'metadata': receipt, 'last_update': timezone.now(), 'admin_profile': profile, @@ -1331,6 +1330,9 @@ def grant_new(request, project_id=None): new_grant(grant, profile) add_grant_to_active_clrs(grant) + if project_pk: + HackathonProject.objects.filter(pk=project_pk).update(grant_link=grant.url) + return JsonResponse({ 'success': True, 'url': grant.url, From 496c02dfc70fa610b23e31ee62ddf3ccb6baa87e Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sun, 13 Sep 2020 01:06:43 +0530 Subject: [PATCH 07/25] Add grant_link in serializer & grant-tag to card - grant_link in serializer - grant tag to project tag of hackathon projects view --- app/assets/v2/images/grants/grants-tag.svg | 7 +++++++ app/assets/v2/js/vue-components.js | 1 + app/dashboard/models.py | 1 + app/dashboard/router.py | 2 +- .../templates/dashboard/hackathon/project_page.html | 2 +- 5 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 app/assets/v2/images/grants/grants-tag.svg diff --git a/app/assets/v2/images/grants/grants-tag.svg b/app/assets/v2/images/grants/grants-tag.svg new file mode 100644 index 00000000000..036d4bfaafd --- /dev/null +++ b/app/assets/v2/images/grants/grants-tag.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/assets/v2/js/vue-components.js b/app/assets/v2/js/vue-components.js index 3eaa4f2c52c..4d69fc69c59 100644 --- a/app/assets/v2/js/vue-components.js +++ b/app/assets/v2/js/vue-components.js @@ -644,6 +644,7 @@ Vue.component('project-card', {
mark winner + grant_tag badge
winner
diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 50b70622957..df1d89df736 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -5183,6 +5183,7 @@ def to_json(self): 'paid': paid, 'payment_date': date(submission.accepted_on, 'Y-m-d H:i') if paid else '', 'winner': self.winner, + 'grant_link': self.grant_link, 'extra': self.extra, 'timestamp': submission.created_on.timestamp() if submission else 0 } diff --git a/app/dashboard/router.py b/app/dashboard/router.py index 074382c15cb..8c6be10a049 100644 --- a/app/dashboard/router.py +++ b/app/dashboard/router.py @@ -212,7 +212,7 @@ class HackathonProjectSerializer(serializers.ModelSerializer): class Meta: model = HackathonProject - fields = ('pk', 'chat_channel_id', 'status', 'badge', 'bounty', 'name', 'summary', 'work_url', 'profiles', 'hackathon', 'summary', 'logo', 'message', 'looking_members', 'winner', 'admin_url') + fields = ('pk', 'chat_channel_id', 'status', 'badge', 'bounty', 'name', 'summary', 'work_url', 'profiles', 'hackathon', 'summary', 'logo', 'message', 'looking_members', 'winner', "grant_link", 'admin_url') depth = 1 diff --git a/app/dashboard/templates/dashboard/hackathon/project_page.html b/app/dashboard/templates/dashboard/hackathon/project_page.html index 0851594cd00..c7a5d306501 100644 --- a/app/dashboard/templates/dashboard/hackathon/project_page.html +++ b/app/dashboard/templates/dashboard/hackathon/project_page.html @@ -78,7 +78,7 @@ {% if is_member %} {% if project_obj.grant_link is None %} - Triangles CONVERT TO GRANT + Create CONVERT TO GRANT {% endif %} {% endif %} From 2729ac07e5f886735de93c8edd67b76a23c7bbf3 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sun, 13 Sep 2020 01:48:44 +0530 Subject: [PATCH 08/25] Add: grants filter for projects tab for hackathon. - grant filter for hackathon projects. --- app/dashboard/router.py | 6 +++++- app/dashboard/templates/dashboard/index-vue.html | 3 +++ app/dashboard/views.py | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/dashboard/router.py b/app/dashboard/router.py index 8c6be10a049..20a3c5085a8 100644 --- a/app/dashboard/router.py +++ b/app/dashboard/router.py @@ -212,7 +212,7 @@ class HackathonProjectSerializer(serializers.ModelSerializer): class Meta: model = HackathonProject - fields = ('pk', 'chat_channel_id', 'status', 'badge', 'bounty', 'name', 'summary', 'work_url', 'profiles', 'hackathon', 'summary', 'logo', 'message', 'looking_members', 'winner', "grant_link", 'admin_url') + fields = ('pk', 'chat_channel_id', 'status', 'badge', 'bounty', 'name', 'summary', 'work_url', 'profiles', 'hackathon', 'summary', 'logo', 'message', 'looking_members', 'winner', 'grant_link', 'admin_url') depth = 1 @@ -293,6 +293,10 @@ def get_queryset(self): queryset = queryset.filter( Q(winner=True) ) + if 'grants' in filters: + queryset = queryset.filter( + Q(grant_link__isnull=False) + ) if 'lfm' in filters: queryset = queryset.filter( Q(looking_members=True) diff --git a/app/dashboard/templates/dashboard/index-vue.html b/app/dashboard/templates/dashboard/index-vue.html index 9e505c70808..803ff91d0f8 100644 --- a/app/dashboard/templates/dashboard/index-vue.html +++ b/app/dashboard/templates/dashboard/index-vue.html @@ -279,6 +279,9 @@

Hackathon Coming Soon!

Looking for Members + + Grants +
diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 1382e689371..985ab03058b 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -4318,6 +4318,12 @@ def hackathon_projects(request, hackathon='', specify_project=''): projects = projects.filter( Q(badge__isnull=False) ) + + if filters == 'grants': + projects = projects.filter( + Q(grant_link__isnull=False) + ) + if specify_project: projects = projects.filter(name__iexact=specify_project.replace('-', ' ')) if projects.exists(): From 60c7d2f1f3127336ed6096751dab1fab6bfaeb08 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sun, 13 Sep 2020 01:56:38 +0530 Subject: [PATCH 09/25] Add: ordering of project based on grants ordering of projects - winners, grants, created_on, id --- app/dashboard/router.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/dashboard/router.py b/app/dashboard/router.py index 20a3c5085a8..1afa3e32c23 100644 --- a/app/dashboard/router.py +++ b/app/dashboard/router.py @@ -252,7 +252,7 @@ def get_queryset(self): hackathon_event = HackathonEvent.objects.last() queryset = HackathonProject.objects.filter(hackathon=hackathon_event).exclude( - status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', order_by, 'id') + status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', 'grant_link', order_by, 'id') if sponsor: queryset = queryset.filter( @@ -261,7 +261,7 @@ def get_queryset(self): elif sponsor: queryset = HackathonProject.objects.filter(Q(hackathon__sponsor_profiles__handle__iexact=sponsor) | Q( bounty__bounty_owner_github_username=sponsor)).exclude( - status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', order_by, 'id') + status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', 'grant_link', order_by, 'id') projects = [] for project in queryset: From 29f7ea5c6919c81225166134feda2d937fc80ef7 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sun, 13 Sep 2020 13:07:21 +0530 Subject: [PATCH 10/25] Add replace winner ribbon with tag - winner ribbon conflicting with grant tag. - fetch project_pk --- app/assets/v2/images/project/winner.svg | 17 +++++++++++++++++ app/assets/v2/js/vue-components.js | 4 ++-- app/grants/templates/grants/new.html | 1 + app/grants/views.py | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 app/assets/v2/images/project/winner.svg diff --git a/app/assets/v2/images/project/winner.svg b/app/assets/v2/images/project/winner.svg new file mode 100644 index 00000000000..f3d6dcb3fd7 --- /dev/null +++ b/app/assets/v2/images/project/winner.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/app/assets/v2/js/vue-components.js b/app/assets/v2/js/vue-components.js index 4d69fc69c59..fb6a0f1354d 100644 --- a/app/assets/v2/js/vue-components.js +++ b/app/assets/v2/js/vue-components.js @@ -643,11 +643,11 @@ Vue.component('project-card', { template: `
mark winner - + grant_tag + winner badge
-
winner
diff --git a/app/grants/templates/grants/new.html b/app/grants/templates/grants/new.html index edd79492f87..d057340af2f 100644 --- a/app/grants/templates/grants/new.html +++ b/app/grants/templates/grants/new.html @@ -83,6 +83,7 @@
Project Information
+
diff --git a/app/grants/views.py b/app/grants/views.py index 3e12eb1de4a..c6f53144cda 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1330,6 +1330,7 @@ def grant_new(request, project_id=None): new_grant(grant, profile) add_grant_to_active_clrs(grant) + project_pk = request.POST.get('project_pk', '') if project_pk: HackathonProject.objects.filter(pk=project_pk).update(grant_link=grant.url) From 85d7c4447b5e581d71dd790f79f38170be2ef436 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sun, 13 Sep 2020 13:22:56 +0530 Subject: [PATCH 11/25] chg: project-card with winner & grant tag for tribe --- .../templates/profiles/tribes-vue.html | 53 +------------------ 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/app/dashboard/templates/profiles/tribes-vue.html b/app/dashboard/templates/profiles/tribes-vue.html index 29d32d62014..9e74cd00b04 100644 --- a/app/dashboard/templates/profiles/tribes-vue.html +++ b/app/dashboard/templates/profiles/tribes-vue.html @@ -549,58 +549,7 @@
-
-
- badge - -
- - -
-
-
[[ project.name ]]
-
-

- [[ project.summary | truncate(500) ]] -

-
- View Project - View Bounty - - - - @ [[ profile.handle ]] - - -
-
- -
- Team Members -
- - - -
-
- -
-
Looking for team members
-

- [[ project.message ]] -

-
- -
- Sponsored by - - [[ project.bounty.org_name ]] -
-
-
-
+
From 420e31c7b178b7ba67bc96564f4b8f5f6699618a Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sun, 13 Sep 2020 13:39:22 +0530 Subject: [PATCH 12/25] Add: grant & winner filter in tribe --- app/dashboard/templates/dashboard/index-vue.html | 2 -- app/dashboard/templates/profiles/tribes-vue.html | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/dashboard/templates/dashboard/index-vue.html b/app/dashboard/templates/dashboard/index-vue.html index 803ff91d0f8..3401ea9a220 100644 --- a/app/dashboard/templates/dashboard/index-vue.html +++ b/app/dashboard/templates/dashboard/index-vue.html @@ -302,8 +302,6 @@

Hackathon Coming Soon!

- -

[[ numProjects ]] projects found diff --git a/app/dashboard/templates/profiles/tribes-vue.html b/app/dashboard/templates/profiles/tribes-vue.html index 9e74cd00b04..1c692a2ed4e 100644 --- a/app/dashboard/templates/profiles/tribes-vue.html +++ b/app/dashboard/templates/profiles/tribes-vue.html @@ -518,6 +518,14 @@ [[ numProjects ]] projects found

+
+ + Winners + + + Grants + +
From 57e3d5d36cb7060f04281955296ee1ad8d6029e2 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sun, 13 Sep 2020 14:00:23 +0530 Subject: [PATCH 13/25] build fix --- app/dashboard/views.py | 2 +- app/grants/views.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 985ab03058b..046e2512a4d 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -86,6 +86,7 @@ from git.utils import ( get_auth_url, get_gh_issue_details, get_github_user_data, get_url_dict, is_github_token_valid, search_users, ) +from grants.models import Grant from kudos.models import KudosTransfer, Token, Wallet from kudos.utils import humanize_name from mailchimp3 import MailChimp @@ -122,7 +123,6 @@ ProfileSerializer, ProfileVerification, ProfileView, Question, SearchHistory, Sponsor, Subscription, Tool, ToolVote, TribeMember, UserAction, UserDirectory, UserVerificationModel, ) -from grants.models import Grant from .notifications import ( maybe_market_tip_to_email, maybe_market_tip_to_github, maybe_market_tip_to_slack, maybe_market_to_email, maybe_market_to_github, maybe_market_to_slack, maybe_market_to_user_slack, diff --git a/app/grants/views.py b/app/grants/views.py index c6f53144cda..ab104c81e12 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -58,10 +58,10 @@ from bs4 import BeautifulSoup from cacheops import cached_view from chartit import PivotChart, PivotDataPool -from dashboard.models import Activity, Profile, SearchHistory, HackathonProject -from dashboard.views import project +from dashboard.models import Activity, HackathonProject, Profile, SearchHistory from dashboard.tasks import increment_view_count from dashboard.utils import get_web3, has_tx_mined +from dashboard.views import project from economy.models import Token as FTokens from economy.utils import convert_amount from gas.utils import conf_time_spread, eth_usd_conv_rate, gas_advisories, recommend_min_gas_price_to_confirm_in_time From 143c4c59f9097b93abfc5eaa25e378765575af1d Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sun, 13 Sep 2020 17:35:03 +0530 Subject: [PATCH 14/25] chg: temp solution to update HackathonProject data - After making change to grant_link - API call to DB doesn't fetch the updates - if queried with filter then updated data is fetched only --- app/dashboard/router.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/dashboard/router.py b/app/dashboard/router.py index 1afa3e32c23..d9375d19253 100644 --- a/app/dashboard/router.py +++ b/app/dashboard/router.py @@ -262,6 +262,12 @@ def get_queryset(self): queryset = HackathonProject.objects.filter(Q(hackathon__sponsor_profiles__handle__iexact=sponsor) | Q( bounty__bounty_owner_github_username=sponsor)).exclude( status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', 'grant_link', order_by, 'id') + + # TODO Temp Solution to update grant_link after updating grant + queryset = queryset.filter( + Q(grant_link__isnull=False) | + Q(grant_link__isnull=True) + ) projects = [] for project in queryset: @@ -283,7 +289,6 @@ def get_queryset(self): queryset = queryset.filter( Q(profiles__keywords__icontains=skills) ) - if rating: queryset = queryset.filter( Q(rating__gte=rating) From d567c3bbca426d09c99631b7e3671363a00d0538 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Sun, 13 Sep 2020 20:43:15 +0530 Subject: [PATCH 15/25] chg: grant link field change from url to char. - revert the changes done in last commit --- .../migrations/0150_auto_20200913_1437.py | 18 ++++++++++++++++++ app/dashboard/models.py | 3 ++- app/dashboard/router.py | 6 ------ 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 app/dashboard/migrations/0150_auto_20200913_1437.py diff --git a/app/dashboard/migrations/0150_auto_20200913_1437.py b/app/dashboard/migrations/0150_auto_20200913_1437.py new file mode 100644 index 00000000000..3fcd688b96d --- /dev/null +++ b/app/dashboard/migrations/0150_auto_20200913_1437.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.4 on 2020-09-13 14:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0149_hackathonproject_grant_link'), + ] + + operations = [ + migrations.AlterField( + model_name='hackathonproject', + name='grant_link', + field=models.CharField(blank=True, db_index=True, help_text='Grant Link', max_length=255, null=True), + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index df1d89df736..9b6f85ea278 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -5120,10 +5120,11 @@ class HackathonProject(SuperModel): chat_channel_id = models.CharField(max_length=255, blank=True, null=True) winner = models.BooleanField(default=False) extra = JSONField(default=dict, blank=True, null=True) - grant_link = models.URLField( + grant_link = models.CharField( blank=True, null=True, db_index=True, + max_length=255, help_text='Grant Link' ) diff --git a/app/dashboard/router.py b/app/dashboard/router.py index d9375d19253..1dd925ad504 100644 --- a/app/dashboard/router.py +++ b/app/dashboard/router.py @@ -262,12 +262,6 @@ def get_queryset(self): queryset = HackathonProject.objects.filter(Q(hackathon__sponsor_profiles__handle__iexact=sponsor) | Q( bounty__bounty_owner_github_username=sponsor)).exclude( status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', 'grant_link', order_by, 'id') - - # TODO Temp Solution to update grant_link after updating grant - queryset = queryset.filter( - Q(grant_link__isnull=False) | - Q(grant_link__isnull=True) - ) projects = [] for project in queryset: From 2998638c5651560c1cd3a3c02b9e9e4ced2a8ea5 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Mon, 14 Sep 2020 15:43:45 +0530 Subject: [PATCH 16/25] fix: requested changes - change the styling close to the design - rmv the unwanted logic --- app/assets/v2/images/grants/grants-logo-2.svg | 5 +++++ .../templates/dashboard/hackathon/project_page.html | 6 +++--- app/grants/views.py | 4 +--- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 app/assets/v2/images/grants/grants-logo-2.svg diff --git a/app/assets/v2/images/grants/grants-logo-2.svg b/app/assets/v2/images/grants/grants-logo-2.svg new file mode 100644 index 00000000000..11bc380763a --- /dev/null +++ b/app/assets/v2/images/grants/grants-logo-2.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/app/dashboard/templates/dashboard/hackathon/project_page.html b/app/dashboard/templates/dashboard/hackathon/project_page.html index c7a5d306501..2149d738784 100644 --- a/app/dashboard/templates/dashboard/hackathon/project_page.html +++ b/app/dashboard/templates/dashboard/hackathon/project_page.html @@ -70,15 +70,15 @@ {% if project_obj.grant_link %} {% if is_member %} - Triangles EDIT GRANT + Triangles EDIT GRANT {% else %} - Triangles DONATE TO GRANT + Triangles DONATE TO GRANT {% endif %} {% endif %} {% if is_member %} {% if project_obj.grant_link is None %} - Create CONVERT TO GRANT + Create CONVERT TO GRANT {% endif %} {% endif %} diff --git a/app/grants/views.py b/app/grants/views.py index ab104c81e12..a047b94a182 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1361,10 +1361,8 @@ def grant_new(request, project_id=None): 'gas_advisories': gas_advisories(), 'trusted_relayer': settings.GRANTS_OWNER_ACCOUNT, 'grant_types': GrantType.objects.all(), - 'data': {} + 'data': project_data } - if check_profile is not None: - params["data"] = project_data return TemplateResponse(request, 'grants/new.html', params) From 8f7213264ba3c4983a8948dbe2e6146173b2a4ff Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Mon, 14 Sep 2020 17:50:33 +0530 Subject: [PATCH 17/25] chg: winner tag with the ribbon used prior - padding change for ribbon tag to make it smaller - change the position of grant tag to left --- app/assets/v2/css/dashboard-vue-hackathon.css | 2 +- app/assets/v2/images/project/winner.svg | 17 ----------------- app/assets/v2/js/vue-components.js | 4 ++-- 3 files changed, 3 insertions(+), 20 deletions(-) delete mode 100644 app/assets/v2/images/project/winner.svg diff --git a/app/assets/v2/css/dashboard-vue-hackathon.css b/app/assets/v2/css/dashboard-vue-hackathon.css index 1ed0c6273e7..da09e0b6915 100644 --- a/app/assets/v2/css/dashboard-vue-hackathon.css +++ b/app/assets/v2/css/dashboard-vue-hackathon.css @@ -18,7 +18,7 @@ position: absolute; display: block; width: 225px; - padding: 15px 0; + padding: 8px 0; background-color: #25E899; box-shadow: 0 5px 10px rgba(0, 0, 0, .1); color: #000; diff --git a/app/assets/v2/images/project/winner.svg b/app/assets/v2/images/project/winner.svg deleted file mode 100644 index f3d6dcb3fd7..00000000000 --- a/app/assets/v2/images/project/winner.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/app/assets/v2/js/vue-components.js b/app/assets/v2/js/vue-components.js index fb6a0f1354d..db715a2a570 100644 --- a/app/assets/v2/js/vue-components.js +++ b/app/assets/v2/js/vue-components.js @@ -644,10 +644,10 @@ Vue.component('project-card', {
mark winner - grant_tag - winner + grant_tag badge
+
winner
From b1f5ba71aff44cb4af8c5eb4fab984cca8b69e2b Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Mon, 21 Sep 2020 21:46:10 +0530 Subject: [PATCH 18/25] chg: grant_link from char to foriegn key grant --- .../migrations/0151_auto_20200921_1510.py | 19 +++++++++++++++++++ app/dashboard/models.py | 9 ++++----- .../dashboard/hackathon/project_page.html | 8 ++++---- app/dashboard/views.py | 2 +- app/grants/views.py | 2 +- 5 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 app/dashboard/migrations/0151_auto_20200921_1510.py diff --git a/app/dashboard/migrations/0151_auto_20200921_1510.py b/app/dashboard/migrations/0151_auto_20200921_1510.py new file mode 100644 index 00000000000..4e85befd507 --- /dev/null +++ b/app/dashboard/migrations/0151_auto_20200921_1510.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.4 on 2020-09-21 15:10 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0150_auto_20200913_1437'), + ] + + operations = [ + migrations.AlterField( + model_name='hackathonproject', + name='grant_link', + field=models.ForeignKey(help_text='Link to grant if project is converted to grant', null=True, on_delete=django.db.models.deletion.SET_NULL, to='grants.Grant'), + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 9b6f85ea278..e2a55c6bbd7 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -5120,12 +5120,11 @@ class HackathonProject(SuperModel): chat_channel_id = models.CharField(max_length=255, blank=True, null=True) winner = models.BooleanField(default=False) extra = JSONField(default=dict, blank=True, null=True) - grant_link = models.CharField( - blank=True, + grant_link = models.ForeignKey( + 'grants.Grant', null=True, - db_index=True, - max_length=255, - help_text='Grant Link' + on_delete=models.SET_NULL, + help_text=_('Link to grant if project is converted to grant') ) class Meta: diff --git a/app/dashboard/templates/dashboard/hackathon/project_page.html b/app/dashboard/templates/dashboard/hackathon/project_page.html index 2149d738784..0cb64816593 100644 --- a/app/dashboard/templates/dashboard/hackathon/project_page.html +++ b/app/dashboard/templates/dashboard/hackathon/project_page.html @@ -68,16 +68,16 @@
- {% if project_obj.grant_link %} + {% if project_obj.grant_url %} {% if is_member %} - Triangles EDIT GRANT + Triangles EDIT GRANT {% else %} - Triangles DONATE TO GRANT + Triangles DONATE TO GRANT {% endif %} {% endif %} {% if is_member %} - {% if project_obj.grant_link is None %} + {% if project_obj.grant_url is None %} Create CONVERT TO GRANT {% endif %} diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 046e2512a4d..e163f16140c 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -4589,7 +4589,7 @@ def hackathon_project_page(request, hackathon, project_id, project_name, tab='') 'handle': member_profile.handle, 'avatar': member_profile.avatar_url } for member_profile in project.profiles.all()], - 'grant_link': project.grant_link + 'grant_url': project.grant_link.url }, 'hackathon_obj': hackathon_obj[0], 'hackathon': hackathon, diff --git a/app/grants/views.py b/app/grants/views.py index a047b94a182..282b9c6eda3 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1332,7 +1332,7 @@ def grant_new(request, project_id=None): project_pk = request.POST.get('project_pk', '') if project_pk: - HackathonProject.objects.filter(pk=project_pk).update(grant_link=grant.url) + HackathonProject.objects.filter(pk=project_pk).update(grant_link=grant) return JsonResponse({ 'success': True, From a8a1fea511ee264fddac1312d81ad92b40547105 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Tue, 29 Sep 2020 21:52:40 +0530 Subject: [PATCH 19/25] fix: requested changes --- .../templates/dashboard/hackathon/project_page.html | 8 ++------ app/dashboard/views.py | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/dashboard/templates/dashboard/hackathon/project_page.html b/app/dashboard/templates/dashboard/hackathon/project_page.html index 0cb64816593..438681966fe 100644 --- a/app/dashboard/templates/dashboard/hackathon/project_page.html +++ b/app/dashboard/templates/dashboard/hackathon/project_page.html @@ -69,15 +69,11 @@
{% if project_obj.grant_url %} - {% if is_member %} - Triangles EDIT GRANT - {% else %} - Triangles DONATE TO GRANT - {% endif %} + Triangles {% if is_member %} EDIT GRANT {% else %} DONATE TO GRANT {% endif %} {% endif %} {% if is_member %} - {% if project_obj.grant_url is None %} + {% if not project_obj.grant_url %} Create CONVERT TO GRANT {% endif %} diff --git a/app/dashboard/views.py b/app/dashboard/views.py index e163f16140c..19299d3a32a 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -4589,7 +4589,7 @@ def hackathon_project_page(request, hackathon, project_id, project_name, tab='') 'handle': member_profile.handle, 'avatar': member_profile.avatar_url } for member_profile in project.profiles.all()], - 'grant_url': project.grant_link.url + 'grant_url': project.grant_link.url if project.grant_link else False }, 'hackathon_obj': hackathon_obj[0], 'hackathon': hackathon, From 47b6fa7e6f067ff5192239246660a64fa76b95d4 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Tue, 29 Sep 2020 23:12:39 +0530 Subject: [PATCH 20/25] fix: squash migrations --- ...t_link_squashed_0151_auto_20200921_1510.py | 21 +++++++++++++++++++ .../migrations/0077_grant_project_link.py | 18 ---------------- .../0078_remove_grant_project_link.py | 17 --------------- 3 files changed, 21 insertions(+), 35 deletions(-) create mode 100644 app/dashboard/migrations/0149_hackathonproject_grant_link_squashed_0151_auto_20200921_1510.py delete mode 100644 app/grants/migrations/0077_grant_project_link.py delete mode 100644 app/grants/migrations/0078_remove_grant_project_link.py diff --git a/app/dashboard/migrations/0149_hackathonproject_grant_link_squashed_0151_auto_20200921_1510.py b/app/dashboard/migrations/0149_hackathonproject_grant_link_squashed_0151_auto_20200921_1510.py new file mode 100644 index 00000000000..3b8d5495b3b --- /dev/null +++ b/app/dashboard/migrations/0149_hackathonproject_grant_link_squashed_0151_auto_20200921_1510.py @@ -0,0 +1,21 @@ +# Generated by Django 2.2.4 on 2020-09-29 17:41 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + replaces = [('dashboard', '0149_hackathonproject_grant_link'), ('dashboard', '0150_auto_20200913_1437'), ('dashboard', '0151_auto_20200921_1510')] + + dependencies = [ + ('dashboard', '0148_add_brightid_status'), + ] + + operations = [ + migrations.AddField( + model_name='hackathonproject', + name='grant_link', + field=models.ForeignKey(help_text='Link to grant if project is converted to grant', null=True, on_delete=django.db.models.deletion.SET_NULL, to='grants.Grant'), + ), + ] diff --git a/app/grants/migrations/0077_grant_project_link.py b/app/grants/migrations/0077_grant_project_link.py deleted file mode 100644 index 788f3dab25d..00000000000 --- a/app/grants/migrations/0077_grant_project_link.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.4 on 2020-09-11 16:23 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('grants', '0076_matchpledge_data'), - ] - - operations = [ - migrations.AddField( - model_name='grant', - name='project_link', - field=models.PositiveIntegerField(blank=True, help_text='Project Id which is converted to grant', null=True), - ), - ] diff --git a/app/grants/migrations/0078_remove_grant_project_link.py b/app/grants/migrations/0078_remove_grant_project_link.py deleted file mode 100644 index c4f6680c23e..00000000000 --- a/app/grants/migrations/0078_remove_grant_project_link.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 2.2.4 on 2020-09-12 16:26 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('grants', '0077_grant_project_link'), - ] - - operations = [ - migrations.RemoveField( - model_name='grant', - name='project_link', - ), - ] From 6db437126eb15b042d6851ccdb519cd4c502d000 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Wed, 30 Sep 2020 00:31:09 +0530 Subject: [PATCH 21/25] fix: requested changes --- app/assets/v2/js/grants/new.js | 2 +- app/dashboard/templates/dashboard/hackathon/project_page.html | 2 +- app/grants/urls.py | 2 +- app/grants/views.py | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/assets/v2/js/grants/new.js b/app/assets/v2/js/grants/new.js index 23d8ebb541d..a6ccbac6ee9 100644 --- a/app/assets/v2/js/grants/new.js +++ b/app/assets/v2/js/grants/new.js @@ -207,7 +207,7 @@ function saveGrant(grantData, isFinal) { $.ajax({ type: 'post', - url: '/grants/new/', + url: '/grants/new', processData: false, contentType: false, data: grantData, diff --git a/app/dashboard/templates/dashboard/hackathon/project_page.html b/app/dashboard/templates/dashboard/hackathon/project_page.html index 438681966fe..08cca7a9605 100644 --- a/app/dashboard/templates/dashboard/hackathon/project_page.html +++ b/app/dashboard/templates/dashboard/hackathon/project_page.html @@ -74,7 +74,7 @@ {% if is_member %} {% if not project_obj.grant_url %} - Create CONVERT TO GRANT + Create CREATE GRANT {% endif %} {% endif %} diff --git a/app/grants/urls.py b/app/grants/urls.py index 168f5bc4cbd..8747966f57e 100644 --- a/app/grants/urls.py +++ b/app/grants/urls.py @@ -44,7 +44,7 @@ path('/', grant_details, name='details'), path('//', grant_details, name='details2'), re_path(r'^matic/new', grant_new_whitelabel, name='new_whitelabel'), - re_path(r'^new/(?:(?P\d+)/)?$', grant_new, name='new'), + re_path(r'^new/?$', grant_new, name='new'), re_path(r'^categories', grant_categories, name='grant_categories'), path('//fund', grant_fund, name='fund'), path('bulk-fund', bulk_fund, name='bulk_fund'), diff --git a/app/grants/views.py b/app/grants/views.py index 282b9c6eda3..06b8386c8a4 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1266,7 +1266,7 @@ def grant_new_whitelabel(request): @login_required -def grant_new(request, project_id=None): +def grant_new(request): """Handle new grant.""" from grants.utils import add_grant_to_active_clrs @@ -1341,6 +1341,7 @@ def grant_new(request, project_id=None): check_profile = None project_data = None + project_id = request.GET.get('project_id', None) if project_id is not None: check_profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None project_data = project(project_id) From 036db4d375860e255239f22e8d100811b695eddd Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Thu, 1 Oct 2020 05:39:12 +0530 Subject: [PATCH 22/25] fix: fix indent & squash migrations. --- .../0149_hackathonproject_grant_link.py | 6 ++++-- ...t_link_squashed_0151_auto_20200921_1510.py | 21 ------------------- .../migrations/0150_auto_20200913_1437.py | 18 ---------------- .../migrations/0151_auto_20200921_1510.py | 19 ----------------- app/dashboard/models.py | 1 + app/grants/templates/grants/new.html | 2 +- 6 files changed, 6 insertions(+), 61 deletions(-) delete mode 100644 app/dashboard/migrations/0149_hackathonproject_grant_link_squashed_0151_auto_20200921_1510.py delete mode 100644 app/dashboard/migrations/0150_auto_20200913_1437.py delete mode 100644 app/dashboard/migrations/0151_auto_20200921_1510.py diff --git a/app/dashboard/migrations/0149_hackathonproject_grant_link.py b/app/dashboard/migrations/0149_hackathonproject_grant_link.py index d956be49ed5..532f41a675d 100644 --- a/app/dashboard/migrations/0149_hackathonproject_grant_link.py +++ b/app/dashboard/migrations/0149_hackathonproject_grant_link.py @@ -1,11 +1,13 @@ -# Generated by Django 2.2.4 on 2020-09-12 16:26 +# Generated by Django 2.2.4 on 2020-09-30 23:58 from django.db import migrations, models +import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ + ('grants', '0076_matchpledge_data'), ('dashboard', '0148_add_brightid_status'), ] @@ -13,6 +15,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='hackathonproject', name='grant_link', - field=models.URLField(blank=True, db_index=True, help_text='Grant Link', null=True), + field=models.ForeignKey(blank=True, help_text='Link to grant if project is converted to grant', null=True, on_delete=django.db.models.deletion.SET_NULL, to='grants.Grant'), ), ] diff --git a/app/dashboard/migrations/0149_hackathonproject_grant_link_squashed_0151_auto_20200921_1510.py b/app/dashboard/migrations/0149_hackathonproject_grant_link_squashed_0151_auto_20200921_1510.py deleted file mode 100644 index 3b8d5495b3b..00000000000 --- a/app/dashboard/migrations/0149_hackathonproject_grant_link_squashed_0151_auto_20200921_1510.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by Django 2.2.4 on 2020-09-29 17:41 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - replaces = [('dashboard', '0149_hackathonproject_grant_link'), ('dashboard', '0150_auto_20200913_1437'), ('dashboard', '0151_auto_20200921_1510')] - - dependencies = [ - ('dashboard', '0148_add_brightid_status'), - ] - - operations = [ - migrations.AddField( - model_name='hackathonproject', - name='grant_link', - field=models.ForeignKey(help_text='Link to grant if project is converted to grant', null=True, on_delete=django.db.models.deletion.SET_NULL, to='grants.Grant'), - ), - ] diff --git a/app/dashboard/migrations/0150_auto_20200913_1437.py b/app/dashboard/migrations/0150_auto_20200913_1437.py deleted file mode 100644 index 3fcd688b96d..00000000000 --- a/app/dashboard/migrations/0150_auto_20200913_1437.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.4 on 2020-09-13 14:37 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('dashboard', '0149_hackathonproject_grant_link'), - ] - - operations = [ - migrations.AlterField( - model_name='hackathonproject', - name='grant_link', - field=models.CharField(blank=True, db_index=True, help_text='Grant Link', max_length=255, null=True), - ), - ] diff --git a/app/dashboard/migrations/0151_auto_20200921_1510.py b/app/dashboard/migrations/0151_auto_20200921_1510.py deleted file mode 100644 index 4e85befd507..00000000000 --- a/app/dashboard/migrations/0151_auto_20200921_1510.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 2.2.4 on 2020-09-21 15:10 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('dashboard', '0150_auto_20200913_1437'), - ] - - operations = [ - migrations.AlterField( - model_name='hackathonproject', - name='grant_link', - field=models.ForeignKey(help_text='Link to grant if project is converted to grant', null=True, on_delete=django.db.models.deletion.SET_NULL, to='grants.Grant'), - ), - ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index e2a55c6bbd7..cc45eed0cfe 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -5123,6 +5123,7 @@ class HackathonProject(SuperModel): grant_link = models.ForeignKey( 'grants.Grant', null=True, + blank=True, on_delete=models.SET_NULL, help_text=_('Link to grant if project is converted to grant') ) diff --git a/app/grants/templates/grants/new.html b/app/grants/templates/grants/new.html index d057340af2f..418e0493812 100644 --- a/app/grants/templates/grants/new.html +++ b/app/grants/templates/grants/new.html @@ -96,7 +96,7 @@
Project Information
From e384bc97dfd97c9748d0d47e65b7f80cfce8dba1 Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Wed, 7 Oct 2020 19:12:41 +0530 Subject: [PATCH 23/25] fix: migration file. --- app/assets/v2/js/vue-components.js | 2 +- app/dashboard/admin.py | 2 +- ...t_grant_link.py => 0154_hackathonproject_grant_obj.py} | 8 ++++---- app/dashboard/models.py | 4 ++-- app/dashboard/router.py | 8 ++++---- app/dashboard/views.py | 4 ++-- app/grants/views.py | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) rename app/dashboard/migrations/{0149_hackathonproject_grant_link.py => 0154_hackathonproject_grant_obj.py} (70%) diff --git a/app/assets/v2/js/vue-components.js b/app/assets/v2/js/vue-components.js index db715a2a570..7f79d17e5c8 100644 --- a/app/assets/v2/js/vue-components.js +++ b/app/assets/v2/js/vue-components.js @@ -644,7 +644,7 @@ Vue.component('project-card', {
mark winner - grant_tag + grant_tag badge
winner
diff --git a/app/dashboard/admin.py b/app/dashboard/admin.py index 3d187d30c12..83b2187d5b6 100644 --- a/app/dashboard/admin.py +++ b/app/dashboard/admin.py @@ -454,7 +454,7 @@ class HackathonRegistrationAdmin(admin.ModelAdmin): class HackathonProjectAdmin(admin.ModelAdmin): - list_display = ['pk', 'img', 'name', 'bounty', 'hackathon_link', 'grant_link', 'usernames', 'status', 'sponsor'] + list_display = ['pk', 'img', 'name', 'bounty', 'hackathon_link', 'grant_obj', 'usernames', 'status', 'sponsor'] raw_id_fields = ['profiles', 'bounty', 'hackathon'] search_fields = ['name', 'summary', 'status'] diff --git a/app/dashboard/migrations/0149_hackathonproject_grant_link.py b/app/dashboard/migrations/0154_hackathonproject_grant_obj.py similarity index 70% rename from app/dashboard/migrations/0149_hackathonproject_grant_link.py rename to app/dashboard/migrations/0154_hackathonproject_grant_obj.py index 532f41a675d..836c697e995 100644 --- a/app/dashboard/migrations/0149_hackathonproject_grant_link.py +++ b/app/dashboard/migrations/0154_hackathonproject_grant_obj.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.4 on 2020-09-30 23:58 +# Generated by Django 2.2.4 on 2020-10-07 13:20 from django.db import migrations, models import django.db.models.deletion @@ -7,14 +7,14 @@ class Migration(migrations.Migration): dependencies = [ - ('grants', '0076_matchpledge_data'), - ('dashboard', '0148_add_brightid_status'), + ('grants', '0088_auto_20200924_1536'), + ('dashboard', '0153_hackathonevent_use_circle'), ] operations = [ migrations.AddField( model_name='hackathonproject', - name='grant_link', + name='grant_obj', field=models.ForeignKey(blank=True, help_text='Link to grant if project is converted to grant', null=True, on_delete=django.db.models.deletion.SET_NULL, to='grants.Grant'), ), ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index cc45eed0cfe..683881534cc 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -5120,7 +5120,7 @@ class HackathonProject(SuperModel): chat_channel_id = models.CharField(max_length=255, blank=True, null=True) winner = models.BooleanField(default=False) extra = JSONField(default=dict, blank=True, null=True) - grant_link = models.ForeignKey( + grant_obj = models.ForeignKey( 'grants.Grant', null=True, blank=True, @@ -5184,7 +5184,7 @@ def to_json(self): 'paid': paid, 'payment_date': date(submission.accepted_on, 'Y-m-d H:i') if paid else '', 'winner': self.winner, - 'grant_link': self.grant_link, + 'grant_obj': self.grant_obj, 'extra': self.extra, 'timestamp': submission.created_on.timestamp() if submission else 0 } diff --git a/app/dashboard/router.py b/app/dashboard/router.py index 1dd925ad504..563ef57970e 100644 --- a/app/dashboard/router.py +++ b/app/dashboard/router.py @@ -212,7 +212,7 @@ class HackathonProjectSerializer(serializers.ModelSerializer): class Meta: model = HackathonProject - fields = ('pk', 'chat_channel_id', 'status', 'badge', 'bounty', 'name', 'summary', 'work_url', 'profiles', 'hackathon', 'summary', 'logo', 'message', 'looking_members', 'winner', 'grant_link', 'admin_url') + fields = ('pk', 'chat_channel_id', 'status', 'badge', 'bounty', 'name', 'summary', 'work_url', 'profiles', 'hackathon', 'summary', 'logo', 'message', 'looking_members', 'winner', 'grant_obj', 'admin_url') depth = 1 @@ -252,7 +252,7 @@ def get_queryset(self): hackathon_event = HackathonEvent.objects.last() queryset = HackathonProject.objects.filter(hackathon=hackathon_event).exclude( - status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', 'grant_link', order_by, 'id') + status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', 'grant_obj', order_by, 'id') if sponsor: queryset = queryset.filter( @@ -261,7 +261,7 @@ def get_queryset(self): elif sponsor: queryset = HackathonProject.objects.filter(Q(hackathon__sponsor_profiles__handle__iexact=sponsor) | Q( bounty__bounty_owner_github_username=sponsor)).exclude( - status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', 'grant_link', order_by, 'id') + status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', 'grant_obj', order_by, 'id') projects = [] for project in queryset: @@ -294,7 +294,7 @@ def get_queryset(self): ) if 'grants' in filters: queryset = queryset.filter( - Q(grant_link__isnull=False) + Q(grant_obj__isnull=False) ) if 'lfm' in filters: queryset = queryset.filter( diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 19299d3a32a..a1d22171f23 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -4321,7 +4321,7 @@ def hackathon_projects(request, hackathon='', specify_project=''): if filters == 'grants': projects = projects.filter( - Q(grant_link__isnull=False) + Q(grant_obj__isnull=False) ) if specify_project: @@ -4589,7 +4589,7 @@ def hackathon_project_page(request, hackathon, project_id, project_name, tab='') 'handle': member_profile.handle, 'avatar': member_profile.avatar_url } for member_profile in project.profiles.all()], - 'grant_url': project.grant_link.url if project.grant_link else False + 'grant_url': project.grant_obj.url if project.grant_obj else False }, 'hackathon_obj': hackathon_obj[0], 'hackathon': hackathon, diff --git a/app/grants/views.py b/app/grants/views.py index 06b8386c8a4..3bb7bf62dee 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1332,7 +1332,7 @@ def grant_new(request): project_pk = request.POST.get('project_pk', '') if project_pk: - HackathonProject.objects.filter(pk=project_pk).update(grant_link=grant) + HackathonProject.objects.filter(pk=project_pk).update(grant_obj=grant) return JsonResponse({ 'success': True, From ac98c7508b3722a4248d001f9d3719f8ac941dac Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Fri, 9 Oct 2020 17:37:47 +0530 Subject: [PATCH 24/25] fix: indentation --- .../dashboard/hackathon/project_page.html | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/dashboard/templates/dashboard/hackathon/project_page.html b/app/dashboard/templates/dashboard/hackathon/project_page.html index 08cca7a9605..18efce8a9b4 100644 --- a/app/dashboard/templates/dashboard/hackathon/project_page.html +++ b/app/dashboard/templates/dashboard/hackathon/project_page.html @@ -64,27 +64,26 @@ {% trans "View Admin" %}
{% endif %} -
+
- - {% if project_obj.grant_url %} + {% if project_obj.grant_url %} Triangles {% if is_member %} EDIT GRANT {% else %} DONATE TO GRANT {% endif %} - {% endif %} + {% endif %} - {% if is_member %} - {% if not project_obj.grant_url %} - Create CREATE GRANT + {% if is_member %} + {% if not project_obj.grant_url %} + Create CREATE GRANT + {% endif %} + {% endif %} - - {% endif %}
{% include 'project/detail/info.html' %}
-
+
{% include 'shared/bottom_notification.html' %} {% include 'shared/analytics.html' %} {% include 'shared/footer_scripts.html' with ignore_inject_web3=1 vue=True %} From d9439e89264106c3ec840ab4cd169b3b649fed5e Mon Sep 17 00:00:00 2001 From: sanchaymittal Date: Mon, 12 Oct 2020 23:12:39 +0530 Subject: [PATCH 25/25] add: validation for covert to grant query rnm: rename data to project_data --- app/dashboard/views.py | 6 +++--- app/grants/templates/grants/new.html | 10 +++++----- app/grants/views.py | 11 +++++------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index a1d22171f23..eafa295ef73 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -4493,13 +4493,13 @@ def hackathon_save_project(request): def get_project(request, project_id): profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None - params = project(project_id) + params = project_data(project_id) if not params: raise Http404("The project doesnt exists.") return JsonResponse(params) -def project(project_id): +def project_data(project_id): project = HackathonProject.objects.filter(pk=project_id).nocache().first() if not project: return None @@ -4530,7 +4530,7 @@ def project(project_id): 'handle': member_profile.handle, 'avatar': member_profile.avatar_url } for member_profile in project.profiles.all()], - 'team_members_profile': [member_profile for member_profile in project.profiles.all()] + 'team_members_profile': project.profiles.all() }, 'hackathon': hackathon_obj[0], } diff --git a/app/grants/templates/grants/new.html b/app/grants/templates/grants/new.html index 418e0493812..f4117f2825c 100644 --- a/app/grants/templates/grants/new.html +++ b/app/grants/templates/grants/new.html @@ -77,7 +77,7 @@
Project Information
- +
@@ -89,14 +89,14 @@
Project Information
- +
@@ -115,7 +115,7 @@
Project Information
- +
Categorization Information
@@ -167,7 +167,7 @@
Funding Information
- + diff --git a/app/grants/views.py b/app/grants/views.py index 3bb7bf62dee..187f2bd5b0a 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -61,7 +61,6 @@ from dashboard.models import Activity, HackathonProject, Profile, SearchHistory from dashboard.tasks import increment_view_count from dashboard.utils import get_web3, has_tx_mined -from dashboard.views import project from economy.models import Token as FTokens from economy.utils import convert_amount from gas.utils import conf_time_spread, eth_usd_conv_rate, gas_advisories, recommend_min_gas_price_to_confirm_in_time @@ -1339,12 +1338,12 @@ def grant_new(request): 'url': grant.url, }) - check_profile = None - project_data = None + project = None project_id = request.GET.get('project_id', None) if project_id is not None: - check_profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None - project_data = project(project_id) + hackathon_project = HackathonProject.objects.filter(pk=project_id).nocache().first() + if request.user.profile in hackathon_project.profiles.all(): + project = hackathon_project params = { 'active': 'new_grant', @@ -1362,7 +1361,7 @@ def grant_new(request): 'gas_advisories': gas_advisories(), 'trusted_relayer': settings.GRANTS_OWNER_ACCOUNT, 'grant_types': GrantType.objects.all(), - 'data': project_data + 'project_data': project } return TemplateResponse(request, 'grants/new.html', params)