From 28c221383e267e6ffee4ed8be68e8972444c2e7c Mon Sep 17 00:00:00 2001 From: Owocki Date: Thu, 26 Sep 2019 11:39:42 -0600 Subject: [PATCH 01/11] manual stats --- app/marketing/admin.py | 3 ++- app/marketing/migrations/0006_manualstat.py | 28 +++++++++++++++++++++ app/marketing/models.py | 11 ++++++++ app/retail/utils.py | 2 +- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 app/marketing/migrations/0006_manualstat.py diff --git a/app/marketing/admin.py b/app/marketing/admin.py index 96fbd9da92f..1fb385de288 100644 --- a/app/marketing/admin.py +++ b/app/marketing/admin.py @@ -23,7 +23,7 @@ from .models import ( AccountDeletionRequest, Alumni, EmailEvent, EmailSubscriber, EmailSupressionList, GithubEvent, - GithubOrgToTwitterHandleMapping, Keyword, LeaderboardRank, MarketingCallback, Match, SlackPresence, SlackUser, Stat, + GithubOrgToTwitterHandleMapping, Keyword, LeaderboardRank, MarketingCallback, Match, SlackPresence, SlackUser, Stat, ManualStat ) @@ -120,6 +120,7 @@ def membership_length_in_days(self, instance): admin.site.register(Alumni, AlumniAdmin) admin.site.register(GithubEvent, GithubEventAdmin) admin.site.register(Match, MatchAdmin) +admin.site.register(ManualStat, GeneralAdmin) admin.site.register(Stat, GeneralAdmin) admin.site.register(Keyword, GeneralAdmin) admin.site.register(EmailEvent, EmailEventAdmin) diff --git a/app/marketing/migrations/0006_manualstat.py b/app/marketing/migrations/0006_manualstat.py new file mode 100644 index 00000000000..df6f05fad4e --- /dev/null +++ b/app/marketing/migrations/0006_manualstat.py @@ -0,0 +1,28 @@ +# Generated by Django 2.2.3 on 2019-09-26 17:34 + +from django.db import migrations, models +import economy.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('marketing', '0005_marketingcallback'), + ] + + operations = [ + migrations.CreateModel( + name='ManualStat', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created_on', models.DateTimeField(db_index=True, default=economy.models.get_time)), + ('modified_on', models.DateTimeField(default=economy.models.get_time)), + ('key', models.CharField(db_index=True, max_length=50)), + ('date', models.DateTimeField(db_index=True)), + ('val', models.FloatField()), + ], + options={ + 'abstract': False, + }, + ), + ] diff --git a/app/marketing/models.py b/app/marketing/models.py index 5d54bbceb54..76b89ab8b7a 100644 --- a/app/marketing/models.py +++ b/app/marketing/models.py @@ -137,6 +137,17 @@ def psave_es(sender, instance, **kwargs): instance.build_email_preferences() +class ManualStat(SuperModel): + """Define the manual stat model; which records stats that are not available on the platform + """ + + key = models.CharField(max_length=50, db_index=True) + date = models.DateTimeField(db_index=True) + val = models.FloatField() + + def __str__(self): + return f"{self.key}: {self.date}: {self.val}" + class Stat(SuperModel): key = models.CharField(max_length=50, db_index=True) diff --git a/app/retail/utils.py b/app/retail/utils.py index 45f1bb53c4b..86cdf17b294 100644 --- a/app/retail/utils.py +++ b/app/retail/utils.py @@ -179,7 +179,7 @@ def get_codefund_history_at_date(date, keyword): if date > timezone.datetime(2019, 9, 9): amount += 52000 if date > timezone.datetime(2019, 10, 9): - amount += 0 # october month to date + amount += sum(ManualStat.objects.filter(date__gt=date).values_list('val', flat=True)) return amount From 81f2e0d92a1c1f296799667062a2cb15d3f3ec3d Mon Sep 17 00:00:00 2001 From: Owocki Date: Thu, 26 Sep 2019 11:43:18 -0600 Subject: [PATCH 02/11] make fix --- app/marketing/admin.py | 3 ++- app/retail/utils.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/marketing/admin.py b/app/marketing/admin.py index 1fb385de288..b66a4d7aac1 100644 --- a/app/marketing/admin.py +++ b/app/marketing/admin.py @@ -23,7 +23,8 @@ from .models import ( AccountDeletionRequest, Alumni, EmailEvent, EmailSubscriber, EmailSupressionList, GithubEvent, - GithubOrgToTwitterHandleMapping, Keyword, LeaderboardRank, MarketingCallback, Match, SlackPresence, SlackUser, Stat, ManualStat + GithubOrgToTwitterHandleMapping, Keyword, LeaderboardRank, ManualStat, MarketingCallback, Match, SlackPresence, + SlackUser, Stat, ) diff --git a/app/retail/utils.py b/app/retail/utils.py index 86cdf17b294..cc3e2a96765 100644 --- a/app/retail/utils.py +++ b/app/retail/utils.py @@ -144,6 +144,7 @@ def get_ecosystem_history_at_date(date, keyword): def get_codefund_history_at_date(date, keyword): + from marketing.models import ManualStat date = date.replace(tzinfo=None) amount = 0 # July => Feb 2019 From 0779732738405711a3b1ba719e5324f895e698a8 Mon Sep 17 00:00:00 2001 From: Owocki Date: Thu, 26 Sep 2019 11:43:57 -0600 Subject: [PATCH 03/11] gmv --- app/retail/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/retail/utils.py b/app/retail/utils.py index cc3e2a96765..0d6692f2190 100644 --- a/app/retail/utils.py +++ b/app/retail/utils.py @@ -180,7 +180,7 @@ def get_codefund_history_at_date(date, keyword): if date > timezone.datetime(2019, 9, 9): amount += 52000 if date > timezone.datetime(2019, 10, 9): - amount += sum(ManualStat.objects.filter(date__gt=date).values_list('val', flat=True)) + amount += sum(ManualStat.objects.filter(key='codefund_gmv', date__gt=date).values_list('val', flat=True)) return amount From c0e48e0f28c0bc95289566362838d573c5b58f45 Mon Sep 17 00:00:00 2001 From: aewens Date: Wed, 2 Oct 2019 16:00:35 -0500 Subject: [PATCH 04/11] Using d-md-block d-none to hide #kudos_header on mobile --- app/dashboard/templates/profiles/profile.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/dashboard/templates/profiles/profile.html b/app/dashboard/templates/profiles/profile.html index 08166092157..c89044fc063 100644 --- a/app/dashboard/templates/profiles/profile.html +++ b/app/dashboard/templates/profiles/profile.html @@ -47,7 +47,7 @@
{% if total_kudos_count %} -
+
{% for kudos_group in my_kudos %} {% endfor %} @@ -118,4 +118,4 @@ {% endif %} - \ No newline at end of file + From d9e93c2dc975580efa618c9efc6240c8ac3def02 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Sat, 5 Oct 2019 06:26:06 +0900 Subject: [PATCH 05/11] hide clr info on card once it's ended --- app/grants/templates/grants/card/front.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/grants/templates/grants/card/front.html b/app/grants/templates/grants/card/front.html index 7e867ea7cfc..23fa27862f3 100644 --- a/app/grants/templates/grants/card/front.html +++ b/app/grants/templates/grants/card/front.html @@ -41,7 +41,7 @@

