Skip to content

Commit

Permalink
Merge pull request #4209 from magfest/fix-updating-admin-accounts
Browse files Browse the repository at this point in the history
Fix updating admin accounts
  • Loading branch information
kitsuta authored Aug 10, 2023
2 parents 658b0e0 + 9db626c commit 1aff827
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 60 deletions.
2 changes: 1 addition & 1 deletion uber/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def PREREG_AGE_GROUP_OPTS(self):

@property
def NOW_OR_AT_CON(self):
return c.EPOCH.date() if date.today().date() <= c.EPOCH.date() else uber.utils.localized_now().date()
return c.EPOCH.date() if date.today() <= c.EPOCH.date() else uber.utils.localized_now().date()

@property
def AT_OR_POST_CON(self):
Expand Down
1 change: 1 addition & 0 deletions uber/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,4 @@ def getlist(self, arg):


from uber.forms.attendee import * # noqa: F401,E402,F403
from uber.forms.group import * # noqa: F401,E402,F403
6 changes: 2 additions & 4 deletions uber/models/attendee.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ def times_printed(cls):
def age_now_or_at_con(self):
if not self.birthdate:
return None

return get_age_from_birthday(self.birthdate, c.NOW_OR_AT_CON)

@presave_adjustment
Expand Down Expand Up @@ -856,10 +857,7 @@ def age_discount(self):

@property
def age_group_conf(self):
if self.birthdate:
return get_age_conf_from_birthday(self.birthdate, c.NOW_OR_AT_CON)

return c.AGE_GROUP_CONFIGS[int(self.age_group or c.AGE_UNKNOWN)]
return get_age_conf_from_birthday(self.birthdate, c.NOW_OR_AT_CON)

@property
def total_cost(self):
Expand Down
4 changes: 2 additions & 2 deletions uber/site_sections/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def index(self, session, message=''):
def update(self, session, password='', message='', **params):
if not params.get('attendee_id', '') and params.get('id', 'None') == 'None':
message = "Please select an attendee to create an admin account for."
attendee = session.attendee(params['attendee_id'])


if not message:
account = session.admin_account(params)

Expand All @@ -72,6 +71,7 @@ def update(self, session, password='', message='', **params):
message = message or check(account)
if not message:
message = 'Account settings uploaded'
attendee = session.attendee(account.attendee_id) # dumb temporary hack, will fix later with tests
account.attendee = attendee
session.add(account)
if account.is_new and not c.AT_OR_POST_CON:
Expand Down
8 changes: 4 additions & 4 deletions uber/templates/accounts/access_groups.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,21 @@ <h3 class="card-title">Access Groups</h3>
</td>
<td>{{ section|replace('_', ' ')|title }}</td>
<td>
<select class="form-control select_access" id="{{ section }}_access" name="{{ section }}_access">{{ options(c.ACCESS_GROUP_WRITE_LEVEL_OPTS,access_group.access) }}</select>
<select class="form-select select_access" id="{{ section }}_access" name="{{ section }}_access">{{ options(c.ACCESS_GROUP_WRITE_LEVEL_OPTS,access_group.access) }}</select>
</td>
<td>
<select class="form-control select_read_only_access" id="{{ section }}_read_only_access" name="{{ section }}_read_only_access">{{ options(c.ACCESS_GROUP_READ_LEVEL_OPTS,access_group.read_only_access) }}</select>
<select class="form-select select_read_only_access" id="{{ section }}_read_only_access" name="{{ section }}_read_only_access">{{ options(c.ACCESS_GROUP_READ_LEVEL_OPTS,access_group.read_only_access) }}</select>
</td>
</tr>
{% for page in c.ADMIN_PAGES[section] %}
<tr class="collapse {{ section }}">
<td></td>
<td><span class="col-sm-offset-1">{{ page }}</span></td>
<td>
<select class="form-control select_access" id="{{ section }}_{{ page }}_access" name="{{ section }}_{{ page }}_access">{{ options(c.ACCESS_GROUP_WRITE_LEVEL_OPTS,access_group.access) }}</select>
<select class="form-select select_access" id="{{ section }}_{{ page }}_access" name="{{ section }}_{{ page }}_access">{{ options(c.ACCESS_GROUP_WRITE_LEVEL_OPTS,access_group.access) }}</select>
</td>
<td>
<select class="form-control select_read_only_access" id="{{ section }}_{{ page }}_read_only_access" name="{{ section }}_{{ page }}_read_only_access">{{ options(c.ACCESS_GROUP_READ_LEVEL_OPTS,access_group.read_only_access) }}</select>
<select class="form-select select_read_only_access" id="{{ section }}_{{ page }}_read_only_access" name="{{ section }}_{{ page }}_read_only_access">{{ options(c.ACCESS_GROUP_READ_LEVEL_OPTS,access_group.read_only_access) }}</select>
</td>
</tr>
{% endfor %}
Expand Down
64 changes: 34 additions & 30 deletions uber/templates/accounts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,49 @@

