Skip to content

Commit

Permalink
refactor: remove cmd / cmda handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
MenxLi committed Aug 18, 2023
1 parent 372d78c commit d7a32da
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 70 deletions.
27 changes: 9 additions & 18 deletions resbibman/core/serverConn.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,23 @@ def deleteData(self, uid: str) -> bool:
return self._checkRes(res)

def deleteTag(self, tag_to_be_deleted: str) -> bool:
post_url = self.SERVER_URL + "/dataman/tag-delete"
post_args = {
"key": self.hash_key,
"cmd": "deleteTagAll",
"uuid": "_",
"args": json.dumps([tag_to_be_deleted]),
"kwargs": json.dumps({})
"tag": tag_to_be_deleted
}
return self._remoteCMD(post_args)
res = requests.post(post_url, data = post_args)
return self._checkRes(res)

def renameTag(self, src_tag: str, dst_tag: str) -> bool:
post_url = self.SERVER_URL + "/dataman/tag-rename"
post_args = {
"key": self.hash_key,
"cmd": "renameTagAll",
"uuid": "_",
"args": json.dumps([src_tag, dst_tag]),
"kwargs": json.dumps({})
"oldTag": src_tag,
"newTag": dst_tag
}
return self._remoteCMD(post_args)
res = requests.post(post_url, data = post_args)
return self._checkRes(res)

def postDiscussion(self, uid: str, name: str, content: str) -> bool:
post_url = self.SERVER_URL + "/discussion_mod"
Expand All @@ -194,14 +193,6 @@ def postDiscussion(self, uid: str, name: str, content: str) -> bool:
res = requests.post(url = post_url, data = post_args)
return self._checkRes(res)

def _remoteCMD(self, post_args) -> bool:
"""
post command to remote/cmdA
"""
post_addr = "{}/cmdA".format(self.SERVER_URL)
res = requests.post(post_addr, params = post_args)
return self._checkRes(res)

def getDocURL(self, uid: str, dtype: Literal["pdf, hpack"]) -> str:
if dtype == "pdf":
return self.SERVER_URL + "/doc/{}".format(uid)
Expand Down
1 change: 0 additions & 1 deletion resbibman/server/handlers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .dataInfo import DataInfoHandler, DataListHandler
from .documents import DocHandler, HDocHandler
from .commands import CMDArgHandler, CMDHandler
from .comment import CommentHandler
from .file import FileHandler
from .auth import AuthHandler
Expand Down
47 changes: 0 additions & 47 deletions resbibman/server/handlers/commands.py

This file was deleted.

4 changes: 2 additions & 2 deletions resbibman/server/handlers/dataMan.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def post(self):
# only admin can rename tags
raise tornado.web.HTTPError(403)
self.db.renameTag(old_tag, new_tag)
self.logger.info(f"Tag {old_tag} renamed to {new_tag}")
self.logger.info(f"Tag [{old_tag}] renamed to [{new_tag}] by [{permission['identifier']}]")
self.write("OK")

class TagDeleteHandler(RequestHandlerMixin, tornado.web.RequestHandler):
Expand All @@ -170,5 +170,5 @@ def post(self):
# only admin can delete tags
raise tornado.web.HTTPError(403)
self.db.deleteTag(tag)
self.logger.info(f"Tag {tag} deleted")
self.logger.info(f"Tag [{tag}] deleted by [{permission['identifier']}]")
self.write("OK")
2 changes: 0 additions & 2 deletions resbibman/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def __init__(self) -> None:
(r"/comment/(.*)", CommentHandler, {"path": "/"}),

## For both clients
# (r"/cmd/(.*)", CMDHandler), # will replace (reload-db)
(r"/cmdA", CMDArgHandler), # will replace
(r"/discussions/(.*)", DiscussionHandler),
(r"/discussion_mod", DiscussionModHandler),
(r"/summary", SummaryHandler), # may deprecate
Expand Down

0 comments on commit d7a32da

Please sign in to comment.