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/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/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/grants/new.js b/app/assets/v2/js/grants/new.js index 96433285021..a6ccbac6ee9 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_pk', $('#project_pk').val()); if ($('#network').val()) { formData.append('network', $('#network').val()); } else { diff --git a/app/assets/v2/js/vue-components.js b/app/assets/v2/js/vue-components.js index 3eaa4f2c52c..7f79d17e5c8 100644 --- a/app/assets/v2/js/vue-components.js +++ b/app/assets/v2/js/vue-components.js @@ -643,7 +643,8 @@ Vue.component('project-card', { template: `
mark winner - + + grant_tag badge
winner
diff --git a/app/dashboard/admin.py b/app/dashboard/admin.py index 8520b8961ed..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', '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/0154_hackathonproject_grant_obj.py b/app/dashboard/migrations/0154_hackathonproject_grant_obj.py new file mode 100644 index 00000000000..836c697e995 --- /dev/null +++ b/app/dashboard/migrations/0154_hackathonproject_grant_obj.py @@ -0,0 +1,20 @@ +# Generated by Django 2.2.4 on 2020-10-07 13:20 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('grants', '0088_auto_20200924_1536'), + ('dashboard', '0153_hackathonevent_use_circle'), + ] + + operations = [ + migrations.AddField( + model_name='hackathonproject', + 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 82f55b5d218..683881534cc 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -5120,6 +5120,13 @@ 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_obj = models.ForeignKey( + 'grants.Grant', + null=True, + blank=True, + on_delete=models.SET_NULL, + help_text=_('Link to grant if project is converted to grant') + ) class Meta: ordering = ['-name'] @@ -5177,6 +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_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 074382c15cb..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', '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', 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', order_by, 'id') + status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', 'grant_obj', order_by, 'id') projects = [] for project in queryset: @@ -283,7 +283,6 @@ def get_queryset(self): queryset = queryset.filter( Q(profiles__keywords__icontains=skills) ) - if rating: queryset = queryset.filter( Q(rating__gte=rating) @@ -293,6 +292,10 @@ def get_queryset(self): queryset = queryset.filter( Q(winner=True) ) + if 'grants' in filters: + queryset = queryset.filter( + Q(grant_obj__isnull=False) + ) if 'lfm' in filters: queryset = queryset.filter( Q(looking_members=True) diff --git a/app/dashboard/templates/dashboard/hackathon/project_page.html b/app/dashboard/templates/dashboard/hackathon/project_page.html index 64d7915f4b0..18efce8a9b4 100644 --- a/app/dashboard/templates/dashboard/hackathon/project_page.html +++ b/app/dashboard/templates/dashboard/hackathon/project_page.html @@ -64,20 +64,26 @@ {% trans "View Admin" %}
{% endif %} -
-
-
- {% if is_member %} - - {% endif %} -
-
- {% include 'project/detail/info.html' %} -
+
+
+
+ {% if project_obj.grant_url %} + Triangles {% if is_member %} EDIT GRANT {% else %} DONATE TO GRANT {% endif %} + {% endif %} + + {% if is_member %} + {% if not project_obj.grant_url %} + Create CREATE GRANT + {% 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 %} diff --git a/app/dashboard/templates/dashboard/index-vue.html b/app/dashboard/templates/dashboard/index-vue.html index 9e505c70808..3401ea9a220 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 +
@@ -299,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 29d32d62014..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 + +
@@ -549,58 +557,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 ]] -
-
-
-
+
diff --git a/app/dashboard/views.py b/app/dashboard/views.py index b47ef1a176b..eafa295ef73 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 @@ -4317,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_obj__isnull=False) + ) + if specify_project: projects = projects.filter(name__iexact=specify_project.replace('-', ' ')) if projects.exists(): @@ -4486,10 +4493,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_data(project_id) + if not params: raise Http404("The project doesnt exists.") + return JsonResponse(params) + +def project_data(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,18 +4529,19 @@ 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': 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 project = HackathonProject.objects.filter(pk=project_id).nocache().first() + if not project: raise Http404("No Hackathon Project matches the given query.") @@ -4573,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()], + 'grant_url': project.grant_obj.url if project.grant_obj else False }, 'hackathon_obj': hackathon_obj[0], 'hackathon': hackathon, diff --git a/app/grants/templates/grants/new.html b/app/grants/templates/grants/new.html index c45f5883a71..f4117f2825c 100644 --- a/app/grants/templates/grants/new.html +++ b/app/grants/templates/grants/new.html @@ -77,24 +77,28 @@
Project Information
- +
+
- +
@@ -111,7 +115,7 @@
Project Information
- +
Categorization Information
@@ -163,6 +167,7 @@
Funding Information
+ diff --git a/app/grants/urls.py b/app/grants/urls.py index 5aa937c5f88..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', 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 589e8ab3317..187f2bd5b0a 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -58,7 +58,7 @@ 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, HackathonProject, Profile, SearchHistory from dashboard.tasks import increment_view_count from dashboard.utils import get_web3, has_tx_mined from economy.models import Token as FTokens @@ -1329,12 +1329,21 @@ def grant_new(request): 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_obj=grant) + return JsonResponse({ 'success': True, 'url': grant.url, }) - + project = None + project_id = request.GET.get('project_id', None) + if project_id is not None: + 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', @@ -1351,8 +1360,10 @@ 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(), + 'project_data': project } + return TemplateResponse(request, 'grants/new.html', params)