Skip to content

Commit

Permalink
Corrected group slug validation and help text.
Browse files Browse the repository at this point in the history
  • Loading branch information
melinath committed Aug 17, 2014
1 parent 80aae1f commit 917aa1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion argus/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ def save(self):
fields=('name',))


class GroupSlugInput(forms.SlugInput):
def get_context(self, name, value, attrs):
context = super(GroupSlugInput, self).get_context(name, value, attrs)
context['attrs']['pattern'] = Group.SLUG_REGEX
return context


class GroupForm(forms.ModelForm):
subject_template_name = "argus/mail/group_email_confirm_subject.txt"
body_template_name = "argus/mail/group_email_confirm_body.txt"
Expand All @@ -67,7 +74,7 @@ class Meta:
model = Group
exclude = ('password', 'confirmed_email', 'created',)
widgets = {
'slug': forms.SlugInput,
'slug': GroupSlugInput,
'name': forms.TextInput,
'email': forms.EmailInput,
'currency': forms.TextInput,
Expand Down
6 changes: 5 additions & 1 deletion argus/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class Group(models.Model):
SLUG_REGEX = "[\w_~\.-]+"

slug = models.CharField(max_length=50, unique=True,
validators=[RegexValidator(SLUG_REGEX)])
validators=[RegexValidator(SLUG_REGEX)],
help_text="Allowed characters: a-z, A-Z, 0-9, and "
"-.~_. Note: changing the slug changes "
"your group URL, so you will not be "
"able to hit \"back.\"")
name = models.CharField(max_length=64, blank=True)
email = models.EmailField(blank=True)
confirmed_email = models.EmailField(blank=True)
Expand Down
1 change: 0 additions & 1 deletion argus/templates/argus/group_update.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ <h1><a href="{{ group.get_absolute_url }}">{{ group.name|default:group.slug }}</

<form action="{{ request.path }}" method="post">
{% csrf_token %}
<small>Note: changing the slug changes your group URL, so you will not be able to hit "back."</small>
{% form form %}
<button class='btn' type="submit">Save changes</button>
</form>
Expand Down

0 comments on commit 917aa1f

Please sign in to comment.