1429 Commits

Author SHA1 Message Date
Dalai Felinto
303a33c3bf Internationalization: Backend support to localization based on user browser
User experience
===============
For users it means we can provide localized web-sites to enrich their
overall experiences.

Although for the Blender Cloud this doesn't make much sense (since the
content is in English), Flamenco and Attract can really benefit from
this.

New configuration settings
==========================
There are two new parameters in config.py:

* DEFAULT_LOCALE='en_US'
* SUPPORT_ENGLISH=True

They are both properly documented in the `config.py` file.

Technicall details
==================
We are using the 'Accept-Languages' header to match the
available translations with the user supported languages.

If an extension has a `translations` folder, it's used for translations.
However the main application (e.g., Blender Cloud) is the one that
determines the supported languages based on its `languages` folder.

How to mark strings for translation
===================================
See the documentation in README.md.

But as an example, 404.pug and pillar/__init__.py::handle_sdk_resource_invalid
have marked up strings that will be extracted once you install pillar,
or run any of the translations commangs.

Remember to **gulp** after you update the template files.

How to setup translations
=========================
You will need to create translation for the main project, and for each
extension that you want to see translated. I added a new entry-point to
the installation of Pillar.

So all you need is to use the `translations`
script to initialize, update and compile your translations.

Pending tasks
=============
Aside from marking more strings for extraction and start the translation
effort it would be interesting to replace the pretty_date routine with
momentjs.

Acknowledgement
===============
Many thanks for Sybren Stüvel for the suggestions and throughout code
review. Thanks also to Francesco Siddi for the original documentation
and suggesting me to tackle this. And Kudos for Pablo Vazquez for the
motivational support and for the upcoming "strings mark up" task force!

The core of the implementation is based on Miguel Grinberg i18n chapter
of his great 'The Mega Flask Tutorial'.

Reviewers: sybren

Differential Revision: https://developer.blender.org/D2826
2017-09-09 00:26:18 +02:00
Dalai Felinto
b769cc6c3c Fix app_root in unittests 2017-09-08 14:06:55 +02:00
4e5ce71a52 File storage link refreshing: log nr of documents to refresh. 2017-09-07 15:53:16 +02:00
7dbd0c7896 Exclude Flamenco task logs when dumping the database. 2017-09-07 15:52:57 +02:00
Dalai Felinto
d5a55f71a7 Fix Flask and Eve dependency issue
Eve expects 'flask>=0.10.1,<=0.12' so we can't use flask==0.12.2 in
pillar for now.

This needs to be fixed upstream (eve), but for now `python setup.py
install`.
2017-09-06 17:51:21 +02:00
ebcd280886 Updated requirements in setup.py 2017-09-06 17:30:55 +02:00
Dalai Felinto
216b9278af A user should not be able to vote on own content
This should be hidden in the UI as well, but the backend should support this too.
We also want to set initial rating of 1 for contents that need it.

This commit includes a new unittest for this case.

Reviewers: sybren

