Skip to content

Commit

Permalink
Bug fixes; add s3_str to controller globals so that it can be accessed
Browse files Browse the repository at this point in the history
without s3base prefix (frequently used for modifying s3.actions)
  • Loading branch information
nursix committed Dec 2, 2019
1 parent 7c1e758 commit 1656c8b
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 65 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b'1ff91fe15' (2019-12-02 11:33:28)
nursix-dev-3367-g7c1e758 (2019-12-02 14:29:14)
2 changes: 0 additions & 2 deletions controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ def user():
# auth_membership = "user_id",
# )

s3_str = s3base.s3_str

list_fields = ["first_name",
"last_name",
"email",
Expand Down
3 changes: 0 additions & 3 deletions controllers/cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ def prep(r):
rows = db(query).select(itable.sender_name,
groupby=itable.sender_name)
sender_options = {}
from s3 import s3_str
for row in rows:
sender_name = row.sender_name
sender_options[sender_name] = s3_str(T(sender_name))
Expand Down Expand Up @@ -1491,7 +1490,6 @@ def set_priority_js():
orderby = wptable.name,
)

from s3 import s3_str
priorities = [(s3_str(T(r.name)), r.urgency, r.severity, r.certainty, r.color_code)\
for r in rows]

Expand Down Expand Up @@ -1528,7 +1526,6 @@ def cap_AreaRowOptionsBuilder(alert_id, caller=None):
values = [row.id for row in rows]
count = len(values)
if count:
from s3 import s3_str
if count == 1:
query_ = (atable.id == values[0])
else:
Expand Down
28 changes: 15 additions & 13 deletions controllers/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,22 +950,24 @@ def postp(r, output):
restrict_e = [str(row.id) for row in rows if not row.enabled]
restrict_d = [str(row.id) for row in rows if row.enabled]

