Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split create_new_bounty kwargs building and check if once #1892

Merged
merged 5 commits into from
Aug 10, 2018

Conversation

mbeacom
Copy link
Contributor

@mbeacom mbeacom commented Jul 31, 2018

Description

The goal of this PR is to reduce the number of checks whether or not latest_old_bounty exists and offload the last_old_bounty to a class level method for pertinent dict keys/values.

Checklist
  • linter status: 100% pass
  • changes don't break existing behavior
  • commit message follows commit guidelines
Affected core subsystem(s)

bounty creation/updating

Testing

Locally via sync_geth

@mbeacom mbeacom added backend This needs backend expertise. bounties labels Jul 31, 2018
@mbeacom mbeacom self-assigned this Jul 31, 2018
@mbeacom mbeacom requested a review from owocki July 31, 2018 22:23
@codecov
Copy link

codecov bot commented Jul 31, 2018

Codecov Report

Merging #1892 into master will decrease coverage by <.01%.
The diff coverage is 18.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1892      +/-   ##
==========================================
- Coverage   25.52%   25.51%   -0.01%     
==========================================
  Files         130      130              
  Lines       10669    10683      +14     
  Branches     1420     1423       +3     
==========================================
+ Hits         2723     2726       +3     
- Misses       7868     7879      +11     
  Partials       78       78
