Skip to content

Commit

Permalink
chore: bounty fulfilment changes (#6670)
Browse files Browse the repository at this point in the history
* chore: bounty fulfilment changes

- remove fields which aren't needed from bounty submission UI
- make fulfiller_email, fulfiller_name into a prop
- remove fulfiller_github_username
- update code references which use the removed db fields

* create migrations

* fix tests
  • Loading branch information
thelostone-mc authored May 20, 2020
1 parent 1e2d273 commit cc18786
Show file tree
Hide file tree
Showing 25 changed files with 100 additions and 165 deletions.
55 changes: 2 additions & 53 deletions app/app/fixtures/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -5803,9 +5803,6 @@
"created_on": "2019-06-09T18:31:03.534Z",
"modified_on": "2019-06-09T18:31:03.536Z",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_email": "",
"fulfiller_github_username": "test3",
"fulfiller_name": "",
"fulfiller_metadata": {
"id": 0,
"data": {
Expand Down Expand Up @@ -5849,9 +5846,6 @@
"created_on": "2019-06-09T18:31:12.409Z",
"modified_on": "2019-06-09T18:31:12.411Z",
"fulfiller_address": "0xeDa95eD3e3436C689376889F9eD0a8f4bA23E866",
"fulfiller_email": "[email protected]",
"fulfiller_github_username": "octavioamu",
"fulfiller_name": "",
"fulfiller_metadata": {
"id": 0,
"data": {
Expand Down Expand Up @@ -5895,9 +5889,6 @@
"created_on": "2019-06-09T18:31:07.439Z",
"modified_on": "2019-06-09T19:00:10.461Z",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_email": "",
"fulfiller_github_username": "test4",
"fulfiller_name": "",
"fulfiller_metadata": {
"id": 0,
"data": {
Expand Down Expand Up @@ -5941,9 +5932,6 @@
"created_on": "2019-06-09T18:31:07.446Z",
"modified_on": "2019-06-09T19:00:10.479Z",
"fulfiller_address": "0xCC4b3DE30576E161C8632786560Fa7DD3Fb33f77",
"fulfiller_email": "",
"fulfiller_github_username": "test5",
"fulfiller_name": "",
"fulfiller_metadata": {
"id": 1,
"data": {
Expand Down Expand Up @@ -5987,9 +5975,6 @@
"created_on": "2019-06-09T18:31:07.452Z",
"modified_on": "2019-06-09T19:00:10.496Z",
"fulfiller_address": "0x0B8C767a91DdbE99ABA14685d03B14D4265c1E5B",
"fulfiller_email": "",
"fulfiller_github_username": "owocki",
"fulfiller_name": "",
"fulfiller_metadata": {
"id": 2,
"data": {
Expand Down Expand Up @@ -6033,9 +6018,6 @@
"created_on": "2019-06-09T18:31:07Z",
"modified_on": "2019-06-10T09:49:45.646Z",
"fulfiller_address": "0xBcAfdD642118e5536024675e776d32413728dd08",
"fulfiller_email": "",
"fulfiller_github_username": "test3",
"fulfiller_name": "",
"fulfiller_metadata": {
"id": 3,
"data": {
Expand Down Expand Up @@ -6079,9 +6061,6 @@
"created_on": "2019-06-09T18:31:07Z",
"modified_on": "2019-06-10T09:49:38.760Z",
"fulfiller_address": "0xCC4b3DE30576E161C8632786560Fa7DD3Fb33f77",
"fulfiller_email": "",
"fulfiller_github_username": "test10",
"fulfiller_name": "",
"fulfiller_metadata": {
"id": 4,
"data": {
Expand Down Expand Up @@ -6125,9 +6104,6 @@
"created_on": "2019-06-10T09:41:33Z",
"modified_on": "2019-06-10T09:42:42.114Z",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_email": "",
"fulfiller_github_username": "",
"fulfiller_name": "",
"fulfiller_metadata": {},
"fulfillment_id": null,
"fulfiller_hours_worked": null,
Expand All @@ -6146,9 +6122,6 @@
"created_on": "2019-06-10T09:42:47Z",
"modified_on": "2019-06-10T09:43:16.481Z",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_email": "",
"fulfiller_github_username": "",
"fulfiller_name": "",
"fulfiller_metadata": {},
"fulfillment_id": null,
"fulfiller_hours_worked": null,
Expand All @@ -6167,9 +6140,6 @@
"created_on": "2019-06-10T09:43:34Z",
"modified_on": "2019-06-10T09:44:16.848Z",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_email": "",
"fulfiller_github_username": "",
"fulfiller_name": "",
"fulfiller_metadata": {},
"fulfillment_id": null,
"fulfiller_hours_worked": null,
Expand All @@ -6188,9 +6158,6 @@
"created_on": "2019-06-10T09:44:29Z",
"modified_on": "2019-06-10T09:45:03.943Z",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_email": "",
"fulfiller_github_username": "",
"fulfiller_name": "",
"fulfiller_metadata": {},
"fulfillment_id": null,
"fulfiller_hours_worked": null,
Expand All @@ -6209,9 +6176,6 @@
"created_on": "2019-06-10T09:52:43Z",
"modified_on": "2019-06-10T09:53:12.807Z",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_email": "",
"fulfiller_github_username": "",
"fulfiller_name": "",
"fulfiller_metadata": {},
"fulfillment_id": null,
"fulfiller_hours_worked": null,
Expand All @@ -6230,9 +6194,6 @@
"created_on": "2019-06-27T01:08:08.620Z",
"modified_on": "2019-06-27T01:08:08.625Z",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_email": "",
"fulfiller_github_username": "test4",
"fulfiller_name": "",
"fulfiller_metadata": {
"id": 0,
"data": {
Expand Down Expand Up @@ -6276,9 +6237,6 @@
"created_on": "2019-06-27T01:08:08.635Z",
"modified_on": "2019-06-27T01:08:08.640Z",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_email": "",
"fulfiller_github_username": "test4",
"fulfiller_name": "",
"fulfiller_metadata": {
"id": 1,
"data": {
Expand Down Expand Up @@ -6322,9 +6280,6 @@
"created_on": "2019-06-30T19:27:18.223Z",
"modified_on": "2019-06-30T19:27:18.234Z",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_email": "",
"fulfiller_github_username": "test8",
"fulfiller_name": "",
"fulfiller_metadata": {
"id": 0,
"data": {
Expand Down Expand Up @@ -7321,9 +7276,7 @@
"id": 19,
"accepted": false,
"accepted_on": "None",
"fulfiller_name": "",
"fulfillment_id": 1,
"fulfiller_email": "",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_metadata": {
"id": 1,
Expand Down Expand Up @@ -7352,8 +7305,7 @@
"fulfiller": "0x27FC067c91f1bA562C7978920722B07B70122897"
},
"fulfiller_github_url": "",
"fulfiller_hours_worked": "20.00",
"fulfiller_github_username": "test4"
"fulfiller_hours_worked": "20.00"
}
},
"needs_review": false
Expand Down Expand Up @@ -7595,9 +7547,7 @@
"id": 20,
"accepted": false,
"accepted_on": "None",
"fulfiller_name": "",
"fulfillment_id": 0,
"fulfiller_email": "",
"fulfiller_address": "0x27FC067c91f1bA562C7978920722B07B70122897",
"fulfiller_metadata": {
"id": 0,
Expand Down Expand Up @@ -7626,8 +7576,7 @@
"fulfiller": "0x27FC067c91f1bA562C7978920722B07B70122897"
},
"fulfiller_github_url": "",
"fulfiller_hours_worked": "100.00",
"fulfiller_github_username": "test8"
"fulfiller_hours_worked": "100.00"
}
},
"needs_review": false
Expand Down
2 changes: 1 addition & 1 deletion app/assets/v2/js/pages/change_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const getSuggestions = () => {
}

obj.children.forEach(children => {
children.text = children.fulfiller_github_username || children.user__profile__handle;
children.text = children.profile__handle || children.user__profile__handle;
children.id = generalIndex;
generalIndex++;
});
Expand Down
2 changes: 0 additions & 2 deletions app/assets/v2/js/pages/fulfill_bounty/ETH.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const ethFulfillBounty = data => {
loading_button($('.js-submit'));
const githubUsername = data.githubUsername;
const issueURL = data.issueURL;
const notificationEmail = data.notificationEmail;
const githubPRLink = data.githubPRLink;
const hoursWorked = data.hoursWorked;
const address = data.payoutAddress;
Expand All @@ -46,7 +45,6 @@ const ethFulfillBounty = data => {
fulfiller: {
githubPRLink: githubPRLink,
hoursWorked: hoursWorked,
email: notificationEmail,
githubUsername: githubUsername,
address: address
},
Expand Down
3 changes: 0 additions & 3 deletions app/assets/v2/js/pages/fulfill_bounty/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ window.onload = function() {
$('input[name=githubUsername]').val(localStorage['githubUsername']);
}
}
if (typeof localStorage['notificationEmail'] != 'undefined') {
$('input[name=notificationEmail]').val(localStorage['notificationEmail']);
}
if (getParam('source')) {
$('input[name=issueURL]').val(getParam('source'));
}
Expand Down
2 changes: 0 additions & 2 deletions app/assets/v2/js/pages/fulfill_bounty/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ fulfillBounty = data => {
'data': {
'payload': {
'fulfiller': {
'email': data.notificationEmail,
'address': data.payoutAddress,
'hoursWorked': data.hoursWorked,
'githubPRLink': data.githubPRLink
Expand All @@ -33,7 +32,6 @@ fulfillBounty = data => {

const params = {
'issueURL': data.issueURL,
'email': data.notificationEmail,
'githubPRLink': data.githubPRLink,
'hoursWorked': data.hoursWorked,
'metadata': JSON.stringify(metadata),
Expand Down
4 changes: 2 additions & 2 deletions app/dashboard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class BountyEventAdmin(admin.ModelAdmin):

class BountyFulfillmentAdmin(admin.ModelAdmin):
raw_id_fields = ['bounty', 'profile']
readonly_fields = ['fulfiller_github_username']
list_display = ['id', 'bounty', 'profile', 'fulfiller_github_url']
search_fields = [
'fulfiller_address', 'fulfiller_email', 'fulfiller_github_username',
'fulfiller_name', 'fulfiller_metadata', 'fulfiller_github_url'
'fulfiller_address', 'fulfiller_metadata', 'fulfiller_github_url'
]
ordering = ['-id']

Expand Down
12 changes: 2 additions & 10 deletions app/dashboard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,6 @@ def handle_bounty_fulfillments(fulfillments, new_bounty, old_bounty):
try:
created_on = timezone.now()
modified_on = timezone.now()
fulfiller_email = fulfillment.get('data', {}).get(
'payload', {}).get('fulfiller', {}).get('email', '')
fulfiller_name = fulfillment.get('data', {}).get(
'payload', {}).get('fulfiller', {}).get('name', '')
fulfiller_github_url = fulfillment.get('data', {}).get(
'payload', {}).get('fulfiller', {}).get('githubPRLink', '')
hours_worked = fulfillment.get('data', {}).get(
Expand All @@ -372,9 +368,6 @@ def handle_bounty_fulfillments(fulfillments, new_bounty, old_bounty):
tenant = 'ETH',
token_name=new_bounty.token_name,
fulfiller_address=fulfiller_address,
fulfiller_email=fulfiller_email,
fulfiller_github_username=github_username,
fulfiller_name=fulfiller_name,
fulfiller_metadata=fulfillment,
fulfillment_id=fulfillment.get('id'),
fulfiller_github_url=fulfiller_github_url,
Expand Down Expand Up @@ -767,7 +760,6 @@ def get_fulfillment_data_for_activity(fulfillment):
'fulfiller_address': fulfillment.fulfiller_address,
'fulfiller_email': fulfillment.fulfiller_email,
'fulfiller_github_username': fulfillment.fulfiller_github_username,
'fulfiller_name': fulfillment.fulfiller_name,
'fulfiller_metadata': fulfillment.fulfiller_metadata,
'fulfillment_id': fulfillment.fulfillment_id,
'fulfiller_hours_worked': str(fulfillment.fulfiller_hours_worked),
Expand Down Expand Up @@ -823,9 +815,9 @@ def record_bounty_activity(event_name, old_bounty, new_bounty, _fulfillment=None
if event_name == 'work_done':
fulfillment = new_bounty.fulfillments.filter(accepted=True).latest('fulfillment_id')
if fulfillment:
user_profile = Profile.objects.filter(handle=fulfillment.fulfiller_github_username.lower()).first()
user_profile = Profile.objects.filter(handle=fulfillment.profile__handle.lower()).first()
if not user_profile:
user_profile = sync_profile(fulfillment.fulfiller_github_username)
user_profile = sync_profile(fulfillment.profile__handle)

except Exception as e:
logger.error(f'{e} during record_bounty_activity for {new_bounty}')
Expand Down
25 changes: 25 additions & 0 deletions app/dashboard/migrations/0111_auto_20200520_0457.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 2.2.4 on 2020-05-20 04:57

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0110_auto_20200519_1417'),
]

operations = [
migrations.RemoveField(
model_name='bountyfulfillment',
name='fulfiller_email',
),
migrations.RemoveField(
model_name='bountyfulfillment',
name='fulfiller_github_username',
),
migrations.RemoveField(
model_name='bountyfulfillment',
name='fulfiller_name',
),
]
24 changes: 11 additions & 13 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def keywords_list(self):

@property
def fulfillers_handles(self):
bounty_fulfillers = self.fulfillments.filter(accepted=True).values_list('fulfiller_github_username', flat=True)
bounty_fulfillers = self.fulfillments.filter(accepted=True).values_list('profile__handle', flat=True)
tip_fulfillers = self.tips.values_list('username', flat=True)
return list(bounty_fulfillers) + list(tip_fulfillers)

Expand Down Expand Up @@ -1362,12 +1362,6 @@ class BountyFulfillment(SuperModel):
profile = models.ForeignKey('dashboard.Profile', related_name='fulfilled', on_delete=models.CASCADE, null=True, help_text="fulfillers's profile")
funder_profile = models.ForeignKey('dashboard.Profile', null=True, on_delete=models.CASCADE, help_text="funder's profile")

# TODO: MAKE AS PROP
fulfiller_email = models.CharField(max_length=255, blank=True)
# TODO: MAKE AS PROP
fulfiller_github_username = models.CharField(max_length=255, blank=True)
# TODO: MAKE AS PROP
fulfiller_name = models.CharField(max_length=255, blank=True)

# TODO: rename to hours_worked
fulfiller_hours_worked = models.DecimalField(null=True, blank=True, decimal_places=2, max_digits=50)
Expand Down Expand Up @@ -1398,17 +1392,22 @@ def __str__(self):
"""
return f'BountyFulfillment ID: ({self.pk}) - Bounty ID: ({self.bounty.pk})'

def save(self, *args, **kwargs):
"""Define custom handling for saving bounty fulfillments."""
if self.fulfiller_github_username:
self.fulfiller_github_username = self.fulfiller_github_username.lstrip('@')
super().save(*args, **kwargs)

@property
def fulfiller_email(self):
return self.profile.email


@property
def fulfiller_github_username(self):
return self.profile.handle


@property
def should_hide(self):
return self.fulfiller_github_username in settings.BLOCKED_USERS


@property
def to_json(self):
"""Define the JSON representation of BountyFulfillment.
Expand All @@ -1422,7 +1421,6 @@ def to_json(self):
'bounty_id': self.bounty.pk,
'email': self.fulfiller_email,
'githubUsername': self.fulfiller_github_username,
'name': self.fulfiller_name,
'payout_status': self.payout_status,
'payout_amount': self.payout_amount,
'token_name': self.token_name,
Expand Down
Loading

0 comments on commit cc18786

Please sign in to comment.