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

fix: Same discount and access codes cannot be applied to two different events #6208

Merged

Conversation

@prateekj117
Copy link
Member

prateekj117 commented Jul 17, 2019

Fixes #6027

Short description of what this resolves:

Same discount and access code not able to apply to two different events.

Changes proposed in this pull request:

Checking discount and access code with event_id and access/discount code name, and changing the endpoint accordingly.

Checklist

  • I have read the Contribution & Best practices Guide and my PR follows them.
  • My branch is up-to-date with the Upstream development branch.
  • The unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All the functions created/modified in this PR contain relevant docstrings.
# filter on deleted_at is required to catch the id of a
# discount code which has not been deleted.
discount = db.session.query(DiscountCode).filter_by(code=kwargs.get('code'), deleted_at=None).first()
discount = db.session.query(DiscountCode).filter_by(code=kwargs.get('code'), event_id=kwargs.get('event_id')

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Jul 17, 2019

whitespace before ','

from app.api.event_sub_topics import EventSubTopicList, EventSubTopicListPost, EventSubTopicDetail, \
EventSubTopicRelationshipRequired, EventSubTopicRelationshipOptional
from app.api.event_topics import EventTopicList, EventTopicDetail, EventTopicRelationship
from app.api.event_types import EventTypeList, EventTypeDetail, EventTypeRelationship
from app.api.events import EventList, EventDetail, EventRelationship, EventCopyResource

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Jul 17, 2019

'app.api.events.EventCopyResource' imported but unused

@auto-label auto-label bot added the fix label Jul 17, 2019
@@ -613,7 +614,7 @@
# Admin Statistics API
api.route(AdminStatisticsSessionDetail, 'admin_statistics_session_detail', '/admin/statistics/sessions')
api.route(AdminStatisticsEventDetail, 'admin_statistics_event_detail', '/admin/statistics/events')
api.route(AdminStatisticsUserDetail, 'admin_statistics_user_detail', '/admin/statistics/users')
api.route(AdminStatisticsUserDetail, 'admin_statistics_user_detail', '/admin/tistics/users')

This comment has been minimized.

Copy link
@iamareebjamal

iamareebjamal Jul 17, 2019

Member

What is tistics? Is it something millenials use instead of statistics?

@fossasia fossasia deleted a comment Jul 18, 2019
@fossasia fossasia deleted a comment Jul 18, 2019
@prateekj117 prateekj117 changed the title fix: Same discount and access codes cannot be applied to two different events [WIP] - fix: Same discount and access codes cannot be applied to two different events Jul 19, 2019
@auto-label auto-label bot removed the fix label Jul 19, 2019
@fossasia fossasia deleted a comment Jul 19, 2019
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
db.session.commit()

This comment has been minimized.

Copy link
@iamareebjamal

iamareebjamal Jul 19, 2019

Member

If you're going to remove this, how the discount code is going to be attached to the event?

@@ -2804,15 +2804,11 @@ def discount_delete(transaction):
@hooks.before("Discount Codes > Get Discount Code Detail using the code > Get Discount Code Detail")
def discount_code_get_detail_using_code(transaction):
"""
GET /discount-codes/DC101
GET event_id/1/discount-code/DC101

This comment has been minimized.

Copy link
@iamareebjamal

iamareebjamal Jul 19, 2019

Member

And this is absolutely wrong. There is no route event_id/ in the API. Not sure what you're trying to do

This comment has been minimized.

Copy link
@prateekj117

prateekj117 Jul 19, 2019

Author Member

@iamareebjamal Had to write event/, made a mistake.

@prateekj117 prateekj117 force-pushed the prateekj117:same-discount-access-code branch from 887ed48 to f85ed5f Jul 19, 2019
@fossasia fossasia deleted a comment Jul 19, 2019
@fossasia fossasia deleted a comment Jul 20, 2019
@fossasia fossasia deleted a comment Jul 20, 2019
@fossasia fossasia deleted a comment Jul 20, 2019
@fossasia fossasia deleted a comment Jul 20, 2019
@fossasia fossasia deleted a comment Jul 20, 2019
@prateekj117 prateekj117 force-pushed the prateekj117:same-discount-access-code branch from c691eb1 to 1cc7d11 Jul 20, 2019
@fossasia fossasia deleted a comment Jul 20, 2019
@codecov

This comment has been minimized.

Copy link

codecov bot commented Jul 20, 2019

Codecov Report

Merging #6208 into development will not change coverage.
The diff coverage is 95.08%.

Impacted file tree graph

@@             Coverage Diff              @@
##           development    #6208   +/-   ##
============================================
  Coverage        65.88%   65.88%           
============================================
  Files              288      288           
  Lines            14575    14575           
============================================
  Hits              9603     9603           
  Misses            4972     4972
Impacted Files Coverage Δ
app/api/discount_codes.py 23.07% <0%> (ø) ⬆️
app/api/access_codes.py 53.16% <0%> (ø) ⬆️
app/api/__init__.py 100% <100%> (ø) ⬆️

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 5a3ea1a...5cff8ad. Read the comment docs.

@prateekj117

This comment has been minimized.

Copy link
Member Author

prateekj117 commented Jul 21, 2019

@prateekj117 prateekj117 changed the title [WIP] - fix: Same discount and access codes cannot be applied to two different events fix: Same discount and access codes cannot be applied to two different events Jul 21, 2019
@auto-label auto-label bot added the fix label Jul 21, 2019
@iamareebjamal

This comment has been minimized.

Copy link
Member

iamareebjamal commented Jul 21, 2019

See how simple it was. Had to make small changes. And how complicated you made it

@prateekj117

This comment has been minimized.

Copy link
Member Author

prateekj117 commented Jul 21, 2019

@iamareebjamal Yaa !!!

@iamareebjamal iamareebjamal merged commit 1f91603 into fossasia:development Jul 21, 2019
5 checks passed
5 checks passed
Codacy/PR Quality Review Up to standards. A positive pull request.
Details
Hound 1 violation found.
codecov/patch 95.08% of diff hit (target 65.88%)
Details
codecov/project 65.88% (+0%) compared to 5a3ea1a
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
iamareebjamal added a commit to iamareebjamal/open-event-server that referenced this pull request Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.