Merge branch 'bug/dev-schedules-users' into 'dev'

Fix cron edit traceback.

See merge request crafty-controller/crafty-4!466
This commit is contained in:
Iain Powrie 2022-09-20 22:13:08 +00:00
commit 251e676fec
3 changed files with 26 additions and 3 deletions

View File

@ -13,6 +13,12 @@
### Tweaks ### Tweaks
- Add button to scroll to bottom of vterm ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/454)) - Add button to scroll to bottom of vterm ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/454))
- Persist schedules and execution commands across backup restores ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/458)) - Persist schedules and execution commands across backup restores ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/458))
### Release Testing- Bug fixes
- Fix bug with logical issues surrounding gravatar caching ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/465))
- Fix bug where server terminal would not scroll on startup ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/465))
- Fix issue on post with adding users when no email is included (this also affected editing users) ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/466))
- Fix issue with schedules allowing days to be more than 30 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/466))
- Fix issue with schedules when trying to edit a cron task ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/466))
<br><br> <br><br>
## --- [4.0.12] - 2022/09/04 ## --- [4.0.12] - 2022/09/04

View File

@ -157,9 +157,13 @@ class UsersController:
base_data = HelperUsers.get_user(user_id) base_data = HelperUsers.get_user(user_id)
up_data = {} up_data = {}
# check if we updated user email. If so we update gravatar # check if we updated user email. If so we update gravatar
try:
if user_data["email"] != base_data["email"]: if user_data["email"] != base_data["email"]:
pfp = self.helper.get_gravatar_image(user_data["email"]) pfp = self.helper.get_gravatar_image(user_data["email"])
up_data["pfp"] = pfp up_data["pfp"] = pfp
except KeyError:
logger.debug("Email not updated")
# email not updated
# create sets to store role data # create sets to store role data
added_roles = set() added_roles = set()
removed_roles = set() removed_roles = set()

View File

@ -1068,6 +1068,7 @@ class PanelHandler(BaseHandler):
page_data["parent"] = None page_data["parent"] = None
else: else:
difficulty = "advanced" difficulty = "advanced"
page_data["parent"] = None
page_data["schedule"]["difficulty"] = difficulty page_data["schedule"]["difficulty"] = difficulty
if not EnumPermissionsServer.SCHEDULE in page_data["user_permissions"]: if not EnumPermissionsServer.SCHEDULE in page_data["user_permissions"]:
@ -1699,6 +1700,12 @@ class PanelHandler(BaseHandler):
# only check for time if it's number of days # only check for time if it's number of days
if interval_type == "days": if interval_type == "days":
sch_time = bleach.clean(self.get_argument("time", None)) sch_time = bleach.clean(self.get_argument("time", None))
if interval > 30:
self.redirect(
"/panel/error?error=Invalid argument."
" Days must be 30 or fewer."
)
return
if action == "command": if action == "command":
command = self.get_argument("command", None) command = self.get_argument("command", None)
elif action == "start": elif action == "start":
@ -1861,6 +1868,12 @@ class PanelHandler(BaseHandler):
# only check for time if it's number of days # only check for time if it's number of days
if interval_type == "days": if interval_type == "days":
sch_time = bleach.clean(self.get_argument("time", None)) sch_time = bleach.clean(self.get_argument("time", None))
if interval > 30:
self.redirect(
"/panel/error?error=Invalid argument."
" Days must be 30 or fewer."
)
return
if action == "command": if action == "command":
command = self.get_argument("command", None) command = self.get_argument("command", None)
elif action == "start": elif action == "start":