~abie-riseup/sahana-eden/devel

« back to all changes in this revision

Viewing changes to controllers/default.py

  • Committer: Fran Boon
  • Date: 2009-01-11 23:41:47 UTC
  • Revision ID: flavour@partyvibe.com-20090111234147-48sewcoeylpulg5q
Authorisation: Remove s3_role tables & just use t2_group
session.s3.roles
- appadmin.py uses this to (dis)allow access
- menu items hidden in layout.html
- protect setting() in default.py
Fix calendar.js (includes more than just the 2 files we thought it did)
Cleanup of GIS module: Features now use std RESTlike controller

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
# T2 framework functions
10
10
def login():
11
11
    return dict(form=t2.login(),module_name=module_name,modules=modules,options=options)
12
 
def logout(): t2.logout(next='login')
 
12
def logout():
 
13
    t2.logout(next='login')
13
14
# Self-registration can be disabled by amending the setting in the s3_settings table
14
15
def register():
15
16
    if session.s3.self_registration:
17
18
        return dict(form=t2.register(),module_name=module_name,modules=modules,options=options)
18
19
    else:
19
20
        redirect(URL(r=request,c='default',f='index'))
20
 
def profile(): return dict(form=t2.profile(),module_name=module_name,modules=modules,options=options)
 
21
def profile():
 
22
    return dict(form=t2.profile(),module_name=module_name,modules=modules,options=options)
21
23
 
22
24
# S3 framework functions
23
25
def index():
43
45
        redirect(URL(r=request,f='index'))
44
46
    option=options[0].function
45
47
    redirect(URL(r=request,f=option))
46
 
# The settings should be protected by T2 AAA beyond just 'authenticated'
47
 
#@t2.have_membership(1)
48
48
def setting():
49
 
    "RESTlike CRUD controller"
50
 
    return shn_rest_controller(module,'setting')
 
49
    """RESTlike CRUD controller
 
50
    Access only permitted to admins.
 
51
    """
 
52
    if 1 in session.s3.roles:
 
53
        return shn_rest_controller(module,'setting')
 
54
    else:
 
55
        redirect(URL(r=request,f='index'))
51
56
 
52
57
    
53
58
# About Sahana
54
59
def apath(path=''):
 
60
    "Application path"
55
61
    import os
56
62
    from gluon.fileutils import up
57
63
    opath=up(request.folder)
67
73
    sahana_version=open(apath('sahana/VERSION'),'r').read()
68
74
    return dict(module_name=module_name,modules=modules,options=options,python_version=python_version,sahana_version=sahana_version,web2py_version=web2py_version)
69
75
 
 
76
# Administration Page
 
77
def admin():
 
78
    """Administration Page.
 
79
    For now just redirect to appadmin.
 
80
    """
 
81
    redirect(URL(r=request,a='admin',c='default',f='site'))
 
82
    
70
83
# Import Data
71
84
def import_data():
72
85
    "Import data via POST upload to CRUD controller."
75
88
 
76
89
# M2M Tests
77
90
def list_dogs():
 
91
    "Test for M2M widget"
78
92
    list=t2.itemize(db.dog)
79
93
    response.view='list_plain.html'
80
94
    return dict(list=list)
81
95
 
82
96
def display_dog():
 
97
    "Test for M2M widget"
83
98
    list=t2.display(db.dog)
84
99
    response.view='list_plain.html'
85
100
    return dict(list=list)
86
101
 
87
102
def update_dog():
 
103
    "Test for M2M widget"
88
104
    list=t2.update(db.dog)
89
105
    response.view='list_plain.html'
90
106
    return dict(list=list)
91
107
 
92
108
def delete_dog():
 
109
    "Test for M2M widget"
93
110
    list=t2.delete(db.dog)
94
111
    response.view='list_plain.html'
95
112
    return dict(list=list)
96
113
 
97
114
def delete_owner():
 
115
    "Test for M2M widget"
98
116
    list=t2.delete(db.owner)
99
117
    response.view='list_plain.html'
100
118
    return dict(list=list)