This page shows how to customize templates: https://docs.wagtail.io/en/stable/advanced_topics/customisation/admin_templates.html
But I want to customize the forms instead. I'm trying to add reCaptcha to all of them.
Is this possible?
Wagtail provides a Django setting called WAGTAILADMIN_USER_LOGIN_FORM which allows a custom form to be declared for the login form.
Wagtail does not provide a setting for the password reset workflow though unfortunately.
settings/base.py
WAGTAILADMIN_USER_LOGIN_FORM = 'app.forms.CustomLoginForm'
forms.py
from django import forms
from wagtail.admin.forms.auth import LoginForm
class CustomLoginForm(LoginForm):
captcha = forms.CharField(required=True)
A reminder that there is a way to work with custom User models in Wagtail which may also suit your customisation needed.
Related
I would like to crate a really simple react app where a registered and logged in user can create a post with an featured image and some custom fields (acf fields).
I wonder whats the best way build and include that in a static Wordpress Page?
I did not found any answer to this. So is there a way in Wagtail to have an AbstractEmailForm without AbstractFormField (for example, can I hard code them into AbstractEmailForm? I know that AbstractEmailField has some variables that Django requires). I just need to have a contact form only with email field, I dont need to set fields dynamically.
And the second question: How do I set permission for that form page so that only superuser can edit the form page?(And the translated version too? There are a lot of answers to this, but I don't actually understand how to do it with AbstractEmailForm).
Thanks a lot!
If you're hard-coding your form fields, then the Wagtail forms module doesn't really give you anything that you don't already get from Django's forms framework, and so you're better off using Django forms directly. The serve method on a Wagtail page is equivalent to a Django view function, so any form-processing logic that would normally go into a view function can be placed in serve.
There's an example of this here (but written for Wagtail 1.x, so imports will need adjusting): https://github.com/gasman/wagtail-form-example/commits/master
I have an app within my wagtail site which uses several pages constructed in views.py (here because they contain complex-ish processing of forms and data and do not need any CMS functionality). One of these views, I want to restrict to users of a specific group.
For other pages, I use a #logon required mixin, which works fine. I can write some code which uses something like def has_group(user, group_name):
return user.groups.filter(name=group_name).exists(), but this seems messy when wagtail has a nice built in permissions model. Therefore, I am trying to use the following hook in wagtail_hook.py:
from django.contrib.auth.models import Permission
from wagtail.core import hooks
#hooks.register('register_permissions')
def view_committee_page():
return Permission.objects.filter(codename="view_committee_page")
This isn't showing up in wagtail admin under group object permissions as I believe it should.
My understanding is only based on the odd example I've found using Wagtail v1.X. The documentation is vague on this specific hook: https://docs.wagtail.io/en/v2.5.1/reference/hooks.html#register-permissions
The only modification I've made to the examples I've seen (eg. here: Wagtail set additional permissions for MyPage ) is to update wagtail.wagtailcore to wagtail.core as per 2.0 release notes.
I know my wagtail_hooks.py file is being picked up correctly as I have another hook in there working as expected.
Am I missing something? Is there a more up to date way to solve this problem?
How about creating your own function with the decorator:
#hooks.register('before_serve_page')
in watail_hooks.py there is a function called check_view_restrictions() so you could do something similar to this?
You would also need to set the permissions on your Page model.
from wagtail.core.models import Page
class MyPage(Page):
class Meta:
permissions = (("page_view_only", "Can view my pages"),)
Then use the hook in wagtail_hooks.py
from django.contrib.auth.models import Permission
from wagtail.core import hooks
#hooks.register('register_permissions')
def page_view_only():
return Permission.objects.filter(codename="page_view_only")
There should be a new permission available in the admin Group settings.
I am using reactjs & mvc web api 2 to build my website. and I want to add captcha in my UI form.
Is there any other way to add captcha in reactJS / Web Api 2 beside using google recaptcha.
It seems everybody are using recaptcha v2. but in my case, I prefer use text based captcha, like recaptcha v1.
Thanks
You don't have to rely on the Google's solution to this problem. If you're using React you can simply create your own component named Captcha which will decide if the form can be passed. How to do that?
Create new React Component Captcha and place it wherever you want
in your app. You can generate 2 random Integers and ask the user to
add them.
According to the above create a verification method. Just check if the result given is equal to what it should be. Place the verification on the server side of your application, since browser side can be manipulated.
Only pass the form when the verification has passed.
Set some delay if your user fails the
verification. Can be small- remember it is to prevent bots from
spaming you.
As simple as that! Your imagination is the limit. Inside of that React Component you can define whatever method of verification you'd like to. Can be simple math task, can be distinguishing the shapes, colors, whatever you want...
I am using joomla 3.3.x version. In this joomla version one built in component is there for registration and login.That component name is com_user. I have to create two registration forms for my site.
Form names are Registration and Client Registration.
For registration I will use the registration form already present in this component.
File Structure for this:
//joomlaroot/components/com_users/models/forms/registration.xml
//joomlaroot/components/com_users/models/registration.php
//joomlaroot/components/com_users/views/registration/tmpl/default.php
//joomlaroot/components/com_users/controllers/registration.php
For Client Registration I have to add a view file in this component.
How can I add that?
You can create another layout within:
//joomlaroot/components/com_users/views/registration/tmpl/your_file.php
And switch to this layout at the
//joomlaroot/components/com_users/controllers/registration.php with:
$view = $this->getView('users', 'html');
$view->setLayout('your_file_name');