Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nursix/eden-asp
Browse files Browse the repository at this point in the history
  • Loading branch information
nursix committed Oct 30, 2023
2 parents 7ec4b95 + 657df79 commit 4599722
Show file tree
Hide file tree
Showing 181 changed files with 14,649 additions and 5,616 deletions.
43 changes: 38 additions & 5 deletions controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,25 @@ def disable_user(r, **args):
session.confirmation = T("User Account has been Disabled")
redirect(URL(args=[]))

def enable_user(r, **args):
user_id = r.id
if not user_id:
session.error = T("Can only re-enable 1 record at a time!")
redirect(URL(args=[]))

query = (table.id == user_id)
row = db(query).select(table.id,
table.registration_key,
limitby = (0, 1),
).first()
if row and row.registration_key != "disabled":
session.error = T("User Account not Disabled")
redirect(URL(args=[]))

row.update_record(registration_key=None)
session.confirmation = T("User Account has been Re-enabled")
redirect(URL(args=[]))

def approve_user(r, **args):
if not r.id:
session.error = T("Can only approve 1 record at a time!")
Expand Down Expand Up @@ -177,6 +196,10 @@ def link_user(r, **args):
method = "disable",
action = disable_user)

set_method("auth_user",
method = "enable",
action = enable_user)

set_method("auth_user",
method = "approve",
action = approve_user)
Expand Down Expand Up @@ -334,20 +357,30 @@ def postp(r, output):

# Only show the disable button if the user is not currently disabled
table = r.table
query = (table.registration_key == None) | \
(table.registration_key == "")
query = (table.registration_key == "disabled") & \
(table.deleted == False)
rows = db(query).select(table.id)
restrict = [str(row.id) for row in rows]
disabled = [str(row.id) for row in rows]

actions.append({"label": str(T("Re-enable")),
"restrict": disabled,
"url": URL(c="admin", f="user",
args = ["[id]", "enable"],
),
"_class": "action-btn",
})

actions.append({"label": str(T("Disable")),
"restrict": restrict,
"exclude": disabled,
"url": URL(c="admin", f="user",
args = ["[id]", "disable"],
),
"_class": "action-btn",
})

if settings.get_auth_show_link():
actions.insert(1, {"label": s3_str(T("Link")),
"restrict": restrict,
"exclude": disabled,
"url": URL(c="admin", f="user",
args = ["[id]", "link"],
),
Expand Down
37 changes: 21 additions & 16 deletions controllers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,6 @@ def prep(r):
title_display = T("Personal Profile"),
title_update = T("Personal Profile"))

# Organisation-dependent Fields
#set_org_dependent_field = settings.set_org_dependent_field
#set_org_dependent_field("pr_person_details", "father_name")
#set_org_dependent_field("pr_person_details", "mother_name")
#set_org_dependent_field("pr_person_details", "affiliations")
#set_org_dependent_field("pr_person_details", "company")

if r.component:
if r.component_name == "physical_description":
# Hide all but those details that we want
Expand All @@ -687,6 +680,11 @@ def prep(r):
table.other_details.writable = True
table.other_details.readable = True

elif r.component_name == "human_resource":
r.component.configure(insertable = False,
deletable = False,
)

elif r.component_name == "config":
ctable = s3db.gis_config
s3db.gis_config_form_setup()
Expand Down Expand Up @@ -747,16 +745,23 @@ def prep(r):

# CRUD post-process
def postp(r, output):
if r.interactive and r.component:
if r.component_name == "config":
update_url = URL(c="gis", f="config",
args="[id]")

if r.interactive:
if not r.component and r.record and isinstance(output, dict):
# Remove all CRUD buttons except Edit-button
buttons = output.get("buttons")
if isinstance(buttons, dict):
output["buttons"] = {"edit_btn": buttons["edit_btn"]} \
if "edit_btn" in buttons else {}

elif r.component_name == "config":
update_url = URL(c="gis", f="config", args="[id]")
s3_action_buttons(r, update_url=update_url)
s3.actions.append(dict(url=URL(c="gis", f="index",
vars={"config":"[id]"}),
label=str(T("Show")),
_class="action-btn",
))
s3.actions.append({"url": URL(c="gis", f="index", vars={"config":"[id]"}),
"label": str(T("Show")),
"_class": "action-btn",
})

elif r.component_name == "asset":
# Provide a link to assign a new Asset
# @ToDo: Proper Widget to do this inline
Expand Down
Loading

0 comments on commit 4599722

Please sign in to comment.