- {% if clr_active or show_past_clr %} + {% if clr_active %} {% include 'grants/card/clr_match.html' %} {% else %}

MONTHLY RECURRING

@@ -70,7 +70,7 @@

-
+
{% if grant.active %}
@@ -84,7 +84,7 @@

+
{{ grant.contribution_count}} contribution{% if grant.contribution_count > 1 %}s{% endif %} by {{ grant.contributor_count}} contributor{% if grant.contributor_count > 1 %}s{% endif %} From 2bd337bec66ca80a60648ba1e3b4732da5879f19 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Sat, 5 Oct 2019 23:54:13 -0300 Subject: [PATCH 06/11] add register hackathon --- app/app/urls.py | 1 + app/dashboard/admin.py | 11 +- .../migrations/0056_auto_20191006_0252.py | 35 ++++ app/dashboard/models.py | 26 +++ app/dashboard/templates/addinterest.html | 152 ++++++++++-------- .../dashboard/hackathon_onboard.html | 81 +++++++++- app/dashboard/views.py | 75 ++++++++- 7 files changed, 301 insertions(+), 80 deletions(-) create mode 100644 app/dashboard/migrations/0056_auto_20191006_0252.py diff --git a/app/app/urls.py b/app/app/urls.py index 362a9039359..762b323ee44 100644 --- a/app/app/urls.py +++ b/app/app/urls.py @@ -173,6 +173,7 @@ path('hackathon/onboard//', dashboard.views.hackathon_onboard, name='hackathon_onboard'), path('hackathon/', dashboard.views.hackathon, name='hackathon_idx'), path('hackathon-list/', dashboard.views.get_hackathons, name='get_hackathons'), + url(r'^register_hackathon/', dashboard.views.hackathon_registration, name='hackathon_registration'), # action URLs url(r'^funder', retail.views.funder_bounties_redirect, name='funder_bounties_redirect'), diff --git a/app/dashboard/admin.py b/app/dashboard/admin.py index 67c9362950e..40ec9d7d1e0 100644 --- a/app/dashboard/admin.py +++ b/app/dashboard/admin.py @@ -24,9 +24,9 @@ from .models import ( Activity, BlockedUser, Bounty, BountyFulfillment, BountyInvites, BountySyncRequest, CoinRedemption, - CoinRedemptionRequest, Coupon, Earning, FeedbackEntry, HackathonEvent, HackathonSponsor, Interest, LabsResearch, - PortfolioItem, Profile, ProfileView, RefundFeeRequest, SearchHistory, Sponsor, Tip, TokenApproval, Tool, ToolVote, - UserAction, UserVerificationModel, + CoinRedemptionRequest, Coupon, Earning, FeedbackEntry, HackathonEvent, HackathonRegistration, + HackathonSponsor, Interest, LabsResearch, PortfolioItem, Profile, ProfileView, RefundFeeRequest, + SearchHistory, Sponsor, Tip, TokenApproval, Tool, ToolVote, UserAction, UserVerificationModel, ) @@ -343,6 +343,10 @@ def link(self, instance): return mark_safe(f'http://gitcoin.co{url}') +class HackathonRegistrationAdmin(admin.ModelAdmin): + list_display = ['pk', 'name', 'referer'] + raw_id_fields = ['registrant'] + admin.site.register(SearchHistory, SearchHistoryAdmin) admin.site.register(Activity, ActivityAdmin) admin.site.register(Earning, EarningAdmin) @@ -365,6 +369,7 @@ def link(self, instance): admin.site.register(Sponsor, SponsorAdmin) admin.site.register(HackathonEvent, HackathonEventAdmin) admin.site.register(HackathonSponsor, HackathonSponsorAdmin) +admin.site.register(HackathonRegistration, HackathonRegistrationAdmin) admin.site.register(FeedbackEntry, FeedbackAdmin) admin.site.register(LabsResearch) admin.site.register(UserVerificationModel, VerificationAdmin) diff --git a/app/dashboard/migrations/0056_auto_20191006_0252.py b/app/dashboard/migrations/0056_auto_20191006_0252.py new file mode 100644 index 00000000000..2c1c3995543 --- /dev/null +++ b/app/dashboard/migrations/0056_auto_20191006_0252.py @@ -0,0 +1,35 @@ +# Generated by Django 2.2.4 on 2019-10-06 02:52 + +from django.db import migrations, models +import django.db.models.deletion +import economy.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0055_profile_referrer'), + ] + + operations = [ + migrations.CreateModel( + name='HackathonRegistration', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created_on', models.DateTimeField(db_index=True, default=economy.models.get_time)), + ('modified_on', models.DateTimeField(default=economy.models.get_time)), + ('name', models.CharField(help_text='Hackathon slug', max_length=255)), + ('referer', models.URLField(blank=True, help_text='Url comes from', null=True)), + ('hackathon', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='dashboard.HackathonEvent')), + ('registrant', models.ForeignKey(help_text='User profile', on_delete=django.db.models.deletion.CASCADE, related_name='hackathon_registration', to='dashboard.Profile')), + ], + options={ + 'ordering': ('name',), + }, + ), + migrations.AddField( + model_name='profile', + name='hackathons', + field=models.ManyToManyField(blank=True, to='dashboard.HackathonRegistration'), + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index b41b6d618d7..901d863a31a 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -2142,6 +2142,30 @@ def hidden(self): return self.filter(hide_profile=True) +class HackathonRegistration(SuperModel): + """Defines the Hackthon profiles registrations""" + name = models.CharField(max_length=255, help_text='Hackathon slug') + hackathon = models.OneToOneField( + 'HackathonEvent', + on_delete=models.SET_NULL, + null=True, + blank=True + ) + referer = models.URLField(null=True, blank=True, help_text='Url comes from') + registrant = models.ForeignKey( + 'dashboard.Profile', + related_name='hackathon_registration', + on_delete=models.CASCADE, + help_text='User profile' + ) + + class Meta: + ordering = ('name',) + + def __str__(self): + return f"Name: {self.name}; Hackathon: {self.hackathon}; Referer: {self.referer}; Registrant: {self.registrant}" + + class Profile(SuperModel): """Define the structure of the user profile. @@ -2236,6 +2260,8 @@ class Profile(SuperModel): rank_org = models.IntegerField(default=0) rank_coder = models.IntegerField(default=0) referrer = models.ForeignKey('dashboard.Profile', related_name='referred', on_delete=models.CASCADE, null=True, db_index=True) + hackathons = models.ManyToManyField(HackathonRegistration, blank=True) + objects = ProfileQuerySet.as_manager() diff --git a/app/dashboard/templates/addinterest.html b/app/dashboard/templates/addinterest.html index d0c6cbe30b0..6061964850d 100644 --- a/app/dashboard/templates/addinterest.html +++ b/app/dashboard/templates/addinterest.html @@ -25,84 +25,98 @@
{% trans "Submit a Plan" %}
{% if user_logged_in %}
-
- {% if bounty.repo_type == 'private' %} -
-
-
-
{% trans "Non-Disclosure Agreement" %}
- {% blocktrans %} -

