Skip to content

Commit

Permalink
Tweaks for "work" module, stop reporting server error 501 for invalid
Browse files Browse the repository at this point in the history
format when it's actually the client's fault (and also tweak a couple of
501 for BAD_METHOD => that too is the client's fault, so 405).
  • Loading branch information
nursix committed Oct 17, 2015
1 parent 7f3c587 commit bfda2bc
Show file tree
Hide file tree
Showing 34 changed files with 126 additions and 115 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5a11026 (2015-10-17 22:16:02)
nursix-1.1.0-devel-2938-g7f3c587 (2015-10-17 23:10:56)
2 changes: 1 addition & 1 deletion controllers/assess2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ def assess_rat_summary(r, **attr):
# Other formats?
raise HTTP(501, ERROR.BAD_FORMAT)
else:
raise HTTP(501, ERROR.BAD_METHOD)
raise HTTP(405, ERROR.BAD_METHOD)


s3db.set_method("assess", "rat",
Expand Down
2 changes: 1 addition & 1 deletion controllers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def organisation():
draw)
else:
from gluon.http import HTTP
raise HTTP(501, ERROR.BAD_FORMAT)
raise HTTP(415, ERROR.BAD_FORMAT)
return items

# -----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion controllers/gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def s3_gis_location_parents(r, **attr):
raise HTTP(404, ERROR.BAD_RECORD)

else:
raise HTTP(501, ERROR.BAD_FORMAT)
raise HTTP(415, ERROR.BAD_FORMAT)

# -----------------------------------------------------------------------------
def l0():
Expand Down
5 changes: 2 additions & 3 deletions controllers/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
def index():
""" Module's Home Page """

output = {}

return output
# Redirect to job list
s3_redirect_default(URL(f="job", args=["datalist"]))

# -----------------------------------------------------------------------------
def context():
Expand Down
10 changes: 5 additions & 5 deletions modules/s3/s3aaa.py
Original file line number Diff line number Diff line change
Expand Up @@ -7269,7 +7269,7 @@ def _list(self, r, **attr):
r.error(501, current.ERROR.BAD_FORMAT)

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down Expand Up @@ -7709,7 +7709,7 @@ def _edit(self, r, **attr):
current.response.view = "admin/role_edit.html"

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down Expand Up @@ -7766,7 +7766,7 @@ def _delete(self, r, **attr):
else:
session.error = T("No role to delete")
else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

redirect(URL(c="admin", f="role", vars=request.get_vars))

Expand Down Expand Up @@ -8009,7 +8009,7 @@ def _roles(self, r, **attr):

current.response.view = "admin/membership_manage.html"
else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

else:
r.error(404, current.ERROR.BAD_RECORD)
Expand Down Expand Up @@ -8273,7 +8273,7 @@ def _users(self, r, **attr):
add_btn=add_btn)
current.response.view = "admin/membership_manage.html"
else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)
else:
r.error(404, current.ERROR.BAD_RECORD)

Expand Down
18 changes: 9 additions & 9 deletions modules/s3/s3crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def create(self, r, **attr):
return results

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down Expand Up @@ -785,7 +785,7 @@ def read(self, r, **attr):
return exporter(resource, tooltip=tooltip)

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down Expand Up @@ -972,7 +972,7 @@ def update(self, r, **attr):
return self.import_url(r)

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down Expand Up @@ -1340,7 +1340,7 @@ def select(self, r, **attr):
r.error(405, current.ERROR.BAD_METHOD)

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

# -------------------------------------------------------------------------
def _datatable(self, r, **attr):
Expand Down Expand Up @@ -1520,7 +1520,7 @@ def _datatable(self, r, **attr):
'"data":[]}' % (totalrows, list_id, draw)

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down Expand Up @@ -1683,7 +1683,7 @@ def _datalist(self, r, **attr):
# dl.insert(0, DIV(empty, _class="empty"))
data = dl
else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)