Impacted Files Coverage Δ
app/dashboard/helpers.py 17.2% <12.5%> (-0.02%) ⬇️
app/economy/models.py 77.77% <25%> (-7.68%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 383ac60...4641760. Read the comment docs.

privacy_preferences=bounty_payload.get('privacy_preferences', {}) if not latest_old_bounty else latest_old_bounty.privacy_preferences,
expires_date=timezone.make_aware(
timezone=UTC),
'github_url': url,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

thelostone-mc
thelostone-mc previously approved these changes Aug 2, 2018
Copy link
Member

@thelostone-mc thelostone-mc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

'network': bounty_details.get('network'),
'bounty_type': metadata.get('bountyType', ''),
'project_length': metadata.get('projectLength', ''),
'experience_level': metadata.get('experienceLevel', ''),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooh this is much cleaner... yay!

@@ -827,6 +827,41 @@ def additional_funding_summary_sentence(self):
sentence += f" worth ${afs['usd_value']}"
return sentence

def creation_to_dict(self):
return {
# info to xfr over from self as override fields (this is because sometimes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there not a django object to dict() method that we could just use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a django.forms utility method to do this... I suppose I can use that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@owocki Updated to use django.form.models.model_to_dict

owocki
owocki previously approved these changes Aug 2, 2018
Copy link
Contributor

@owocki owocki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 @mbeacom kevin owocki has sent you a 'boy scout' kudos for leaving this code better than you found it!

@mbeacom mbeacom dismissed stale reviews from owocki and thelostone-mc via e53d8a1 August 2, 2018 19:18
@mbeacom
Copy link
Contributor Author

mbeacom commented Aug 2, 2018

@thelostone-mc @owocki Can I have another review of this PR? I have introduced the SuperModel.to_standard_dict method until we update previously implemented to_dict() methods on some of the subclasses to maintain parity. But now, we can simply call to_standard_dict() on any of our subclasses of SuperModel and get a dictionary representation. to_standard_dict also takes the same two kwargs as model_to_dict to allow for customization of the returned dictionary as shown in the one usage example so far.

@mbeacom mbeacom requested review from owocki and thelostone-mc August 2, 2018 19:42
})
else:
latest_old_bounty_dict = latest_old_bounty.to_standard_dict(
fields=[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is fields used here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wait nvm i see it now

Copy link
Contributor

@owocki owocki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didnt test, can you test a bounty end to end of rinkeby?

code LGTM

@mbeacom
Copy link
Contributor Author

mbeacom commented Aug 2, 2018

@owocki
Copy link
Contributor

owocki commented Aug 6, 2018

:shipit:

Copy link
Member

@thelostone-mc thelostone-mc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mbeacom mbeacom merged commit 192430d into master Aug 10, 2018
@mbeacom mbeacom deleted the mark-split-create-bounty branch August 10, 2018 19:56
CuriousLearner added a commit to CuriousLearner/web that referenced this pull request Aug 12, 2018
* 'master' of https://github.com/gitcoinco/web: (76 commits)
  hack: trailing slash for profile (gitcoinco#1937)
  Minor tweaks to action plan textarea (gitcoinco#1856)
  fixes label on gas guzzler page, and adds an admin view for vizuailzations
  keep an eye on unsubscribes in preferences
  keep an eye on unsubscribes in preferences
  Split create_new_bounty kwargs building and check if once (gitcoinco#1892)
  press
  satisfy linter
  fix for https://gitcoincore.slack.com/archives/CAXQ7PT60/p1533912000000126
  Update profile check to getattr
  share link not edit link
  does tip receive math in BigNumber, bc JS rounding issues
  copy updates
  newsletter 8/10
  fix for slack not showing UP
  gas guzzlers
  linter
  gas guzzlers
  Error: insufficient funds for gas * price + value
  starts to track gas guzzlers, for later inclusion in the gitcoin gas station
  ...
shad-k added a commit to shad-k/web that referenced this pull request Aug 12, 2018
* put reasons above the other two modules

* gitcoinco#1854

* css: minor refactor

* token approvals

* fix for email not being sent

* retail: added template tag matches

- matches tag does a regex match
- updated nav to use matches to display network status on
  explorer, issue, bounty - create + submit + payout pages

* code refactor + clean up

- removed redundant uris
- reindent code
- fixed uneven padding of network banner on tip page

* send2: convert CRLF -> LF

* isort fixes

* console error, responseJSON did not exist

* change name of missing image

* fix for exception in bounty.additional_funding_summary_sentence()

* funder stale email

* linter stinter

* days

* Fix linting issues and docstyle all teh thingz

* Fix bad variable out of scope reference in render_bounty_startwork_expired email

* restructure: landing

- renamed index -> funder
- moved funder related templates into it's own folder
- added heading to top contributors

* restructure: dashboard

- renamed _dashboard -> dashboard
- renamed dashboard.html -> dasboard/index.html

* onboard: prettified metamask wallet address

* Sentry integration (gitcoinco#1846)

* Sentry integration - deprecate rollbar

* Imports are hard

* dbl quotez

* Single quotes

* Fix travis

* Forgot to save this file xD

* Add middleware and wsgi handler

* Logging adjustments for Sentry

* Fix gitcoinco#1898 - Adjust ordering of mailchimp args and cast envvars to str

* Merge branch 'master' into restructure

* gitcoinco@dead551#diff-8d7b20d795398cf2b0e792ee8c1a165c

* space in sentence

* Update presskit copy (gitcoinco#1900)

* Fix sentry release script revision handling

* add no a token page

* disabled metamask

* stickler hate me

* add item to menu

* dashboard: remove tech stack filter

* fixes press kit

* add no a token page

* blank

* Solve conflicts

* sitemap fixes

* disabled metamask

* stickler hate me

* i have grammar OCD

* bad link

* Fix gitcoin logo

* documentation about chain of custody

* cahin of custoyddyyyyyyyyyy

* Modify raven handling

* Add sentry request feedback on error

* Extending expiration backend code added

* Some minor changes

* Adds cancel button

* Adds alert notifying extending of expiration

* Fixes linting issues

* expiration: final touches

- stickler fixes
- show current expiration in modal
- add stopwatch icon
- extra css

* Fixes travis

* shared.js/mutate_interest: Show a generic message on network errors.

followup 3960c6
PR gitcoinco#1681

* Round up millisecond position

* Moderators v1 (gitcoinco#1903)

* Ref gitcoinco#1669 - Base escalation/interest statuses and handling

* Moderation changes

* Add faucet change to perms

* No mod

* Fix mig for local

* Update mod handling throughout remaining views and check gh closures

* Whoops

* Fix some tests

* Fix some pytest cases

* Fix more tests

* indent fix

* More test changes

* Add property back to tips method

* Fix gitcoinco#1919 - Catch attribute error if the keywords prop isn't a string

* Adjust Raven JS to no longer load async

* Revert "Adjust Raven JS to no longer load async"

This reverts commit 37d4584.

* Fix funding/details path

* Adjust github details field

* gh dict

* catch on gh details

* Remove temporarily

* Disable url dict

* Disable GH funcs

* Display project length in issue details page

* Fix GH token usage

* translation tags and clarification on lcoalhost

* facebook verify

* facebook verify

* Revert "facebook verify"

This reverts commit 50b7ebb.

* Revert "facebook verify"

This reverts commit 51f5e54.

* Adjust saving of gh issue details

* sync geth stopgap fix

* Adjust default limit on bounty router

* Revert "Adjust default limit on bounty router"

This reverts commit a7d872c.

* stopgap fix

* fixes

* runs make fix on master branhc

* sync mail fix to make it less aggressive

* Adjust yapf to no longer touch settings.py

* Update precommit yapf config

* fix for sync_listener

* linting sync_geth

* copy updates

* merge migration

* Adjust gh state checks

* Update gh state

* Updates to gh pulling...

* GH Pulling adjustments

* meta tags

* title

* no ico life

* conflicts

* fix for https://gitcoincore.slack.com/archives/CC24APWGN/p1533245102000397

* prod bug

* prod bug

* prod bug

* prod bug

* graphs r fun

* fix for not being able to ERC20 approve tokens

* fix for leaderboards

* eslint

* adjusts hourly rate distribution calculation criteria

* Switching tree section

* landing: css + refactor

* lander video switcharooooooooooooO

* joe dominance was busttedd

* shared: updated what_is_gitcoin

* added branding style to terms page

* changed style of headers on terms page, moved terms.txt into terms.html, added blocktrans tag

* Confirming Auto-translation (gitcoinco#1916)

* Update makefile with build/push/login and add OCI compliant labels

* terms: moved to internal css + mt-4 -> mt-5

* Adjust sentry to use split projects

* Fix config

* Adjust fe sentry template

* Sentry adjustments

* livestream 8/3

* Sentry adjustments

* livestream 8/3 (gitcoinco#1930)

* Show Just 1 Alert Banner for ERC20 Token

Fixes gitcoinco#1566

* allow trailing slah for profile (gitcoinco#1931)

* Improve tip slack notification (gitcoinco#1929)

* Improve tip slack notification

* Remove title var and simply check tip.github_url

* Add new lines

* Adjust sentry raven JS

* Adjust sentry raven JS

* Revert profile url change

* Revert "Adjust sentry raven JS"

This reverts commit 5432bc4.

* Revert "Adjust sentry raven JS"

This reverts commit 25e9987.

* Sentry adjustments

* Final sentry js adjustments!

* tip receive is eth

* nonce value

* bounty: restructure pages

* Fix gitcoinco#1949 - Adjust getattr for profile

* prod debugging; dupe emails

* prod debugging of dupe emails

* prod debugging of dupe emails

* remove dupe to_email

* dupe email fix

* dupe email fix

* dupe email fix

* reverts debug code

* fix for bad preferred profile addresses

* fix for https://sentry.gitcoin.co/gitcoin/gitcoin-prod-frontend/issues/278/

* http 404 on hidden prfiles

* SEO fixes, linting

* content type for robots.txt

* SEO stuff

* sync_geth latest disabler

* Fix isort / travis

* what_is_gitcoin : revert to old design (gitcoinco#1957)

* fix gitcoinco#1921

* Fix gitcoinco#1934 - Resolve funded total in profile (gitcoinco#1935)

* fix for https://sentry.gitcoin.co/gitcoin/gitcoin-prod-backend/issues/321/?referrer=slack

* support for https://sentry.gitcoin.co/gitcoin/gitcoin-prod-backend/issues/320/?referrer=slack

* disqus url now canonical

* funder stale args

* very small copy change

* smarter funder stale emails

* fix for ipfs hashes not existing

* fix for being redirected to old bounty id upon submission

* copy updates

* handler for not sending funder stale emails if n email

* puts the right network linkn on the web3 waiter

* metamask reloader

* explorer:  ensure results from latest api call are served to the user (gitcoinco#1941)

* explorer: abort pending request for fetchingBounties

* added review feedback

* Upgrade django to 2.1, modify field defaults, and address deprecations (gitcoinco#1915)

* Upgrade django to 2.1 and address deprecations

* Remove commented out imports

* fix: sticker issue

* Update reqs

* Remove unused import

* Fix gitcoinco#1972 - Strip characters from stdbounties_id and check isdigit

* replaced misspelled 'deonomination' with 'denomination' throughout the codebase (gitcoinco#1974)

* dashboard: uri cleanup (gitcoinco#1971)

* img: removed unused images

* Resolve outdated deps in package-lock.json

* Upgrade FE npm deps

* Upgrade FE npm deps

* Pin raven

* starts to track gas guzzlers, for later inclusion in the gitcoin gas station

* Error: insufficient funds for gas * price + value

* gas guzzlers

* linter

* gas guzzlers

* fix for slack not showing UP

* newsletter 8/10

* copy updates

* does tip receive math in BigNumber, bc JS rounding issues

* share link not edit link

* Update profile check to getattr

* fix for https://gitcoincore.slack.com/archives/CAXQ7PT60/p1533912000000126

* satisfy linter

* press

* Split create_new_bounty kwargs building and check if once (gitcoinco#1892)

* Split create_new_bounty kwargs building and check if once

* Update to_dict to use model_to_dict form helper

* Fix import - whoops

* Adjust to dict handling via supermodel method

* keep an eye on unsubscribes in preferences

* keep an eye on unsubscribes in preferences

* fixes label on gas guzzler page, and adds an admin view for vizuailzations

* Minor tweaks to action plan textarea (gitcoinco#1856)

* Clear example action plan when the textarea is focused

* Fix minor typo

* hack: trailing slash for profile (gitcoinco#1937)

* start work : update placeholder

* added feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend This needs backend expertise. bounties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants