from ocyan.main.loading import get_ocyan_class

account_chooser_viewset = get_ocyan_class(
    "ocyan_plugin_wagtail.viewsets", "account_chooser_viewset"
)


class NonStaffAccountChooserWidget(account_chooser_viewset.widget_class):
    """
    Only shows users that are not staff or superuser.
    Please make sure you add the correct validation on the model as well,
    this does NOT validate the input so it can be tempered with!
    """

    def get_chooser_modal_url(self):
        url = super().get_chooser_modal_url()
        return "%s?is_superuser=False&is_staff=False" % url