if representation == "html":
Expand Down Expand Up @@ -1893,7 +1893,7 @@ def unapproved(self, r, **attr):
'"data": []}' % (totalrows, list_id, draw)

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down Expand Up @@ -1990,7 +1990,7 @@ def review(self, r, **attr):
current.response.view = "review.html"

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down Expand Up @@ -2034,7 +2034,7 @@ def validate(self, r, **attr):
"""

if r.representation != "json":
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

resource = self.resource

Expand Down
2 changes: 1 addition & 1 deletion modules/s3/s3filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2613,7 +2613,7 @@ def apply_method(self, r, **attr):
return self._form(r, **attr)

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

# -------------------------------------------------------------------------
def _form(self, r, **attr):
Expand Down
4 changes: 2 additions & 2 deletions modules/s3/s3gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9087,7 +9087,7 @@ def page(self, r, **attr):
return output

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

# -------------------------------------------------------------------------
def widget(self,
Expand Down Expand Up @@ -9575,6 +9575,6 @@ def apply_method(r, **attr):
return output

else:
raise HTTP(501, current.ERROR.BAD_METHOD)
raise HTTP(405, current.ERROR.BAD_METHOD)

# END =========================================================================
4 changes: 2 additions & 2 deletions modules/s3/s3grouped.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def widget(self, r, method=None, widget_id=None, visible=True, **attr):

output = {}
if r.http == "GET":
r.error(405, current.ERROR.NOT_IMPLEMENTED)
r.error(501, current.ERROR.NOT_IMPLEMENTED)
else:
r.error(405, current.ERROR.BAD_METHOD)
return output
Expand Down Expand Up @@ -280,7 +280,7 @@ def report(self, r, **attr):
return gi_table.xls(r)

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down
2 changes: 1 addition & 1 deletion modules/s3/s3hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def apply_method(self, r, **attr):
elif r.representation == "xls":
output = self.export_xls(r, **attr)
else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)
else:
r.error(405, current.ERROR.BAD_METHOD)

Expand Down
2 changes: 1 addition & 1 deletion modules/s3/s3merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def duplicates(self, r, **attr):
current.response.view = self._view(r, "list.html")

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down
2 changes: 1 addition & 1 deletion modules/s3/s3msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,7 @@ def compose(self, r, **attr):
if self.method == "compose":
output = dict(form=form)
else:
r.error(501, current.ERROR.BAD_METHOD)
r.error(405, current.ERROR.BAD_METHOD)

# Complete the page
if r.representation == "html":
Expand Down
2 changes: 1 addition & 1 deletion modules/s3/s3profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def default_orderby():

else:
# Really raise an exception here?
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

# -------------------------------------------------------------------------
def _form(self, r, widget, **attr):
Expand Down
4 changes: 2 additions & 2 deletions modules/s3/s3report.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def report(self, r, **attr):
output = json.dumps(pivotdata, separators=SEPARATORS)

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down Expand Up @@ -513,7 +513,7 @@ def widget(self, r, method=None, widget_id=None, visible=True, **attr):
output = XML(current.response.render(view, output))

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down
4 changes: 2 additions & 2 deletions modules/s3/s3rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ def get_fields(r, **attr):
as_json=True)
content_type = "application/json"
else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)
response = current.response
response.headers["Content-Type"] = content_type
return output
Expand Down Expand Up @@ -1152,7 +1152,7 @@ def get_options(r, **attr):
as_json = True
content_type = "application/json"
else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

component = r.component_name
output = r.resource.export_options(component=component,
Expand Down
2 changes: 1 addition & 1 deletion modules/s3/s3sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def apply_method(self, r, **attr):
output = r(subtitle=None,
rheader=self.rheader)
else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down
4 changes: 2 additions & 2 deletions modules/s3/s3timeplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def widget(self, r, method=None, widget_id=None, visible=True, **attr):
output = XML(current.response.render(view, output))

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down Expand Up @@ -334,7 +334,7 @@ def timeplot(self, r, **attr):
output = json.dumps(data, separators=SEPARATORS)

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)

return output

Expand Down
4 changes: 2 additions & 2 deletions modules/s3/s3track.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ def apply_method(r, **attr):

# @ToDo: JSON representation for check-in from mobile devices
else:
raise HTTP(501, current.ERROR.BAD_METHOD)
raise HTTP(415, current.ERROR.BAD_FORMAT)

# =============================================================================
class S3CheckOutMethod(S3Method):
Expand Down Expand Up @@ -908,6 +908,6 @@ def apply_method(r, **attr):

# @ToDo: JSON representation for check-out from mobile devices
else:
raise HTTP(501, current.ERROR.BAD_METHOD)
raise HTTP(415, current.ERROR.BAD_FORMAT)

# END =========================================================================
8 changes: 4 additions & 4 deletions modules/s3db/cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ def cap_rheader(r):
db = current.db
auth = current.auth
has_permission = auth.s3_has_permission

# For Alert Editor
if has_permission("update", "cap_alert",
record_id=alert_id):
Expand All @@ -1761,7 +1761,7 @@ def cap_rheader(r):
pe_append = pe_ids.append
for user_id in user_ids:
pe_append(user_pe_id(int(user_id)))

action_btn = A(T("Submit for Approval"),
_href = URL(f = "compose",
vars = {"cap_alert.id": record.id,
Expand Down Expand Up @@ -2571,7 +2571,7 @@ def apply_method(r, **attr):
return output

else:
raise HTTP(501, current.ERROR.BAD_METHOD)
raise HTTP(405, current.ERROR.BAD_METHOD)

# -----------------------------------------------------------------------------
class cap_AssignArea(S3Method):
Expand Down Expand Up @@ -2792,7 +2792,7 @@ def apply_method(self, r, **attr):
return items

else:
r.error(501, current.ERROR.BAD_FORMAT)
r.error(415, current.ERROR.BAD_FORMAT)
else:
r.error(405, current.ERROR.BAD_METHOD)

Expand Down
Loading

0 comments on commit bfda2bc

Please sign in to comment.