Mercurial > libervia-web
annotate libervia/pages/register/page_meta.py @ 1344:472267dcd4d8
browser (alt_media_player): native player support + poster + flags + restricted area:
- alt_media_player will now use native player when possible. This allows to use its controls
and behaviour instead of native ones.
- a poster can be specified when instanciated manually
- video is not preloaded anymore
- handle events propagation to plays nicely when used in slideshow
- a "restricted area" mode can be used to let click propagation on video border, and thus
catch only play/pause in the center. This is notably useful when used in the slideshow,
as border can be used to show/hide slideshow controls
- player can be reset, in which case the play button overlay is put back, and video
is put at its beginning
- once video is played at least once, a `in_use` class is added to the element, play
button overlay is removed then. This fix a bug when the overlay was still appearing when
using bottom play button.
- VideoPlayer has been renamed to MediaPlayer
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 24 Aug 2020 23:04:35 +0200 |
parents | f511f8fbbf8a |
children | 6a35167a4e2c |
rev | line source |
---|---|
1216 | 1 #!/usr/bin/env python3 |
1239 | 2 |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 from libervia.server.constants import Const as C |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 from libervia.server import session_iface |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 from twisted.internet import defer |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 from sat.core.log import getLogger |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
8 |
1145
29eb15062416
pages: set __name__ for imported pages
Goffi <goffi@goffi.org>
parents:
1124
diff
changeset
|
9 log = getLogger(__name__) |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 """SàT account registration page""" |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 |
1216 | 13 name = "register" |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 access = C.PAGES_ACCESS_PUBLIC |
1216 | 15 template = "login/register.html" |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 def prepare_render(self, request): |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 profile = self.getProfile(request) |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 if profile is not None: |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
21 self.pageRedirect("/login/logged", request) |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 template_data = request.template_data |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
23 template_data["login_url"] = self.getPageByName("login").url |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
24 template_data["S_C"] = C # we need server constants in template |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 # login error message |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 session_data = self.host.getSessionData(request, session_iface.ISATSession) |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
28 login_error = session_data.popPageData(self, "login_error") |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 if login_error is not None: |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
30 template_data["login_error"] = login_error |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
32 # if fields were already filled, we reuse them |
1216 | 33 for k in ("login", "email", "password"): |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 template_data[k] = session_data.popPageData(self, k) |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
36 |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 @defer.inlineCallbacks |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 def on_data_post(self, request): |
1216 | 39 type_ = self.getPostedData(request, "type") |
40 if type_ == "register": | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
41 login, email, password = self.getPostedData( |
1216 | 42 request, ("login", "email", "password") |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
43 ) |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 status = yield self.host.registerNewAccount(request, login, password, email) |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 session_data = self.host.getSessionData(request, session_iface.ISATSession) |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 if status == C.REGISTRATION_SUCCEED: |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 # we prefill login field for login page |
1216 | 48 session_data.setPageData(self.getPageByName("login"), "login", login) |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 # if we have a redirect_url we follow it |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 self.redirectOrContinue(request) |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 # else we redirect to login page |
1216 | 52 self.HTTPRedirect(request, self.getPageByName("login").url) |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 else: |
1216 | 54 session_data.setPageData(self, "login_error", status) |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 l = locals() |
1216 | 56 for k in ("login", "email", "password"): |
963
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 # we save fields so user doesn't have to enter them again |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 session_data.setPageData(self, k, l[k]) |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 defer.returnValue(C.POST_NO_CONFIRM) |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 else: |
2932170bb526
pages: added login/logged and register pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 self.pageError(request, C.HTTP_BAD_REQUEST) |