Differential Revision: https://developer.blender.org/D2825
2017-09-06 13:51:32 +02:00
eb467474f8 Make our require_login() optionally redirect to the login page
This mimicks the behaviour of flask_login. In our case, it only redirects
when redirect_to_login=True and the user is anonymous. Otheriwse it still
results in a 403 Forbidden response.
2017-09-06 12:07:20 +02:00
e5b80297ba Fixed user ID, we now pass a UserClass instance to compute the capabilities 2017-09-05 16:05:57 +02:00
6b32c4ede8 Use has_cap('admin') instead of has_role('admin') 2017-09-05 16:05:39 +02:00
2db0ee11db Fixed case for packages.
'pip freeze -r requirements.txt' otherwise complains about this.
2017-09-05 13:38:04 +02:00
146bf97432 Removed doubly-listed CommonMark package 2017-09-05 13:37:43 +02:00
fc5177d58b Removed pycrypto package; it's not used. 2017-09-05 13:35:30 +02:00
97564022c3 Renamed 'child' to 'variation', since it's not about child nodes. 2017-09-05 11:56:41 +02:00
941fd8dd9c Show max filesize of variations, rather than original file size.
The original file isn't always accessible, and can be of completely
different size than the downloadable variations. This is mostly appliccable
to videos.
2017-09-05 11:56:28 +02:00
b6b7aad046 Have a nicer 403 Forbidden message when the user isn't logged in.
Since we don't know who the user is, just stating that they don't have
access isn't correct.
2017-09-05 11:35:21 +02:00
a8e912fcb1 Include 'next' URL when logging in through a 403 Forbidden page 2017-09-05 11:35:21 +02:00
903bb6cfe9 Typo 2017-09-04 19:46:42 +02:00
94efdcd9b5 Small layout style fixes 2017-09-04 19:16:47 +02:00
b8153b5c9a Assets: Move details to its own file and share across assets
And new styling for the details as well
2017-09-04 19:13:38 +02:00
923b4bd9d6 Notifications: no minimum width 2017-09-04 16:19:17 +02:00
4c25248e5f Project: breadcrumbs no longer exist 2017-09-04 16:19:17 +02:00
06dd24bcf9 Project Edit: Node types editing embedded 2017-09-04 16:19:17 +02:00
941ec94313 Node Type Edit: Save node_type description 2017-09-04 16:19:17 +02:00
adcbebd7b6 Videos: Keep a 16:9 aspect ratio 2017-09-04 16:19:17 +02:00
4a68821dee JS: Fix 50px offset on containerResizeY 2017-09-04 16:19:17 +02:00
4b1bb6283e Let Flask know our preferred URL scheme 2017-09-01 16:20:37 +02:00
3a3b3c3269 Revert "Replaced config SCHEME with Flask's own PREFERRED_URL_SCHEME setting."
This reverts commit 8318d4b1f69846e21002acafd4f410f5003af6f6.
2017-09-01 16:19:58 +02:00
fe64a0c70e Changed organizations endpoint /orgs → /o 2017-09-01 11:39:59 +02:00
ea9af92bd4 Organizations: Click anywhere in the list item to open
Suggestion by Dr. Sybren
2017-09-01 11:39:46 +02:00
dd3cfe80ef CSS: don't use cursor pointer for organizations/projects lists 2017-09-01 11:35:55 +02:00
314f0b8dbe Quote token when logging
This helps when debugging strange tokens.
2017-09-01 11:21:02 +02:00
6a4f571b05 Organizations list styling 2017-08-31 16:35:31 +02:00
30b3d6abaf Full width projects, search, and top navbar 2017-08-31 16:35:31 +02:00
01c8f6cdae Inputs: Dim the placeholder text 2017-08-31 16:35:31 +02:00
8318d4b1f6 Replaced config SCHEME with Flask's own PREFERRED_URL_SCHEME setting.
This prevents us from explicitly passing SCHEME to url_for() calls.

NOTE: this possibly requires an update to your config_local.py
2017-08-31 14:37:35 +02:00
d6dd0d69d0 Fix for missing underscore in _scheme arg
Be more careful next time!
2017-08-31 14:32:39 +02:00
2d3b54b80b Use app config SCHEME to enforce https when doing oauth redirects 2017-08-31 14:22:07 +02:00
89f24ac4e6 Buttons: Don't force uppercase text 2017-08-30 23:18:59 +02:00
7890cd2622 Introducing settings blueprint
Now settings live in a dedicated space, the settings blueprint can be used by Pillar applications, and the templates can be extended or overridden. Moved subscription and email settings to the blender-cloud repository.
2017-08-30 23:10:28 +02:00
b6bd40f956 Theatre View: backdrop block not needed anymore 2017-08-30 15:34:13 +02:00
c0b380f215 Gulp: Fix livereload 2017-08-30 15:05:38 +02:00
811236cff4 Migrate Jade to Pug template engine
Jade templates engine has been renamed to Pug.

We are using Pug already on the Blender Cloud repository, following is Flamenco and Attract
2017-08-30 14:04:15 +02:00
62542f0329 Rolled back some flask_login and g.current_user integration
Setting flask_login.current_user ourselves was a bad idea, and messed up
flask_login's internal administration. Our code now just manages
g.current_user in these specific instances, which works fine.
2017-08-30 12:39:46 +02:00
6825b8bf74 Fixed infinite recursion. 2017-08-29 12:31:52 +02:00
bdd603fb17 Using new UserClass instances everywhere:
- No more direct access to g.current_user, unless unavoidable.
  - Using pillar.auth.current_user instead of g.current_user or
    flask_login.current_user.
  - p.a.current_user is never checked against None.
  - p.a.current_user.is_authenticated or is_anonymous is used, and never
    together with a negation (instead of 'not is_anon' use 'is_auth').
  - No more accessing current_user a a dict.
  - No more checks for admin role, use capability check instead.
2017-08-29 11:34:48 +02:00
86e76aaa5f Use UserClass instead of assigning dict to g.current_user 2017-08-29 11:34:48 +02:00
88af86ae61 Toastr: Style buttons in notifications 2017-08-27 17:44:40 +02:00
a6f56a4811 OAuth test: checking email address too 2017-08-25 12:53:21 +02:00
c7c867f1c7 OAuth signin: streamlined instantiation of OAuthSignIn subclasses 2017-08-25 12:35:08 +02:00