1881 Commits

Author SHA1 Message Date
fe7e078f8b Added unit test
Should have been part of prev commit.
2018-03-28 12:42:36 +02:00
8288455468 Fixed a KeyError when editing a comment. 2018-03-28 12:36:03 +02:00
d3ff88e5cf Also replace node types when key with underscore changed
Previously all keys starting with an underscore were ignored (so changes
to _created wouldn't count as "different"), but this clashes with saving
Markdown output to _xxx_html keys.
2018-03-27 17:56:38 +02:00
f22dc4d92a Fixed PATCHing comments 2018-03-27 17:42:29 +02:00
540dd28861 Short-circuit check_permissions() when logged in as CLI user
The CLI user should just be able to do anything.
2018-03-27 17:42:12 +02:00
218c3f0dca Fixed comment rendering 2018-03-27 17:13:12 +02:00
dfaac59e20 Cache Markdown'ed HTML in database
This is done via coercion rules. To cache the field 'content' in the
database, include this in your Eve schema:

    {'content': {'type': 'string', 'coerce': 'markdown'},
     '_content_html': {'type': 'string'}}

The `_content_html` field will be filled automatically when saving the
document via Eve.

To display the cached HTML, and fall back to display-time rendering if it
is not there, use `{{ document | markdowned('content') }}` in your template.

Still needs unit testing, a CLI command for regenerating the caches, and
a CLI command for migrating the node type definitions in existing projects.
2018-03-27 16:34:32 +02:00
08ce84fe31 Drop 'template' from blog node type 2018-03-27 15:56:06 +02:00
d2a0a5ae26 Added CLI command 'maintenance purge_home_projects'
This command soft-deletes home projects when their owning user is no longer
there.
2018-03-27 15:45:32 +02:00
bf498b829c @manager.command and @manager.option are sometimes mutually exclusive
@manager.option also registers the function as command, so the double use
is generally unnecessary.

Furthermore, @manager.command will register CLI options based on the
function parameters, which potentially conflict with the ones registered
with the following @manager.options decorators.

Note that positional arguments should be given in reverse order.
2018-03-27 15:45:32 +02:00
195edf679c Improved replace_pillar_node_type_schemas CLI cmd further 2018-03-27 15:32:36 +02:00
d24715a224 Smarter upgrades of node type definitions
- No changes are applied unless the new --go CLI arg is used.
- Differences to node types are actually shown.
- Dynamic form definitions are kept.
2018-03-27 12:03:18 +02:00
dee0b18429 utils.doc_diff() now also supports list values 2018-03-27 11:50:23 +02:00
de8bff51b5 Added TODO: keep Sentry unconfigured when running CLI commands.
When running CLI stuff the logging is seen by human eyes anyway, so we
don't need to send things to Sentry.
2018-03-27 11:50:23 +02:00
318ccb2d95 Reduce log level
WARNING and higher are sent to Sentry, which isn't necessary here.
2018-03-27 11:50:23 +02:00
12272750c3 T53890: Improving static content serving
Static files are now served with an 8-character hash before the last
extension. For example, `tutti.min.js` is now served as
`tutti.min.abcd1234.js`. When doing a request the hash is removed before
serving the static file.

The hash must be 8 characters long, and is taken from STATIC_FILE_HASH.
It is up to the deployment to change this configuration variable
whenever static files change. This forces browsers that download newly
deployed HTML to also refresh the dependencies (most importantly
JS/CSS).

For this to work, the URL must be built with `url_for('static_xxx',
filename='/path/to/file')`. The 'static' module still returns regular,
hashless URLs.
2018-03-23 17:36:14 +01:00
0cf45c0d78 Use capability check instead of role check in strip_link_and_variations() 2018-03-23 14:23:47 +01:00
e4f229cc70 Fix T51678: 16bit greyscale PNG images thumbnailing fails
generate_local_thumbnails() now uses pathlib and f-string formatting too,
making the code a lot simpler. Furthermore, I removed unused bits of
resize_and_crop() and simplified the rest.
2018-03-22 17:53:14 +01:00
f8ccb8aaaa Follow the convention for error formatting 2018-03-21 20:21:10 +01:00
fb2852acdc Tweak to function docstring 2018-03-21 20:21:10 +01:00
e6edd00e46 Introducing /nodes/preview-markdown
This endpoint receives POST requests and parses the content field
returning it as Markdown. Useful for partially previewing node edits.
2018-03-21 20:21:10 +01:00
d30a11c8f7 Do not index a document if it's empty
The prepare_node_data function returns an empty dict if the node
is not of the INDEX_ALLOWED_NODE_TYPES, or if it's not published, etc.
2018-03-21 02:17:58 +01:00
67a24e9d4e Provide debug log info when nodes are not indexed 2018-03-21 02:15:46 +01:00
2bf0bf1064 Formatting 2018-03-21 02:15:07 +01:00
678f72766e Change elif to if _validate_config
Elif is not needed after a raise.
2018-03-20 10:05:17 +01:00
66e4229b9b Merge branch 'production' 2018-03-18 20:14:17 +01:00
99e0eb7a7a Require SERVER_NAME in the configuration
Since we rely more and more on the presence of SERVER_NAME in the
configuration, we make it a hard requirement, before checking if it is
a FQDN.
2018-03-18 18:53:08 +01:00
6a0e0721e9 Require SERVER_NAME to be a FQDN with TLD
A fully-qualified domain name, including a top-level domain name, is
required for Chrome to accept session cookies. For more info, see
https://stackoverflow.com/questions/27254013/why-does-the-session-cookie-work-when-serving-from-a-domain-but-not-when-using-a#27276450
2018-03-15 11:39:20 +01:00
97091457a8 Check for capabilites instead of roles in allow_link 2018-03-14 22:05:00 +01:00
6f69fe5b8a CSS: Style kbd tag in node description 2018-03-14 21:59:50 +01:00
7292c534ed Fix scrollToLinkedComment()
The test was done against location.hash, which contains a hash symbol.
Strip it for the test.
2018-03-14 21:59:50 +01:00
df6297d40f Fixed project search
The project ID wasn't used at all when searching in a project's context.
2018-03-13 12:24:29 +01:00
257793dcd5 Simplified some code 2018-03-13 12:21:41 +01:00
6e1d255dfc CSS: Style buttons with 'disabled' class 2018-03-11 23:40:23 +01:00
f236845374 CSS Login: Minor tweaks and maintenance 2018-03-07 21:16:35 +01:00
450dde56b7 Pass our OAuth2 client ID to Blender ID when validating tokens
This is a security measure, as it ensures that valid Blender ID OAuth2
tokens that were not generated for Blender Cloud are rejected.
2018-02-21 10:49:33 +01:00
854bc7cfaf Sentry: include extra user information
We perform authentication of the user while handling the request,
but Sentry calls get_user_info() in a before-request handler. This means
that Sentry would miss user info in many cases. This fixes that.
2018-02-14 13:52:52 +01:00
0c7abdb99a Avoid error when there is no #cloud-search element 2018-02-14 10:22:13 +01:00
b10369a867 Removed unused imports 2018-02-13 16:51:42 +01:00
05187cacea Add comment to config.py to point at SERVER_NAME 2018-02-13 16:51:28 +01:00
f79642d69f Refuse to merge projects when SERVER_NAME is unset 2018-02-13 16:50:37 +01:00
1f2fb774b4 Converted another datetime.utcnow() to utils.utcnow() 2018-02-13 16:50:11 +01:00
de801e41e3 CLI command for moving all nodes+files to another project
`manage.py operations merge_project src_url dst_url` moves all nodes and
files from the project with `src_url` to the project with `dst_url`.
This also moves soft-deleted files/nodes, as it ignores the _deleted
field. The actual files on the storage backend are copied rather than
moved.

Note that this may invalidate the nodes, as their node type definition
may differ between projects. Since we use direct MongoDB queries the
nodes are moved to the new project anyway. This allows for a
move-first-then-fix approach).
2018-02-13 15:52:21 +01:00
cd42ce6cba Moving blobs between nodes now uses storage API
Instead of only being GCS-specific, it now works for all storage
backends.
2018-02-13 15:36:11 +01:00
eb18e5b933 Formatting 2018-02-13 14:36:23 +01:00
350cf85cd2 Removed unused imports 2018-02-13 14:36:16 +01:00
f2888069db Added pillar.api.utils.utcnow() which returns a datetime for 'now'
This replaces pillar.web.utils.datetime_now() and can be used in a wider
setting (since we don't import web stuff in the api, but we do vice versa).
2018-02-13 14:36:05 +01:00
d0520484bb User admin: Show selected user as 'active' 2018-02-13 10:24:49 +01:00
d114b5631a User admin: removed cancel button
It didn't do anything useful, but did break the GUI.
2018-02-13 10:21:43 +01:00
ce33ce994f Elastic: Allow resetting and reindexing in one CLI command
Use `manage.py elastic reindex [indexname] --reset` to reset first and then
reindex.
2018-02-13 10:19:05 +01:00