Permalink
Browse files

add restrict_to field to xforms

  • Loading branch information...
1 parent efaf4c5 commit 3e1fb078d6c4a77b8e763be20aa03396a4809f08 @nicpottier nicpottier committed Sep 14, 2011
Showing with 14 additions and 8 deletions.
  1. +4 −0 rapidsms_xforms/models.py
  2. +10 −8 rapidsms_xforms/views.py
View
4 rapidsms_xforms/models.py
@@ -17,6 +17,7 @@
from rapidsms.models import ExtensibleModelBase
from eav.fields import EavSlugField
from django.core.files.base import ContentFile
+from django.contrib.auth.models import Group
class XForm(models.Model):
"""
@@ -55,6 +56,9 @@ class XForm(models.Model):
separator = models.CharField(max_length=1, choices=SEPARATOR_CHOICES, null=True, blank=True,
help_text="The separator character for fields, field values will be split on this character.")
+ restrict_to = models.ForeignKey(Group, null=True, blank=True,
+ help_text="Restrict submissions to users of this group (if unset, anybody can submit this form)")
+
owner = models.ForeignKey(User)
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
View
18 rapidsms_xforms/views.py
@@ -110,23 +110,24 @@ def xforms(req):
class NewXFormForm(forms.ModelForm): # pragma: no cover
class Meta:
model = XForm
- fields = ('name', 'keyword','keyword_prefix', 'command_prefix', 'separator', 'description', 'response')
+ fields = ('name', 'keyword','keyword_prefix', 'command_prefix', 'separator', 'description', 'response', 'restrict_to')
helper = FormHelper()
layout = Layout(
- # first fieldset shows the company
+ # required fields
Fieldset('',
'name',
'keyword',
'description',
'response'),
- # second fieldset shows the contact info
+ # optional attributes
Fieldset('Advanced Settings',
'keyword_prefix',
'command_prefix',
- 'separator'
+ 'separator',
+ 'restrict_to',
)
)
@@ -135,25 +136,26 @@ class Meta:
class EditXFormForm(forms.ModelForm): # pragma: no cover
class Meta:
model = XForm
- fields = ('name', 'keyword','keyword_prefix', 'command_prefix', 'separator', 'description', 'response', 'active')
+ fields = ('name', 'keyword','keyword_prefix', 'command_prefix', 'separator', 'description', 'response', 'active', 'restrict_to')
helper = FormHelper()
layout = Layout(
- # first fieldset shows the company
+ # required fields
Fieldset('',
'name',
'keyword',
'description',
'response',
'active'),
- # second fieldset shows the contact info
+ # optional attributes
Fieldset('Advanced Settings',
'keyword_prefix',
'command_prefix',
- 'separator'
+ 'separator',
+ 'restrict_to',
)
)

0 comments on commit 3e1fb07

Please sign in to comment.