konova/user/forms/modals/user.py
mpeltriaux 05c1bf677c User forms
* refactors user/forms.py by splitting into modals package and regular forms
    * regular forms can now be found at user/forms/user.py and user/forms/team.py
    * modal forms can now be found at user/forms/modals/...
2022-08-18 10:17:09 +02:00

63 lines
1.6 KiB
Python

"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: ksp-servicestelle@sgdnord.rlp.de
Created on: 18.08.22
"""
from django import forms
from django.utils.translation import gettext_lazy as _
from konova.forms.modals import BaseModalForm
class UserContactForm(BaseModalForm):
def save(self):
# Readonly form. No saving needed
pass
name = forms.CharField(
label=_("Username"),
label_suffix="",
required=False,
widget=forms.TextInput(
attrs={
"readonly": True,
"class": "form-control",
}
),
)
person_name = forms.CharField(
label=_("Person name"),
label_suffix="",
required=False,
widget=forms.TextInput(
attrs={
"readonly": True,
"class": "form-control",
}
),
)
mail = forms.EmailField(
label=_("E-Mail"),
label_suffix="",
required=False,
widget=forms.TextInput(
attrs={
"readonly": True,
"class": "form-control",
}
),
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.render_submit = False
self.form_title = _("User contact data")
self.form_caption = ""
self.initialize_form_field("name", self.instance.username)
self.initialize_form_field("person_name", "{} {}".format(self.instance.first_name, self.instance.last_name))
self.initialize_form_field("mail", self.instance.email)