<div class="card">
<div class="card-header">
<h3 class="card-title">New Account</h3>
<span class="card-title">New Account</span>
</div>
<div class="card-body">
<form id="new_admin" method="post" action="update" onsubmit="return check_passwords()" role="form" class="form-inline">
<form id="new_admin" method="post" action="update" onsubmit="return check_passwords()" role="form">
<input type="hidden" name="id" value="None" />
{{ csrf_token() }}
<div class="form-group">
<label for="attendee_id" class="sr-only">Attendee</label>
<select class="form-control" id="attendee_id" name="attendee_id">
<option value="" selected="selected">Select an attendee</option>
{{ options(all_attendees) }}
</select>
</div>
<div class="form-group">
<label for="password" class="sr-only">Password</label>
<div class="input-group">
<input type="password" class="form-control" id="password" name="password" placeholder="Password"
{% if not c.AT_OR_POST_CON %}disabled{% endif %}>
{% if not c.AT_OR_POST_CON %}
<span class="input-group-addon"><i class="fa fa-ban-circle"></i></span>
{% endif %}
<div class="row mb-sm-2">
<div class="col-12 col-sm-6">
<label for="attendee_id" class="visually-hidden">Attendee</label>
<select class="form-select" id="attendee_id" name="attendee_id">
<option value="" selected="selected">Select an attendee</option>
{{ options(all_attendees) }}
</select>
</div>
<div class="col-12 col-sm-6">
{{ macros.checkgroup_opts(
'access_groups_ids',
c.ACCESS_GROUP_OPTS,
include_empty_hidden=True) }}
</div>
<input type="password" class="form-control" id="check-password" name="check-password" placeholder="Re-enter Password"
{% if not c.AT_OR_POST_CON %}disabled{% endif %}>
</div>
<div class="form-group">
{{ macros.checkgroup_opts(
'access_groups_ids',
c.ACCESS_GROUP_OPTS,
include_empty_hidden=True) }}
<div class="row">
{% if c.AT_OR_POST_CON %}
<div class="col-6 col-sm-3">
<label for="password" class="visually-hidden">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Password">
</div>
<div class="col-6 col-sm-3">
<label for="password" class="visually-hidden">Confirm Password</label>
<input type="password" class="form-control" id="check-password" name="check-password" placeholder="Re-enter Password">
</div>
{% endif %}
<div class="col-12 col-sm-6 {% if not c.AT_OR_POST_CON %}offset-sm-6{% endif %}">
<button type="submit" class="btn btn-outline-primary">Create Account</button>
</div>
</div>
<button type="submit" class="btn btn-outline-secondary">Create Account</button>
</form>
</div>
</div>

