profile: add data type in list of fields (#33913)

This commit is contained in:
Frédéric Péters 2019-06-23 11:42:50 +02:00
parent e0192298af
commit e9463c8961
4 changed files with 13 additions and 1 deletions

View File

@ -33,6 +33,7 @@ class Migration(migrations.Migration):
(b'string', 'String'),
(b'boolean', 'Boolean'),
(b'date', 'Date'),
(b'title', 'Civility'),
(b'birthdate', 'Birthdate'),
(b'fr_postcode', 'French Postcode'),
(b'phone_number', 'Phone Number'),

View File

@ -52,6 +52,7 @@ class AttributeDefinition(models.Model):
('string', _('String')),
('boolean', _('Boolean')),
('date', _('Date')),
('title', _('Civility')),
('birthdate', _('Birthdate')),
('fr_postcode', _('French Postcode')),
('phone_number', _('Phone Number')),
@ -70,6 +71,11 @@ class AttributeDefinition(models.Model):
if type(y) in (str, unicode, bool)])
return as_dict
def get_real_kind_display(self):
if self.kind == 'email': # not a real authentic type
return _('Email')
return self.get_kind_display()
def save(self, *args, **kwargs):
if self.order is None:
self.order = max([0] + [x.order for x in AttributeDefinition.objects.all()]) + 1

View File

@ -24,7 +24,7 @@ Use drag and drop with the ⣿ handles to reorder the profile fields.
<div class="objects-list" id="attributes-list" data-reorder-url="{% url 'profile-reorder' %}">
{% for object in object_list %}
<div data-attribute-id="{{object.id}}" {% if object.disabled %}class="disabled"{% endif %}>
<span class="handle"></span> <span class="label">{{object.label}}</span>
<span class="handle"></span> <span class="label">{{object.label}} <span class="extra-info">({{object.get_real_kind_display}})</span></span>
<a rel="popup" href="{% url 'profile-attribute-options' name=object.name %}">{% trans 'options' %}</a>
</div>
{% endfor %}

View File

@ -105,6 +105,11 @@ div.objects-list > div.disabled {
color: #aaa;
}
span.extra-info {
font-size: 80%;
color: #aaa;
}
div#attributes-list a {
float: right;
}