Skip to content

Commit ca8f90f

Browse files
committed
Discarding global lottery buttons
1 parent 373c3ec commit ca8f90f

18 files changed

+58
-177
lines changed

uber/automated_emails.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -861,22 +861,20 @@ def __init__(self, subject, template, filter, ident, **kwargs):
861861

862862

863863
if c.HOTEL_LOTTERY_FORM_START:
864-
earliest_hotel_deadline = c.HOTEL_LOTTERY_FORM_WAITLIST if c.HOTEL_LOTTERY_FORM_WAITLIST else c.HOTEL_LOTTERY_FORM_DEADLINE
865-
866864
AutomatedEmailFixture(
867865
Attendee,
868866
'Did you want to enter the {EVENT_NAME} {EVENT_YEAR} hotel lottery?',
869867
'hotel/enter_lottery.html',
870868
lambda a: a.hotel_lottery_eligible and not a.lottery_application and days_after(1, a.registered)(),
871-
when=[days_before(7, earliest_hotel_deadline)],
869+
when=[days_before(7, c.HOTEL_LOTTERY_FORM_DEADLINE)],
872870
sender=c.HOTEL_LOTTERY_EMAIL,
873871
ident='enter_hotel_lottery')
874872

875873
HotelLotteryEmailFixture(
876874
'Last chance to complete your hotel lottery entry',
877875
'hotel/lottery_reminder.html',
878876
lambda a: a.status == c.PARTIAL and days_after(1, a.entry_started)(),
879-
when=[days_before(3, earliest_hotel_deadline)],
877+
when=[days_before(3, c.HOTEL_LOTTERY_FORM_DEADLINE)],
880878
ident='hotel_lottery_reminder',
881879
)
882880

@@ -885,26 +883,17 @@ def __init__(self, subject, template, filter, ident, **kwargs):
885883
HotelLotteryEmailFixture(
886884
f'{c.EVENT_NAME_AND_YEAR} Hotel Lottery Notification',
887885
'hotel/award_notification.html',
888-
lambda a: a.status == c.AWARDED and not a.final_status_hidden and a.booking_url_ready,
886+
lambda a: a.status == c.AWARDED and a.booking_url_ready,
889887
ident='hotel_lottery_awarded'
890888
)
891889

892890
HotelLotteryEmailFixture(
893891
f'{c.EVENT_NAME_AND_YEAR} Hotel Lottery Notification',
894892
'hotel/reject_notification.html',
895-
lambda a: a.status == c.REJECTED and not a.final_status_hidden,
893+
lambda a: a.status == c.REJECTED,
896894
ident='hotel_lottery_rejected'
897895
)
898896

