Commit Graph

52 Commits

Author SHA1 Message Date
Tom Hacohen
2de51b978a Serializers: fix an issue with handling validation errors. 2020-12-24 16:15:25 +02:00
Tom Hacohen
7eb08d2946 Collection invitation: fix the wrong field type 2020-12-24 16:15:11 +02:00
Tom Hacohen
1cb84cfa6d Serializers: cleanup how we handle validation errors. 2020-12-22 13:15:12 +02:00
Tom Hacohen
3fcea20d68 Serializers: fully clean an object on signup. 2020-12-22 12:46:42 +02:00
Tom Hacohen
3b4ba75930 Chunk serialization: support not passing chunk content if exists. 2020-12-16 15:24:35 +02:00
Tom Hacohen
cd86c060b5 Collection: fix UID validation to return a Conflict error. 2020-12-15 10:14:15 +02:00
Tom Hacohen
baa42d040d Collection: also save the collection UID on the model itself.
This enables us to have db-constraints for making sure that UIDs are
unique, as well as being more efficient for lookups (which are very
common).

The UID should always be the same as the main_item.uid, though that's
easily enforced as neither of them is allowed to change.
2020-12-14 13:33:11 +02:00
Tom Hacohen
c790b5f489 Reformat some files using black. 2020-12-01 12:45:38 +02:00
Tal Leibman
d8e5c37db1
Use black for code formatting and format the code
Merge #65
2020-11-14 17:04:41 +02:00
Tom Hacohen
bdd787b915 Gracefully handle uploading the same item twice.
We were failing until now, but since the uid is sure to be unique,
we can just assume that if it's the same uid it's the same content.
This means we can just gracefully fail as the data is the same.

Until now, we were raising an error, but we now just do nothing
and consider it a success.

This is especially useful when a network error caused an item to
be uploaded but not updated on the client side.
2020-11-10 10:07:56 +02:00
Tom Hacohen
422b62d5b2 Disallow creating new collections without a collection type set. 2020-11-01 11:29:01 +02:00
Tom Hacohen
f55ebeae7c Collection saving: add another verification for collection UID uniqueness.
Even with the previous check, there could still be a race condition where two
collections with the same UID are created. Adding this extra check after
will prevent that from happening.
2020-11-01 11:29:01 +02:00
Tom Hacohen
5bce4d9932 Collection Type: fix backwards compatibility for creating new collections.
Continuation to 409248d419.
2020-10-15 15:06:24 +03:00
Tom Hacohen
409248d419 CollectionTypes: add backward compatibility adjustments until 2.0 is out. 2020-10-15 10:50:07 +03:00
Tom Hacohen
5d8a92f000 Collections: add support for collection types.
We also added the field for invitations, as it's needed for collections
to work.
2020-10-13 18:39:18 +03:00
Tom Hacohen
acd22b9b47 Serializers: remove unused field. 2020-10-13 16:30:16 +03:00
Tom Hacohen
47f3e08846 Signup: improve docs. 2020-10-13 11:10:55 +03:00
Tom Hacohen
24c161b0d8 Signup: don't try to clean fields for objects we haven't created. 2020-10-13 11:09:22 +03:00
Tom Hacohen
6214688170 Invitations: share the username of the inviter. 2020-10-01 16:47:53 +03:00
Tom Hacohen
f5ced873ac Lint: fix lint errors. 2020-09-23 16:27:20 +03:00
Tom Hacohen
5d9b47531b Collectin: make sure collections always have a unique UID. 2020-09-22 12:17:33 +03:00
Tom Hacohen
4dbdb3d7cf Invitations: gracefully error when trying to invite an already invited user. 2020-09-20 19:33:55 +03:00
Tom Hacohen
3de1d48b9e Browsable API: use input fields for relations. 2020-09-13 14:17:57 +03:00
Tom Hacohen
43569727f4 Signup: send a signal on account signup. 2020-09-02 12:54:50 +03:00
Tom Hacohen
42a72ce5c7 Serializers user signup: correctly handle EtebaseValidationErrors.
Don't coerce them to strings
2020-09-02 12:50:51 +03:00
Tom Hacohen
7ab9513e05 Serializers: rename message to detail to conform with the rest of the API.
This was a mistake in the previous commit.
2020-09-02 11:11:20 +03:00
Tom Hacohen
bf22b1676f Serializers: improve field serialization errors. 2020-09-02 11:07:43 +03:00
Tom Hacohen
cf9b6f5904 Prefetch: change the type of value prefetch accept.
It's 'auto' by default, but can be changed to 'medium' and soon
another value.
2020-08-04 17:48:34 +03:00
Tom Hacohen
393b85d3ca Chunks: move to reside under the collection. 2020-08-04 17:39:33 +03:00
Tom Hacohen
11001ed62c Chunk serializer: fix bad error invocation. 2020-08-04 13:17:48 +03:00
Tom Hacohen
c0575cb64c Exceptions: have correct code/status_code for every error. 2020-07-30 10:13:24 +03:00
Tom Hacohen
9c129e5731 Collection erializer: make the item a child instead of trying to merge them. 2020-07-22 11:31:08 +03:00
Tom Hacohen
c9463cadba Add support for a custom user creation function. 2020-07-13 16:20:46 +03:00
Tom Hacohen
46b4f08afa Signup: use the get_user_queryset function when checking if user exists. 2020-07-13 16:03:34 +03:00
Tom Hacohen
af86d877f2 Signup: use the shorthand version of setting an unusable password.
It wasn't actually saving the unusable password before.
2020-07-13 15:40:29 +03:00
Tom Hacohen
a39617cf2e Make sure usernames are case insensitive on lookup 2020-07-13 15:39:08 +03:00
Tom Hacohen
f9add36f18 Add support for custom user filtering. 2020-07-13 15:39:04 +03:00
Tom Hacohen
9ea01d4d93 CollectionMemberSerializer: change the user field to be read only. 2020-07-13 11:15:42 +03:00
Tom Hacohen
41a03e9d3b Invitation: fix the checks making sure you can't invite yourself. 2020-07-12 13:23:45 +03:00
Tom Hacohen
7ec45434ba User: make username case insensitive (and save original styling).
We want 'User' and 'UsEr' to mean the same user. Apparently that's not the default in
django. This normalizes the user to ensure we enforce this.
2020-07-12 11:11:33 +03:00
Tom Hacohen
9a518b3907 Chunks: add error handling for chunks having content or not existing.
If the chunk already has a content and we try to upload it again, we
assume the previous content was correct and this one is the same
(chunks are immutable). We can't actually ensure they are the same due
to the encryption, though they should be.

