Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
oritwoen authored Oct 16, 2019
2 parents 6ad57fe + a04dfea commit 0fc7943
Show file tree
Hide file tree
Showing 16 changed files with 345 additions and 90 deletions.
1 change: 1 addition & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
path('hackathon/onboard/<str:hackathon>/', 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'),
Expand Down
11 changes: 8 additions & 3 deletions app/dashboard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down Expand Up @@ -343,6 +343,10 @@ def link(self, instance):
return mark_safe(f'<a target="_blank" href="{url}">http://gitcoin.co{url}</a>')


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)
Expand All @@ -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)
Expand Down
35 changes: 35 additions & 0 deletions app/dashboard/migrations/0056_auto_20191007_2254.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 2.2.4 on 2019-10-07 22:54

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.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={
'ordering': ('name',),
},
),
migrations.AddField(
model_name='profile',
name='hackathons',
field=models.ManyToManyField(blank=True, to='dashboard.HackathonRegistration'),
),
]
27 changes: 27 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2143,6 +2143,31 @@ 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.ForeignKey(
'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.
Expand Down Expand Up @@ -2237,6 +2262,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()

Expand Down
147 changes: 77 additions & 70 deletions app/dashboard/templates/addinterest.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,84 +25,91 @@ <h5 class="text-center font-title">{% trans "Submit a Plan" %}</h5>
</div>
{% if user_logged_in %}
<div class="col-12">
<form id="action_plan" class="font-body">
{% if bounty.repo_type == 'private' %}
<div id="nda-upload">
<hr class="mt-4">
<div>
<h5 class="font-subheader">{% trans "Non-Disclosure Agreement" %}</h5>
{% blocktrans %}
<p>Download the repo’s <a href="" class="nda-download-link" download>Non-Disclosure Agreement</a> and upload the signed document.</p>
{% endblocktrans %}
<label class="form__label" for=issueNDA>{% trans "Each contributor has to sign your NDA before they can start work. Supported format: pdf, doc, docx." %}</label>
<input required name='issueNDA' id="issueNDA" class="form__input" type="file" accept="application/pdf,application/msword, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.presentationml.presentation"/>
{% if is_registered or not bounty.event %}
<form id="action_plan" class="font-body">
{% if bounty.repo_type == 'private' %}
<div id="nda-upload">
<hr class="mt-4">
<div>
<h5 class="font-subheader">{% trans "Non-Disclosure Agreement" %}</h5>
{% blocktrans %}
<p>Download the repo’s <a href="" class="nda-download-link" download>Non-Disclosure Agreement</a> and upload the signed document.</p>
{% endblocktrans %}
<label class="form__label" for=issueNDA>{% trans "Each contributor has to sign your NDA before they can start work. Supported format: pdf, doc, docx." %}</label>
<input required name='issueNDA' id="issueNDA" class="form__input" type="file" accept="application/pdf,application/msword, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.presentationml.presentation"/>
</div>
<hr class="mt-4">
</div>
<hr class="mt-4">
{% endif %}
<div>
{% if bounty.event %}
<p class="alert-danger p-2">
This bounty is part of <b>{{bounty.event.name}}</b>, please read the <a href="{% url 'hackathon_onboard' bounty.event.slug %}" target="_blank">rules to participate</a> before you continue.
</p>
{% endif %}
<label for="issue_message">
<p>
{% trans "Provide an action plan and any initial questions you have for this ticket." %}
{% if bounty.event %}
{% trans "Include gitcoin team members usernames and project repo url, if you have one." %}
{% endif %}
<br>
<span class="font-smaller-4">
({% trans "Your response will be reflected in a comment on the Github issue." %})
</span>
</p>
</label>
<textarea id="issue_message" class="form__input"></textarea>
</div>
{% endif %}
<div>
<div>
{% if bounty.event %}
<p class="alert-danger p-2">
This bounty is part of hackathon, please read the <a href="{% url 'hackathon_onboard' bounty.event.slug %}" target="_blank">rules to participate</a> before you continue.
</p>
{% endif %}
<label for="issue_message">
<p>
{% trans "Provide an action plan and any initial questions you have for this ticket." %}
{% if bounty.event %}
{% trans "Include gitcoin team members usernames and project repo url, if you have one." %}
{% endif %}
<br>
<span class="font-smaller-4">
({% trans "Your response will be reflected in a comment on the Github issue." %})
</span>
</p>
</label>
<textarea id="issue_message" class="form__input"></textarea>
</div>
<div>
{% if bounty.event %}
<div class="d-flex">
<div class="filter-label ml-0 mb-3">
<label for="checkbox2 mb-0">
{% trans "Discord Username" %}
</label>
<input type="text" id="discord_username" name="discord_username" class="form__input font-body" placeholder="vivek#9746" value="{{gitcoin_discord_username}}" required/>
<span class="font-caption"><a target="_blank" href="https://discord.gg/TxRKTn8">Join Discord</a> to get updates from our sponsors prizes and find help</span>

<div class="d-flex">
<div class="filter-label ml-0 mb-3">
<label for="checkbox2 mb-0">
{% trans "Discord Username" %}
</label>
<input type="text" id="discord_username" name="discord_username" class="form__input font-body" placeholder="vivek#9746" value="{{gitcoin_discord_username}}" required/>
<span class="font-caption"><a target="_blank" href="https://discord.gg/TxRKTn8">Join Discord</a> to get updates from our sponsors prizes and find help</span>
</div>
</div>
</div>
{% endif %}
<div class="checkbox_container d-flex">
<input type="checkbox" id="checkbox2" class="form__input" value="1" required/>
<span class="checkbox"></span>
<div class="filter-label">
<label for="checkbox2">
{% if bounty and bounty.permission_type == 'approval' %}
{% trans "I understand that this is an application and I should wait for approval from the funder before starting work." %}
{% elif bounty and bounty.project_type == 'contest' %}
{% trans "I understand that this bounty is a *contest* and that other bounty hunters may be working in parallel with me." %}
{% elif bounty and bounty.project_type == 'cooperative' %}
{% trans "I understand that this bounty is a multi-worker *cooperative* bounty. Other bounty hunters may be working in parallel with me, but the funder has indicated they will pay the bounty to multiple of us." %}
{% else %}
{% trans "I understand that if anyone has started work on this ticket before me, they may have precedence." %}
{% endif %}
</label>
{% endif %}
<div class="checkbox_container d-flex">
<input type="checkbox" id="checkbox2" class="form__input" value="1" required/>
<span class="checkbox"></span>
<div class="filter-label">
<label for="checkbox2">
{% if bounty and bounty.permission_type == 'approval' %}
{% trans "I understand that this is an application and I should wait for approval from the funder before starting work." %}
{% elif bounty and bounty.project_type == 'contest' %}
{% trans "I understand that this bounty is a *contest* and that other bounty hunters may be working in parallel with me." %}
{% elif bounty and bounty.project_type == 'cooperative' %}
{% trans "I understand that this bounty is a multi-worker *cooperative* bounty. Other bounty hunters may be working in parallel with me, but the funder has indicated they will pay the bounty to multiple of us." %}
{% else %}
{% trans "I understand that if anyone has started work on this ticket before me, they may have precedence." %}
{% endif %}
</label>
</div>
</div>
</div>
<div>
<div class="checkbox_container d-flex">
<input type="checkbox" id="checkbox1" class="form__input" value="1" required/>
<span class="checkbox"></span>
<div class="filter-label">
<label for="checkbox1">
{% trans "I agree to keep the funder informed of my progress every few days." %}
</label>
<div>
<div class="checkbox_container d-flex">
<input type="checkbox" id="checkbox1" class="form__input" value="1" required/>
<span class="checkbox"></span>
<div class="filter-label">
<label for="checkbox1">
{% trans "I agree to keep the funder informed of my progress every few days." %}
</label>
</div>
</div>
</div>
<button id="submit" class="row button button--primary btn-interested" type="submit">{% trans "Submit" %}</button>
</form>
{% else %}
<div class="text-center mb-5 mt-4">
<p class="mb-4">This bounty is part of <b>{{bounty.event.name}}</b>.<br>
Please register for the hackathon and read the rules of participation before you continue.</p>
<a href="{% url 'hackathon_onboard' bounty.event.slug %}" class="btn btn-gc-blue">Register for Hackathon</a>
</div>
<button id="submit" class="row button button--primary btn-interested" type="submit">{% trans "Submit" %}</button>
</form>
{% endif %}
</div>
{% else %}
<div class="col-12 text-center">
Expand Down
58 changes: 54 additions & 4 deletions app/dashboard/templates/dashboard/hackathon_onboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ <h1>{{hackathon.name}} Guide</h1>
</div>

<div class="container-fluid p-5">

{% if hackathon.end_date|timesince >= "1 min" %}
<p class="p-3 mt-3 alert-warning">This hackathon event had ended at {{hackathon.end_date}}, please check the <a href="{% url 'get_hackathons' %}">ongoing hackathons</a>.</p>
{% endif %}
Expand Down Expand Up @@ -162,12 +161,63 @@ <h2 class="text-center">How does the Hackathon work?</h2>
</div>
</div>
</div>
<div class="text-center">
<a class="btn btn-lg btn-gc-blue" href="{% url 'hackathon' hackathon.slug %}">Start Hacking</a>
</div>
{% if not github_handle %}

<div class="text-center">
<a class="btn btn-lg btn-gc-blue" href="{% url 'social:begin' 'github' %}?next={{ request.get_full_path }}?referer={{referer}}"
onclick="dataLayer.push({'event': 'login'});">
<i class="fab fa-github"></i>
<span>{% trans "Register with GitHub for Hackathon" %}</span>
</a>
<p class="text-muted mt-2 font-smaller-1">By registering you agree to receive hackathon emails announcements</p>
</div>

{% else %}
<div class="text-center">
{% if is_registered %}
<a class="btn btn-lg btn-gc-blue" href="{% if referer %}{{referer|safe}}{% else %}{% url 'hackathon' hackathon.slug %}{% endif %}">Start Hacking</a>
{% else %}
<a class="btn btn-lg btn-gc-blue" data-registration="{{hackathon.slug}}" data-referer="{{referer}}" href="{% url 'hackathon' hackathon.slug %}">Register for Hackathon</a>
<p class="text-muted mt-2 font-smaller-1">By registering you agree to receive hackathon emails announcements</p>
{% endif %}
</div>
{% endif %}
</div>
{% csrf_token %}
{% include 'shared/analytics.html' %}
{% include 'shared/footer_scripts.html' %}
{% include 'shared/footer.html' %}

<script>
// Send registration
const is_registered = {{ is_registered|yesno:"true,false" }};
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;
}
const url = '/register_hackathon/'
const data = { 'name': name, 'referer': referer}
const sendRegister = fetchData(url, 'POST', data, {'X-CSRFToken': csrftoken});

$.when(sendRegister).then((response) => {
console.log(response)
document.location.href = response.redirect;
});
}
const params = new URLSearchParams(window.location.search);

if (params.get('referer')) {
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)
});
</script>

</body>
4 changes: 2 additions & 2 deletions app/dashboard/templates/profiles/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<div class="container profile-card mt-md-n5 mh-150">
<div class="row">
{% if total_kudos_count %}
<div id=kudos_header>
<div id="kudos_header" class="d-md-block d-none">
{% for kudos_group in my_kudos %}
<img src="{{ kudos_group.kudos_token_cloned_from.preview_img_url }}" title="{{ kudos_group.kudos_token_cloned_from.name|humanize_name }}" class="img-thumbnail border-transparent kd-shadow" width="70">
{% endfor %}
Expand Down Expand Up @@ -118,4 +118,4 @@
{% endif %}
</script>
</body>
</html>
</html>
Loading

0 comments on commit 0fc7943

Please sign in to comment.