mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-14 05:29:43 +02:00
Review feedback: docstrings, move out form
This commit is contained in:
parent
1c3473d189
commit
7718dbc374
3 changed files with 35 additions and 0 deletions
|
@ -1 +1,2 @@
|
||||||
from .application_wizard import *
|
from .application_wizard import *
|
||||||
|
from .domain import DomainAddUserForm
|
||||||
|
|
21
src/registrar/forms/domain.py
Normal file
21
src/registrar/forms/domain.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
"""Forms for domain management."""
|
||||||
|
|
||||||
|
from django import forms
|
||||||
|
|
||||||
|
from registrar.models import User
|
||||||
|
|
||||||
|
|
||||||
|
class DomainAddUserForm(forms.Form):
|
||||||
|
|
||||||
|
"""Form for adding a user to a domain."""
|
||||||
|
|
||||||
|
email = forms.EmailField(label="Email")
|
||||||
|
|
||||||
|
def clean_email(self):
|
||||||
|
requested_email = self.cleaned_data["email"]
|
||||||
|
try:
|
||||||
|
User.objects.get(email=requested_email)
|
||||||
|
except User.DoesNotExist:
|
||||||
|
# TODO: send an invitation email to a non-existent user
|
||||||
|
raise forms.ValidationError("That user does not exist in this system.")
|
||||||
|
return requested_email
|
|
@ -14,12 +14,18 @@ from .utility import DomainPermission
|
||||||
|
|
||||||
|
|
||||||
class DomainView(DomainPermission, DetailView):
|
class DomainView(DomainPermission, DetailView):
|
||||||
|
|
||||||
|
"""Domain detail overview page."""
|
||||||
|
|
||||||
model = Domain
|
model = Domain
|
||||||
template_name = "domain_detail.html"
|
template_name = "domain_detail.html"
|
||||||
context_object_name = "domain"
|
context_object_name = "domain"
|
||||||
|
|
||||||
|
|
||||||
class DomainUsersView(DomainPermission, DetailView):
|
class DomainUsersView(DomainPermission, DetailView):
|
||||||
|
|
||||||
|
"""User management page in the domain details."""
|
||||||
|
|
||||||
model = Domain
|
model = Domain
|
||||||
template_name = "domain_users.html"
|
template_name = "domain_users.html"
|
||||||
context_object_name = "domain"
|
context_object_name = "domain"
|
||||||
|
@ -42,6 +48,13 @@ class DomainAddUserForm(DomainPermission, forms.Form):
|
||||||
|
|
||||||
|
|
||||||
class DomainAddUserView(DomainPermission, FormMixin, DetailView):
|
class DomainAddUserView(DomainPermission, FormMixin, DetailView):
|
||||||
|
|
||||||
|
"""Inside of a domain's user management, a form for adding users.
|
||||||
|
|
||||||
|
Multiple inheritance is used here for permissions, form handling, and
|
||||||
|
details of the individual domain.
|
||||||
|
"""
|
||||||
|
|
||||||
template_name = "domain_add_user.html"
|
template_name = "domain_add_user.html"
|
||||||
model = Domain
|
model = Domain
|
||||||
form_class = DomainAddUserForm
|
form_class = DomainAddUserForm
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue