From 9db626c1642c6eaee86dad860dbb8282c19a9de2 Mon Sep 17 00:00:00 2001 From: Victoria Earl Date: Wed, 9 Aug 2023 22:06:43 -0400 Subject: [PATCH] Fix updating admin accounts Fixes some issues with updating admin accounts, and updates the look of the admin accounts page to better fit Bootstrap 5. Also fixes an issue with getting attendee age groups. Also also makes some mass updates throughout the admin section to get more Bootstrap 5 stuff working. --- uber/config.py | 2 +- uber/forms/__init__.py | 1 + uber/models/attendee.py | 6 +- uber/site_sections/accounts.py | 4 +- uber/templates/accounts/access_groups.html | 8 +-- uber/templates/accounts/index.html | 64 ++++++++++--------- uber/templates/art_show_admin/form.html | 6 +- .../art_show_common/art_pieces_form.html | 2 +- uber/templates/attractions/events.html | 4 +- uber/templates/attractions_admin/event.html | 2 +- uber/templates/attractions_admin/form.html | 2 +- uber/templates/attractions_macros.html | 4 +- uber/templates/marketplace_admin/form.html | 6 +- .../panels_admin/panel_feedback.html | 2 +- .../promo_codes/generate_promo_codes.html | 2 +- uber/templates/promo_codes/index.html | 2 +- uber/templates/registration/index_base.html | 2 +- .../registration/promo_code_group_form.html | 4 +- 18 files changed, 63 insertions(+), 60 deletions(-) diff --git a/uber/config.py b/uber/config.py index 7f5c5b58f..9bdf31cf4 100644 --- a/uber/config.py +++ b/uber/config.py @@ -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): diff --git a/uber/forms/__init__.py b/uber/forms/__init__.py index 678231207..31cfbf591 100644 --- a/uber/forms/__init__.py +++ b/uber/forms/__init__.py @@ -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 \ No newline at end of file diff --git a/uber/models/attendee.py b/uber/models/attendee.py index 0c410f925..24f223901 100644 --- a/uber/models/attendee.py +++ b/uber/models/attendee.py @@ -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 @@ -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): diff --git a/uber/site_sections/accounts.py b/uber/site_sections/accounts.py index 45691a70c..d499991bc 100644 --- a/uber/site_sections/accounts.py +++ b/uber/site_sections/accounts.py @@ -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) @@ -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: diff --git a/uber/templates/accounts/access_groups.html b/uber/templates/accounts/access_groups.html index 2607cdb84..ae42181b8 100644 --- a/uber/templates/accounts/access_groups.html +++ b/uber/templates/accounts/access_groups.html @@ -162,10 +162,10 @@

Access Groups

{{ section|replace('_', ' ')|title }} - + - + {% for page in c.ADMIN_PAGES[section] %} @@ -173,10 +173,10 @@

Access Groups

{{ page }} - + - + {% endfor %} diff --git a/uber/templates/accounts/index.html b/uber/templates/accounts/index.html index 760f2a00e..01ef9b7db 100644 --- a/uber/templates/accounts/index.html +++ b/uber/templates/accounts/index.html @@ -10,45 +10,49 @@
-

New Account

+ New Account
-
+ {{ csrf_token() }} -
- - -
-
- -
- - {% if not c.AT_OR_POST_CON %} - - {% endif %} +
+
+ + +
+
+ {{ macros.checkgroup_opts( + 'access_groups_ids', + c.ACCESS_GROUP_OPTS, + include_empty_hidden=True) }}
-
-
- {{ macros.checkgroup_opts( - 'access_groups_ids', - c.ACCESS_GROUP_OPTS, - include_empty_hidden=True) }} +
+ {% if c.AT_OR_POST_CON %} +
+ + +
+
+ + +
+ {% endif %} +
+ +
-
- +
-

Existing Accounts

+ Existing Accounts
@@ -72,12 +76,12 @@

Existing Accounts

{{ csrf_token() }} + {{ account.access_groups_ids }}
{{ macros.checkgroup_opts( 'access_groups_ids', c.ACCESS_GROUP_OPTS, - defaults=account.access_groups_ids, - include_empty_hidden=True) }} + defaults=account.access_groups_ids) }}
{% if account.attendee.assigned_depts %} @@ -90,7 +94,7 @@

Existing Accounts

{{ csrf_token() }} diff --git a/uber/templates/art_show_admin/form.html b/uber/templates/art_show_admin/form.html index d6e977096..43ab6906a 100644 --- a/uber/templates/art_show_admin/form.html +++ b/uber/templates/art_show_admin/form.html @@ -31,7 +31,7 @@

Art Show Application Form{% if app.attendee %} for {{ app.attendee|form_link
- {{ options(all_attendees, attendee_id) }} @@ -41,7 +41,7 @@

Art Show Application Form{% if app.attendee %} for {{ app.attendee|form_link
- {{ options(c.BADGE_STATUS_OPTS, app.attendee.badge_status) }}
@@ -51,7 +51,7 @@

Art Show Application Form{% if app.attendee %} for {{ app.attendee|form_link
- {{ options(c.ART_SHOW_STATUS_OPTS, app.status) }}
diff --git a/uber/templates/art_show_common/art_pieces_form.html b/uber/templates/art_show_common/art_pieces_form.html index cf595499f..0342b1cfd 100644 --- a/uber/templates/art_show_common/art_pieces_form.html +++ b/uber/templates/art_show_common/art_pieces_form.html @@ -209,7 +209,7 @@

Art Show Pieces

- +
@@ -430,7 +430,7 @@

{{ day }}

data-event-start-time="{{ event.start_time_label }}">

{{ event.time_span_label }}

{{ event.duration_label }} diff --git a/uber/templates/attractions_admin/event.html b/uber/templates/attractions_admin/event.html index 17c25aa67..deaf8c271 100644 --- a/uber/templates/attractions_admin/event.html +++ b/uber/templates/attractions_admin/event.html @@ -194,7 +194,7 @@

diff --git a/uber/templates/marketplace_admin/form.html b/uber/templates/marketplace_admin/form.html index d02b06cf5..659e16583 100644 --- a/uber/templates/marketplace_admin/form.html +++ b/uber/templates/marketplace_admin/form.html @@ -30,7 +30,7 @@

Marketplace Application Form{% if app.attendee %} for {{ app.attendee|form_l
- {{ options(all_attendees, attendee_id) }} @@ -40,7 +40,7 @@

Marketplace Application Form{% if app.attendee %} for {{ app.attendee|form_l
- {{ options(c.BADGE_STATUS_OPTS, app.attendee.badge_status) }}
@@ -50,7 +50,7 @@

Marketplace Application Form{% if app.attendee %} for {{ app.attendee|form_l
- {{ options(c.MARKETPLACE_STATUS_OPTS, app.status) }}
diff --git a/uber/templates/panels_admin/panel_feedback.html b/uber/templates/panels_admin/panel_feedback.html index e09d518bf..a7b8b0b1f 100644 --- a/uber/templates/panels_admin/panel_feedback.html +++ b/uber/templates/panels_admin/panel_feedback.html @@ -23,7 +23,7 @@

Feedback for {{ event.name }}

- {{ options(c.PANEL_FEEDBACK_OPTS, feedback.rating) }}
diff --git a/uber/templates/promo_codes/generate_promo_codes.html b/uber/templates/promo_codes/generate_promo_codes.html index 1d189cc4c..9682e6bec 100644 --- a/uber/templates/promo_codes/generate_promo_codes.html +++ b/uber/templates/promo_codes/generate_promo_codes.html @@ -319,7 +319,7 @@