from s3 import s3_str
s3.actions += [dict(label=s3_str(T("Enable")),
_class="action-btn",
url=URL(args=["[id]", "enable"]),
restrict = restrict_e),
dict(label=s3_str(T("Disable")),
_class="action-btn",
url = URL(args = ["[id]", "disable"]),
restrict = restrict_d),
s3.actions += [{"label": s3_str(T("Enable")),
"_class": "action-btn",
"url": URL(args=["[id]", "enable"]),
"restrict": restrict_e,
},
{"label": s3_str(T("Disable")),
"_class": "action-btn",
"url": URL(args = ["[id]", "disable"]),
"restrict": restrict_d,
},
]
if not s3task._is_alive():
# No Scheduler Running
s3.actions += [dict(label=s3_str(T("Poll")),
_class="action-btn",
url = URL(args = ["[id]", "poll"]),
restrict = restrict_d)
s3.actions += [{"label": s3_str(T("Poll")),
"_class": "action-btn",
"url": URL(args = ["[id]", "poll"]),
"restrict": restrict_d,
},
]
return output
s3.postp = postp
Expand Down
2 changes: 1 addition & 1 deletion controllers/gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3034,7 +3034,7 @@ def postp(r, output):
# Normal Action Buttons
s3_action_buttons(r, deletable=False)
# Custom Action Buttons
s3.actions += [{"label": s3base.s3_str(T("Show on Map")),
s3.actions += [{"label": s3_str(T("Show on Map")),
"_class": "action-btn",
"url": URL(f = "index",
vars = {"poi": "[id]"},
Expand Down
11 changes: 1 addition & 10 deletions controllers/msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def postp(r, output):
# Normal Action Buttons
s3_action_buttons(r)
# Custom Action Buttons
s3.actions += [{"label": s3base.s3_str(T("Mark Sender")),
s3.actions += [{"label": s3_str(T("Mark Sender")),
"url": URL(f = "mark_sender",
args = ["[id]"],
),
Expand Down Expand Up @@ -765,7 +765,6 @@ def postp(r, output):
restrict_e = [str(row.id) for row in rows if not row.enabled]
restrict_d = [str(row.id) for row in rows if row.enabled]

from s3 import s3_str
s3.actions += [{"label": s3_str(T("Enable")),
"_class": "action-btn",
"url": URL(args=["[id]", "enable"]),
Expand Down Expand Up @@ -829,7 +828,6 @@ def postp(r, output):
restrict_e = [str(row.id) for row in rows if not row.enabled]
restrict_d = [str(row.id) for row in rows if row.enabled]

from s3 import s3_str
s3.actions += [{"label": s3_str(T("Enable")),
"_class": "action-btn",
"url": URL(args=["[id]", "enable"]),
Expand Down Expand Up @@ -910,7 +908,6 @@ def postp(r, output):
restrict_e = [str(row.id) for row in rows if not row.enabled]
restrict_d = [str(row.id) for row in rows if row.enabled]

from s3 import s3_str
s3.actions += [{"label": s3_str(T("Enable")),
"_class": "action-btn",
"url": URL(args=["[id]", "enable"]),
Expand Down Expand Up @@ -981,7 +978,6 @@ def postp(r, output):
restrict_e = [str(row.id) for row in rows if not row.enabled]
restrict_d = [str(row.id) for row in rows if row.enabled]

from s3 import s3_str
s3.actions += [{"label": s3_str(T("Enable")),
"_class": "action-btn",
"url": URL(args=["[id]", "enable"]),
Expand Down Expand Up @@ -1064,7 +1060,6 @@ def postp(r, output):
restrict_e = [str(row.id) for row in rows if not row.enabled]
restrict_d = [str(row.id) for row in rows if row.enabled]

from s3 import s3_str
s3.actions += [{"label": s3_str(T("Subscribe")),
"_class": "action-btn",
"url": URL(args=["[id]", "enable"]),
Expand Down Expand Up @@ -1140,7 +1135,6 @@ def postp(r, output):
restrict_e = [str(row.id) for row in rows if not row.enabled]
restrict_d = [str(row.id) for row in rows if row.enabled]

from s3 import s3_str
s3.actions += [{"label": s3_str(T("Enable")),
"_class": "action-btn",
"url": URL(args=["[id]", "enable"]),
Expand Down Expand Up @@ -1416,7 +1410,6 @@ def postp(r, output):
restrict_e = [str(row.id) for row in rows if not row.enabled]
restrict_d = [str(row.id) for row in rows if row.enabled]

from s3 import s3_str
s3.actions += [{"label": s3_str(T("Enable")),
"_class": "action-btn",
"url": URL(args=["[id]", "enable"]),
Expand Down Expand Up @@ -1612,7 +1605,6 @@ def postp(r, output):
restrict_k = [str(record.id) for record in records]

# @ToDo: Make these S3Methods rather than additional controllers
from s3 import s3_str
s3.actions += [{"label": s3_str(T("Search")),
"_class": "action-btn",
"url": URL(args=["[id]", "poll"]),
Expand Down Expand Up @@ -1836,7 +1828,6 @@ def postp(r, output):
restrict_e = [str(row.id) for row in rows if not row.enabled]
restrict_d = [str(row.id) for row in rows if row.enabled]

from s3 import s3_str
s3.actions += [{"label": s3_str(T("Enable")),
"_class": "action-btn",
"url": URL(args=["[id]", "enable"]),
Expand Down
3 changes: 1 addition & 2 deletions controllers/req.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ def postp(r, output):
r.next = URL(args=[form_vars.id, "req_skill"])
else:
s3_action_buttons(r, deletable =False)
s3_str = s3base.s3_str
# Add delete button for those records which are not completed
# @ToDo: Handle icons
table = r.table
Expand Down Expand Up @@ -770,7 +769,7 @@ def postp(r, output):
#rows = db(query).select(table.id)
#restrict = [str(row.id) for row in rows]
#s3.actions.append(
# {"label": s3_str(T("View Items")),
## {"label": s3_str(T("View Items")),
# "url": URL(c = "req",
# f = "req",
# args = ["[id]", "req_item"],
Expand Down
3 changes: 0 additions & 3 deletions controllers/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def postp(r, output):
restrict_d = [str(row.id) for row in rows if row.task_id is None]
restrict_s = [str(row.id) for row in rows if row.task_id is not None]
restrict_c = [str(row.id) for row in rows if row.type in (3, 4)]
s3_str = s3base.s3_str
s3.actions += [{"url": URL(c = module,
f = "deployment",
args = [deployment_id, "instance", "[id]", "deploy"],
Expand Down Expand Up @@ -278,7 +277,6 @@ def postp(r, output):
)
restrict_e = [str(row.server_id) for row in rows if row.enabled is False]
restrict_d = [str(row.server_id) for row in rows if row.enabled is True]
s3_str = s3base.s3_str
s3.actions += [{"url": URL(args = ["[id]", "enable"]),
"_class": "action-btn",
"label": s3_str(T("Enable")),
Expand Down Expand Up @@ -363,7 +361,6 @@ def postp(r, output):
)
restrict_e = [str(row.id) for row in rows if not row.enabled]
restrict_d = [str(row.id) for row in rows if row.enabled]
s3_str = s3base.s3_str
s3.actions += [{"url": URL(args=["[id]", "enable"]),
"_class": "action-btn",
"label": s3_str(T("Enable")),
Expand Down
30 changes: 18 additions & 12 deletions controllers/stdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@ def postp(r, output):
# Normal Action Buttons
s3_action_buttons(r)
# Custom Action Buttons
s3.actions += [dict(label=s3base.s3_str(T("Certificate")),
_class="action-btn",
url=URL(f="tenure",
args=["[id]", "certificate"])),
s3.actions += [{"label": s3_str(T("Certificate")),
"_class": "action-btn",
"url": URL(f = "tenure",
args = ["[id]", "certificate"],
),
},
]

return output
Expand Down Expand Up @@ -258,10 +260,12 @@ def postp(r, output):
# Normal Action Buttons
s3_action_buttons(r)
# Custom Action Buttons
s3.actions += [dict(label=s3base.s3_str(T("Certificate")),
_class="action-btn",
url=URL(f="tenure",
args=["[id]", "certificate"])),
s3.actions += [{"label": s3_str(T("Certificate")),
"_class": "action-btn",
"url": URL(f = "tenure",
args = ["[id]", "certificate"],
),
},
]

return output
Expand All @@ -279,10 +283,12 @@ def postp(r, output):
# Normal Action Buttons
s3_action_buttons(r)
# Custom Action Buttons
s3.actions += [dict(label=s3base.s3_str(T("Certificate")),
_class="action-btn",
url=URL(f="tenure",
args=["[id]", "certificate"])),
s3.actions += [{"label": s3_str(T("Certificate")),
"_class": "action-btn",
"url": URL(f = "tenure",
args = ["[id]", "certificate"],
),
},
]

return output
Expand Down
2 changes: 1 addition & 1 deletion controllers/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def postp(r, output):
return output["item"]
if not r.component and method != "summary":
# Replace the Action buttons
s3.actions = [{"label": s3base.s3_str(messages.UPDATE),
s3.actions = [{"label": s3_str(messages.UPDATE),
"_class": "action-btn edit",
"url": URL(c="survey",
f="series",
Expand Down
2 changes: 1 addition & 1 deletion controllers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def prep(r):
def postp(r, output):
if r.interactive and r.id:
if r.component and r.component.alias == "job":
s3.actions = [{"label": s3base.s3_str(T("Reset")),
s3.actions = [{"label": s3_str(T("Reset")),
"url": URL(c = "sync",
f = "repository",
args = [str(r.id),
Expand Down
6 changes: 4 additions & 2 deletions models/00_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@
# CRUD
s3.crud = Storage()

# S3 Custom Validators and Widgets, imported here into the global
# namespace in order to access them without the s3base namespace prefix
# Frequently used S3 utilities, validators and widgets, imported here
# into the global namespace in order to access them without the s3base
# namespace prefix
s3_str = s3base.s3_str
s3_action_buttons = s3base.S3CRUD.action_buttons
s3_fullname = s3base.s3_fullname
s3_redirect_default = s3base.s3_redirect_default
Expand Down
1 change: 0 additions & 1 deletion models/zzz_1st_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ def duration(msg, start):
try:
info(error)
except:
s3_str = s3base.s3_str
info("\n".join(s3_str(el) for el in error))

# Check to see if the "SITE_DEFAULT" gis_hierarchy was prepopulated.
Expand Down
23 changes: 10 additions & 13 deletions modules/s3db/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,21 +654,18 @@ def setup_get_templates(path):
join = p.join
isdir = p.isdir
listdir = os.listdir
templates = [basename(t) for t in listdir(path) \
if basename(t) not in ("historic",
"locations",
"mobile",
"skeleton",
"skeletontheme",
"__init__.py",
"__init__.pyc",
"000_config.py",
)
]

# All subdirectories in the path that contain a config.py are
# templates - except skeleton/skeletontheme
dirs = next(os.walk(path))[1]
templates = [d for d in dirs
if d[:8] != "skeleton" and
os.path.isfile(os.path.join(path, d, "config.py"))
]

subtemplates = []
sappend = subtemplates.append
for i in range(0, len(templates)):
template = templates[i]
for template in templates:
tpath = join(path, template)
for d in listdir(tpath):
if isdir(join(tpath, d)):
Expand Down

0 comments on commit 1656c8b

Please sign in to comment.