summaryrefslogtreecommitdiff
path: root/coip
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2011-02-28 22:07:19 +0100
committerLeif Johansson <leifj@sunet.se>2011-02-28 22:07:19 +0100
commit77ceee6e23f2a8daaf5e3247970953313aebcdd3 (patch)
tree90665ac16c025ea1bc7b478f2c84dcebf437f393 /coip
parent36e045ed8aa871ef3bd0bf0e27896658d0a9ef89 (diff)
wizards
Diffstat (limited to 'coip')
-rw-r--r--coip/apps/invitation/forms.py14
-rw-r--r--coip/apps/invitation/views.py2
-rw-r--r--coip/apps/name/forms.py36
-rw-r--r--coip/apps/name/views.py11
4 files changed, 49 insertions, 14 deletions
diff --git a/coip/apps/invitation/forms.py b/coip/apps/invitation/forms.py
index 28add9b..2a1b62f 100644
--- a/coip/apps/invitation/forms.py
+++ b/coip/apps/invitation/forms.py
@@ -5,8 +5,18 @@ Created on Jun 23, 2010
'''
from django import forms
from coip.apps.invitation.models import Invitation
+from form_utils.forms import BetterModelForm
-class InvitationForm(forms.ModelForm):
+class InvitationForm(BetterModelForm):
class Meta:
model = Invitation
- fields = ['email','message','expires'] \ No newline at end of file
+ fields = ['email','message','expires']
+ fieldsets = [('step1', {'fields': ['email','message'],
+ 'legend': 'Step 1: Email and message',
+ 'classes': ['step'],
+ 'description': 'An email message will be sent to the recipient with an invitation-link. After following that link the recipient will be a member of the group.'}),
+ ('step2', {'fields': ['expires'],
+ 'legend': 'Step 2: Expiration (optioinal)',
+ 'classes': ['step','submit_step'],
+ 'description': 'You are encouraged to provide an expiration time for your invitation. The time should be long enough to allow the recipient to answer and short enough prevent the invitation from falling into the wrong hands. The default is usually good enough.'})
+ ] \ No newline at end of file
diff --git a/coip/apps/invitation/views.py b/coip/apps/invitation/views.py
index 359d884..e4cb360 100644
--- a/coip/apps/invitation/views.py
+++ b/coip/apps/invitation/views.py
@@ -34,7 +34,7 @@ def invite(request,id):
invitation=Invitation(message="Please consider joining my group!",expires=exp.strftime("%Y-%m-%d"))
form = InvitationForm(instance=invitation);
- return respond_to(request,{'text/html': 'apps/invitation/edit.html'},{'form': form,'name': name,'formtitle': 'Invite to %s' % (name),'submitname': 'Invite User'})
+ return respond_to(request,{'text/html': 'apps/invitation/edit.html'},{'form': form,'name': name,'formtitle': 'Invite someone to join %s' % (name.short),'submitname': 'Invite User'})
@login_required
def accept(request,nonce):
diff --git a/coip/apps/name/forms.py b/coip/apps/name/forms.py
index a2a659e..759579c 100644
--- a/coip/apps/name/forms.py
+++ b/coip/apps/name/forms.py
@@ -7,6 +7,7 @@ from django import forms
from coip.apps.name.models import Name, Attribute, NameLink
from django.forms import fields
from django.forms.widgets import HiddenInput, CheckboxSelectMultiple
+from form_utils.forms import BetterModelForm, BetterForm
class NameForm(forms.ModelForm):
class Meta:
@@ -16,21 +17,42 @@ class AttributeForm(forms.ModelForm):
class Meta:
model = Attribute
-class NameEditForm(forms.ModelForm):
- description = forms.CharField(widget=forms.Textarea(attrs={'cols': 60, 'rows': 6}))
-
+class NameEditForm(BetterModelForm):
+ description = forms.CharField(widget=forms.Textarea(attrs={'cols': 60, 'rows': 6}))
class Meta:
model = Name
fields = ['short','description']
-
-class NewNameForm(forms.ModelForm):
+ fieldsets = [('step1', {'fields': ['short', 'description'],
+ 'legend': 'Describe your group',
+ 'classes': ['step submit_step'],
+ 'description': 'Provide a short and (optionally) longer description of your group..'})]
+
+class NewNameForm(BetterModelForm):
description = forms.CharField(widget=forms.Textarea(attrs={'cols': 60, 'rows': 6}))
+ value = forms.CharField(label="Name")
class Meta:
model = Name
- fields = ['type','value','short','description']
+ fields = ['value','short','description','type']
+ fieldsets = [('step1', {'fields': ['value'],
+ 'legend': 'Step 1: Name your group',
+ 'classes': ['step'],
+ 'description': 'Provide a short identifier for your groups. Spaces are not allowed here.'}),
+ ('step2', {'fields': ['short', 'description'],
+ 'legend': 'Step 2: Describe your group',
+ 'classes': ['step'],
+ 'description': 'Provide a short and (optionally) longer description of your group..'}),
+ ('step3', {'fields': ['type'],
+ 'legend': 'Step 3 (optional): Advanced options',
+ 'classes': ['step','submit_step'],
+ 'description': 'Only set the type if you know what you are doing. You almost certainly do not need this.'})]
-class NameDeleteForm(forms.Form):
+class NameDeleteForm(BetterForm):
recursive = fields.BooleanField(label="Also delete everything below this name?",required=False)
+ class Meta:
+ fieldsets = [('step1', {'fields': ['recursive'],
+ 'legend': 'Confirm deletion of your group',
+ 'classes': ['step'],
+ 'description': 'This is a destructive operation - there is no way to recover your group once it has been deleted!'})]
class NameLinkForm(forms.ModelForm):
class Meta:
diff --git a/coip/apps/name/views.py b/coip/apps/name/views.py
index df669e7..c6d0621 100644
--- a/coip/apps/name/views.py
+++ b/coip/apps/name/views.py
@@ -45,7 +45,7 @@ def delete(request,id):
else:
form = NameDeleteForm()
- return respond_to(request,{'text/html': 'apps/name/edit.html'},{'form': form,'name': name,'formtitle': 'Remove %s' % (name.short) ,'submitname': 'Delete'})
+ return respond_to(request,{'text/html': 'apps/name/delete.html'},{'form': form,'name': name,'formtitle': 'Remove %s' % (name.short) ,'submitname': 'Delete'})
@login_required
def add(request,id):
@@ -68,7 +68,7 @@ def add(request,id):
else:
form = NewNameForm()
- return respond_to(request,{'text/html': 'apps/name/edit.html'},{'form': form,'name': parent,'formtitle': 'Add group','submitname': 'Create'})
+ return respond_to(request,{'text/html': 'apps/name/add.html'},{'form': form,'name': parent,'formtitle': 'Add group','submitname': 'Create'})
@login_required
def edit(request,id):
@@ -85,7 +85,7 @@ def edit(request,id):
else:
form = NameEditForm(instance=name)
- return respond_to(request,{'text/html': 'apps/name/edit.html'},{'form': form,'name': name,'formtitle': 'Change name','submitname': 'Update'})
+ return respond_to(request,{'text/html': 'apps/name/edit.html'},{'form': form,'name': name,'formtitle': 'Modify %s' % name.short,'submitname': 'Update'})
@login_required
@@ -182,7 +182,10 @@ def show_by_id(request,id=None):
return HttpResponseNotFound()
def _tree_node(name,depth):
- state = 'closed'
+ if depth > 2:
+ state = "closed"
+ else:
+ state = 'open'
return {'data': { 'title': name.relative_name(), 'attr': {'href': name.url() } },
'state': state,
'attr': {'id': name.id}}