Skip to content

Commit

Permalink
Merge branch 'main' of github.com:mausbrand/diwodo-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
timmytiefkuehl committed Sep 25, 2024
2 parents 1bad2f1 + 1c0c926 commit b14d4ba
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
viur-core = "==3.7.0.dev3"
viur-core = {file = "../viur-core", editable = true}

[dev-packages]
viur-cli = "~=2.0"
Expand Down
11 changes: 4 additions & 7 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 19 additions & 21 deletions deploy/modules/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ def addSkel(self):
skel.user = None
return skel

def listFilter(self, query):
if query := super().listFilter(query):
if not utils.string.is_prefix(self.render.kind, "json.vi"):
cuser = current.user.get()
query.mergeExternalFilter({
"user.dest.key": cuser["key"],
})

return query

@exposed
@skey(allow_empty=True)
@access("todo-edit")
Expand Down Expand Up @@ -96,30 +106,18 @@ class TodoAssignSkel(ActionSkel):
action_skel.setBoneValue("todo", key, append=True)

if not kwargs or not action_skel.fromClient(kwargs):
# TODO: Provide generic render action skel
return self.render.edit(action_skel, "assign")
return self.render.render("assign", action_skel)

# TODO: Add program logic here
# TODO: Create skel.update() function for transactional in-place update
for todo in action_skel["todo"]:
skel = self.editSkel()
skel.fromDB(todo["dest"]["key"])
skel["status"] = "open"
skel.setBoneValue("user", action_skel["user"]["dest"]["key"])
skel.toDB()

# TODO: Provide generic render action success
return self.render.editSuccess(action_skel, "assignSuccess")

def listFilter(self, query):
if query := super().listFilter(query):
if not utils.string.is_prefix(self.render.kind, "json.vi"):
cuser = current.user.get()
query.mergeExternalFilter({
"user.dest.key": cuser["key"],
})
self.editSkel().update(
values={
"status": "open",
"user": action_skel["user"]["dest"]["key"],
},
key=todo["dest"]["key"],
)

return query
return self.render.render("assignSuccess", action_skel)


Todo.html = True
Expand Down
2 changes: 1 addition & 1 deletion deploy/skeletons/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TodoSkel(skeleton.Skeleton):
status = SelectBone(
descr="Status",
required=True,
defaultValue="open",
defaultValue="new",
values={
"new": "Neu",
"open": "Zugewiesen",
Expand Down

0 comments on commit b14d4ba

Please sign in to comment.