-
-
-
There really should be a PUT method as well. Resources should be updated through update(), with PUT requests, the update if exists in create is just a convenience.
-
-
-
-
I'm not sure if using a json list is the proper way to do this. Regardless, this should not be a required parameter, creating empty groups should be supported.
-
-
-
-
-
You should probably return an INVALID_FORM_DATA response. Take a look at other create methods that return this (e.g. ReviewReplyDiffCommentResource.create() )
-
-
You should be returning something to the user identifying the new group that was created. Take a look at the other create resources for examples.
-
-
-
-
-
Add group create/update support to webapi.
Review Request #3239 — Created July 20, 2012 and discarded
Third stab at group support in webapi. 1. I can successfully create a group with a list of users (a json encoded string). I couldn't figure how other webapi methods consume lists of things... so I opted to use json. It seems like Djblets/Django consume ',' or ' ' separated lists but that seems fragile. Using json seemed like the most robust solution. 2. Added a `create` and `update` method that create or update a group, respectively. It is an error to create a group that already exists. It is an error to update a group that does not exist.
Description | From | Last Updated |
---|---|---|
Two blanks lines should be here, please add it back. |
SM smacleod | |
There really should be a PUT method as well. Resources should be updated through update(), with PUT requests, the update … |
SM smacleod | |
You are missing the invite_only field. It should be something you can specify during creation. |
SM smacleod | |
Period at end of description. |
SM smacleod | |
Period at end of description. |
SM smacleod | |
I'm not sure if using a json list is the proper way to do this. Regardless, this should not be … |
SM smacleod | |
Period at end of description. |
SM smacleod | |
Lines should be < 80 characters in length. Look at other methods for how to shorten. |
SM smacleod | |
The code pretty much says this, can probably remove the comment. |
SM smacleod | |
Again, code speaks for itself here. |
SM smacleod | |
You should probably return an INVALID_FORM_DATA response. Take a look at other create methods that return this (e.g. ReviewReplyDiffCommentResource.create() ) |
SM smacleod | |
See previous comment on INVALID_FORM_DATA. |
SM smacleod | |
You should be returning something to the user identifying the new group that was created. Take a look at the … |
SM smacleod | |
Once the update() method is created, this case should probably just call in to that. |
SM smacleod | |
"exist" |
SM smacleod | |
Comments should end with a period. |
SM smacleod | |
See previous comments. |
SM smacleod | |
As in the previous comment, this should be returning an identifier for the group as well. |
SM smacleod | |
This import should precede the other django.utils imports. |
chipx86 | |
This isn't quite right. This function is meant to return whether or not we are allowed to modify a specific … |
chipx86 | |
In these cases, just use double quotes for the string, instead of escaping ' Same with the ones below. |
chipx86 | |
Indentation for all this is wrong. The ending } for required, and optional and its children, should be aligning with … |
chipx86 | |
I don't feel comfortable with this. The way our API works is that each resource represents one object, and objects … |
chipx86 | |
visible, invite_only, and user_list are missing default values. |
chipx86 | |
We can't use self.has_modify_permissions for this. What you need to do is create a 'can_create' function in ReviewGroupManager (reviews/managers.py) that … |
chipx86 | |
These aren't necessary if you set the defaults properly. @webapi_request_fields will ensure we get booleans. |
chipx86 | |
Blank line between these. |
chipx86 | |
We don't need this. We already saved during the creation above. |
chipx86 | |
This should be: return 201, { self.item_result_key: group, } We should never populate the payload directly. We always want to … |
chipx86 | |
We shouldn't hard-core error types here. We need a GROUP_ALREADY_EXISTS error defined in errors.py. Make sure to then add the … |
chipx86 | |
Should invert the if statement and do this at the above. See other classes for the proper way to organize … |
chipx86 | |
Same comment as above with double-quoted strings. |
chipx86 | |
Same comment as above. |
chipx86 | |
Needs defaults. |
chipx86 | |
Invert this as well. Needs to include the group as a parameter. |
chipx86 | |
This query will produce incorrect results, as it doesn't take into account the local_site_name. Ideally, you should use get_object to … |
chipx86 | |
This should be the same error we'd use above for a conflicting group. |
chipx86 | |
Style thing: No spaces before the ':', and every entry in a dictionary should have a trailing comma at the … |
chipx86 | |
All these should compare specifically against None, using 'if varname is not None'. Otherwise, blank strings will cause problems. |
chipx86 | |
These will fail for similar reasons. Just assign directly. We don't want to only assign if setting to True. |
chipx86 | |
This can be removed, since we won't be handling user registration here. |
chipx86 | |
Same comment as above with the response. |
chipx86 | |
Can you get rid of the second sentence here? It doesn't add much and is likely to get out of … |
david | |
This list should be alphabetical |
david | |
Unindent this line by 4 spaces |
david | |
There's an extra comma in here |
david | |
There's an extra comma in here |
david | |
Align the second line at the same column as "INVALID_FORM_DATA" |
david | |
There's an extra comma in here |
david | |
Align 2nd and 3rd lines with the DOES_NOT_EXIST |
david | |
Extra comma |
david | |
This line looks like it's > 80 columns |
david |
- Description:
-
~ Second stab at group support in webapi... I couldn't update my old review (http://reviews.reviewboard.org/r/3217/) because kept getting internal server errors for some reason.
~ Third stab at group support in webapi.
-
I can successfully create a group with a list of users (a json encoded string). I couldn't figure how other webapi methods consume lists of things... so I opted to use json. It seems like Djblets/Django consume ',' or ' ' separated lists but that seems fragile. Using json seemed like the most robust solution.
~ -
What errors should I return for various bad values? Should they just be skipped, or should the entire query fail? See the "TODO(sholsapp)" items in the diff.
~ -
Added a
create
andupdate
method that create or update a group, respectively. It is an error to create a group that already exists. It is an error to update a group that does not exist.
- -
Is it worth it to add an
update
method? Right now, you can usecreate
to create or update a group.w
-
- Change Summary:
-
Chris, can you recommend anyone that has work on the webapi take a peek at my diff?
- People:
-
Sorry for dropping the ball on this change. I think this is a great feature to have. There are issues, though, with how this is implemented. I have some notes on what needs to be done.
-
-
This isn't quite right. This function is meant to return whether or not we are allowed to modify a specific group. However, it's not taking a group, and it's being used to determine if we're allowed to create at all. Furthermore, the query is just returning the list of accessible groups. If there are any at all on the server, then this will claim the user can create new groups. If there are none at all, then no user can create groups. Not quite what we want. Instead, this should take a group, and return the result of group.is_mutable_by(request.user).
-
In these cases, just use double quotes for the string, instead of escaping ' Same with the ones below.
-
Indentation for all this is wrong. The ending } for required, and optional and its children, should be aligning with the respective lines from required.
-
I don't feel comfortable with this. The way our API works is that each resource represents one object, and objects are associated by links. Embedding children like this doesn't quite match our design. Adding groups should be done by POSTing something to the users/ child of this resource. Now, right now, this functionality doesn't exist. The create and delete handlers would need to be added for ReviewGroupUserResource. The create function would need to just take a username as a parameter, and it would add that to the group.
-
-
We can't use self.has_modify_permissions for this. What you need to do is create a 'can_create' function in ReviewGroupManager (reviews/managers.py) that works similarly to can_create in RepositoryManager (scmtools/managers.py), and call that instead.
-
These aren't necessary if you set the defaults properly. @webapi_request_fields will ensure we get booleans.
-
-
-
This should be: return 201, { self.item_result_key: group, } We should never populate the payload directly. We always want to reference an object so the central serializers will ensure the correct information is saved.
-
We shouldn't hard-core error types here. We need a GROUP_ALREADY_EXISTS error defined in errors.py. Make sure to then add the error to the list in the decorator for this function.
-
Should invert the if statement and do this at the above. See other classes for the proper way to organize this. No else clause needed.
-
-
-
-
-
This query will produce incorrect results, as it doesn't take into account the local_site_name. Ideally, you should use get_object to do this check, passing in the name and local_site_name.
-
-
Style thing: No spaces before the ':', and every entry in a dictionary should have a trailing comma at the end. Same with all other dicts you introduce in this change.
-
All these should compare specifically against None, using 'if varname is not None'. Otherwise, blank strings will cause problems.
-
These will fail for similar reasons. Just assign directly. We don't want to only assign if setting to True.
-
-