<br/>
<div class="card">
<div class="card-header">
<h3 class="card-title">Existing Accounts</h3>
<span class="card-title">Existing Accounts</span>
</div>
<div class="card-body">
<table class="table table-striped datatable">
Expand All @@ -72,12 +76,12 @@ <h3 class="card-title">Existing Accounts</h3>
<form class="form update-form" method="post" action="update">
<input type="hidden" name="id" value="{{ account.id }}" />
{{ csrf_token() }}
{{ account.access_groups_ids }}
<div class="form-group">
{{ macros.checkgroup_opts(
'access_groups_ids',
c.ACCESS_GROUP_OPTS,
defaults=account.access_groups_ids,
include_empty_hidden=True) }}
defaults=account.access_groups_ids) }}
</div>
</form>
{% if account.attendee.assigned_depts %}
Expand All @@ -90,7 +94,7 @@ <h3 class="card-title">Existing Accounts</h3>
</td>
<td class="text-nowrap">
<button type="submit" class="btn btn-sm btn-primary update-button">
<i class="fa fa-ok"></i>
<i class="fa fa-check"></i>
</button>
<form class="form delete-form" method="post" action="delete">
{{ csrf_token() }}
Expand Down
6 changes: 3 additions & 3 deletions uber/templates/art_show_admin/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h2>Art Show Application Form{% if app.attendee %} for {{ app.attendee|form_link
<div class="form-group">
<label for="attendee" class="col-sm-3 control-label">Attendee</label>
<div class="col-sm-6">
<select class="form-control" id="attendee_id" name="attendee_id" required="true">
<select class="form-select" id="attendee_id" name="attendee_id" required="true">
<option value="" selected="selected">Select an attendee</option>
{{ options(all_attendees, attendee_id) }}
</select>
Expand All @@ -41,7 +41,7 @@ <h2>Art Show Application Form{% if app.attendee %} for {{ app.attendee|form_link
<div class="form-group">
<label for="attendee" class="col-sm-3 control-label">Attendee Badge Status</label>
<div class="col-sm-6">
<select class="form-control" id="badge_status" name="badge_status">
<select class="form-select" id="badge_status" name="badge_status">
{{ options(c.BADGE_STATUS_OPTS, app.attendee.badge_status) }}
</select>
</div>
Expand All @@ -51,7 +51,7 @@ <h2>Art Show Application Form{% if app.attendee %} for {{ app.attendee|form_link
<div class="form-group">
<label for="status" class="col-sm-3 control-label">Application Status</label>
<div class="col-sm-6">
<select class="form-control" name="status">
<select class="form-select" name="status">
{{ options(c.ART_SHOW_STATUS_OPTS, app.status) }}
</select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion uber/templates/art_show_common/art_pieces_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ <h3 class="card-title">Art Show Pieces</h3>
<select name="status" class="form-control">
{{ options(c.ART_PIECE_STATUS_OPTS, piece.status) }}
</select>
<button type="submit" class="btn btn-primary status_button"><i class="fa fa-ok"></i></button>
<button type="submit" class="btn btn-primary status_button"><i class="fa fa-check"></i></button>
<br/><label class="checkbox-label optional-field">
<input type="checkbox" name="voice_auctioned" value="1"{% if piece.voice_auctioned %} checked{% endif %} />
This piece went to voice auction.
Expand Down
4 changes: 2 additions & 2 deletions uber/templates/attractions/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ <h4 class="modal-title">
</div>
<div class="modal-footer">
<button class="btn btn-success btn-lg btn-xl">
<i class="fa fa-ok"></i> Sign up
<i class="fa fa-check"></i> Sign up
</button>
<button class="btn btn-outline-secondary btn-lg btn-xl" data-bs-dismiss="modal">Nevermind</button>
</div>
Expand Down Expand Up @@ -430,7 +430,7 @@ <h2 id="{{ day }}">{{ day }}</h2>
data-event-start-time="{{ event.start_time_label }}">
<div class="hover-btn-title">
<button class="btn btn-success btn-next btn-next-sm pull-right">
<i class="fa fa-ok"></i>
<i class="fa fa-check"></i>
</button>
<h2><span class="bling-icon"></span> {{ event.time_span_label }}</h2>
<em class="text-nowrap">{{ event.duration_label }}</em>
Expand Down
2 changes: 1 addition & 1 deletion uber/templates/attractions_admin/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ <h2 class="event-title">
<button type="submit" name="save_another_0" class="btn btn-primary">Save & Add Another</button>
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="#"><input type="submit" name="save_another_300" value="After 5 minute break"></a></li>
Expand Down
2 changes: 1 addition & 1 deletion uber/templates/attractions_admin/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ <h3 class="feature-title">
<div class="room-col">
<div class="room-title">
{% if can_admin_attraction -%}
<select class="form-control" data-feature-id="{{ feature.id }}" data-initial-value="{{ location }}">
<select class="form-select" data-feature-id="{{ feature.id }}" data-initial-value="{{ location }}">
{% if used_location_opts %}
{{ options(used_location_opts, location) }}
<option disabled="disabled">––––––––––</option>
Expand Down
4 changes: 2 additions & 2 deletions uber/templates/attractions_macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</div>
<div class="col-xs-6" style="padding-left: 8px;">
<button class="btn btn-lg btn-success" style="width: 100%">
<i class="fa fa-ok"></i> Sign up
<i class="fa fa-check"></i> Sign up
</button>
</div>
</div>
Expand All @@ -55,7 +55,7 @@
<i class="fa fa-remove"></i>
</button>
<button class="btn btn-lg btn-success">
<i class="fa fa-ok"></i>
<i class="fa fa-check"></i>
</button>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions uber/templates/marketplace_admin/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h2>Marketplace Application Form{% if app.attendee %} for {{ app.attendee|form_l
<div class="form-group">
<label for="attendee" class="col-sm-3 control-label">Attendee</label>
<div class="col-sm-6">
<select class="form-control" id="attendee_id" name="attendee_id" required="true">
<select class="form-select" id="attendee_id" name="attendee_id" required="true">
<option value="" selected="selected">Select an attendee</option>
{{ options(all_attendees, attendee_id) }}
</select>
Expand All @@ -40,7 +40,7 @@ <h2>Marketplace Application Form{% if app.attendee %} for {{ app.attendee|form_l
<div class="form-group">
<label for="attendee" class="col-sm-3 control-label">Attendee Badge Status</label>
<div class="col-sm-6">
<select class="form-control" id="badge_status" name="badge_status">
<select class="form-select" id="badge_status" name="badge_status">
{{ options(c.BADGE_STATUS_OPTS, app.attendee.badge_status) }}
</select>
</div>
Expand All @@ -50,7 +50,7 @@ <h2>Marketplace Application Form{% if app.attendee %} for {{ app.attendee|form_l
<div class="form-group">
<label for="status" class="col-sm-3 control-label">Application Status</label>
<div class="col-sm-6">
<select class="form-control" name="status">
<select class="form-select" name="status">
{{ options(c.MARKETPLACE_STATUS_OPTS, app.status) }}
</select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion uber/templates/panels_admin/panel_feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2>Feedback for {{ event.name }}</h2>
<div class="form-group">
<label class="col-sm-2 control-label">Rating:</label>
<div class="col-sm-6">
<select class="form-control" name="rating">
<select class="form-select" name="rating">
{{ options(c.PANEL_FEEDBACK_OPTS, feedback.rating) }}
</select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion uber/templates/promo_codes/generate_promo_codes.html
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ <h1>

<div id="discount-group" class="form-group">
<label class="col-sm-3 control-label">
<select class="form-control width-auto" name="discount_type" onchange="onDiscountTypeChanged()">
<select class="form-select width-auto" name="discount_type" onchange="onDiscountTypeChanged()">
{{ options(c.PROMO_CODE_DISCOUNT_TYPE_OPTS, discount_type) }}
</select>
<div class="help-block discount-type-desc">
Expand Down
2 changes: 1 addition & 1 deletion uber/templates/promo_codes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ <h4 class="modal-title" id="title-delete-unused">Delete all unused promo codes?<
{{ csrf_token() }}
<input type="hidden" name="id" value="{{ promo_code.id }}" />
<button type="submit" class="btn btn-sm btn-primary update-button">
<i class="fa fa-ok"></i>
<i class="fa fa-check"></i>
</button>
</form>
<form method="post" action="delete_promo_codes">
Expand Down
2 changes: 1 addition & 1 deletion uber/templates/registration/index_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
</style>
<a href="#set-reg-station" class="btn btn-outline-secondary" data-bs-toggle="collapse">Set At-Door Reg Station</a>
<span id="set-reg-station" class="collapse">
<label class="sr-only" for="reg_station">Reg Station #</label>
<label class="visually-hidden" for="reg_station">Reg Station #</label>
<input class="form-control" id="reg_station" name="reg_station" placeholder="Reg Station #" value="{{ reg_station }}">
<button type="submit" class="btn btn-primary">Save</button>
</span>
Expand Down
4 changes: 2 additions & 2 deletions uber/templates/registration/promo_code_group_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ <h3>Group Info for "{{ group.name }}"</h3>
<div class="form-group">
<label for="attendee" class="col-sm-3 control-label">Buyer</label>
<div class="col-sm-6">
<select class="form-control" id="attendee_id" name="buyer_id" required="required" onChange="setBuyerLink()">
<select class="form-select" id="attendee_id" name="buyer_id" required="required" onChange="setBuyerLink()">
<option value="" selected="selected">Select an attendee</option>
<option value="None">Create new attendee</option>
{{ options(all_attendees, buyer_id) }}
Expand All @@ -103,7 +103,7 @@ <h3>Group Info for "{{ group.name }}"</h3>
<div class="form-group">
<label class="col-sm-3 control-label">Badges{% if not group.is_new %} to Add{% endif %}</label>
<div class="col-sm-6">
<select class="form-control" name="badges">
<select class="form-select" name="badges">
{{ int_options(0, 100, badges) }}
</select>
</div>
Expand Down

0 comments on commit 1aff827

Please sign in to comment.