diff --git a/layerindex/models.py b/layerindex/models.py index 38cea7a..2bec315 100644 --- a/layerindex/models.py +++ b/layerindex/models.py @@ -85,7 +85,7 @@ class LayerMaintainer(models.Model): ('I', 'Inactive'), ) layer = models.ForeignKey(LayerItem) - name = models.CharField(max_length=50) + name = models.CharField(max_length=255) email = models.CharField(max_length=255) responsibility = models.CharField(max_length=200, blank=True, help_text='Specific area(s) this maintainer is responsible for, if not the entire layer') status = models.CharField(max_length=1, choices=MAINTAINER_STATUS_CHOICES, default='A') diff --git a/layerindex/submitlayer.html b/layerindex/submitlayer.html index 7368fb6..e0b824f 100644 --- a/layerindex/submitlayer.html +++ b/layerindex/submitlayer.html @@ -111,6 +111,34 @@ } }; + split_email = function() { + // Split email name/email address pairs + name_input = $(this) + split_regex = /^"?([^"@$<>]+)"? *<([^<> ]+)>[ -]*(.*)?$/ + matches = split_regex.exec(name_input.val()) + if( matches ){ + name_input.val($.trim(matches[1])) + email_id = name_input.attr('id').replace('-name', '-email') + $('#' + email_id).val($.trim(matches[2])) + resp_id = email_id.replace('-email', '-responsibility') + currval = $('#' + resp_id).val() + // Set the responsibility with the remainder of the value unless the user has entered a value for + // responsibility already + if( currval == window['last_' + resp_id] || currval == "" ) { + newval = $.trim(matches[3]) + $('#' + resp_id).val(newval) + window['last_' + resp_id] = newval + } + } + } + + for(i=0;i<{{ maintainerformset.total_form_count }};i++) { + name_input = $('#id_layermaintainer_set-' + i + '-name') + name_input.change(split_email) + resp_id = 'id_layermaintainer_set-' + i + '-responsibility' + window['last_' + resp_id] = "" + } + $(document).ready(function() { $('#id_vcs_url').change(auto_web_fields) });