899-
if c.HOTEL_LOTTERY_FORM_WAITLIST:
900-
HotelLotteryEmailFixture(
901-
f'{c.EVENT_NAME_AND_YEAR} Hotel Lottery Notification',
902-
'hotel/reject_notification.html',
903-
lambda a: a.status == c.COMPLETE and a.qualifies_for_first_round,
904-
when=[after(c.HOTEL_LOTTERY_FORM_WAITLIST)],
905-
ident='hotel_lottery_first_round_rejected'
906-
)
907-
908897
HotelLotteryEmailFixture(
909898
f'Reminder to confirm your {c.EVENT_NAME_AND_YEAR} hotel reservation',
910899
'hotel/guarantee_reminder.html',

uber/configspec.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,10 +1266,6 @@ hotel_lottery_form_deadline = string(default="")
12661266
hotel_lottery_staff_start = string(default="%(hotel_lottery_form_start)s")
12671267
hotel_lottery_staff_deadline = string(default="%(hotel_lottery_form_deadline)s")
12681268

1269-
# If set, this is considered a 'first run' deadline and communicated as such on our forms
1270-
# It is for display only
1271-
hotel_lottery_form_waitlist = string(default="")
1272-
12731269
hotel_lottery_staff_guarantee_due = string(default="")
12741270
hotel_lottery_guarantee_due = string(default="")
12751271

uber/forms/hotel_lottery.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ class LotteryAdminInfo(SuiteLottery):
103103
current_step = IntegerField('Current Step')
104104
confirmation_num = StringField('Confirmation Number', render_kw={'readonly': "true"})
105105
can_edit = BooleanField(f'Make this application editable even after its lottery is closed.')
106-
final_status_hidden = BooleanField(f"This application's final award status is hidden.")
107-
booking_url_hidden = BooleanField(f"This application's booking URL is hidden.")
108106
is_staff_entry = BooleanField(f'This application is entered into the staff lottery.')
109107
legal_first_name = LotteryInfo.legal_first_name
110108
legal_last_name = LotteryInfo.legal_last_name

uber/models/hotel.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ class LotteryApplication(MagModel, table=True):
167167
suite_terms_accepted: bool = False
168168
guarantee_policy_accepted: bool = False
169169
can_edit: bool = False
170-
final_status_hidden: bool = True
171-
booking_url_hidden: bool = True
172170

173171
# If this is set then the above values are ignored
174172
parent_application_id: str | None = Field(sa_type=Uuid(as_uuid=False), foreign_key='lottery_application.id', nullable=True)
@@ -369,10 +367,7 @@ def staff_award_status_str(self):
369367
@property
370368
def award_status_str(self):
371369
app_or_parent = self.parent_application if self.entry_type == c.GROUP_ENTRY else self
372-
if self.final_status_hidden and not self.status in [c.SECURED, c.CANCELLED]:
373-
return ''
374-
if not self.finalized and (
375-
not c.HOTEL_LOTTERY_FORM_WAITLIST or not self.qualifies_for_first_round or c.BEFORE_HOTEL_LOTTERY_FORM_WAITLIST):
370+
if not self.finalized:
376371
return ''
377372
if self.staff_award_status_str:
378373
return self.staff_award_status_str
@@ -403,10 +398,7 @@ def award_status_str(self):
403398
elif app_or_parent.assigned_hotel:
404399
return f"Congratulations! {you_str} entry for the {c.EVENT_NAME_AND_YEAR} {room_type} lottery was chosen."
405400
else:
406-
base_str = f"Unfortunately, {you_str.lower()} entry for the {c.EVENT_NAME_AND_YEAR} hotel lottery was not chosen"
407-
if c.HOTEL_LOTTERY_FORM_WAITLIST and not app_or_parent.finalized and c.AFTER_HOTEL_LOTTERY_FORM_WAITLIST:
408-
return base_str + " in the first round of the lottery."
409-
return base_str + "."
401+
return f"Unfortunately, {you_str.lower()} entry for the {c.EVENT_NAME_AND_YEAR} hotel lottery was not chosen."
410402

411403
@property
412404
def can_reenter(self):
@@ -418,9 +410,7 @@ def finalized(self):
418410

419411
@property
420412
def locked(self):
421-
return self.current_lottery_closed or (
422-
self.qualifies_for_first_round and c.AFTER_HOTEL_LOTTERY_FORM_WAITLIST
423-
) or (self.finalized and not self.final_status_hidden)
413+
return self.current_lottery_closed or self.finalized
424414

425415
@property
426416
def declined(self):
@@ -430,15 +420,10 @@ def declined(self):
430420
def complete_or_processed(self):
431421
return self.status in [c.COMPLETE, c.PROCESSED] or self.finalized
432422

433-
@property
434-
def qualifies_for_first_round(self):
435-
if c.HOTEL_LOTTERY_FORM_WAITLIST:
436-
return self.complete_or_processed and self.last_submitted and self.last_submitted < c.HOTEL_LOTTERY_FORM_WAITLIST
437-
438423
@property
439424
def booking_url_ready(self):
440425
app_or_parent = self.parent_application if self.entry_type == c.GROUP_ENTRY else self
441-
return app_or_parent.booking_url and not app_or_parent.booking_url_hidden
426+
return bool(app_or_parent.booking_url)
442427

443428
@property
444429
def group_status_str(self):
@@ -507,7 +492,7 @@ def last_step(self):
507492
@property
508493
def homepage_link(self):
509494
entry_text = 'Suite Lottery Entry' if self.entry_type == c.SUITE_ENTRY else 'Room Lottery Entry'
510-
if self.status in [c.COMPLETE, c.PROCESSED] or self.finalized and self.final_status_hidden:
495+
if self.status in [c.COMPLETE, c.PROCESSED]:
511496
prepend = "View " if c.ATTENDEE_ACCOUNTS_ENABLED else ""
512497
return f'index?attendee_id={self.attendee.id}', f'{prepend}{entry_text}'
513498
elif self.finalized:

uber/site_sections/hotel_lottery.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ def transfer_leadership(self, session, id=None, member_id=None, message="", **pa
700700
if new_leader not in application.valid_group_members:
701701
raise HTTPRedirect('index?attendee_id={}&message={}', application.attendee.id,
702702
f"{new_leader.attendee.full_name} is not a member of your {c.HOTEL_LOTTERY_GROUP_TERM.lower()}")
703-
elif application.locked and not (application.finalized and not application.final_status_hidden):
703+
elif application.locked:
704704
raise HTTPRedirect('index?id={}&message={}', application.id,
705705
"You cannot transfer group leadership at this time.")
706706

@@ -843,7 +843,7 @@ def join_group(self, session, id=None, message="", **params):
843843
def leave_group(self, session, id=None, message="", **params):
844844
application = session.lottery_application(id)
845845

846-
if application.locked and not (application.finalized and not application.final_status_hidden):
846+
if application.locked:
847847
raise HTTPRedirect('index?id={}&message={}', application.id,
848848
f"You cannot leave your {c.HOTEL_LOTTERY_GROUP_TERM.lower()} at this time.")
849849

@@ -885,7 +885,7 @@ def confirm(self, session, id, message='', **params):
885885

886886
if not application.status in [c.AWARDED, c.SECURED]:
887887
message = f"{you_str} entry does not have a room or suite award."
888-
if not application.booking_url or application.booking_url_hidden:
888+
if not application.booking_url:
889889
message = f"{you_str} entry is still being processed and the booking link is not available yet."
890890

891891
if application.parent_application:

uber/site_sections/hotel_lottery_admin.py

Lines changed: 28 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from copy import deepcopy
88
from collections import defaultdict
99
from datetime import datetime, timedelta
10+
from pytz import UTC
1011
from dateutil import parser as dateparser
1112
from sqlalchemy import and_, func, or_
1213
from sqlalchemy.orm import joinedload
@@ -256,16 +257,6 @@ def feed(self, session, message='', page='1', who='', what='', action=''):
256257
Tracking.model == 'LotteryApplication').distinct().order_by(Tracking.who).values(Tracking.who)]
257258
}
258259

