mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 00:07:22 +00:00
org form fix
This commit is contained in:
parent
297a77753b
commit
0e22c83425
@ -5,6 +5,7 @@ from wtforms import StringField, SubmitField, DecimalField, TextAreaField, FormF
|
||||
from wtforms.fields.html5 import EmailField, TelField
|
||||
from wtforms.validators import DataRequired, Optional
|
||||
import decimal
|
||||
from models import Location
|
||||
|
||||
class OrganizationLocationForm(FlaskForm):
|
||||
street = StringField(lazy_gettext('Street'), validators=[Optional()])
|
||||
@ -23,6 +24,12 @@ class BaseOrganizationForm(FlaskForm):
|
||||
legal_name = TextAreaField(lazy_gettext('Legal name'), validators=[Optional()])
|
||||
location = FormField(OrganizationLocationForm)
|
||||
|
||||
def populate_obj(self, obj):
|
||||
for name, field in self._fields.items():
|
||||
if name == 'location' and not obj.location:
|
||||
obj.location = Location()
|
||||
field.populate_obj(obj, name)
|
||||
|
||||
class CreateOrganizationForm(BaseOrganizationForm):
|
||||
submit = SubmitField(lazy_gettext("Create organization"))
|
||||
admin_unit_id = SelectField(lazy_gettext('Admin unit'), validators=[DataRequired()], coerce=int)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user