supercontest.views.admin

Defines all the views that are available on the admin panel.

Module Attributes

AdminHomeView

The home route for the admin panel.

Classes

AdminModelView

Shows the admin the database tables for checking data.

BackToSupercontestView

Takes you back to the actual supercontest, away from admin views.

ChangeStatusView

Allows an admin to change the status of a game manually.

CommitLinesManualView

Manual entry view for an admin to commit lines.

CommitLinesView

The weekly trigger for an admin to commit lines.

EmailAllUsersView

Allows admin to email the whole league, respecting notification settings.

LatePicksView

Allows admin to submit late picks in an easy form.

PaidLeagueView

Allows admin to add users to the current season's paid league.

SBSCBaseView

Common functionality across all supercontest admin views.

supercontest.views.admin.AdminHomeView = <flask_admin.base.AdminIndexView object>

The home route for the admin panel.

class supercontest.views.admin.AdminModelView(model: Any, session: Any, **kwargs: Any)

Bases: ModelView

Shows the admin the database tables for checking data. Note that I generalize all settings here, rather than a custom class per model.

This one intentionally inherits from a different parent.

action_view()

Mass-model action view.

ajax_lookup()
ajax_update()

Edits a single column of a record in list view.

can_create = False

Is model creation allowed

can_delete = False

Is model deletion allowed

can_edit = False

Is model editing allowed

can_export = True

Is model list export allowed

can_view_details = True

Setting this to true will enable the details view. This is recommended when there are too many columns to display in the list_view.

column_default_sort = ('id', True)

Default sort column if no sorting is applied.

Example:

class MyModelView(BaseModelView):
    column_default_sort = 'user'

You can use tuple to control ascending descending order. In following example, items will be sorted in descending order:

class MyModelView(BaseModelView):
    column_default_sort = ('user', True)

If you want to sort by more than one column, you can pass a list of tuples:

class MyModelView(BaseModelView):
    column_default_sort = [('name', True), ('last_name', True)]
column_display_pk = True

Controls if the primary key should be displayed in the list view.

create_view()

Create model view

delete_view()

Delete model view. Only POST method is allowed.

details_view()

Details model view

edit_view()

Edit model view

export(export_type)
form_base_class

alias of SecureForm

inaccessible_callback(name: str, **kwargs: Any) str

Simply the callback for is_accessible() failure.

Parameters:
  • name – The flask_admin name.

  • kwargs – The flask_admin kwargs.

Returns:

The string when a user cannot access an admin view.

index_view()

List view

is_accessible() bool

Checks if the view is reachable by the current user.

Returns:

If the user is authenticated and has the admin role.

page_size = 100

Default page size for pagination.

class supercontest.views.admin.BackToSupercontestView(name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)

Bases: SBSCBaseView

Takes you back to the actual supercontest, away from admin views.

custom_view() Response

The explicit redirect from the admin panel back to the supercontest.

Returns:

A redirect to the root of the API.

view_caller() str

Generic caller for the actual view function.

Returns:

The rendered template of the route.

class supercontest.views.admin.ChangeStatusView(name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)

Bases: SBSCBaseView

Allows an admin to change the status of a game manually. Useful if the score-fetch is not updated to live/realtime.

custom_view() str

The explicit view to render the status change template.

Returns:

The rendered template of the route.

view_caller() str

Generic caller for the actual view function.

Returns:

The rendered template of the route.

class supercontest.views.admin.CommitLinesManualView(name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)

Bases: SBSCBaseView

Manual entry view for an admin to commit lines.

custom_view() str

The explicit function to render the manual line commit template.

Returns:

The rendered template of the route.

view_caller() str

Generic caller for the actual view function.

Returns:

The rendered template of the route.

class supercontest.views.admin.CommitLinesView(name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)

Bases: SBSCBaseView

The weekly trigger for an admin to commit lines.

custom_view() str

The explicit function to render the line commit template.

Returns:

The rendered template of the route.

view_caller() str

Generic caller for the actual view function.

Returns:

The rendered template of the route.

class supercontest.views.admin.EmailAllUsersView(name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)

Bases: SBSCBaseView

Allows admin to email the whole league, respecting notification settings. Sends to anyone who has ANY of the emails enabled (set union). Could filter down to current users who have picked this season, but then that wouldn’t work in preseason to get people ready. Plus advertising is important - we want to increase reach as much as possible. Notification settings are custom per user, so they have full control, like any other app.

custom_view() str

The explicit function to render the email-all-users template.

Returns:

The rendered template of the route.

view_caller() str

Generic caller for the actual view function.

Returns:

The rendered template of the route.

class supercontest.views.admin.LatePicksView(name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)

Bases: SBSCBaseView

Allows admin to submit late picks in an easy form.

custom_view() str

The explicit function to render the late pick template.

Returns:

The rendered template of the route.

view_caller() str

Generic caller for the actual view function.

Returns:

The rendered template of the route.

class supercontest.views.admin.PaidLeagueView(name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)

Bases: SBSCBaseView

Allows admin to add users to the current season’s paid league.

custom_view() str

The explicit function to render the paid league template.

Returns:

The rendered template of the route.

view_caller() str

Generic caller for the actual view function.

Returns:

The rendered template of the route.

class supercontest.views.admin.SBSCBaseView(name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)

Bases: BaseView

Common functionality across all supercontest admin views.

inaccessible_callback(name: str, **kwargs: Any) str

Simply the callback for is_accessible() failure.

Parameters:
  • name – The flask_admin name.

  • kwargs – The flask_admin kwargs.

Returns:

The string when a user cannot access an admin view.

is_accessible() bool

Checks if the view is reachable by the current user.

Returns:

If the user is authenticated and has the admin role.

view_caller() str

Generic caller for the actual view function.

Returns:

The rendered template of the route.