259-
def mark_staff_processed(self, session, **params):
260-
for app in session.query(LotteryApplication).filter(LotteryApplication.is_staff_entry,
261-
LotteryApplication.status == c.COMPLETE):
262-
app.status = c.PROCESSED
263-
session.add(app)
264-
session.commit()
265-
266-
raise HTTPRedirect('index?message={}',
267-
"All complete staff entries marked as processed.")
268-
269260
@ajax
270261
def validate_hotel_lottery(self, session, id=None, form_list=[], **params):
271262
application = session.lottery_application(id)
@@ -333,41 +324,6 @@ def history(self, session, id):
333324
).order_by(PageViewTracking.when).all(),
334325
}
335326

336-
def show_awards(self, session, **params):
337-
applications = session.query(LotteryApplication).filter(LotteryApplication.status.in_([c.AWARDED, c.REJECTED, c.REMOVED]),
338-
LotteryApplication.final_status_hidden == True)
339-
total = applications.count()
340-
for app in applications:
341-
app.final_status_hidden = False
342-
session.add(app)
343-
344-
raise HTTPRedirect('index?message={}',
345-
f"{total} awarded, rejected, and removed from group lottery entries can now see their status.")
346-
347-
348-
def publish_booking_links(self, session, **params):
349-
applications = session.query(LotteryApplication).filter(LotteryApplication.booking_url != '',
350-
LotteryApplication.booking_url_hidden == True)
351-
total = applications.count()
352-
for app in applications:
353-
app.booking_url_hidden = False
354-
session.add(app)
355-
356-
raise HTTPRedirect('index?message={}',
357-
f"{total} lottery entries can now see their booking link.")
358-
359-
def close_waitlist(self, session, **params):
360-
applications = session.query(LotteryApplication).filter(LotteryApplication.status == c.COMPLETE,
361-
LotteryApplication.last_submitted < c.HOTEL_LOTTERY_FORM_WAITLIST)
362-
363-
total = applications.count()
364-
for app in applications:
365-
app.last_submitted = localized_now()
366-
session.add(app)
367-
368-
raise HTTPRedirect('index?message={}',
369-
f"{total} locked 'first-round' lottery entries are now unlocked.")
370-
371327
def lottery_runs(self, session, message=''):
372328
runs = session.query(LotteryRun).order_by(LotteryRun.run_at.desc()).all()
373329
hotels = session.query(LotteryHotel).filter_by(active=True).order_by(LotteryHotel.name).all()
@@ -451,6 +407,16 @@ def revert_run(self, session, id, **params):
451407
raise HTTPRedirect('lottery_runs?message={}',
452408
f"Run '{lottery_run.name}' reverted. {len(applications)} entries reset to complete.")
453409

