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
uwsgi --socket /var/run/uwsgi/application_name --env DJANGO_SETTINGS_MODULE=application_name.settings --module application_name.wsgi:application --chmod-socket=664 |
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
from django.http import HttpResponseRedirect | |
from django.contrib.auth.decorators import login_required | |
class LoginRequiredMixin(object): | |
""" | |
LoginRequired Mixin | |
""" | |
@classmethod | |
def as_view(cls, **initkwargs): |
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 RedirectChainAnalysisMixin(object): | |
""" | |
A mixin to check if a redirect chain of response is correct | |
Must be used with Django TestCase object | |
""" | |
def chain_check(self, response, needed): | |
""" | |
Checks a chain |
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
from django.http import JsonResponse | |
from django.conf import settings | |
from django_remote_forms.forms import RemoteForm | |
class JsonableFormMixin(object): | |
""" | |
Mixin to adding AJAX support to a form view. | |
Must be used with django model editing views |
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 PrototypeOfBaseView(FormView): | |
""" | |
The prototype of base view, which allows to render a form | |
by Django Form framework, but to validate and save data by API framework | |
""" | |
template_name = None | |
serializer_class = None | |
fields = 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
import importlib | |
from django.conf import settings | |
from django.contrib.auth import SESSION_KEY | |
def get_id_by_session_key(session_key): | |
""" | |
Returns user identifier by session_key | |
""" |
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 PasswordSerializer(serializers.ModelSerializer): | |
""" | |
Changes user password | |
""" | |
old_password = serializers.CharField(required=True) | |
new_password = serializers.CharField(required=True) | |
_required_fields = ['old_password', 'new_password'] |
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
from django.conf import settings | |
import gocardless_pro | |
class GoCardless(object): | |
""" | |
GoCardless wrapper | |
""" | |
def __init__(self): | |
self.client = gocardless_pro.Client( |
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
from rest_framework import serializers | |
class HybridPrimaryKeyRelatedAndSerializerMethodField(serializers.PrimaryKeyRelatedField): | |
""" | |
PrimaryKeyRelatedField & SerializerMethodField | |
""" | |
def __init__(self, method_name=None, **kwargs): | |
self.method_name = method_name | |
super(HybridPrimaryKeyRelatedAndSerializerMethodField, self).__init__(**kwargs) |
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
from rest_framework.authentication import SessionAuthentication | |
class CsrfExemptSessionAuthentication(SessionAuthentication): | |
""" | |
SessionAuthentication without csrf token check | |
""" | |
def enforce_csrf(self, request): | |
""" | |
Not performing csrf token check |
OlderNewer