comparison src/pages/merge-requests/view/page_meta.py @ 1113:cdd389ef97bc

server: code style reformatting using black
author Goffi <goffi@goffi.org>
date Fri, 29 Jun 2018 17:45:26 +0200
parents 01e95ec9df9e
children
comparison
equal deleted inserted replaced
1112:f287fc8bb31a 1113:cdd389ef97bc
13 from sat.core.log import getLogger 13 from sat.core.log import getLogger
14 14
15 name = u"merge-requests_view" 15 name = u"merge-requests_view"
16 access = C.PAGES_ACCESS_PUBLIC 16 access = C.PAGES_ACCESS_PUBLIC
17 template = u"merge-request/item.html" 17 template = u"merge-request/item.html"
18 log = getLogger(u'pages/' + name) 18 log = getLogger(u"pages/" + name)
19 19
20 20
21 def parse_url(self, request): 21 def parse_url(self, request):
22 try: 22 try:
23 item_id = self.nextPath(request) 23 item_id = self.nextPath(request)
24 except IndexError: 24 except IndexError:
25 log.warning(_(u"no ticket id specified")) 25 log.warning(_(u"no ticket id specified"))
26 self.pageError(request, C.HTTP_BAD_REQUEST) 26 self.pageError(request, C.HTTP_BAD_REQUEST)
27 27
28 data = self.getRData(request) 28 data = self.getRData(request)
29 data[u'ticket_id'] = item_id 29 data[u"ticket_id"] = item_id
30
30 31
31 @defer.inlineCallbacks 32 @defer.inlineCallbacks
32 def prepare_render(self, request): 33 def prepare_render(self, request):
33 data = self.getRData(request) 34 data = self.getRData(request)
34 template_data = request.template_data 35 template_data = request.template_data
35 session = self.host.getSessionData(request, session_iface.ISATSession) 36 session = self.host.getSessionData(request, session_iface.ISATSession)
36 service, node, ticket_id = data.get(u'service', u''), data.get(u'node', u''), data[u'ticket_id'] 37 service, node, ticket_id = (
38 data.get(u"service", u""),
39 data.get(u"node", u""),
40 data[u"ticket_id"],
41 )
37 profile = self.getProfile(request) 42 profile = self.getProfile(request)
38 43
39 if profile is None: 44 if profile is None:
40 profile = C.SERVICE_PROFILE 45 profile = C.SERVICE_PROFILE
41 46
42 tickets, metadata, parsed_tickets = yield self.host.bridgeCall("mergeRequestsGet", service.full() if service else u'', 47 tickets, metadata, parsed_tickets = yield self.host.bridgeCall(
43 node, 48 "mergeRequestsGet",
44 C.NO_LIMIT, 49 service.full() if service else u"",
45 [ticket_id], 50 node,
46 '', 51 C.NO_LIMIT,
47 {'parse': C.BOOL_TRUE, 52 [ticket_id],
48 'labels_as_list': C.BOOL_TRUE}, 53 "",
49 profile) 54 {"parse": C.BOOL_TRUE, "labels_as_list": C.BOOL_TRUE},
50 ticket = template_xmlui.create(self.host, tickets[0], ignore=['request_data', 'type']) 55 profile,
51 template_data[u'item'] = ticket 56 )
52 template_data['patches'] = parsed_tickets[0] 57 ticket = template_xmlui.create(self.host, tickets[0], ignore=["request_data", "type"])
53 comments_uri = ticket.widgets['comments_uri'].value 58 template_data[u"item"] = ticket
59 template_data["patches"] = parsed_tickets[0]
60 comments_uri = ticket.widgets["comments_uri"].value
54 if comments_uri: 61 if comments_uri:
55 uri_data = uri.parseXMPPUri(comments_uri) 62 uri_data = uri.parseXMPPUri(comments_uri)
56 template_data['comments_node'] = comments_node = uri_data['node'] 63 template_data["comments_node"] = comments_node = uri_data["node"]
57 template_data['comments_service'] = comments_service = uri_data['path'] 64 template_data["comments_service"] = comments_service = uri_data["path"]
58 comments = yield self.host.bridgeCall("mbGet", 65 comments = yield self.host.bridgeCall(
59 comments_service, 66 "mbGet", comments_service, comments_node, C.NO_LIMIT, [], {}, profile
60 comments_node, 67 )
61 C.NO_LIMIT,
62 [],
63 {},
64 profile)
65 68
66 template_data[u'comments'] = data_objects.BlogItems(comments) 69 template_data[u"comments"] = data_objects.BlogItems(comments)
67 template_data[u'login_url'] = self.getPageRedirectURL(request) 70 template_data[u"login_url"] = self.getPageRedirectURL(request)
68 71
69 if session.connected: 72 if session.connected:
70 # we set edition URL only if user is the publisher or the node owner 73 # we set edition URL only if user is the publisher or the node owner
71 publisher = jid.JID(ticket.widgets['publisher'].value) 74 publisher = jid.JID(ticket.widgets["publisher"].value)
72 is_publisher = publisher.userhostJID() == session.jid.userhostJID() 75 is_publisher = publisher.userhostJID() == session.jid.userhostJID()
73 affiliation = None 76 affiliation = None
74 if not is_publisher: 77 if not is_publisher:
75 node = node or self.host.ns_map['merge_requests'] 78 node = node or self.host.ns_map["merge_requests"]
76 affiliation = yield self.host.getAffiliation(request, service, node) 79 affiliation = yield self.host.getAffiliation(request, service, node)
77 if is_publisher or affiliation == 'owner': 80 if is_publisher or affiliation == "owner":
78 template_data[u'url_ticket_edit'] = self.getURLByPath(SubPage('merge-requests'), service.full(), node or u'@', SubPage('merge-requests_edit'), ticket_id) 81 template_data[u"url_ticket_edit"] = self.getURLByPath(
82 SubPage("merge-requests"),
83 service.full(),
84 node or u"@",
85 SubPage("merge-requests_edit"),
86 ticket_id,
87 )
88
79 89
80 @defer.inlineCallbacks 90 @defer.inlineCallbacks
81 def on_data_post(self, request): 91 def on_data_post(self, request):
82 type_ = self.getPostedData(request, u'type') 92 type_ = self.getPostedData(request, u"type")
83 if type_ == u'comment': 93 if type_ == u"comment":
84 blog_page = self.getPageByName(u'blog_view') 94 blog_page = self.getPageByName(u"blog_view")
85 yield blog_page.on_data_post(self, request) 95 yield blog_page.on_data_post(self, request)
86 else: 96 else:
87 log.warning(_(u"Unhandled data type: {}").format(type_)) 97 log.warning(_(u"Unhandled data type: {}").format(type_))