Skip to content

Conversation

@kushthedude
Copy link
Member

Fixes #6444

@kushthedude
Copy link
Member Author

@iamareebjamal Please Review

@kushthedude
Copy link
Member Author

@iamareebjamal I can't debug the issue with dredd, Can you please point out what's getting wrong, As on local the server is running well

@iamareebjamal
Copy link
Member

Traceback (most recent call last):
  File "manage.py", line 97, in <module>
    manager.run()
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/flask_script/__init__.py", line 417, in run
    result = self.handle(argv[0], argv[1:])
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/flask_script/__init__.py", line 386, in handle
    res = handle(*args, **config)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/flask_script/commands.py", line 216, in __call__
    return self.run(*args, **kwargs)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/flask_migrate/__init__.py", line 95, in wrapped
    f(*args, **kwargs)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/flask_migrate/__init__.py", line 359, in heads
    resolve_dependencies=resolve_dependencies)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/alembic/command.py", line 429, in heads
    heads = script.get_revisions(script.get_heads())
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/alembic/script/base.py", line 316, in get_heads
    return list(self.revision_map.heads)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/alembic/util/langhelpers.py", line 230, in __get__
    obj.__dict__[self.__name__] = result = self.fget(obj)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/alembic/script/revision.py", line 72, in heads
    self._revision_map
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/alembic/util/langhelpers.py", line 230, in __get__
    obj.__dict__[self.__name__] = result = self.fget(obj)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/alembic/script/revision.py", line 123, in _revision_map
    for revision in self._generator():
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/alembic/script/base.py", line 109, in _load_revisions
    script = Script._from_filename(self, vers, file_)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/alembic/script/base.py", line 887, in _from_filename
    module = util.load_python_file(dir_, filename)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/alembic/util/pyfiles.py", line 98, in load_python_file
    module = load_module_py(module_id, path)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/alembic/util/compat.py", line 174, in load_module_py
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/travis/build/fossasia/open-event-server/migrations/versions/rev-2019-09-15-08:29:32-d1c2b8711223_.py", line 27
    nullable=False)

@iamareebjamal
Copy link
Member

The build didn't stop due to this error - #5988

@codecov
Copy link

codecov bot commented Sep 16, 2019

Codecov Report

Merging #6447 into development will increase coverage by <.01%.
The diff coverage is 66.66%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #6447      +/-   ##
===============================================
+ Coverage        65.02%   65.03%   +<.01%     
===============================================
  Files              296      296              
  Lines            15250    15248       -2     
===============================================
  Hits              9917     9917              
+ Misses            5333     5331       -2
Impacted Files Coverage Δ
app/api/orders.py 26.81% <0%> (+0.13%) ⬆️
app/models/order.py 90% <100%> (ø) ⬆️
app/models/event.py 78.92% <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 bde88a4...f07085a. Read the comment docs.

if data.get('is_billing_enabled') and not (data.get('company') and data.get('address')
and data.get('city') and data.get('zipcode') and data.get('country')):
raise UnprocessableEntity({'pointer': '/data/attributes/is_billing_enabled'},
"Billing information is incomplete.")

Choose a reason for hiding this comment

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

continuation line over-indented for visual indent
indentation contains mixed spaces and tabs


def check_billing_info(data, order):
if data.get('is_billing_enabled') and not (data.get('company') and data.get('address')
and data.get('city') and data.get('zipcode') and data.get('country')):

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent
indentation contains mixed spaces and tabs
indentation contains tabs

@kushthedude
Copy link
Member Author

@iamareebjamal Please Review

@iamareebjamal
Copy link
Member

Is it ready for merging now?

@kushthedude
Copy link
Member Author

Is it ready for merging now?

Yes it is working now

:return:
"""
if data.get('amount') or data.get('is_billing_enabled'):
if data.get('amount') or data.get('is_billing_enabled') or order.event.is_billing_info_mandatory:
Copy link
Member

Choose a reason for hiding this comment

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

There's a problem, this will require billing info on any paid order, whereas it is explicitly stated in the issue to make it optional unless is_billing_info_mandatory is True.

Skipping this PR for now, will add in minor version

Copy link
Member Author

Choose a reason for hiding this comment

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

Merging it after release would be better I guess too.

:return:
"""
if data.get('amount') or data.get('is_billing_enabled'):
if data.get('amount') and (data.get('is_billing_enabled') or order.event.is_billing_info_mandatory) :

Choose a reason for hiding this comment

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

whitespace before ':'

Copy link
Member

Choose a reason for hiding this comment

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

Please don't mark hound violations as resolved

@kushthedude
Copy link
Member Author

@iamareebjamal Updated the PR and tested with making orders and requests too. Also Frontend PR is done too fossasia/open-event-frontend#3654

