Auth plugin¶
Plugins for Django CMS QE providing authentication. It allows user to register and login into site.
Usage¶
Authentication forms are activated by default and is possible to use at /auth/login or /auth/register but you can also use login or registration form anywhere you want. Just from section Generic use Login form or Register form.
API¶
Django CMS¶
-
class
cms_qe_auth.cms_plugins.
LoginFormPlugin
(model=None, admin_site=None)[source]¶ CMS plugin allowing the user to log into site.
-
form
¶ alias of
django.forms.widgets.LoginFormPluginForm
-
render
(context: dict, instance: cms.models.pluginmodel.CMSPlugin, placeholder) → dict[source]¶ This method returns the context to be used to render the template specified in
render_template
.Parameters: Return type: dict or
django.template.Context
This method must return a dictionary or an instance of
django.template.Context
, which will be used as context to render the plugin template.By default, this method will add
instance
andplaceholder
to the context, which means for simple plugins, there is no need to overwrite this method.If you overwrite this method it’s recommended to always populate the context with default values by calling the render method of the super class:
def render(self, context, instance, placeholder): context = super().render(context, instance, placeholder) ... return context
-
-
class
cms_qe_auth.cms_plugins.
RegisterFormPlugin
(model=None, admin_site=None)[source]¶ CMS plugin allowing the user to register into site.
-
form
¶ alias of
django.forms.widgets.RegisterFormPluginForm
-
render
(context: dict, instance: cms.models.pluginmodel.CMSPlugin, placeholder) → dict[source]¶ This method returns the context to be used to render the template specified in
render_template
.Parameters: Return type: dict or
django.template.Context
This method must return a dictionary or an instance of
django.template.Context
, which will be used as context to render the plugin template.By default, this method will add
instance
andplaceholder
to the context, which means for simple plugins, there is no need to overwrite this method.If you overwrite this method it’s recommended to always populate the context with default values by calling the render method of the super class:
def render(self, context, instance, placeholder): context = super().render(context, instance, placeholder) ... return context
-
Models¶
-
class
cms_qe_auth.models.
User
(id, password, last_login, is_superuser, username, first_name, last_name, email, is_staff, is_active, date_joined)[source]¶ Parameters: - id (BigAutoField) –
- password (CharField) –
- last_login (DateTimeField) –
- is_superuser (BooleanField) – Designates that this user has all permissions without explicitly assigning them.
- username (CharField) – Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
- first_name (CharField) –
- last_name (CharField) –
- email (EmailField) –
- is_staff (BooleanField) – Designates whether the user can log into this admin site.
- is_active (BooleanField) – Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
- date_joined (DateTimeField) –
- groups (ManyToManyField) – The groups this user belongs to. A user will get all permissions granted to each of their groups.
- user_permissions (ManyToManyField) – Specific permissions for this user.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
save
(*args, **kwargs)[source]¶ Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
Views¶
-
cms_qe_auth.views.
register
(request: django.http.request.HttpRequest, template_name: str = 'cms_qe/auth/register.html', register_form: type = <class 'cms_qe_auth.forms.RegisterForm'>)[source]¶ Displays the register form and handles the register action.
-
class
cms_qe_auth.forms.
PasswordResetFormWithEmailExistenceCheck
(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]¶ Adding verification that the user exists in the database to PasswordResetForm.
https://github.com/django/django/blob/master/django/contrib/auth/views.py