Skip to content

Commit

Permalink
Merge pull request #4495 from gitcoinco/add-categories
Browse files Browse the repository at this point in the history
Add bounty categories
  • Loading branch information
octavioamu authored Jun 12, 2019
2 parents 0f62865 + 3a2fb35 commit 3930b9f
Show file tree
Hide file tree
Showing 28 changed files with 8,964 additions and 44 deletions.
7 changes: 3 additions & 4 deletions app/assets/v2/css/fontawesome-all.min.css

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion app/assets/v2/css/forms/input.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ textarea.form__input {
padding: 8px;
}

.form__input + label.error {
.form__input + label.error,
.cat-error .error,
.form__select2 .error {
color: #D50000;
margin-bottom: 0;
display: block;
Expand Down
19 changes: 19 additions & 0 deletions app/assets/v2/js/pages/bounty_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ var rows = [
'bounty_type',
'expires_date',
'issue_keywords',
'bounty_categories',
'started_owners_username',
'submitted_owners_username',
'fulfilled_owners_username',
Expand Down Expand Up @@ -174,6 +175,24 @@ var callbacks = {
'funding_organisation': function(key, val, result) {
return [ 'funding_organisation', result.funding_organisation ];
},
'bounty_categories': function(key, val, result) {
if (!result.bounty_categories || result.bounty_categories.length == 0)
return [ 'bounty_categories', null ];

const categories = [];
const categoryObj = {
frontend: '<span class="badge badge-secondary mr-1"><i class="fas fa-laptop-code"></i> Front End</span>',
backend: '<span class="badge badge-secondary mr-1"><i class="fas fa-code"></i> Back End</span>',
design: '<span class="badge badge-secondary mr-1"><i class="fas fa-pencil-ruler"></i> Design</span>',
documentation: '<span class="badge badge-secondary mr-1"><i class="fas fa-file-alt"></i> Documentation</span>',
other: '<span class="badge badge-secondary mr-1"><i class="fas fa-briefcase"></i> Other</span>'
};

result.bounty_categories.forEach(function(category) {
categories.push(categoryObj[category]);
});
return [ 'bounty_categories', categories ];
},
'permission_type': function(key, val, result) {
if (val == 'approval') {
val = 'Approval Required';
Expand Down
31 changes: 28 additions & 3 deletions app/assets/v2/js/pages/change_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ $(document).ready(function() {
break;
case 'checkbox':
ctrl.each(function() {
$(this).prop('checked', value);
if (value.length) {
$.each(value, function(key, val) {
$(`.${val}`).button('toggle');
});
} else {
$(this).prop('checked', value);
}
});
break;
default:
ctrl.val(value);
if (value > 0) {
ctrl.val(value);
}
}
});

Expand Down Expand Up @@ -74,13 +82,30 @@ $(document).ready(function() {
);

form.validate({
errorPlacement: function(error, element) {
if (element.attr('name') == 'bounty_categories') {
error.appendTo($(element).parents('.btn-group-toggle').next('.cat-error'));
} else {
error.insertAfter(element);
}
},
ignore: '',
messages: {
select2Start: {
required: 'Please select the right keywords.'
}
},
submitHandler: function(form) {
const inputElements = $(form).find(':input');
const formData = {};

inputElements.removeAttr('disabled');
$.each($(form).serializeArray(), function() {
formData[this.name] = this.value;
if (formData[this.name]) {
formData[this.name] += ',' + this.value;
} else {
formData[this.name] = this.value;
}
});
inputElements.attr('disabled', 'disabled');

Expand Down
16 changes: 15 additions & 1 deletion app/assets/v2/js/pages/new_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,19 @@ $('#specialEvent').on('click', () => {
});

$('#submitBounty').validate({
errorPlacement: function(error, element) {
if (element.attr('name') == 'bounty_category') {
error.appendTo($(element).parents('.btn-group-toggle').next('.cat-error'));
} else {
error.insertAfter(element);
}
},
ignore: '',
messages: {
select2Start: {
required: 'Please select the right keywords.'
}
},
submitHandler: function(form) {
try {
bounty_address();
Expand Down Expand Up @@ -447,7 +460,8 @@ $('#submitBounty').validate({
featuring_date: data.featuredBounty && ((new Date().getTime() / 1000) | 0) || 0,
reservedFor: reservedFor ? reservedFor.text : '',
tokenName,
invite: inviteContributors
invite: inviteContributors,
bounty_categories: data.bounty_category
};

var privacy_preferences = {
Expand Down
Binary file modified app/assets/v2/webfonts/fa-brands-400.eot
Binary file not shown.
3,453 changes: 3,452 additions & 1 deletion app/assets/v2/webfonts/fa-brands-400.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/v2/webfonts/fa-brands-400.ttf
Binary file not shown.
Binary file modified app/assets/v2/webfonts/fa-brands-400.woff
Binary file not shown.
Binary file modified app/assets/v2/webfonts/fa-brands-400.woff2
Binary file not shown.
Binary file modified app/assets/v2/webfonts/fa-regular-400.eot
Binary file not shown.
804 changes: 803 additions & 1 deletion app/assets/v2/webfonts/fa-regular-400.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/v2/webfonts/fa-regular-400.ttf
Binary file not shown.
Binary file modified app/assets/v2/webfonts/fa-regular-400.woff
Binary file not shown.
Binary file modified app/assets/v2/webfonts/fa-regular-400.woff2
Binary file not shown.
Binary file modified app/assets/v2/webfonts/fa-solid-900.eot
Binary file not shown.
4,528 changes: 4,527 additions & 1 deletion app/assets/v2/webfonts/fa-solid-900.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/v2/webfonts/fa-solid-900.ttf
Binary file not shown.
Binary file modified app/assets/v2/webfonts/fa-solid-900.woff
Binary file not shown.
Binary file modified app/assets/v2/webfonts/fa-solid-900.woff2
Binary file not shown.
15 changes: 8 additions & 7 deletions app/dashboard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id):
url = normalize_url(url)
else:
raise UnsupportedSchemaException('No webReferenceURL found. Cannot continue!')

# check conditions for private repos
if metadata.get('repo_type', None) == 'private' and \
bounty_payload.get('schemes', {}).get('permission_type', 'permissionless') != 'approval' and \
Expand Down Expand Up @@ -455,6 +455,7 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id):
'contract_address': bounty_details.get('token'),
'network': bounty_details.get('network'),
'bounty_type': metadata.get('bountyType', ''),
'bounty_categories': metadata.get('bounty_categories', '').split(','),
'funding_organisation': metadata.get('fundingOrganisation', ''),
'project_length': metadata.get('projectLength', ''),
'estimated_hours': metadata.get('estimatedHours'),
Expand Down Expand Up @@ -482,12 +483,12 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id):
fields=[
'web3_created', 'github_url', 'token_name', 'token_address', 'privacy_preferences', 'expires_date',
'title', 'issue_description', 'balance', 'contract_address', 'network', 'bounty_type',
'project_length', 'experience_level', 'project_type', 'permission_type', 'attached_job_description',
'bounty_owner_github_username', 'bounty_owner_address', 'bounty_owner_email', 'bounty_owner_name',
'github_comments', 'override_status', 'last_comment_date', 'snooze_warnings_for_days',
'admin_override_and_hide', 'admin_override_suspend_auto_approval', 'admin_mark_as_remarket_ready',
'funding_organisation', 'bounty_reserved_for_user', 'is_featured', 'featuring_date', 'coupon_code',
'fee_tx_id', 'fee_amount', 'repo_type', 'unsigned_nda'
'bounty_categories', 'project_length', 'experience_level', 'project_type', 'permission_type',
'attached_job_description', 'bounty_owner_github_username', 'bounty_owner_address',
'bounty_owner_email', 'bounty_owner_name', 'github_comments', 'override_status', 'last_comment_date',
'snooze_warnings_for_days', 'admin_override_and_hide', 'admin_override_suspend_auto_approval',
'admin_mark_as_remarket_ready', 'funding_organisation', 'bounty_reserved_for_user', 'is_featured',
'featuring_date', 'fee_tx_id', 'fee_amount', 'repo_type', 'unsigned_nda', 'coupon_code'
],
)
if latest_old_bounty_dict['bounty_reserved_for_user']:
Expand Down
19 changes: 19 additions & 0 deletions app/dashboard/migrations/0033_bounty_bounty_categories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.1.7 on 2019-06-12 18:40

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0032_auto_20190601_1103'),
]

operations = [
migrations.AddField(
model_name='bounty',
name='bounty_categories',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(choices=[('frontend', 'frontend'), ('backend', 'backend'), ('design', 'design'), ('documentation', 'documentation'), ('other', 'other')], max_length=50), default=list, size=None),
),
]
10 changes: 9 additions & 1 deletion app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ class Bounty(SuperModel):
('contest', 'contest'),
('cooperative', 'cooperative'),
]
BOUNTY_CATEGORIES = [
('frontend', 'frontend'),
('backend', 'backend'),
('design', 'design'),
('documentation', 'documentation'),
('other', 'other'),
]
BOUNTY_TYPES = [
('Bug', 'Bug'),
('Security', 'Security'),
Expand Down Expand Up @@ -275,6 +282,7 @@ class Bounty(SuperModel):
canceled_on = models.DateTimeField(null=True, blank=True)
canceled_bounty_reason = models.TextField(default='', blank=True, verbose_name=_('Cancelation reason'))
project_type = models.CharField(max_length=50, choices=PROJECT_TYPES, default='traditional')
bounty_categories = ArrayField(models.CharField(max_length=50, choices=BOUNTY_CATEGORIES), default=list)
permission_type = models.CharField(max_length=50, choices=PERMISSION_TYPES, default='permissionless')
repo_type = models.CharField(max_length=50, choices=REPO_TYPES, default='public')
snooze_warnings_for_days = models.IntegerField(default=0)
Expand Down Expand Up @@ -2841,7 +2849,7 @@ def to_representation(self, instance):
dict: The serialized Profile.
"""

return {
'id': instance.id,
'handle': instance.handle,
Expand Down
28 changes: 15 additions & 13 deletions app/dashboard/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,20 @@ class Meta:
model = Bounty
fields = (
'url', 'created_on', 'modified_on', 'title', 'web3_created', 'value_in_token', 'token_name',
'token_address', 'bounty_type', 'project_length', 'experience_level', 'github_url', 'github_comments',
'bounty_owner_address', 'bounty_owner_email', 'bounty_owner_github_username', 'bounty_owner_name',
'fulfillments', 'interested', 'is_open', 'expires_date', 'activities', 'keywords', 'current_bounty',
'value_in_eth', 'token_value_in_usdt', 'value_in_usdt_now', 'value_in_usdt', 'status', 'now', 'avatar_url',
'token_address', 'bounty_type', 'bounty_categories', 'project_length', 'experience_level',
'github_url', 'github_comments', 'bounty_owner_address', 'bounty_owner_email',
'bounty_owner_github_username', 'bounty_owner_name', 'fulfillments', 'interested', 'is_open',
'expires_date', 'activities', 'keywords', 'current_bounty', 'value_in_eth',
'token_value_in_usdt', 'value_in_usdt_now', 'value_in_usdt', 'status', 'now', 'avatar_url',
'value_true', 'issue_description', 'network', 'org_name', 'pk', 'issue_description_text',
'standard_bounties_id', 'web3_type', 'can_submit_after_expiration_date', 'github_issue_number',
'github_org_name', 'github_repo_name', 'idx_status', 'token_value_time_peg', 'fulfillment_accepted_on',
'fulfillment_submitted_on', 'fulfillment_started_on', 'canceled_on', 'canceled_bounty_reason',
'action_urls', 'project_type', 'permission_type', 'attached_job_description', 'needs_review',
'github_issue_state', 'is_issue_closed', 'additional_funding_summary', 'funding_organisation', 'paid',
'admin_override_suspend_auto_approval', 'reserved_for_user_handle', 'is_featured', 'featuring_date', 'repo_type',
'unsigned_nda', 'funder_last_messaged_on',
'github_org_name', 'github_repo_name', 'idx_status', 'token_value_time_peg',
'fulfillment_accepted_on', 'fulfillment_submitted_on', 'fulfillment_started_on', 'canceled_on',
'canceled_bounty_reason', 'action_urls', 'project_type', 'permission_type',
'attached_job_description', 'needs_review', 'github_issue_state', 'is_issue_closed',
'additional_funding_summary', 'funding_organisation', 'paid',
'admin_override_suspend_auto_approval', 'reserved_for_user_handle', 'is_featured',
'featuring_date', 'repo_type', 'unsigned_nda', 'funder_last_messaged_on',
)

def create(self, validated_data):
Expand Down Expand Up @@ -225,9 +227,9 @@ def get_queryset(self):
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']:
for key in ['raw_data', 'experience_level', 'project_length', 'bounty_type', 'bounty_categories',
'bounty_owner_address', 'idx_status', 'network', 'bounty_owner_github_username',
'standard_bounties_id', 'permission_type', 'project_type']:
if key in param_keys:
# special hack just for looking up bounties posted by a certain person
request_key = key if key != 'bounty_owner_address' else 'coinbase'
Expand Down
30 changes: 27 additions & 3 deletions app/dashboard/templates/bounty/change.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ <h1 class="text-center title">{% trans "Change Bounty Details" %}</h1>
</div>
</div>
</div>
<div class="mt-4">
<label class="font-caption letter-spacing text-black-60 text-uppercase" for=issueURL>{% trans "Bounty category" %} <span class="badge badge-greylight text-capitalize">Required</span></label>
<p class="font-body">Pick the most accurate categories for this bounty to get the right contributors</p>

<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-radio frontend mr-2 font-weight-bold py-2 px-4" for="frontend_cat">
<input type="checkbox" name="bounty_categories" id="frontend_cat" value="frontend" autocomplete="off" required><i class="fas fa-laptop-code mr-2"></i> {% trans "Front End" %}
</label>
<label class="btn btn-radio backend mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="backend_cat" value="backend" autocomplete="off" required><i class="fas fa-code mr-2"></i> {% trans "Back End" %}
</label>
<label class="btn btn-radio design mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="design_cat" value="design" autocomplete="off" required><i class="fas fa-pencil-ruler mr-2"></i> {% trans "Design" %}
</label>
<label class="btn btn-radio doc mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="doc_cat" value="doc" autocomplete="off" required><i class="fas fa-file-alt mr-2"></i> {% trans "Documentation" %}
</label>
<label class="btn btn-radio other font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="other_cat" value="other" autocomplete="off" required><i class="fas fa-briefcase mr-2"></i> {% trans "Other" %}
</label>
</div>
<div class="cat-error"></div>

</div>
<div class="mt-4">
{% include 'shared/reserved.html' %}
</div>
Expand All @@ -101,7 +125,7 @@ <h1 class="text-center title">{% trans "Change Bounty Details" %}</h1>
</div>
{% include 'shared/bottom_notification.html' %}
{% include 'shared/analytics.html' %}
{% include 'shared/footer_scripts.html' %}
{% include 'shared/footer_scripts_lite.html' %}
{% include 'shared/footer.html' %}
{% include 'shared/messages.html' %}
{% include 'shared/current_profile.html' %}
Expand All @@ -110,9 +134,9 @@ <h1 class="text-center title">{% trans "Change Bounty Details" %}</h1>
document.pk = {{ pk }};
document.result = {{ result|safe }};
</script>
<script src="{% static "v2/js/lib/jquery.validate.min.js" %}"></script>
<script src="{% static "v2/js/shared.js" %}"></script>
<script src="{% static "v2/js/amounts.js" %}"></script>
<script src="{% static "v2/js/lib/popper.min.js" %}"></script>
<script src="{% static "v2/js/lib/bootstrap.min.js" %}" crossorigin="anonymous"></script>
<script src="{% static "v2/js/user-search.js" %}"></script>
<script src="{% static "v2/js/pages/change_bounty.js" %}"></script>
</html>
4 changes: 3 additions & 1 deletion app/dashboard/templates/bounty/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ <h4 id="title" class="font-title"></h4>
<span>USD</span>
</p>
</div>
<div class="d-inline-block font-subheader" id="bounty_categories"></div>
</div>

</div>
<div class="notif-info mb-3 font-caption" id="funder_notif_info"></div>
</div>
Expand Down Expand Up @@ -447,7 +449,7 @@ <h5 class="bounty-heading">{% trans "Funder" %}</h5>
<script>
$.fn.runTooltip = bootstrapTooltip
$('[data-toggle="popover"]').popover()

$("body").on("mouseover", "[data-username] img", function(e) {
openContributorPopOver($(this).parent().data("username"), $(this));
});
Expand Down
Loading

0 comments on commit 3930b9f

Please sign in to comment.