reviewboard.accounts.forms.pages¶
- class AccountPageForm(page, request, user, *args, **kwargs)[source]¶
Bases:
ConfigPageForm
Base class for a form on the My Account page.
AccountPageForms belong to AccountPages, and will be displayed on the My Account page for a user.
A simple form presents fields that can be filled out and posted. More advanced forms can supply their own template or even their own JavaScript models and views.
- is_visible()[source]¶
Return whether or not the form should be rendered.
This is a base implementation that takes into account a set of required features.
- Returns
bool: Whether or not the form should be rendered.
- __annotations__ = {'css_bundle_names': 'List[str]', 'form_id': 'Optional[str]', 'form_title': 'Optional[StrOrPromise]', 'js_bundle_names': 'List[str]', 'js_model_class': 'Optional[str]', 'js_view_class': 'Optional[str]', 'save_label': 'Optional[StrOrPromise]'}¶
- declared_fields = {'form_target': <django.forms.fields.CharField object>}¶
- class AccountSettingsForm(page, request, user, *args, **kwargs)[source]¶
Bases:
AccountPageForm
Form for the Settings page for an account.
- form_id: Optional[str] = 'settings'[source]¶
The unique ID of the form.
This must be unique across all ConfigPages at a given URL.
- __annotations__ = {'css_bundle_names': 'List[str]', 'form_id': 'Optional[str]', 'form_title': 'Optional[StrOrPromise]', 'js_bundle_names': 'List[str]', 'js_model_class': 'Optional[str]', 'js_view_class': 'Optional[str]', 'save_label': 'Optional[StrOrPromise]'}¶
- declared_fields = {'default_use_rich_text': <django.forms.fields.BooleanField object>, 'enable_desktop_notifications': <django.forms.fields.BooleanField object>, 'form_target': <django.forms.fields.CharField object>, 'open_an_issue': <django.forms.fields.BooleanField object>, 'should_send_email': <django.forms.fields.BooleanField object>, 'should_send_own_updates': <django.forms.fields.BooleanField object>, 'syntax_highlighting': <django.forms.fields.BooleanField object>, 'timezone': <djblets.forms.fields.TimeZoneField object>}¶
- class AvatarSettingsForm(*args, **kwargs)[source]¶
Bases:
AvatarSettingsForm
A form for configuring the avatar for a user.
This form will only be shown when avatars are enabled for the server.
- avatar_service_registry = <SimpleLazyObject: <reviewboard.avatars.registry.AvatarServiceRegistry object>>[source]¶
The avatar service registry. Subclasses must override this.
- is_visible()[source]¶
Return whether or not to show the avatar settings form.
- Returns:
Whether or not to show the avatar settings form.
- Return type:
- __annotations__ = {'css_bundle_names': 'List[str]', 'form_id': 'Optional[str]', 'form_title': 'Optional[StrOrPromise]', 'js_bundle_names': 'List[str]', 'js_model_class': 'Optional[str]', 'js_view_class': 'Optional[str]', 'save_label': 'Optional[StrOrPromise]'}¶
- declared_fields = {'avatar_service_id': <django.forms.fields.ChoiceField object>, 'form_target': <django.forms.fields.CharField object>}¶
- class APITokensForm(page, request, user, *args, **kwargs)[source]¶
Bases:
AccountPageForm
Form for showing a user’s API tokens.
- form_id: Optional[str] = 'api_tokens'[source]¶
The unique ID of the form.
This must be unique across all ConfigPages at a given URL.
- save_label: Optional[StrOrPromise] = None[source]¶
The label for the save button.
This can be set to
None
to disable the button.
- js_view_class: Optional[str] = 'RB.APITokensView'[source]¶
The optional Backbone view used to render the form.
- __annotations__ = {'css_bundle_names': 'List[str]', 'form_id': 'Optional[str]', 'form_title': 'Optional[StrOrPromise]', 'js_bundle_names': 'List[str]', 'js_model_class': 'Optional[str]', 'js_view_class': 'Optional[str]', 'save_label': 'Optional[StrOrPromise]'}¶
- declared_fields = {'form_target': <django.forms.fields.CharField object>}¶
- class ChangePasswordForm(page, request, user, *args, **kwargs)[source]¶
Bases:
AccountPageForm
Form for changing a user’s password.
- form_id: Optional[str] = 'change_password'[source]¶
The unique ID of the form.
This must be unique across all ConfigPages at a given URL.
- save_label: Optional[StrOrPromise] = 'Change Password'[source]¶
The label for the save button.
This can be set to
None
to disable the button.
- is_visible()[source]¶
Return whether or not the “change password” form should be shown.
- Returns:
Whether or not the form will be rendered.
- Return type:
- clean_old_password()[source]¶
Validate the ‘old_password’ field.
This checks to make sure the old password is correct when changing the password.
- clean_password2()[source]¶
Validate the ‘password2’ field.
This makes sure that the two password fields match.
- __annotations__ = {'css_bundle_names': 'List[str]', 'form_id': 'Optional[str]', 'form_title': 'Optional[StrOrPromise]', 'js_bundle_names': 'List[str]', 'js_model_class': 'Optional[str]', 'js_view_class': 'Optional[str]', 'save_label': 'Optional[StrOrPromise]'}¶
- declared_fields = {'form_target': <django.forms.fields.CharField object>, 'old_password': <django.forms.fields.CharField object>, 'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>}¶
- class ProfileForm(page, request, user, *args, **kwargs)[source]¶
Bases:
AccountPageForm
Form for the Profile page for an account.
- form_id: Optional[str] = 'profile'[source]¶
The unique ID of the form.
This must be unique across all ConfigPages at a given URL.
- save_label: Optional[StrOrPromise] = 'Save Profile'[source]¶
The label for the save button.
This can be set to
None
to disable the button.
- __annotations__ = {'css_bundle_names': 'List[str]', 'form_id': 'Optional[str]', 'form_title': 'Optional[StrOrPromise]', 'js_bundle_names': 'List[str]', 'js_model_class': 'Optional[str]', 'js_view_class': 'Optional[str]', 'save_label': 'Optional[StrOrPromise]'}¶
- declared_fields = {'email': <django.forms.fields.EmailField object>, 'first_name': <django.forms.fields.CharField object>, 'form_target': <django.forms.fields.CharField object>, 'last_name': <django.forms.fields.CharField object>, 'profile_private': <django.forms.fields.BooleanField object>}¶
- class GroupsForm(page, request, user, *args, **kwargs)[source]¶
Bases:
AccountPageForm
Form for the group membership page.
Unlike most forms, this doesn’t deal with fields or saving to the database. Instead, it sets up the JavaScript View and provides serialized data representing the groups. The View handles group membership through the API.
- form_id: Optional[str] = 'groups'[source]¶
The unique ID of the form.
This must be unique across all ConfigPages at a given URL.
- save_label: Optional[StrOrPromise] = None[source]¶
The label for the save button.
This can be set to
None
to disable the button.
- js_view_class: Optional[str] = 'RB.JoinedGroupsView'[source]¶
The optional Backbone view used to render the form.
- __annotations__ = {'css_bundle_names': 'List[str]', 'form_id': 'Optional[str]', 'form_title': 'Optional[StrOrPromise]', 'js_bundle_names': 'List[str]', 'js_model_class': 'Optional[str]', 'js_view_class': 'Optional[str]', 'save_label': 'Optional[StrOrPromise]'}¶
- declared_fields = {'form_target': <django.forms.fields.CharField object>}¶
- class OAuthApplicationsForm(page, request, user, *args, **kwargs)[source]¶
Bases:
AccountPageForm
The OAuth Application form.
This provides a list of all current OAuth2 applications the user has access to.
- form_id: Optional[str] = 'oauth'[source]¶
The unique ID of the form.
This must be unique across all ConfigPages at a given URL.
- form_title: Optional[StrOrPromise] = 'OAuth Applications'[source]¶
The displayed title for the form.
- js_view_class: Optional[str] = 'RB.OAuthApplicationsView'[source]¶
The optional Backbone view used to render the form.
- required_features = [<reviewboard.oauth.features.OAuth2ServiceFeature object>][source]¶
Features required for a form to be displayed.
- save_label: Optional[StrOrPromise] = None[source]¶
The label for the save button.
This can be set to
None
to disable the button.
- get_js_view_data()[source]¶
Return the data for the associated Javascript view.
- Returns:
Data to be passed to the Javascript view.
- Return type:
- static serialize_app(app)[source]¶
Serialize an application for the JavaScript view.
- Parameters:
app (
reviewboard.oauth.models.Application
) – The application to serialize.- Returns:
The serialized application.
- Return type:
- __annotations__ = {'css_bundle_names': 'List[str]', 'form_id': 'Optional[str]', 'form_title': 'Optional[StrOrPromise]', 'js_bundle_names': 'List[str]', 'js_model_class': 'Optional[str]', 'js_view_class': 'Optional[str]', 'save_label': 'Optional[StrOrPromise]'}¶
- declared_fields = {'form_target': <django.forms.fields.CharField object>}¶
- class OAuthTokensForm(page, request, user, *args, **kwargs)[source]¶
Bases:
AccountPageForm
The OAuth Token form
This provides a list of all current OAuth2 tokens the user has created.
- form_id: Optional[str] = 'oauth_tokens'[source]¶
The unique ID of the form.
This must be unique across all ConfigPages at a given URL.
- js_view_class: Optional[str] = 'RB.OAuthTokensView'[source]¶
The optional Backbone view used to render the form.
- required_features = [<reviewboard.oauth.features.OAuth2ServiceFeature object>][source]¶
Features required for a form to be displayed.
- save_label: Optional[StrOrPromise] = None[source]¶
The label for the save button.
This can be set to
None
to disable the button.
- static serialize_token(token)[source]¶
Serialize a single token for the JavaScript view.
- Returns:
A dict with the following keys:
'apiURL'
(unicode
):The URL to access the token via the API.
'application'
(unicode
):The name of the application the token is associated with.
- Return type:
- __annotations__ = {'css_bundle_names': 'List[str]', 'form_id': 'Optional[str]', 'form_title': 'Optional[StrOrPromise]', 'js_bundle_names': 'List[str]', 'js_model_class': 'Optional[str]', 'js_view_class': 'Optional[str]', 'save_label': 'Optional[StrOrPromise]'}¶
- declared_fields = {'form_target': <django.forms.fields.CharField object>}¶
- class PrivacyForm(*args, **kwargs)[source]¶
Bases:
ConsentConfigPageFormMixin
,AccountPageForm
A form for displaying privacy information and gathering consent.
This will display a user’s privacy rights, link to any configured Privacy Policy document, and display a form for gathering consent for features that make use of the user’s personally identifying information.
- load()[source]¶
Load the form data.
If a
?next
query argument is provided, it will be loaded into the initial value for thenext_url
so that it will persist through page submission.
- is_visible()[source]¶
Return whether or not the form should be rendered.
This will check if there’s any information to display in this form. It’s only displayed if consent requirements are enabled or there’s any privacy information configured in Admin Settings.
- Returns
bool: Whether or not the form should be rendered.
- get_extra_context()[source]¶
Return extra context for the template.
- Returns:
Context used for rendering the form’s template.
- Return type:
- clean_next_url()[source]¶
Clean the next_url field.
- Returns:
The URL to redirect to, if any.
- Return type:
- save()[source]¶
Save the privacy form.
This may redirect the user to the next URL if it is specified.
- Returns:
A redirect to the next URL if given and
None
otherwise.- Return type:
- __annotations__ = {'css_bundle_names': 'List[str]', 'form_id': 'Optional[str]', 'form_title': 'Optional[StrOrPromise]', 'js_bundle_names': 'List[str]', 'js_model_class': 'Optional[str]', 'js_view_class': 'Optional[str]', 'save_label': 'Optional[StrOrPromise]'}¶
- declared_fields = {'form_target': <django.forms.fields.CharField object>, 'next_url': <django.forms.fields.CharField object>}¶