comparison libervia/pages/merge-requests/view/page_meta.py @ 1509:106bae41f5c8

massive refactoring from camelCase -> snake_case. See backend commit log for more details
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:44:11 +0200
parents ce879da7fcf7
children
comparison
equal deleted inserted replaced
1508:ec3ad9abf9f9 1509:106bae41f5c8
17 log = getLogger(__name__) 17 log = getLogger(__name__)
18 18
19 19
20 def parse_url(self, request): 20 def parse_url(self, request):
21 try: 21 try:
22 item_id = self.nextPath(request) 22 item_id = self.next_path(request)
23 except IndexError: 23 except IndexError:
24 log.warning(_("no list item id specified")) 24 log.warning(_("no list item id specified"))
25 self.pageError(request, C.HTTP_BAD_REQUEST) 25 self.page_error(request, C.HTTP_BAD_REQUEST)
26 26
27 data = self.getRData(request) 27 data = self.get_r_data(request)
28 data["list_item_id"] = item_id 28 data["list_item_id"] = item_id
29 29
30 30
31 async def prepare_render(self, request): 31 async def prepare_render(self, request):
32 data = self.getRData(request) 32 data = self.get_r_data(request)
33 template_data = request.template_data 33 template_data = request.template_data
34 session = self.host.getSessionData(request, session_iface.IWebSession) 34 session = self.host.get_session_data(request, session_iface.IWebSession)
35 service, node, list_item_id = ( 35 service, node, list_item_id = (
36 data.get("service", ""), 36 data.get("service", ""),
37 data.get("node", ""), 37 data.get("node", ""),
38 data["list_item_id"], 38 data["list_item_id"],
39 ) 39 )
40 profile = self.getProfile(request) 40 profile = self.get_profile(request)
41 41
42 if profile is None: 42 if profile is None:
43 profile = C.SERVICE_PROFILE 43 profile = C.SERVICE_PROFILE
44 44
45 merge_requests = data_format.deserialise( 45 merge_requests = data_format.deserialise(
46 await self.host.bridgeCall( 46 await self.host.bridge_call(
47 "mergeRequestsGet", 47 "merge_requests_get",
48 service.full() if service else "", 48 service.full() if service else "",
49 node, 49 node,
50 C.NO_LIMIT, 50 C.NO_LIMIT,
51 [list_item_id], 51 [list_item_id],
52 "", 52 "",
59 ) 59 )
60 template_data["item"] = list_item 60 template_data["item"] = list_item
61 template_data["patches"] = merge_requests['items_patches'][0] 61 template_data["patches"] = merge_requests['items_patches'][0]
62 comments_uri = list_item.widgets["comments_uri"].value 62 comments_uri = list_item.widgets["comments_uri"].value
63 if comments_uri: 63 if comments_uri:
64 uri_data = uri.parseXMPPUri(comments_uri) 64 uri_data = uri.parse_xmpp_uri(comments_uri)
65 template_data["comments_node"] = comments_node = uri_data["node"] 65 template_data["comments_node"] = comments_node = uri_data["node"]
66 template_data["comments_service"] = comments_service = uri_data["path"] 66 template_data["comments_service"] = comments_service = uri_data["path"]
67 template_data["comments"] = data_format.deserialise(await self.host.bridgeCall( 67 template_data["comments"] = data_format.deserialise(await self.host.bridge_call(
68 "mbGet", comments_service, comments_node, C.NO_LIMIT, [], 68 "mb_get", comments_service, comments_node, C.NO_LIMIT, [],
69 data_format.serialise({}), profile 69 data_format.serialise({}), profile
70 )) 70 ))
71 71
72 template_data["login_url"] = self.getPageRedirectURL(request) 72 template_data["login_url"] = self.get_page_redirect_url(request)
73 73
74 if session.connected: 74 if session.connected:
75 # we set edition URL only if user is the publisher or the node owner 75 # we set edition URL only if user is the publisher or the node owner
76 publisher = jid.JID(list_item.widgets["publisher"].value) 76 publisher = jid.JID(list_item.widgets["publisher"].value)
77 is_publisher = publisher.userhostJID() == session.jid.userhostJID() 77 is_publisher = publisher.userhostJID() == session.jid.userhostJID()
78 affiliation = None 78 affiliation = None
79 if not is_publisher: 79 if not is_publisher:
80 node = node or self.host.ns_map["merge_requests"] 80 node = node or self.host.ns_map["merge_requests"]
81 affiliation = await self.host.getAffiliation(request, service, node) 81 affiliation = await self.host.get_affiliation(request, service, node)
82 if is_publisher or affiliation == "owner": 82 if is_publisher or affiliation == "owner":
83 template_data["url_list_item_edit"] = self.getURLByPath( 83 template_data["url_list_item_edit"] = self.get_url_by_path(
84 SubPage("merge-requests"), 84 SubPage("merge-requests"),
85 service.full(), 85 service.full(),
86 node or "@", 86 node or "@",
87 SubPage("merge-requests_edit"), 87 SubPage("merge-requests_edit"),
88 list_item_id, 88 list_item_id,
89 ) 89 )
90 90
91 91
92 async def on_data_post(self, request): 92 async def on_data_post(self, request):
93 type_ = self.getPostedData(request, "type") 93 type_ = self.get_posted_data(request, "type")
94 if type_ == "comment": 94 if type_ == "comment":
95 blog_page = self.getPageByName("blog_view") 95 blog_page = self.get_page_by_name("blog_view")
96 await blog_page.on_data_post(self, request) 96 await blog_page.on_data_post(self, request)
97 else: 97 else:
98 log.warning(_("Unhandled data type: {}").format(type_)) 98 log.warning(_("Unhandled data type: {}").format(type_))