Python allauth.account.forms.SignupForm() Examples
The following are 1
code examples of allauth.account.forms.SignupForm().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
allauth.account.forms
, or try the search function
.
Example #1
Source File: views_landing.py From govready-q with GNU General Public License v3.0 | 4 votes |
def new_org_group(request): # Create new organization group class NewOrgForm(forms.ModelForm): class Meta: model = Organization fields = ['name', 'slug'] labels = { "name": "Group name", "slug": "Group \"slug\" to appear in URLs", } help_texts = { "name": "An organizational group for you teams assessments.", "slug": "Only lowercase letters, digits, and dashes.", } widgets = { "name": forms.TextInput(attrs={"placeholder": "Privacy Office"}), "slug": forms.TextInput(attrs={"placeholder": "privacy"}) } def clean_slug(self): # Not sure why the field validator isn't being run by the ModelForm. import re from .models import subdomain_regex from django.forms import ValidationError if not re.match(subdomain_regex, self.cleaned_data['slug']): raise ValidationError("The organization address must contain only lowercase letters, digits, and dashes and cannot start or end with a dash.") return self.cleaned_data['slug'] neworg_form = NewOrgForm() if request.POST.get("action") == "neworg": # signup_form = SignupForm(request.POST) neworg_form = NewOrgForm(request.POST) if request.user.is_authenticated and neworg_form.is_valid(): # Perform new org group creation, then redirect # to that org group. with transaction.atomic(): if not request.user.is_authenticated: # TODO Log message that usunloged in user tried to create a group return HttpResponseRedirect("/") else: user = request.user org = Organization.create(admin_user=user, **neworg_form.cleaned_data) return HttpResponseRedirect("/" + org.slug + "/projects") return render(request, "org_groups/new_org_group.html", { "neworg_form": neworg_form, # "member_of_orgs": Organization.get_all_readable_by(request.user) if request.user.is_authenticated else None, })