This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "name":"jazztpt", | |
| "days": | |
| [ | |
| { | |
| "date":"2011-06-20", | |
| "tweets":"18", | |
| "mentions":"4", | |
| "pm":"2", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(void) alertBasedOnCode:(int)errorCode message:(NSString*)message | |
| { | |
| if (errorCode == 3) { | |
| [self showAlertViewWithTitle:@"Authentication" message:message]; | |
| LoginViewController* loginVC = [[[LoginViewController alloc] | |
| initWithNibName:@"LoginViewController" bundle:nil] autorelease]; | |
| [self.navigationController presentModalViewController:loginVC animated:YES]; | |
| } | |
| else if (errorCode == 12) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def wrap_view(self, view): | |
| @csrf_exempt | |
| def wrapper(request, *args, **kwargs): | |
| try: | |
| ...(bunch of standard stuff here)... | |
| return response | |
| except (BadRequest, ApiFieldError), e: | |
| message = e.args[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CardResource(ModelResource): | |
| track_set = fields.ToManyField(TrackResource, 'track_set', full=True) | |
| def get_object_list(self, request, *args, **kwargs): | |
| return Card.objects.filter(user=request.user) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CardResource(ModelResource): | |
| track_set = fields.ToManyField(TrackResource, 'track_set', full=True) | |
| def get_object_list(self, request, *args, **kwargs): | |
| return Card.objects.filter(user=request.user) | |
| class Meta: | |
| queryset = Card.objects.all() | |
| resource_name = 'card' | |
| authentication = BasicAuthentication() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CardResource(ModelResource): | |
| track_set = fields.ToManyField(TrackResource, 'track_set', full=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def post_list(self, request, **kwargs): | |
| """ | |
| Creates a new resource/object with the provided data. | |
| Calls get_tracks to get all track info from various apis. | |
| """ | |
| deserialized = self.deserialize(request, request.raw_post_data, format=request.META.get('CONTENT_TYPE', 'application/json')) | |
| bundle = self.build_bundle(data=dict_strip_unicode_keys(deserialized)) | |
| self.is_valid(bundle, request) | |
| updated_bundle = self.obj_create(bundle, request=request, user=request.user) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "create_date": "2011-06-06T06:41:31.454924", | |
| "id": "1", | |
| "interests": "dancing, coffee", | |
| "intro_note": "", | |
| "recipient_email": "", | |
| "recipient_name": "Anna", | |
| "recipient_phone": "", | |
| "resource_uri": "/api/card/1/", | |
| "track_set": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "create_date": "2011-06-06T06:41:31.454924", | |
| "id": "1", | |
| "interests": "dancing, coffee", | |
| "intro_note": "", | |
| "recipient_email": "", | |
| "recipient_name": "Anna", | |
| "recipient_phone": "", | |
| "resource_uri": "/api/card/1/" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ curl -X POST -H 'Content-Type: application/json' -u nate:nate | |
| --data '{"recipient_name" : "Anna", | |
| "interests" : "dancing, coffee"}' | |
| http://localhost:8000/api/card/ |