From 6ef3f7f4310c0dd02e64c13a1dad6f47b74fdd88 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 8 Apr 2016 02:52:33 +0200 Subject: Adpat person form to new fields --- ishtar_common/forms_common.py | 41 +++++++++++---- ishtar_common/static/media/style.css | 30 +++++++++++ ishtar_common/templates/blocks/table_field.html | 4 ++ .../templates/ishtar/wizard/default_wizard.html | 2 + .../templates/ishtar/wizard/wizard_person.html | 59 ++++++++++++++++++++++ ishtar_common/templatetags/table_form.py | 5 ++ ishtar_common/wizards.py | 4 ++ 7 files changed, 135 insertions(+), 10 deletions(-) create mode 100644 ishtar_common/templates/blocks/table_field.html create mode 100644 ishtar_common/templates/ishtar/wizard/wizard_person.html (limited to 'ishtar_common') diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index ae72d173f..1d8dc2092 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -260,18 +260,19 @@ class SimplePersonForm(NewItemForm): validators=[name_validator]) raw_name = forms.CharField(label=_(u"Raw name"), max_length=300, required=False) - address = forms.CharField(label=_(u"Address"), widget=forms.Textarea, - required=False) - address_complement = forms.CharField(label=_(u"Address complement"), - widget=forms.Textarea, required=False) - postal_code = forms.CharField(label=_(u"Postal code"), max_length=10, - required=False) - town = forms.CharField(label=_(u"Town"), max_length=30, required=False) - country = forms.CharField(label=_(u"Country"), max_length=30, - required=False) email = forms.EmailField(label=_(u"Email"), required=False) + phone_desc = forms.CharField(label=_(u"Phone description"), max_length=300, + required=False) phone = forms.CharField(label=_(u"Phone"), max_length=18, required=False) - mobile_phone = forms.CharField(label=_(u"Town"), max_length=18, + phone_desc2 = forms.CharField(label=_(u"Phone description 2"), + max_length=300, required=False) + phone2 = forms.CharField(label=_(u"Phone 2"), max_length=18, + required=False) + phone_desc3 = forms.CharField(label=_(u"Phone description 3"), + max_length=300, required=False) + phone3 = forms.CharField(label=_(u"Phone 3"), max_length=18, + required=False) + mobile_phone = forms.CharField(label=_(u"Mobile phone"), max_length=18, required=False) attached_to = forms.IntegerField( label=_("Current organization"), @@ -279,6 +280,26 @@ class SimplePersonForm(NewItemForm): reverse_lazy('autocomplete-organization'), associated_model=models.Organization, new=True), validators=[models.valid_id(models.Organization)], required=False) + address = forms.CharField(label=_(u"Address"), widget=forms.Textarea, + required=False) + address_complement = forms.CharField( + label=_(u"Address complement"), widget=forms.Textarea, required=False) + postal_code = forms.CharField(label=_(u"Postal code"), max_length=10, + required=False) + town = forms.CharField(label=_(u"Town"), max_length=30, required=False) + country = forms.CharField(label=_(u"Country"), max_length=30, + required=False) + alt_address = forms.CharField(label=_(u"Other address: address"), + widget=forms.Textarea, required=False) + alt_address_complement = forms.CharField( + label=_(u"Other address: address complement"), + widget=forms.Textarea, required=False) + alt_postal_code = forms.CharField(label=_(u"Other address: postal code"), + max_length=10, required=False) + alt_town = forms.CharField(label=_(u"Other address: town"), max_length=30, + required=False) + alt_country = forms.CharField(label=_(u"Other address: country"), + max_length=30, required=False) def __init__(self, *args, **kwargs): super(SimplePersonForm, self).__init__(*args, **kwargs) diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 4467a0639..09c39f598 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -57,6 +57,12 @@ div.form { border-bottom:1px solid #D14; } +hr.spacer{ + clear:both; + border:0; + margin: 13px; +} + /* shadows */ #progress-content, .sheet{ @@ -1103,3 +1109,27 @@ a.remove{ background-image: none; } +table.table-form{ + background: #fff; + border-collapse: collapse; + text-align: center; + padding: 10px 8px; +} + +table.table-form th { + text-align: center; + font-weight: normal; + padding: 8px 6px; + color: #922; + border-bottom: 2px solid #922; +} + +table.table-form td { + text-align: center; + color: #666; + padding: 6px 2px; +} + +table.table-form td input{ + border-color:#922; +} diff --git a/ishtar_common/templates/blocks/table_field.html b/ishtar_common/templates/blocks/table_field.html new file mode 100644 index 000000000..5816a4b90 --- /dev/null +++ b/ishtar_common/templates/blocks/table_field.html @@ -0,0 +1,4 @@ + + {{ field.label_tag }} + {{ field.errors }}{{field|safe}} + diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html index 1a17cf32b..6491b7a0f 100644 --- a/ishtar_common/templates/ishtar/wizard/default_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html @@ -24,6 +24,7 @@
{{ wizard.form.media }} {{ wizard.management_form }} +{% block form_detail %} {% if wizard.form.forms %} {{ wizard.form.management_form }}
@@ -39,6 +40,7 @@ {% table_form wizard.form %} {% if not is_search %}{% endif %} {% endif %} +{% endblock %} {{ previous_fields|safe }} {% block "validation_bar" %} diff --git a/ishtar_common/templates/ishtar/wizard/wizard_person.html b/ishtar_common/templates/ishtar/wizard/wizard_person.html new file mode 100644 index 000000000..c1806132f --- /dev/null +++ b/ishtar_common/templates/ishtar/wizard/wizard_person.html @@ -0,0 +1,59 @@ +{% extends "ishtar/wizard/default_wizard.html" %} +{% load i18n range table_form %} +{% block form_detail %} + + + + {% table_field wizard.form.title %} + {% table_field wizard.form.surname 1 %} + {% table_field wizard.form.name 1 %} + {% table_field wizard.form.raw_name %} + {% table_field wizard.form.email %} + {% table_field wizard.form.attached_to %} +
{% trans "Identity" %}
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
{% trans "Phone" %}
{% trans "Phone type" %}{% trans "Number" %}
{{ wizard.form.phone_desc.errors }}{{wizard.form.phone_desc|safe}}{{ wizard.form.phone.errors }}{{wizard.form.phone|safe}}
{{ wizard.form.phone_desc2.errors }}{{wizard.form.phone_desc2|safe}}{{ wizard.form.phone2.errors }}{{wizard.form.phone2|safe}}
{{ wizard.form.phone_desc3.errors }}{{wizard.form.phone_desc3|safe}}{{ wizard.form.phone3.errors }}{{wizard.form.phone3|safe}}
{% trans "Mobile phone" %}{{ wizard.form.mobile_phone.errors }}{{wizard.form.mobile_phone|safe}}
+
+ + + + {% table_field wizard.form.address %} + {% table_field wizard.form.address_complement %} + {% table_field wizard.form.postal_code %} + {% table_field wizard.form.town %} + {% table_field wizard.form.country %} +
{% trans "Business address" %}
+
+ + + {% table_field wizard.form.alt_address %} + {% table_field wizard.form.alt_address_complement %} + {% table_field wizard.form.alt_postal_code %} + {% table_field wizard.form.alt_town %} + {% table_field wizard.form.alt_country %} +
{% trans "Other address" %}
+ +{% endblock %} diff --git a/ishtar_common/templatetags/table_form.py b/ishtar_common/templatetags/table_form.py index 6ee99b9a5..6f768183c 100644 --- a/ishtar_common/templatetags/table_form.py +++ b/ishtar_common/templatetags/table_form.py @@ -9,3 +9,8 @@ register = Library() @register.inclusion_tag('blocks/form_snippet.html') def table_form(form): return {'form': form} + + +@register.inclusion_tag('blocks/table_field.html') +def table_field(field, required=False): + return {'field': field, 'required': required} diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 0b121fd76..e974942b7 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -1112,10 +1112,14 @@ class ClosingWizard(Wizard): class PersonWizard(Wizard): model = models.Person + wizard_templates = { + 'identity-person_creation': "ishtar/wizard/wizard_person.html"} class PersonModifWizard(PersonWizard): modification = True + wizard_templates = { + 'identity-person_modification': "ishtar/wizard/wizard_person.html"} class PersonDeletionWizard(DeletionWizard): -- cgit v1.2.3