This is a test of stuff.
This file contains 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
{ | |
"users": [ | |
{ | |
"organisations": [ | |
{ | |
"id": 456, | |
"role": "OWNER", | |
"editable": false, | |
"name": "Acme Org", | |
"permissions": ["SDFDS::SDFDS", "SDFDFS::SASDA"] |
This file contains 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
permissions = [ | |
Permission(permission=permission, user=user, organisation=self) | |
for permission in ACCOUNT_PERMISSIONS | |
] |
This file contains 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
https://github.com/tomchristie/django-rest-framework/issues/1936 | |
https://github.com/tomchristie/django-rest-framework/issues/1891 | |
https://github.com/tomchristie/django-rest-framework/issues/1860 | |
https://github.com/tomchristie/django-rest-framework/issues/1767 | |
https://github.com/tomchristie/django-rest-framework/issues/1649 | |
https://github.com/tomchristie/django-rest-framework/issues/1338 |
This file contains 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
currency_serializer = CurrencySerializer(Currency.objects.all(), many=True) | |
service_serializer = ServiceModuleMinSerializer(ServiceModule.objects.all(), many=True) | |
return Response({ | |
'currencies': currency_serializer.data, | |
'services': service_serializer.data | |
}) |
This file contains 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
* REST framework 0.x - The top branch is the framework. Red branch to the left is docs. Bottom is example projects. | |
* Big pause - This'd be when my first son was born. Had my hands full. | |
* You can see when version 2.0 arrives as there's a flurry of activity - the code examples disappear and the docs get loads of work instead. | |
* During 2.x the tests move out of the package itself, causing another branch off of the center. | |
* You can tell when version 3.0 arrives, as a whole bunch of blue sponsor images appear in the red docs branch. | |
* The templated HTML rendering results in three sets of small purple branchs in the main framework, corresponding to vertical, horizontal and inline style templates. | |
* The big white flower is all the supported languages as we add internationalization to the project. |
This file contains 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 InvoiceList(ManyRelatedField): | |
def __init__(self): | |
child = InvoiceSerializer() | |
super(InvoiceList, self).__init__() | |
def to_representation(self, iterable): | |
request = self.parent.context['request'] | |
return [ | |
self.child_relation.to_representation(value) | |
for value in iterable.filter(user=request.user) |
This file contains 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 UnicodeJSONRenderer(BaseRenderer): | |
""" | |
Renderer which serializes to JSON | |
""" | |
media_type = 'application/json' | |
format = 'json' | |
def render(self, obj=None, media_type=None): | |
""" |
This file contains 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 DocumentingTemplateRenderer(BaseRenderer): | |
... | |
escape_binary = True | |
def _escape_binary(content): | |
if self.escape_binary and not all(char in string.printable for char in content): | |
return '[%d bytes of binary content]' % len(content) | |
return content | |
... |
This file contains 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 SeleniumTestCase(LiveServerTestCase): | |
_selenium_server_running = None | |
@property | |
def selenium_server_running(self): | |
""" | |
Determine if we can connect to the Selenium RC server. | |
Only evaluated once for performance reasons. | |
""" |
OlderNewer