:return:
"""
if data.get('amount') or data.get('is_billing_enabled'):
if data.get('amount') and (data.get('is_billing_enabled') or order.event.is_billing_info_mandatory) :
Copy link
Member

Choose a reason for hiding this comment

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

This will again, require billing info even if the organizer has asked not to. Please read the issue again. I don't think you understand what the goal is.

Can you tell me what is the goal of this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

This PR goal is, If a order is paid and organiser has made billing mandatory , user has to fill it.
And if its not mandatory then user has option to fill or not

Copy link
Member Author

Choose a reason for hiding this comment

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

Also Billing information is only needed for paid order hence a condition for data.get(amount)

Copy link
Member Author

Choose a reason for hiding this comment

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

what

If organiser has not asked for billing info, Then it wont require as I have used and over there

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, and this is going to require billing info even when organizer has set event.is_billing_info_mandatory = False

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

a) Only make billing info required if the organizer chose "Require billing info.." (in Wizard). If billing > info is required always show the fields. If the organizer did not require it, show it as an option > > > using a tick box. -> So, if the organizer does not require it, the user can still add the

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, and this is going to require billing info even when organizer has set event.is_billing_info_mandatory = False

It will billing info only then when the user wants to enter it

Copy link
Member

@iamareebjamal iamareebjamal left a comment

Choose a reason for hiding this comment

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

Understand the issue first

@kushthedude
Copy link
Member Author

Understand the issue first

Please see the comments. Its working as expected

@iamareebjamal
Copy link
Member

Please see the comments. Its working as expected

data.get('amount') and (data.get('is_billing_enabled') or order.event.is_billing_info_mandatory)

What's the use of data.get('is_billing_enabled') here?

@kushthedude
Copy link
Member Author

Please see the comments. Its working as expected

data.get('amount') and (data.get('is_billing_enabled') or order.event.is_billing_info_mandatory)

What's the use of data.get('is_billing_enabled') here?

If billing is not mandatory, then its dependent upon the user to enter or not.

@kushthedude
Copy link
Member Author

kushthedude commented Nov 25, 2019

@iamareebjamal

a) Only make billing info required if the organizer chose "Require billing info.." (in Wizard). If billing > info is required always show the fields. If the organizer did not require it, show it as an option > > > using a tick box. -> So, if the organizer does not require it, the user can still add the

@iamareebjamal
Copy link
Member

It's not necessary that the user will set is_billing_enabled as True or not. There is something else which needs to be thought in order to ensure checking of billing info before storing it.

@kushthedude
Copy link
Member Author

It's not necessary that the user will set is_billing_enabled as True or not. There is something else which needs to be thought in order to ensure checking of billing info before storing it.

If user sets it as true when Billing_info is not mandatory, Then he can enter the data. If he doesn't he will not enter ?

data.get('zipcode') and data.get('country')):
"Billing information is mandatory for this order.")
if data.get('is_billing_enabled') and not (data.get('company') and data.get('address')
and data.get('city') and data.get('zipcode') and data.get('country')):
Copy link
Member

Choose a reason for hiding this comment

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

Revert this please. The previous format was according to PEP8

"Billing information is mandatory for paid orders")
if data.get('is_billing_enabled') and not (data.get('company') and data.get('address') and data.get('city') and
data.get('zipcode') and data.get('country')):
"Billing information is mandatory for this order.")
Copy link
Member

Choose a reason for hiding this comment

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

Remove period from the end

and data.get('city') and data.get('zipcode') and data.get('country')):
raise UnprocessableEntity({'pointer': '/data/attributes/is_billing_enabled'},
"Billing information incomplete")
"Billing information is incomplete.")
Copy link
Member

Choose a reason for hiding this comment

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

Remove the period from the end

@iamareebjamal
Copy link
Member

If user sets it as true when Billing_info is not mandatory, Then he can enter the data. If he doesn't he will not enter ?

For now, it is fine. But this may happen - a user enters billing info and does not set is_billing_enabled as true, then incomplete and inconsistent data may be stored in the DB. But, that can be handled later

@kushthedude
Copy link
Member Author

If user sets it as true when Billing_info is not mandatory, Then he can enter the data. If he doesn't he will not enter ?

For now, it is fine. But this may happen - a user enters billing info and does not set is_billing_enabled as true, then incomplete and inconsistent data may be stored in the DB. But, that can be handled later

@iamareebjamal Made the requested changes.

@iamareebjamal iamareebjamal changed the title enh: Addition and Updation of billing related fields feat: Addition and Updation of billing related fields Nov 25, 2019
@auto-label auto-label bot added the feature label Nov 25, 2019
@niranjan94
Copy link
Member

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- app/api/orders.py  1
         

See the complete overview on Codacy

@iamareebjamal iamareebjamal merged commit 4f32edf into fossasia:development Nov 25, 2019
@kushthedude kushthedude deleted the fields branch November 25, 2019 07:04
codedsun pushed a commit to codedsun/open-event-server that referenced this pull request Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add fields regarding Billing Info on choice of Attendee or Organiser

6 participants