410+
def delete_run(self, session, id, **params):
411+
lottery_run = session.query(LotteryRun).get(id)
412+
if lottery_run.status != c.LOTTERY_REVERTED:
413+
raise HTTPRedirect('lottery_run_detail?id={}&message={}', id, 'Only reverted runs can be deleted.')
414+
415+
name = lottery_run.name
416+
session.delete(lottery_run)
417+
session.commit()
418+
raise HTTPRedirect('lottery_runs?message={}', f"Run '{name}' has been deleted.")
419+
454420
def manage_inventory(self, session, message=''):
455421
inventory = session.query(HotelRoomInventory).order_by(
456422
HotelRoomInventory.hotel_id, HotelRoomInventory.is_suite, HotelRoomInventory.name).all()
@@ -760,30 +726,32 @@ def hotel_inventory(self, session, message=''):
760726
for hotel_id, room_type_id, status, count in assigned_applications:
761727
assigned_applications_dict[(hotel_id, room_type_id)].append((status, count))
762728

729+
hotel_lookup = {str(h.id): h for h in session.query(LotteryHotel).all()}
730+
room_type_lookup = {str(rt.id): rt for rt in session.query(LotteryRoomType).all()}
731+
763732
room_inventory = defaultdict(list)
764-
for inventory_info in HotelRoomInventory.get_inventory(session, is_suite=False):
765-
hotel, room_type = inventory_info['id'], inventory_info['room_type']
766-
info_for_room = {'room_type': room_type, 'quantity': inventory_info['quantity']}
767-
if assigned_applications_dict.get((hotel, room_type)):
768-
for status, count in assigned_applications_dict[(hotel, room_type)]:
733+
for inv in session.query(HotelRoomInventory).filter_by(is_suite=False, active=True).all():
734+
hotel_obj = hotel_lookup.get(str(inv.hotel_id))
735+
rt_obj = room_type_lookup.get(str(inv.room_type_id))
736+
info_for_room = {'room_type': rt_obj, 'quantity': inv.quantity}
737+
if assigned_applications_dict.get((str(inv.hotel_id), str(inv.room_type_id))):
738+
for status, count in assigned_applications_dict[(str(inv.hotel_id), str(inv.room_type_id))]:
769739
info_for_room[status] = count
770-
room_inventory[hotel].append(info_for_room)
740+
room_inventory[hotel_obj].append(info_for_room)
771741

