Skip to content

Commit a1a1332

Browse files
committed
Use hint text instead of Django help text for providing the help for
EmailsField and clarify the text displayed when the input is invalid so it's hopefully more clear what happens - Legacy-Id: 8272
1 parent 691befb commit a1a1332

4 files changed

Lines changed: 9 additions & 6 deletions

File tree

ietf/group/edit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class GroupForm(forms.Form):
3232
chairs = EmailsField(label="Chairs", required=False)
3333
secretaries = EmailsField(label="Secretaries", required=False)
3434
techadv = EmailsField(label="Technical Advisors", required=False)
35-
delegates = EmailsField(label="Delegates", required=False, help_text=mark_safe("Type in name to search for person<br>Chairs can delegate the authority to update the state of group documents - max %s persons at a given time" % MAX_GROUP_DELEGATES))
35+
delegates = EmailsField(label="Delegates", required=False, help_text=mark_safe("Chairs can delegate the authority to update the state of group documents - max %s persons at a given time" % MAX_GROUP_DELEGATES), max_entries=MAX_GROUP_DELEGATES)
3636
ad = forms.ModelChoiceField(Person.objects.filter(role__name="ad", role__group__state="active").order_by('name'), label="Shepherding AD", empty_label="(None)", required=False)
3737
parent = forms.ModelChoiceField(Group.objects.filter(state="active").order_by('name'), empty_label="(None)", required=False)
3838
list_email = forms.CharField(max_length=64, required=False)

ietf/group/views_stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def stream_documents(request, acronym):
3131
return render_to_response('group/stream_documents.html', {'stream':stream, 'docs':docs, 'meta':meta }, context_instance=RequestContext(request))
3232

3333
class StreamEditForm(forms.Form):
34-
delegates = EmailsField(label="Delegates", required=False, help_text=u"Type in name to search for person")
34+
delegates = EmailsField(label="Delegates", required=False)
3535

3636
def stream_edit(request, acronym):
3737
group = get_object_or_404(Group, acronym=acronym)

ietf/person/fields.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ class EmailsField(forms.CharField):
2222

2323
def __init__(self, *args, **kwargs):
2424
kwargs["max_length"] = 1000
25-
if not "help_text" in kwargs:
26-
kwargs["help_text"] = "Type in name to search for person"
2725
self.max_entries = kwargs.pop("max_entries", None)
26+
hint_text = kwargs.pop("hint_text", "Type in name or email to search for person and email address")
27+
2828
super(EmailsField, self).__init__(*args, **kwargs)
29+
2930
self.widget.attrs["class"] = "tokenized-field"
3031
self.widget.attrs["data-ajax-url"] = lazy(urlreverse, str)("ajax_search_emails") # make this lazy to prevent initialization problem
32+
self.widget.attrs["data-hint-text"] = hint_text
3133
if self.max_entries != None:
3234
self.widget.attrs["data-max-entries"] = self.max_entries
3335

static/js/tokenized-field.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ function setupTokenizedField(field) {
77
pre = JSON.parse((field.attr("data-pre") || "").replace(/&quot;/g, '"'));
88

99
field.tokenInput(field.attr("data-ajax-url"), {
10-
hintText: "",
1110
preventDuplicates: true,
1211
prePopulate: pre,
13-
tokenLimit: field.attr("data-max-entries")
12+
tokenLimit: field.attr("data-max-entries"),
13+
noResultsText: "No results - cannot use this entry",
14+
hintText: field.attr("data-hint-text")
1415
});
1516
}
1617

0 commit comments

Comments
 (0)