Skip to content

Conversation

prateekj117
Copy link
Member

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')

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

'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')
Copy link
Member

Choose a reason for hiding this comment

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

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()
Copy link
Member

Choose a reason for hiding this comment

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

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
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

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

@prateekj117 prateekj117 force-pushed the same-discount-access-code branch from 887ed48 to f85ed5f Compare July 19, 2019 10:13
@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 same-discount-access-code branch from c691eb1 to 1cc7d11 Compare July 20, 2019 21:57
@fossasia fossasia deleted a comment Jul 20, 2019
@codecov
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
Copy link
Member Author

@iamareebjamal @uds5501 @mrsaicharan1 Please review.

@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
Copy link
Member

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

@prateekj117
Copy link
Member Author

@iamareebjamal Yaa !!!

@iamareebjamal iamareebjamal merged commit 1f91603 into fossasia:development Jul 21, 2019
iamareebjamal pushed 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
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Same Discount Code is not able to be applied for two different events
3 participants