772742
suite_inventory = defaultdict(list)
773-
for inventory_info in HotelRoomInventory.get_inventory(session, is_suite=True):
774-
hotel, room_type = inventory_info['id'], inventory_info['room_type']
775-
info_for_room = {'room_type': room_type, 'quantity': inventory_info['quantity']}
776-
if assigned_applications_dict.get((hotel, room_type)):
777-
for status, count in assigned_applications_dict[(hotel, room_type)]:
743+
for inv in session.query(HotelRoomInventory).filter_by(is_suite=True, active=True).all():
744+
hotel_obj = hotel_lookup.get(str(inv.hotel_id))
745+
st_obj = room_type_lookup.get(str(inv.suite_type_id))
746+
info_for_room = {'room_type': st_obj, 'quantity': inv.quantity}
747+
if assigned_applications_dict.get((str(inv.hotel_id), str(inv.suite_type_id))):
748+
for status, count in assigned_applications_dict[(str(inv.hotel_id), str(inv.suite_type_id))]:
778749
info_for_room[status] = count
779-
suite_inventory[hotel].append(info_for_room)
750+
suite_inventory[hotel_obj].append(info_for_room)
780751

781752
return {
782753
'room_inventory': room_inventory,
783754
'suite_inventory': suite_inventory,
784-
'hotels': session.query(LotteryHotel).filter_by(active=True).order_by(LotteryHotel.name).all(),
785-
'room_types': session.query(LotteryRoomType).filter_by(is_suite=False, active=True).order_by(LotteryRoomType.name).all(),
786-
'suite_types': session.query(LotteryRoomType).filter_by(is_suite=True, active=True).order_by(LotteryRoomType.name).all(),
787755
'now': localized_now(),
788756
}
789757

uber/templates/confirm_tabs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<li class="nav-item" role="presentation">
7171
<a href="../hotel_lottery/index?attendee_id={{ attendee.id }}" class="nav-link{% if 'hotel_lottery' in c.PAGE_PATH %} active{% endif %}">
7272
<span class="fa fa-hotel"></span>
73-
{% if attendee.lottery_application and attendee.lottery_application.finalized and not attendee.lottery_application.final_status_hidden %}
73+
{% if attendee.lottery_application and attendee.lottery_application.finalized %}
7474
Hotel Lottery Results
7575
{% elif attendee.lottery_application and attendee.lottery_application.complete_or_processed %}
7676
{% set app_or_parent = attendee.lottery_application.parent_application if attendee.lottery_application.entry_type == c.GROUP_ENTRY else attendee.lottery_application %}

