~ellimistd/lessonplan/trunk

« back to all changes in this revision

Viewing changes to controllers/default.py

  • Committer: David Reich
  • Date: 2010-07-19 22:29:33 UTC
  • Revision ID: ellimistd@gmail.com-20100719222933-2qt29bft3gav66c4
added an edit feature

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
        
11
11
def new():
12
12
        #session.nextWIPstep=0
13
 
        if not session.nextWIPstep:
14
 
                
 
13
        if not session.nextWIPstep:     
15
14
                form = SQLFORM(db.WIPplan,fields=['topic'],requires='IS_NOT_EMPTY')
16
15
                pagetitle="Start a lessonplan"
17
16
                if form.accepts(request.vars,session):
18
17
                        session.WIPplanid = form.vars.id
19
18
                        session.nextWIPstep = "coreinfo"
20
 
                        response.flash = 'Topic accepted, begin filling the form'
 
19
                        response.flash = 'Topic accepted'
21
20
                        redirect(URL(r=request, f='new'))
22
 
                else:
23
 
                        response.flash = "Please enter a topic"
24
21
                return dict(form=form,pagetitle=pagetitle)
25
22
                
26
23
        elif session.nextWIPstep == 'coreinfo':
32
29
                        session.nextWIPstep = False
33
30
                        plan = db(db.WIPplan.id==session.WIPplanid)
34
31
                        plan.update(coreinfo = session.coreinfoid)
35
 
                        print plan
36
32
                        redirect(URL(r=request, f='new'))
37
33
                return dict(form=form,pagetitle=pagetitle)
38
34
                        
39
35
        
40
36
def show():
41
37
        plan = db(db.WIPplan.id==request.args(0)).select()[0]
42
 
        print plan
43
38
        return dict(plan=plan)
44
39
        
 
40
def edit():
 
41
        plan = db(db.WIPplan.id==request.args(0)).select()[0]
 
42
        part = request.args(1)
 
43
        if part=="coreinfo":
 
44
                form = SQLFORM(db.CoreInfo, plan.coreinfo)
 
45
                if form.accepts(request.vars,session):
 
46
                        response.flash = "Edit to Core Information accepted"
 
47
                        redirect(URL(r=request, f='index'))
 
48
        return dict(form=form)
 
49
        
45
50
 
46
51
 
47
52