Download the repo’s Non-Disclosure Agreement and upload the signed document.

- {% endblocktrans %} - - + {% if is_registered or not bounty.event %} + + {% if bounty.repo_type == 'private' %} +
+
+
+
{% trans "Non-Disclosure Agreement" %}
+ {% blocktrans %} +

Download the repo’s Non-Disclosure Agreement and upload the signed document.

+ {% endblocktrans %} + + +
+
-
+ {% endif %} +
+ {% if bounty.event %} +

+ This bounty is part of {{bounty.event.name}}, please read the rules to participate before you continue. +

+ {% endif %} + +
- {% endif %} -
+
{% if bounty.event %} -

- This bounty is part of hackathon, please read the rules to participate before you continue. -

- {% endif %} - - -
-
- {% if bounty.event %} -
-
- - - Join Discord to get updates from our sponsors prizes and find help + {{registration}} + {{registration.hackathon_id}} + // + + event: + {{bounty.event.id}} +
+
+ + + Join Discord to get updates from our sponsors prizes and find help +
-
- {% endif %} -
- - -
- + {% endif %} +
+ + +
+ +
-
-
-
- - -
- +
+
+ + +
+ +
+ + + {% else %} +
+

This bounty is part of {{bounty.event.name}}.
+ Please register for the hackathon and read the rules of participation before you continue.

