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

Hotel Lottery Forms #4360

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Hotel Lottery Forms #4360

wants to merge 4 commits into from

Conversation

bitbyt3r
Copy link
Member

A very rough start at adding the necessary forms for a hotel lottery.

Copy link
Member

@kitsuta kitsuta left a comment

Choose a reason for hiding this comment

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

One requested change and some questions!

@@ -255,6 +255,7 @@ def returns_json(*args, **kwargs):
assert cherrypy.request.method == 'POST', 'POST required, got {}'.format(cherrypy.request.method)
check_csrf(kwargs.pop('csrf_token', None))
except Exception:
traceback.print_exc()
Copy link
Member

Choose a reason for hiding this comment

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

Just to double-check, is/was this a temporary statement for debugging?

@@ -28,6 +29,10 @@ def valid_cellphone(form, field):
'include a country code (e.g. +44) for international numbers.')


class LotteryApplication(MagForm):
Copy link
Member

Choose a reason for hiding this comment

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

Let's move this into its own forms/hotel.py file, to more closely reflect where it is in models/. I'm sure we'll have plenty of lottery-related forms as we progress so it won't be a file with just one class in it.

Also, just wondering, why is this a StringField and not a SelectMultipleField or similar? Is it because the choices have to be ordered?



class HotelLotteryApplication(MagForm):
ranked_hotels = Ranking(c.HOTEL_LOTTERY.keys())
Copy link
Member

Choose a reason for hiding this comment

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

Is Ranking() a widget or a field class? I see this form isn't being used, is it just left over from something else you were trying?

@@ -102,3 +102,59 @@ def render_option(cls, value, label, selected, **kwargs):
return Markup(
"<option {}>{}</option>".format(html_params(**options), escape(label))
)

class Ranking():
Copy link
Member

Choose a reason for hiding this comment

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

Just to double-check, should this be subclassing an existing WTForms widget?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants