annotate libervia/pages/photos/page_meta.py @ 1207:67ec22356457

pages (blog/view, u): added atom feed URL to "atom_url" in template
author Goffi <goffi@goffi.org>
date Fri, 19 Jul 2019 18:01:25 +0200
parents ddc1e704bc41
children b2d067339de3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1074
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
1 #!/usr/bin/env python2.7
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
2 # -*- coding: utf-8 -*-
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
3
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
4 from libervia.server.constants import Const as C
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
5 from twisted.internet import defer
1172
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
6 from sat.core.i18n import _
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
7 from sat.core.log import getLogger
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
8
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
9 log = getLogger(__name__)
1074
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
10
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1074
diff changeset
11 name = u"photos"
1074
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
12 access = C.PAGES_ACCESS_PROFILE
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
13 template = u"photo/discover.html"
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
14
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
15
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
16 @defer.inlineCallbacks
1176
ddc1e704bc41 pages (photos): moved code getting interests in prepare_render
Goffi <goffi@goffi.org>
parents: 1172
diff changeset
17 def prepare_render(self, request):
1172
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
18 profile = self.getProfile(request)
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
19 template_data = request.template_data
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
20 namespace = self.host.ns_map["fis"]
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
21 if profile is not None:
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
22 try:
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
23 interests = yield self.host.bridgeCall(
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
24 "interestsList", "", "", namespace, profile)
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
25 except Exception:
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
26 log.warning(_(u"Can't get interests list for {profile}").format(
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
27 profile=profile))
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
28 else:
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
29 # we only want photo albums
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
30 filtered_interests = []
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
31 for interest in interests:
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
32 if interest.get(u'subtype') != u'photos':
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
33 continue
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
34 path = interest.get(u'path', u'')
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
35 path_args = [p for p in path.split(u'/') if p]
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
36 interest["url"] = self.getSubPageURL(
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
37 request,
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
38 u"photos_album",
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
39 interest[u'service'],
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
40 *path_args
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
41 )
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
42 filtered_interests.append(interest)
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
43
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
44 template_data[u'interests'] = filtered_interests
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
45
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
46
7b8e123ba043 pages (photos): retrieve photo albums from list of interests, and fill "interests" template data.
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
47 @defer.inlineCallbacks
1074
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
48 def on_data_post(self, request):
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1074
diff changeset
49 jid_ = self.getPostedData(request, u"jid")
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1074
diff changeset
50 url = self.getPageByName(u"photos_album").getURL(jid_)
1074
2e1f7e78b147 pages (photos): default page now handle free jid (but don't display anything else yet)
Goffi <goffi@goffi.org>
parents: 1070
diff changeset
51 self.HTTPRedirect(request, url)