uber/templates/emails/hotel/enter_lottery.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
<p>
55
{{ attendee.full_name }},<br/>
66
Your registration qualifies for entering the {{ c.EVENT_NAME_AND_YEAR }} hotel lottery, but you haven't entered yet.
7-
{% if c.HOTEL_LOTTERY_FORM_WAITLIST %}
8-
The deadline for entering the first run of the lottery is in {{ ((c.HOTEL_LOTTERY_FORM_WAITLIST - now_localized()).total_seconds() // 86400)|int }} days, on {{ c.HOTEL_LOTTERY_FORM_WAITLIST|datetime_local("%B %-d, %Y at %-I:%M%p %Z") }},
9-
{% else %}
107
The lottery closes in {{ ((c.HOTEL_LOTTERY_FORM_DEADLINE - now_localized()).total_seconds() // 86400)|int }} days, on {{ c.HOTEL_LOTTERY_FORM_DEADLINE|datetime_local("%B %-d, %Y at %-I:%M%p %Z") }},
11-
{% endif %}
128
so hurry and <a href="{{ c.URL_BASE }}/hotel_lottery/start?attendee_id={{ attendee.id }}" target="_blank">enter your preferences</a> before then!
139
</p>
1410
<p>

uber/templates/emails/hotel/lottery_reminder.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
<p>
77
{{ app.attendee.full_name }},<br/>
88
Your entry into the {{ c.EVENT_NAME }} {% if staff_lottery %}staff {% endif %}hotel lottery is not complete!
9-
{% if c.HOTEL_LOTTERY_FORM_WAITLIST and not (c.STAFF_HOTEL_LOTTERY_OPEN and app_or_parent.qualifies_for_staff_lottery) %}
10-
The deadline for entering the first run of the lottery is in {{ ((c.HOTEL_LOTTERY_FORM_WAITLIST - now_localized()).total_seconds() // 86400)|int }} days, on {{ c.HOTEL_LOTTERY_FORM_WAITLIST|datetime_local("%B %-d, %Y at %-I:%M%p %Z") }}.
11-
{% else %}
129
The lottery closes in {{ ((app.current_lottery_deadline - now_localized()).total_seconds() // 86400)|int }} days, on {{ app.current_lottery_deadline|datetime_local("%B %-d, %Y at %-I:%M%p %Z") }}.
13-
{% endif %}
1410
</p>
1511
<p>
1612
You can complete your entry or withdraw from the lottery by {% if c.ATTENDEE_ACCOUNTS_ENABLED %}logging into{% else %}visiting{% endif %} your <a href="{{ c.URL_BASE }}/hotel_lottery/index?attendee_id={{ app.attendee.id }}" target="_blank">lottery options page</a>.

uber/templates/emails/hotel/reject_notification.html

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,6 @@
66
{{ app.attendee.full_name }},<br/>
77
<strong><span class="text-danger">{{ app.award_status_str }}</span></strong>
88
</p>
9-
{% block reject_info %}
10-
{% if not app_or_parent.finalized and c.HOTEL_LOTTERY_OPEN and c.HOTEL_LOTTERY_FORM_WAITLIST and c.AFTER_HOTEL_LOTTERY_FORM_WAITLIST %}
11-
<p>
12-
Your{% if app.parent_application %} {{ c.HOTEL_LOTTERY_GROUP_TERM|lower }}'s{% endif %} lottery entry is still active and will be considered when allocating cancelled rooms.
13-
If you{% if app.parent_application %}r {{ c.HOTEL_LOTTERY_GROUP_TERM|lower }} is{% else %} are{% endif %} chosen for one of these rooms, you will receive an email and
14-
you{% if app.parent_application %}r {{ c.HOTEL_LOTTERY_GROUP_TERM|lower }} leader{% endif %} will be given the chance to confirm or decline the reservation.
15-
</p>
16-
{% endif %}
17-
{% endblock %}
18-
{% if not app_or_parent.finalized and c.HOTEL_LOTTERY_OPEN and c.HOTEL_LOTTERY_FORM_WAITLIST and c.AFTER_HOTEL_LOTTERY_FORM_WAITLIST %}
19-
<p>
20-
You can also
21-
{% if not app.parent_application %}edit your lottery entry details{% else %}view your {{ c.HOTEL_LOTTERY_GROUP_TERM|lower }}'s entry or leave your {{ c.HOTEL_LOTTERY_GROUP_TERM|lower }}{% endif %}
22-
by {% if c.ATTENDEE_ACCOUNTS_ENABLED %}logging into{% else %}visiting{% endif %} your <a href="{{ c.URL_BASE }}/hotel_lottery/index?attendee_id={{ app.attendee.id }}" target="_blank">lottery options page</a>.
23-
</p>
24-
{% endif %}
9+
{% block reject_info %}{% endblock %}
2510
</body>
2611
</html>

0 commit comments

Comments
 (0)