+ Register for Hackathon
- - + {% endif %}
{% else %}
diff --git a/app/dashboard/templates/dashboard/hackathon_onboard.html b/app/dashboard/templates/dashboard/hackathon_onboard.html index af7b162ae8e..0d528120713 100644 --- a/app/dashboard/templates/dashboard/hackathon_onboard.html +++ b/app/dashboard/templates/dashboard/hackathon_onboard.html @@ -50,6 +50,7 @@

{{hackathon.name}} Guide

+ {{referer}} {% if hackathon.end_date|timesince >= "1 min" %}

This hackathon event had ended at {{hackathon.end_date}}, please check the ongoing hackathons.

@@ -162,12 +163,86 @@

How does the Hackathon work?

- + {% if not github_handle %} + +
+ + + {% trans "Register with GitHub for Hackathon" %} + +

By registering you agree to receive hackathon emails announcements

+
+ + {% else %} +
+ {% if is_registered %} + Start Hacking + {% else %} + Register for Hackathon +

By registering you agree to receive hackathon emails announcements

+ {% endif %} + {{hackathon.pk}} + +
+ {% endif %}
+ {% csrf_token %} {% include 'shared/analytics.html' %} {% include 'shared/footer_scripts.html' %} {% include 'shared/footer.html' %} + + diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 9a6f7ed9fd4..976c4e49e6c 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -43,6 +43,7 @@ from django.urls import reverse from django.utils import timezone from django.utils.html import escape, strip_tags +from django.utils.http import is_safe_url from django.utils.text import slugify from django.utils.translation import gettext_lazy as _ from django.views.decorators.clickjacking import xframe_options_exempt @@ -75,9 +76,9 @@ from .helpers import get_bounty_data_for_activity, handle_bounty_views, load_files_in_directory from .models import ( Activity, Bounty, BountyDocuments, BountyFulfillment, BountyInvites, CoinRedemption, CoinRedemptionRequest, Coupon, - Earning, FeedbackEntry, HackathonEvent, HackathonSponsor, Interest, LabsResearch, PortfolioItem, Profile, - ProfileSerializer, ProfileView, RefundFeeRequest, SearchHistory, Sponsor, Subscription, Tool, ToolVote, UserAction, - UserVerificationModel, + Earning, FeedbackEntry, HackathonEvent, HackathonRegistration, HackathonSponsor, Interest, LabsResearch, + PortfolioItem, Profile, ProfileSerializer, ProfileView, RefundFeeRequest, SearchHistory, Sponsor, Subscription, + Tool, ToolVote, UserAction, UserVerificationModel, ) from .notifications import ( maybe_market_tip_to_email, maybe_market_tip_to_github, maybe_market_tip_to_slack, maybe_market_to_email, @@ -212,12 +213,23 @@ def get_interest_modal(request): except Bounty.DoesNotExist: raise Http404 + print (request.user.profile.hackathons.all()) + print(bounty.event) + if bounty.event and request.user.is_authenticated: + is_registered = request.user.profile.hackathons.filter(hackathon_id=bounty.event.id).first() or None + print(is_registered) + else: + is_registered = None + + context = { 'bounty': bounty, 'gitcoin_discord_username': request.user.profile.gitcoin_discord_username if request.user.is_authenticated else None, 'active': 'get_interest_modal', 'title': _('Add Interest'), 'user_logged_in': request.user.is_authenticated, + # 'is_registered': request.user.profile.hackathons.all(), + 'is_registered': is_registered, 'login_link': '/login/github?next=' + request.GET.get('redirect', '/') } return TemplateResponse(request, 'addinterest.html', context) @@ -2437,7 +2449,7 @@ def profile(request, handle, tab=None): default_tab = 'activity' tab = tab if tab else default_tab handle = handle.replace("@", "") - + # make sure tab param is correct all_tabs = ['active', 'ratings', 'portfolio', 'viewers', 'activity', 'resume', 'kudos', 'earnings', 'spent', 'orgs', 'people'] tab = default_tab if tab not in all_tabs else tab @@ -2445,7 +2457,7 @@ def profile(request, handle, tab=None): # someone trying to go to their own profile? tab = handle handle = request.user.profile.handle - + # user only tabs if not handle and request.user.is_authenticated: handle = request.user.username @@ -3277,19 +3289,72 @@ def hackathon(request, hackathon=''): def hackathon_onboard(request, hackathon=''): + referer = request.META.get('HTTP_REFERER', '') try: hackathon_event = HackathonEvent.objects.filter(slug__iexact=hackathon).latest('id') + is_registered = request.user.profile.hackathons.filter(hackathon_id=hackathon_event.pk).first() if request.user.is_authenticated else None except HackathonEvent.DoesNotExist: hackathon_event = HackathonEvent.objects.last() + params = { 'active': 'hackathon_onboard', 'title': 'Hackathon Onboard', 'hackathon': hackathon_event, + 'referer': referer, + 'is_registered': is_registered, } return TemplateResponse(request, 'dashboard/hackathon_onboard.html', params) +@csrf_exempt +@require_POST +def hackathon_registration(request): + """Claim Work for a Bounty. + + :request method: POST + + Args: + bounty_id (int): ID of the Bounty. + + Returns: + dict: The success key with a boolean value and accompanying error. + + """ + profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None + hackathon = request.POST.get('name') + referer = request.POST.get('referer') + print(hackathon, referer) + + # return redirect('hackathon', hackathon=hackathon) + if not profile: + return JsonResponse( + {'error': _('You must be authenticated via github to use this feature!')}, + status=401) + try: + hackathon_event = HackathonEvent.objects.filter(slug__iexact=hackathon).latest('id') + registration_data = HackathonRegistration.objects.get_or_create( + name=hackathon, + hackathon= hackathon_event, + referer=referer, + registrant=profile + )[0] + + profile.hackathons.add(registration_data) + except Exception as e: + logger.error('Error while saving registration', e) + + if referer and is_safe_url(referer, request.get_host()): + messages.success(request, _(f'You have successfully registered to {hackathon_event.name}. Happy hacking!')) + # return redirect(referer) + redirect = referer + else: + messages.success(request, _(f'You have successfully registered to {hackathon_event.name}. Happy hacking!')) + # return redirect('hackathon', hackathon=hackathon) + redirect = f'/hackathon/{hackathon}' + + return JsonResponse({'redirect': redirect}) + def get_hackathons(request): """Handle rendering all Hackathons.""" From 3488413c685fe12b4f6314c8bfe62ec0159cd645 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Mon, 7 Oct 2019 19:58:25 -0300 Subject: [PATCH 07/11] Send data to mailchimp --- app/app/settings.py | 1 + ...006_0252.py => 0056_auto_20191007_2254.py} | 4 +- app/dashboard/models.py | 3 +- app/dashboard/views.py | 40 ++++++++++++++++--- 4 files changed, 40 insertions(+), 8 deletions(-) rename app/dashboard/migrations/{0056_auto_20191006_0252.py => 0056_auto_20191007_2254.py} (86%) diff --git a/app/app/settings.py b/app/app/settings.py index 70cf0b4b109..6061ad1e721 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -509,6 +509,7 @@ MAILCHIMP_LIST_ID = env.str('MAILCHIMP_LIST_ID', default='') MAILCHIMP_LIST_ID_HUNTERS = env.str('MAILCHIMP_LIST_ID_HUNTERS', default='') MAILCHIMP_LIST_ID_FUNDERS = env.str('MAILCHIMP_LIST_ID_FUNDERS', default='') +MAILCHIMP_LIST_ID_HACKERS = env.str('MAILCHIMP_LIST_ID_HACKERS', default='') # Github GITHUB_API_BASE_URL = env('GITHUB_API_BASE_URL', default='https://api.github.com') diff --git a/app/dashboard/migrations/0056_auto_20191006_0252.py b/app/dashboard/migrations/0056_auto_20191007_2254.py similarity index 86% rename from app/dashboard/migrations/0056_auto_20191006_0252.py rename to app/dashboard/migrations/0056_auto_20191007_2254.py index 2c1c3995543..c3fccf3ab41 100644 --- a/app/dashboard/migrations/0056_auto_20191006_0252.py +++ b/app/dashboard/migrations/0056_auto_20191007_2254.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.4 on 2019-10-06 02:52 +# Generated by Django 2.2.4 on 2019-10-07 22:54 from django.db import migrations, models import django.db.models.deletion @@ -20,7 +20,7 @@ class Migration(migrations.Migration): ('modified_on', models.DateTimeField(default=economy.models.get_time)), ('name', models.CharField(help_text='Hackathon slug', max_length=255)), ('referer', models.URLField(blank=True, help_text='Url comes from', null=True)), - ('hackathon', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='dashboard.HackathonEvent')), + ('hackathon', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='dashboard.HackathonEvent')), ('registrant', models.ForeignKey(help_text='User profile', on_delete=django.db.models.deletion.CASCADE, related_name='hackathon_registration', to='dashboard.Profile')), ], options={ diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 901d863a31a..905424cc73d 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -2145,7 +2145,8 @@ def hidden(self): class HackathonRegistration(SuperModel): """Defines the Hackthon profiles registrations""" name = models.CharField(max_length=255, help_text='Hackathon slug') - hackathon = models.OneToOneField( + + hackathon = models.ForeignKey( 'HackathonEvent', on_delete=models.SET_NULL, null=True, diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 976c4e49e6c..d62ea2b7ec9 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -60,8 +60,10 @@ from eth_utils import to_checksum_address, to_normalized_address from gas.utils import recommend_min_gas_price_to_confirm_in_time from git.utils import get_auth_url, get_github_user_data, is_github_token_valid, search_users +import hashlib from kudos.models import KudosTransfer, Token, Wallet from kudos.utils import humanize_name +from mailchimp3 import MailChimp from marketing.mails import admin_contact_funder, bounty_uninterested from marketing.mails import funder_payout_reminder as funder_payout_reminder_mail from marketing.mails import ( @@ -3333,24 +3335,52 @@ def hackathon_registration(request): status=401) try: hackathon_event = HackathonEvent.objects.filter(slug__iexact=hackathon).latest('id') - registration_data = HackathonRegistration.objects.get_or_create( + registration_data = HackathonRegistration.objects.create( name=hackathon, hackathon= hackathon_event, referer=referer, registrant=profile - )[0] + ) - profile.hackathons.add(registration_data) + profile.hackathons.add(registration_data.id) except Exception as e: logger.error('Error while saving registration', e) + client = MailChimp(mc_api=settings.MAILCHIMP_API_KEY, mc_user=settings.MAILCHIMP_USER) + mailchimp_data = { + 'email_address': profile.email, + 'status_if_new': 'subscribed', + 'status': 'subscribed', + + 'merge_fields': { + 'HANDLE': profile.handle, + 'HACKATHON': hackathon, + }, + } + + user_email_hash = hashlib.md5(profile.email.encode('utf')).hexdigest() + + try: + client.lists.members.create_or_update(settings.MAILCHIMP_LIST_ID_HACKERS, user_email_hash, mailchimp_data) + client.lists.members.tags.update( + settings.MAILCHIMP_LIST_ID_HACKERS, + user_email_hash, + { + 'tags': [ + {'name': hackathon, 'status': 'active'}, + ], + } + ) + print('pushed_to_list') + except Exception as e: + logger.error(f"error in record_action: {e} - {instance}") + pass + if referer and is_safe_url(referer, request.get_host()): messages.success(request, _(f'You have successfully registered to {hackathon_event.name}. Happy hacking!')) - # return redirect(referer) redirect = referer else: messages.success(request, _(f'You have successfully registered to {hackathon_event.name}. Happy hacking!')) - # return redirect('hackathon', hackathon=hackathon) redirect = f'/hackathon/{hackathon}' return JsonResponse({'redirect': redirect}) From a4ee769a62b9f1593ba3b92f916d913062ee8755 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Mon, 7 Oct 2019 20:12:50 -0300 Subject: [PATCH 08/11] fix isort --- app/dashboard/admin.py | 6 +++--- app/dashboard/views.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/dashboard/admin.py b/app/dashboard/admin.py index 40ec9d7d1e0..e7f9d000762 100644 --- a/app/dashboard/admin.py +++ b/app/dashboard/admin.py @@ -24,9 +24,9 @@ from .models import ( Activity, BlockedUser, Bounty, BountyFulfillment, BountyInvites, BountySyncRequest, CoinRedemption, - CoinRedemptionRequest, Coupon, Earning, FeedbackEntry, HackathonEvent, HackathonRegistration, - HackathonSponsor, Interest, LabsResearch, PortfolioItem, Profile, ProfileView, RefundFeeRequest, - SearchHistory, Sponsor, Tip, TokenApproval, Tool, ToolVote, UserAction, UserVerificationModel, + CoinRedemptionRequest, Coupon, Earning, FeedbackEntry, HackathonEvent, HackathonRegistration, HackathonSponsor, + Interest, LabsResearch, PortfolioItem, Profile, ProfileView, RefundFeeRequest, SearchHistory, Sponsor, Tip, + TokenApproval, Tool, ToolVote, UserAction, UserVerificationModel, ) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index d62ea2b7ec9..4a7a81e2a97 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -18,6 +18,7 @@ ''' from __future__ import print_function, unicode_literals +import hashlib import json import logging import os @@ -60,7 +61,6 @@ from eth_utils import to_checksum_address, to_normalized_address from gas.utils import recommend_min_gas_price_to_confirm_in_time from git.utils import get_auth_url, get_github_user_data, is_github_token_valid, search_users -import hashlib from kudos.models import KudosTransfer, Token, Wallet from kudos.utils import humanize_name from mailchimp3 import MailChimp From e16a296e6c9ddd340b9f7b73c07016d489efe16f Mon Sep 17 00:00:00 2001 From: octavioamu Date: Mon, 7 Oct 2019 20:25:21 -0300 Subject: [PATCH 09/11] cleanup --- app/dashboard/templates/addinterest.html | 7 ---- .../dashboard/hackathon_onboard.html | 39 ++++--------------- app/dashboard/views.py | 7 ---- 3 files changed, 7 insertions(+), 46 deletions(-) diff --git a/app/dashboard/templates/addinterest.html b/app/dashboard/templates/addinterest.html index 6061964850d..8bca8bba2ab 100644 --- a/app/dashboard/templates/addinterest.html +++ b/app/dashboard/templates/addinterest.html @@ -63,12 +63,6 @@
{% trans "Non-Disclosure Agreement" %}
{% if bounty.event %} - {{registration}} - {{registration.hackathon_id}} - // - - event: - {{bounty.event.id}}
Join Discord to get updates from our sponsors prizes and find help -
{% endif %} diff --git a/app/dashboard/templates/dashboard/hackathon_onboard.html b/app/dashboard/templates/dashboard/hackathon_onboard.html index 0d528120713..6439668b714 100644 --- a/app/dashboard/templates/dashboard/hackathon_onboard.html +++ b/app/dashboard/templates/dashboard/hackathon_onboard.html @@ -50,8 +50,6 @@

{{hackathon.name}} Guide

- {{referer}} - {% if hackathon.end_date|timesince >= "1 min" %}

This hackathon event had ended at {{hackathon.end_date}}, please check the ongoing hackathons.

{% endif %} @@ -182,8 +180,6 @@

How does the Hackathon work?

Register for Hackathon

By registering you agree to receive hackathon emails announcements

{% endif %} - {{hackathon.pk}} -
{% endif %}
@@ -198,7 +194,6 @@

How does the Hackathon work?

const hackathon_slug = '{{ hackathon.slug|safe }}'; const redirect = '{% if referer %}{{referer|safe}}{% else %}{% url 'hackathon' hackathon.slug %}{% endif %}'; const csrftoken = $('[name=csrfmiddlewaretoken]').val(); - const register = (name, referer) => { if (is_registered) { return; @@ -210,39 +205,19 @@

How does the Hackathon work?

$.when(sendRegister).then((response) => { console.log(response) document.location.href = response.redirect; - - // if (referer.indexOf(location.origin) > -1) { - // document.location.href = referer; - // } else { - // document.location.href = redirect - // } - // redirect }); - } - - //logged in, not registered > click > send registration > redirect if same hostname - - // not logged login > register > redirect if same hostname (avoid click 2 times) const params = new URLSearchParams(window.location.search); + if (params.get('referer')) { - // send data - // redirect register(hackathon_slug, params.get('referer')) - } - - - - $('[data-registration]').on('click', function(e) { - e.preventDefault(); - let name = $(this).data('registration'); - let referer = $(this).data('referer'); - register(name, referer) - }); - - - + $('[data-registration]').on('click', function(e) { + e.preventDefault(); + let name = $(this).data('registration'); + let referer = $(this).data('referer'); + register(name, referer) + }); diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 4a7a81e2a97..f4ab88febf1 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -215,22 +215,17 @@ def get_interest_modal(request): except Bounty.DoesNotExist: raise Http404 - print (request.user.profile.hackathons.all()) - print(bounty.event) if bounty.event and request.user.is_authenticated: is_registered = request.user.profile.hackathons.filter(hackathon_id=bounty.event.id).first() or None - print(is_registered) else: is_registered = None - context = { 'bounty': bounty, 'gitcoin_discord_username': request.user.profile.gitcoin_discord_username if request.user.is_authenticated else None, 'active': 'get_interest_modal', 'title': _('Add Interest'), 'user_logged_in': request.user.is_authenticated, - # 'is_registered': request.user.profile.hackathons.all(), 'is_registered': is_registered, 'login_link': '/login/github?next=' + request.GET.get('redirect', '/') } @@ -3326,9 +3321,7 @@ def hackathon_registration(request): profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None hackathon = request.POST.get('name') referer = request.POST.get('referer') - print(hackathon, referer) - # return redirect('hackathon', hackathon=hackathon) if not profile: return JsonResponse( {'error': _('You must be authenticated via github to use this feature!')}, From 9c4877dd977190370e7c6d611b9e6e74e11bc90e Mon Sep 17 00:00:00 2001 From: Sebastian T F Date: Thu, 10 Oct 2019 15:26:09 +0530 Subject: [PATCH 10/11] fix: #logo image wider than email container --- app/retail/templates/emails/template.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/retail/templates/emails/template.html b/app/retail/templates/emails/template.html index f524204d6ef..47045aabcdf 100644 --- a/app/retail/templates/emails/template.html +++ b/app/retail/templates/emails/template.html @@ -126,11 +126,10 @@ display: inline-block; {% if email_style %} max-height: 300px; - max-width: 100%; + width: 80%; {% else %} max-height: 80px; {% endif %} - max-width: 100%; } #grow-oss { From e27df078ae0eb64fd71c366c064746a448c3e45a Mon Sep 17 00:00:00 2001 From: Rajat Gupta Date: Sun, 13 Oct 2019 16:43:58 +0530 Subject: [PATCH 11/11] typo fixed --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index a708639c3db..93f0c17bb0e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -191,7 +191,7 @@ We may introduce Arbitration [via Delphi](http://delphi.network/) at some point #### Showing Support to Individuals - via [Tips](https://gitcoin.co/tips) - - A free, fast way to show immediate gratitude towards an individual via github username or email adress + - A free, fast way to show immediate gratitude towards an individual via github username or email address - via [Kudos](https://gitcoin.co/kudos) - Showcases special skills and appreciation towards other Gitcoin members.