annotate libervia/pages/g/page_meta.py @ 1200:f9091f4e04f0

browser (contact_group): fixed bad property name used in closeAndSave: bad property name was used in closeAndSave resulting in a crash when used wanted to save modifications. fix 309
author Goffi <goffi@goffi.org>
date Tue, 09 Jul 2019 20:41:50 +0200
parents bfbfe04209e9
children b2d067339de3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2.7
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
3
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
4 from libervia.server.constants import Const as C
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
5 from sat.core.i18n import _
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
6 from twisted.internet import defer
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
7 from libervia.server import session_iface
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
8 from sat.core.log import getLogger
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
9
1145
29eb15062416 pages: set __name__ for imported pages
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
10 log = getLogger(__name__)
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
11
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
12 access = C.PAGES_ACCESS_PUBLIC
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
13 template = u"invitation/welcome.html"
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
14
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
15
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
16 @defer.inlineCallbacks
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
17 def parse_url(self, request):
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
18 """check invitation id in URL and start session if needed
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
19
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
20 if a session already exists for an other guest/profile, it will be purged
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
21 """
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
22 try:
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
23 invitation_id = self.nextPath(request)
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
24 except IndexError:
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
25 self.pageError(request)
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
26
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
27 sat_session, guest_session = self.host.getSessionData(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
28 request, session_iface.ISATSession, session_iface.ISATGuestSession
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
29 )
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
30 current_id = guest_session.id
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
31
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
32 if current_id is not None and current_id != invitation_id:
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
33 log.info(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
34 _(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
35 u"killing guest session [{old_id}] because it is connecting with an other ID [{new_id}]"
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
36 ).format(old_id=current_id, new_id=invitation_id)
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
37 )
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
38 self.host.purgeSession(request)
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
39 sat_session, guest_session = self.host.getSessionData(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
40 request, session_iface.ISATSession, session_iface.ISATGuestSession
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
41 )
1179
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
42 current_id = None # FIXME: id not reset here
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
43 profile = None
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
44
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
45 profile = sat_session.profile
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
46 if profile is not None and current_id is None:
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
47 log.info(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
48 _(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
49 u"killing current profile session [{profile}] because a guest id is used"
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
50 ).format(profile=profile)
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
51 )
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
52 self.host.purgeSession(request)
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
53 sat_session, guest_session = self.host.getSessionData(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
54 request, session_iface.ISATSession, session_iface.ISATGuestSession
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
55 )
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
56 profile = None
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
57
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
58 if current_id is None:
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
59 log.debug(_(u"checking invitation [{id}]").format(id=invitation_id))
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
60 try:
1098
01e95ec9df9e server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents: 953
diff changeset
61 data = yield self.host.bridgeCall("invitationGet", invitation_id)
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
62 except Exception:
1173
0f37b65fe7c2 server: replaced wrong usage of C.HTTP_UNAUTHORIZED by C.HTTP_FORBIDDEN
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
63 self.pageError(request, C.HTTP_FORBIDDEN)
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
64 else:
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
65 guest_session.id = invitation_id
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
66 guest_session.data = data
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
67 else:
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
68 data = guest_session.data
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
69
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
70 if profile is None:
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
71 log.debug(_(u"connecting profile [{}]").format(profile))
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
72 # we need to connect the profile
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
73 profile = data["guest_profile"]
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
74 password = data["password"]
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
75 try:
1100
5976dcd42591 pages (g): use server's connect method to connect instead of bridge, this way normal Libervia workflow is used, and session attributes are initialised.
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
76 yield self.host.connect(request, profile, password)
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
77 except Exception as e:
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
78 log.warning(_(u"Can't connect profile: {msg}").format(msg=e))
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
79 # FIXME: no good error code correspond
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
80 # maybe use a custom one?
938
9be057e23ce6 pages (g): use new constants
Goffi <goffi@goffi.org>
parents: 930
diff changeset
81 self.pageError(request, code=C.HTTP_SERVICE_UNAVAILABLE)
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
82
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
83 log.info(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
84 _(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
85 u"guest session started, connected with profile [{profile}]".format(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
86 profile=profile
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
87 )
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
88 )
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
89 )
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
90
941
aba7208d9d50 pages (g): guest name is added to template data
Goffi <goffi@goffi.org>
parents: 938
diff changeset
91 # we copy data useful in templates
aba7208d9d50 pages (g): guest name is added to template data
Goffi <goffi@goffi.org>
parents: 938
diff changeset
92 template_data = request.template_data
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
93 template_data["norobots"] = True
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
94 if u"name" in data:
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
95 template_data[u"name"] = data[u"name"]
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
96 if u"language" in data:
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1100
diff changeset
97 template_data[u"locale"] = data[u"language"]
941
aba7208d9d50 pages (g): guest name is added to template data
Goffi <goffi@goffi.org>
parents: 938
diff changeset
98
1179
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
99 def handleEventInterest(self, interest):
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
100 if C.bool(interest.get("creator", C.BOOL_FALSE)):
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
101 page_name = u"event_admin"
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
102 else:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
103 page_name = u"event_rsvp"
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
104
1179
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
105 interest["url"] = self.getPageByName(page_name).getURL(
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
106 interest.get("service", ""),
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
107 interest.get("node", ""),
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
108 interest.get("item"),
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
109 )
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
110
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
111 if u"thumb_url" not in interest and u"image" in interest:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
112 interest[u"thumb_url"] = interest[u"image"]
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
113
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
114 def handleFISInterest(self, interest):
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
115 path = interest.get(u'path', u'')
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
116 path_args = [p for p in path.split(u'/') if p]
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
117 subtype = interest.get(u'subtype')
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
118
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
119 if subtype == u'files':
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
120 page_name = u"files_view"
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
121 elif interest.get(u'subtype') == u'photos':
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
122 page_name = u"photos_album"
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
123 else:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
124 log.warning(u"unknown interest subtype: {subtype}".format(subtype=subtype))
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
125 return False
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
126
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
127 interest["url"] = self.getPageByName(page_name).getURL(
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
128 interest[u'service'], *path_args)
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
129
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
130 @defer.inlineCallbacks
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
131 def prepare_render(self, request):
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
132 template_data = request.template_data
1179
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
133 profile = self.getProfile(request)
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
134
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
135 # interests
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
136 try:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
137 interests = yield self.host.bridgeCall(
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
138 "interestsList", "", "", "", profile)
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
139 except Exception:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
140 log.warning(_(u"Can't get interests list for {profile}").format(
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
141 profile=profile))
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
142 else:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
143 # we only want known interests (photos and events for now)
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
144 # this dict map namespaces of interest to a callback which can manipulate
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
145 # the data. If it returns False, the interest is skipped
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
146 ns_data = {}
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
147 template_data[u'interests_map'] = interests_map = {}
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
148
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
149 for short_name, cb in ((u'event', handleEventInterest),
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
150 (u'fis', handleFISInterest),
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
151 ):
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
152 try:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
153 namespace = self.host.ns_map[short_name]
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
154 except KeyError:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
155 pass
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
156 else:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
157 ns_data[namespace] = (cb, short_name)
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
158
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
159 for interest in interests:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
160 namespace = interest.get(u'namespace')
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
161 if namespace not in ns_data:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
162 continue
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
163 cb, short_name = ns_data[namespace]
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
164 if cb(self, interest) == False:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
165 continue
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
166 key = interest.get(u'subtype', short_name)
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
167 interests_map.setdefault(key, []).append(interest)
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
168
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
169 # main URI
930
b5490fa65348 pages (g): added g (for guest) page to handle invitations
Goffi <goffi@goffi.org>
parents:
diff changeset
170 guest_session = self.host.getSessionData(request, session_iface.ISATGuestSession)
1179
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
171 main_uri = guest_session.data.get("event_uri")
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
172 if main_uri:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
173 include_url = self.getPagePathFromURI(main_uri)
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
174 if include_url is not None:
bfbfe04209e9 pages (g): retrieve interests for events/photo albums/file sharing + only set "include_url" if "main_uri" is set
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
175 template_data[u"include_url"] = include_url