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
"""Gunicorn config file. | |
by HacKan (https://hackan.net) | |
Find it at: https://gist.github.com/HacKanCuBa/275bfca09d614ee9370727f5f40dab9e | |
Based on: https://gist.github.com/KodeKracker/6bc6a3a35dcfbc36e2b7 | |
Changelog | |
========= | |
See revisions to access other versions of this file. |
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 ProductVariantAdminInline(admin.TabularInline): | |
extra = 0 | |
model = ProductVariant | |
def get_parent_object_from_request(self, request): | |
""" | |
Returns the parent object from the request or None. | |
Note that this only works for Inlines, because the `parent_model` | |
is not available in the regular admin.ModelAdmin as an attribute. |
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
#!/usr/bin/python | |
# | |
# Copyright 2017 Otto Seiskari | |
# Licensed under the Apache License, Version 2.0. | |
# See http://www.apache.org/licenses/LICENSE-2.0 for the full text. | |
# | |
# This file is based on | |
# https://github.com/swagger-api/swagger-ui/blob/4f1772f6544699bc748299bd65f7ae2112777abc/dist/index.html | |
# (Copyright 2017 SmartBear Software, Licensed under Apache 2.0) | |
# |
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
""" | |
Sometimes in your Django model you want to raise a ``ValidationError`` in the ``save`` method, for | |
some reason. | |
This exception is not managed by Django Rest Framework because it occurs after its validation | |
process. So at the end, you'll have a 500. | |
Correcting this is as simple as overriding the exception handler, by converting the Django | |
``ValidationError`` to a DRF one. | |
""" | |
from django.core.exceptions import ValidationError as DjangoValidationError |
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
data:image/gif;base64,R0lGODlhAQABAAAAACw= |
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
[T]he difference between a bad programmer and a | |
good one is whether he considers his code or his | |
data structures more important. Bad programmers | |
worry about the code. Good programmers worry about | |
data structures and their relationships. | |
-- Linus Torvalds | |
~~~ | |
Clarity and brevity sometimes are at odds. | |
When they are, I choose clarity. | |
-- Jacob Kaplan-Moss |
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
import ldap | |
def check_credentials(username, password): | |
"""Verifies credentials for username and password. | |
Returns None on success or a string describing the error on failure | |
# Adapt to your needs | |
""" | |
LDAP_SERVER = 'ldap://xxx' | |
# fully qualified AD user name | |
LDAP_USERNAME = '%[email protected]' % username |