If a chunk is being uploaded for the first time and doesn't have a
content, throw a validation error rather than throwing an ugly error.
2020-07-10 09:29:21 +03:00
Tom Hacohen
f147f4ae58 Serializers: allow encryptionKey to be null. 2020-06-29 15:39:40 +03:00
Tom Hacohen
3dfceb63b1 Views: move the base64 encoding to the renderers.
Hard-coding the serialization encoding in the serializers is wrong.
This fix now enables us to change to easily change to msgpack as the
transport layer.
2020-06-29 15:39:40 +03:00
Tom Hacohen
fbf5552a62 Modify binary64 field to support binary renderers/parsers
Fixes 39c1dfc53c30e65bcbff9e0ba0bb07bfc8bfc577
2020-06-29 13:36:37 +03:00
Tom Hacohen
453275eadf Authentication: move to msgpack for the encrypted parts. 2020-06-29 11:30:59 +03:00
Tom Hacohen
c00cf50163 Revision: remove salt field.
It's not really needed. More information in the respective change
in the js client.
2020-06-26 11:21:53 +03:00
Tom Hacohen
625df22989 Make item encryption key optional for collections/items
Collections still have a unique encryption key (their collection key), and items
just have a unique key per item in a collection that's derived from the main key
and if we ever want to share items across collections or do something fancy like
that we can just add an encrypted key in there.
2020-06-26 10:31:03 +03:00
Tom Hacohen
cbb1d81850 Rename inline to prefetch and have it on by default. 2020-06-24 15:55:36 +03:00
Tom Hacohen
267d749c45 Collection: change collections to be an extension of items
Each collection now has an item and the item's UID is the collections
UID. This lets us manipulate collections just like items, and as part of
transactions. This is significant because it lets us change them as part
of transactions!
2020-06-23 13:03:46 +03:00
Tom Hacohen
ab0d85c84f Change password: change to require a signed request, just like login.
Without this, it would be sufficient to steal an auth token to render the account
unusable because it would be possible to just reset the encrypted content
of the account. With this change we require the user to actually know
the account password in order to do it.
2020-06-17 14:38:02 +03:00