Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
127 lines (105 sloc) 3.87 KB
# -*- coding: utf-8 -*-
"""
Transport
"""
module = request.controller
if not settings.has_module(module):
raise HTTP(404, body="Module disabled: %s" % module)
# -----------------------------------------------------------------------------
def index():
"Module's Home Page"
module_name = settings.modules[module].name_nice
response.title = module_name
item = None
if settings.has_module("cms"):
table = s3db.cms_post
_item = db(table.module == module).select(table.id,
table.body,
limitby=(0, 1)).first()
if _item:
if s3_has_role(ADMIN):
item = DIV(XML(_item.body),
BR(),
A(T("Edit"),
_href=URL(c="cms", f="post",
args=[_item.id, "update"],
vars={"module":module}),
_class="action-btn"))
else:
item = XML(_item.body)
elif s3_has_role(ADMIN):
item = DIV(H2(module_name),
A(T("Edit"),
_href=URL(c="cms", f="post", args="create",
vars={"module":module}),
_class="action-btn"))
if not item:
item = H2(module_name)
# tbc
report = ""
response.view = "index.html"
return dict(item=item, report=report)
# -----------------------------------------------------------------------------
def airport():
""" RESTful CRUD controller """
# Pre-processor
def prep(r):
# Location Filter
s3db.gis_location_filter(r)
if r.interactive:
if r.component:
# remove CRUD generated buttons in the tabs
s3db.configure("inv_inv_item",
create=False,
listadd=False,
editable=False,
deletable=False,
)
elif r.method == "update":
field = r.table.obsolete
field.readable = field.writable = True
return True
s3.prep = prep
return s3_rest_controller(rheader=transport_rheader)
# -----------------------------------------------------------------------------
def seaport():
""" RESTful CRUD controller """
# Pre-processor
def prep(r):
# Location Filter
s3db.gis_location_filter(r)
if r.interactive:
if r.component:
# remove CRUD generated buttons in the tabs
s3db.configure("inv_inv_item",
create=False,
listadd=False,
editable=False,
deletable=False,
)
elif r.method == "update":
field = r.table.obsolete
field.readable = field.writable = True
return True
s3.prep = prep
return s3_rest_controller(rheader=transport_rheader)
# -----------------------------------------------------------------------------
def transport_rheader(r, tabs=[]):
# Need to use this format as otherwise /inv/incoming?viewing=org_office.x
# doesn't have an rheader
tablename, record = s3base.s3_rheader_resource(r)
r.record = record
r.table = s3db[tablename]
tabs = [(T("Details"), None)]
try:
tabs = tabs + s3db.req_tabs(r)
except:
pass
try:
tabs = tabs + s3db.inv_tabs(r)
except:
pass
rheader_fields = [["name"], ["location_id"]]
rheader = S3ResourceHeader(rheader_fields, tabs)(r)
return rheader
# END =========================================================================
Jump to Line
Something went wrong with that request. Please try again.