Skip to content

Commit

Permalink
Merge branch 'master' into onboard
Browse files Browse the repository at this point in the history
  • Loading branch information
SaptakS authored Mar 27, 2019
2 parents ad02498 + 5ca2520 commit 9d1788b
Show file tree
Hide file tree
Showing 14 changed files with 352 additions and 66 deletions.
4 changes: 4 additions & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@
url(r'^hackathon/ethhack2019', dashboard.views.ethhack, name='ethhack_2019'),
path('revenue/attestations/new', revenue.views.new_attestation, name='revenue_new_attestation'),

# Hackathons / special events
re_path(r'^hackathon/(?P<hackathon>.*)?/', dashboard.views.hackathon, name='hackathon'),
path('hackathon-list/', dashboard.views.get_hackathons, name='get_hackathons'),

# action URLs
url(r'^bounties/funder', retail.views.funder_bounties, name='funder_bounties'),
re_path(
Expand Down
3 changes: 3 additions & 0 deletions app/assets/v2/js/pages/bounty_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,9 @@ const build_uri_for_pull_bounty_from_api = function() {
if (typeof document.issue_stdbounties_id != 'undefined') {
uri = uri + '&standard_bounties_id=' + document.issue_stdbounties_id;
}
if (typeof document.eventTag != 'undefined') {
uri = uri + '&event_tag=' + document.eventTag;
}
return uri;
};

Expand Down
43 changes: 25 additions & 18 deletions app/assets/v2/js/pages/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,14 @@ var get_search_URI = function(offset, order) {
order_by = localStorage['order_by'];
}

if (typeof order_by !== 'undefined') {
uri += '&order_by=' + order_by;
if (!document.hackathon) {
if (typeof order_by !== 'undefined') {
uri += '&order_by=' + order_by;
}
} else {
uri += '&event_tag=' + document.hackathon;
}

uri += '&offset=' + offset;
uri += '&limit=' + results_limit;
return uri;
Expand Down Expand Up @@ -420,31 +425,33 @@ var refreshBounties = function(event, offset, append, do_save_search) {
var orgInput = $('#org')[0];

$('#results-count span.num').html('<i class="fas fa-spinner fa-spin"></i>');
if (searchInput.value.length > 0) {
if (searchInput && searchInput.value.length > 0) {
addTechStackKeywordFilters(searchInput.value.trim());
searchInput.value = '';
searchInput.blur();
$('.close-icon').hide();
}

if (orgInput.value.length > 0) {
addTechStackOrgFilters(orgInput.value.trim());
orgInput.value = '';
orgInput.blur();
$('.close-icon').hide();
}
if (!document.hackathon) {
if (orgInput.value.length > 0) {
addTechStackOrgFilters(orgInput.value.trim());
orgInput.value = '';
orgInput.blur();
$('.close-icon').hide();
}

save_sidebar_latest();
toggleAny(event);
getFilters();
if (do_save_search) {
if (!is_search_already_saved()) {
save_search();
}

save_sidebar_latest();
toggleAny(event);
getFilters();
if (do_save_search) {
if (!is_search_already_saved()) {
save_search();
paint_search_tabs();
window.history.pushState('', '', window.location.pathname + '?' + buildURI());
}
}
paint_search_tabs();

window.history.pushState('', '', '/explorer?' + buildURI());

if (!append) {
$('.nonefound').css('display', 'none');
Expand Down
33 changes: 12 additions & 21 deletions app/assets/v2/js/pages/new_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,37 +176,27 @@ $(document).ready(function() {
setUsdAmount();
}

var open_hiring_panel = function(do_focus) {
var open_panel = function(checkboxSelector, targetSelector, do_focus) {
setTimeout(function() {
var hiringRightNow = $('#hiringRightNow').is(':checked');
var isChecked = $(checkboxSelector).is(':checked');

if (hiringRightNow) {
$('#jobDescription').removeClass('hidden');
if (isChecked) {
$(targetSelector).removeClass('hidden');
if (do_focus) {
$('#jobDescription').focus();
$(targetSelector).focus();
}
} else {
$('#jobDescription').addClass('hidden');
$(targetSelector).addClass('hidden');
}
}, 10);
};

$('#hiringRightNow').on('click', function() {
open_hiring_panel(true);
$('#hiringRightNow').on('click', () => {
open_panel('#hiringRightNow', '#jobDescription', true);
});


$('#advancedLink a').on('click', function(e) {
e.preventDefault();
var target = $('#advanced_container');

if (target.css('display') == 'none') {
target.css('display', 'block');
$(this).text('Advanced ⬆');
} else {
target.css('display', 'none');
$(this).text('Advanced ⬇ ');
}
$('#specialEvent').on('click', () => {
open_panel('#specialEvent', '#eventTag', true);
});

userSearch('#reservedFor', false);
Expand Down Expand Up @@ -264,6 +254,7 @@ $(document).ready(function() {
bountyType: data.bounty_type,
estimatedHours: data.hours,
fundingOrganisation: data.fundingOrganisation,
eventTag: data.specialEvent ? (data.eventTag || '') : '',
is_featured: data.featuredBounty,
repo_type: data.repo_type,
featuring_date: data.featuredBounty && ((new Date().getTime() / 1000) | 0) || 0,
Expand Down Expand Up @@ -300,7 +291,7 @@ $(document).ready(function() {
auto_approve_workers: !!data.auto_approve_workers
},
hiring: {
hiringRightNow: data.hiringRightNow,
hiringRightNow: !!data.hiringRightNow,
jobDescription: data.jobDescription
},
funding_organisation: metadata.fundingOrganisation,
Expand Down
34 changes: 32 additions & 2 deletions app/dashboard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

from .models import (
Activity, BlockedUser, Bounty, BountyFulfillment, BountyInvites, BountySyncRequest, CoinRedemption,
CoinRedemptionRequest, FeedbackEntry, Interest, LabsResearch, Profile, SearchHistory, Tip, TokenApproval, Tool,
ToolVote, UserAction, UserVerificationModel,
CoinRedemptionRequest, FeedbackEntry, HackathonEvent, Interest, LabsResearch, Profile, SearchHistory, Tip,
TokenApproval, Tool, ToolVote, UserAction, UserVerificationModel,
)


Expand Down Expand Up @@ -174,6 +174,35 @@ def network_link(self, instance):
return mark_safe(f"<a href={url}>{copy}</a>")


class HackathonEventAdmin(admin.ModelAdmin):
"""The admin object for the HackathonEvent model."""

list_display = ['pk', 'img', 'name', 'start_date', 'end_date', 'explorer_link']
readonly_fields = ['img', 'explorer_link']

def img(self, instance):
"""Returns a formatted HTML img node or 'n/a' if the HackathonEvent has no logo.
Returns:
str: A formatted HTML img node or 'n/a' if the HackathonEvent has no logo.
"""
logo = instance.logo_svg or instance.logo
if not logo:
return 'n/a'
img_html = format_html('<img src={} style="max-width:30px; max-height: 30px">', mark_safe(logo.url))
return img_html

def explorer_link(self, instance):
"""Returns a formatted HTML <a> node.
Returns:
str: A formatted HTML <a> node.
"""

url = f'/hackathon/{instance.slug}'
return mark_safe(f'<a href="{url}">Explorer Link</a>')


admin.site.register(SearchHistory, SearchHistoryAdmin)
admin.site.register(Activity, ActivityAdmin)
admin.site.register(BlockedUser, GeneralAdmin)
Expand All @@ -190,6 +219,7 @@ def network_link(self, instance):
admin.site.register(CoinRedemptionRequest, GeneralAdmin)
admin.site.register(Tool, ToolAdmin)
admin.site.register(ToolVote, ToolVoteAdmin)
admin.site.register(HackathonEvent, HackathonEventAdmin)
admin.site.register(FeedbackEntry, FeedbackAdmin)
admin.site.register(LabsResearch)
admin.site.register(UserVerificationModel, VerificationAdmin)
13 changes: 12 additions & 1 deletion app/dashboard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
from django.utils import timezone

from app.utils import get_semaphore, sync_profile
from dashboard.models import Activity, Bounty, BountyDocuments, BountyFulfillment, BountySyncRequest, UserAction
from dashboard.models import (
Activity, Bounty, BountyDocuments, BountyFulfillment, BountySyncRequest, HackathonEvent, UserAction,
)
from dashboard.notifications import (
maybe_market_to_email, maybe_market_to_github, maybe_market_to_slack, maybe_market_to_twitter,
maybe_market_to_user_discord, maybe_market_to_user_slack,
Expand Down Expand Up @@ -480,6 +482,15 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id):
except Exception as e:
logger.error(e)

event_tag = metadata.get('eventTag', '')
if event_tag:
try:
evt = HackathonEvent.objects.filter(name__iexact=event_tag).latest('id')
new_bounty.event = evt
new_bounty.save()
except Exception as e:
logger.error(e)

# migrate data objects from old bounty
if latest_old_bounty:
# Pull the interested parties off the last old_bounty
Expand Down
37 changes: 37 additions & 0 deletions app/dashboard/migrations/0024_auto_20190326_1759.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 2.1.7 on 2019-03-26 17:59

from django.db import migrations, models
import django.db.models.deletion
import economy.models


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0023_auto_20190325_1404'),
]

operations = [
migrations.CreateModel(
name='HackathonEvent',
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(max_length=255)),
('slug', models.SlugField(blank=True)),
('logo', models.ImageField(blank=True, upload_to='')),
('logo_svg', models.FileField(blank=True, upload_to='')),
('start_date', models.DateTimeField()),
('end_date', models.DateTimeField()),
],
options={
'abstract': False,
},
),
migrations.AddField(
model_name='bounty',
name='event',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='bounties', to='dashboard.HackathonEvent'),
),
]
26 changes: 26 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ class Bounty(SuperModel):
default=False, help_text=_('Admin override to mark as remarketing ready')
)
attached_job_description = models.URLField(blank=True, null=True)
event = models.ForeignKey('dashboard.HackathonEvent', related_name='bounties', null=True, on_delete=models.SET_NULL)

# Bounty QuerySet Manager
objects = BountyQuerySet.as_manager()
Expand Down Expand Up @@ -2950,6 +2951,31 @@ def __str__(self):
return f'<BlockedUser: {self.handle}>'


class HackathonEvent(SuperModel):
"""Defines the HackathonEvent model."""

name = models.CharField(max_length=255)
slug = models.SlugField(blank=True)
logo = models.ImageField(blank=True)
logo_svg = models.FileField(blank=True)
start_date = models.DateTimeField()
end_date = models.DateTimeField()

def __str__(self):
"""String representation for HackathonEvent.
Returns:
str: The string representation of a HackathonEvent.
"""
return f'{self.name} - {self.start_date}'

def save(self, *args, **kwargs):
"""Define custom handling for saving HackathonEvent."""
from django.utils.text import slugify
if not self.slug:
self.slug = slugify(self.name)
super().save(*args, **kwargs)

class FeedbackEntry(SuperModel):
bounty = models.ForeignKey(
'dashboard.Bounty',
Expand Down
13 changes: 12 additions & 1 deletion app/dashboard/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from retail.helpers import get_ip

from .models import (
Activity, Bounty, BountyDocuments, BountyFulfillment, BountyInvites, Interest, ProfileSerializer, SearchHistory,
Activity, Bounty, BountyDocuments, BountyFulfillment, BountyInvites, HackathonEvent, Interest, ProfileSerializer,
SearchHistory,
)


Expand Down Expand Up @@ -195,6 +196,16 @@ def get_queryset(self):
queryset = queryset.order_by('-web3_created')

# filtering
event_tag = self.request.query_params.get('event_tag', '')
if event_tag:
try:
evt = HackathonEvent.objects.filter(slug__iexact=event_tag).latest('id')
queryset = queryset.filter(event__pk=evt.pk)
except HackathonEvent.DoesNotExist:
return Bounty.objects.none()
else:
queryset = queryset.filter(event=None)

for key in ['raw_data', 'experience_level', 'project_length', 'bounty_type', 'bounty_owner_address',
'idx_status', 'network', 'bounty_owner_github_username', 'standard_bounties_id',
'permission_type', 'project_type']:
Expand Down
3 changes: 3 additions & 0 deletions app/dashboard/templates/bounty/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ <h5 class="bounty-heading">{% trans "Funder" %}</h5>
document.issueURL = '{{ issueURL }}';
document.issueNetwork = '{{ network }}';
document.issue_stdbounties_id = '{{ stdbounties_id }}';
{% if event_tag %}
document.eventTag = '{{ event_tag }}';
{% endif %}
</script>

<!-- jQuery -->
Expand Down
24 changes: 21 additions & 3 deletions app/dashboard/templates/bounty/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ <h5 class="font-subheader">{% trans "Contact" %}</h5>
{% include 'shared/notification_email.html' with show_information_publicly_checkbox=1 %}
{% include 'shared/github_username.html' %}
</div>
<div id="advanced_container"></div>
<hr class="mt-4">
</div>
{% include 'shared/pricing.html' %}
Expand All @@ -184,9 +183,28 @@ <h5 class="font-subheader">{% trans "Contact" %}</h5>
<label class="form__label" for=hiringRightNow>{% trans "I am hiring for a full time, part time, or contract position, right now and would like Gitcoin to attach this job description to the bounty." %}
</label>
</div>
<hr class="mt-4">
<input name='jobDescription' id='jobDescription' type="url" class="form__input hidden" type="text" placeholder="https://link.to/job/description" value="" />
<hr class="mt-4">
</div>
</div>
<div class="w-100 mt-2">
<div class="form__checkbox">
<input name="specialEvent" id="specialEvent" type="checkbox" value=1 />
<label class="form__label" for="specialEvent">
{% trans 'Is this Bounty part of a Hackathon or Special Event?' %}
</label>
</div>
<input name='jobDescription' id='jobDescription' type="url" class="form__input hidden" type="text" placeholder="https://link.to/job/description" value="" />
<div id="eventTag" class="hidden">
<label class="form__label" for="eventTag">{% trans "Choose Event" %}</label>
<div class="form__select2">
<select class="js-select2" name="eventTag" id="eventTag">
{% for evt in events %}
<option value="{{ evt.name }}">{{ evt.name }}</option>
{% endfor %}
</select>
</div>
</div>
<hr class="mt-4"/>
</div>
<div id="gas-section" class="pt-2">
<h5 class="font-subheader pb-2">{% trans "Gas Settings" %}</h5>
Expand Down
Loading

0 comments on commit 9d1788b

Please sign in to comment.