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
| # Authorization with django-graphene | |
| # using django-jwt-auth==0.0.2 | |
| from django.conf.urls import url | |
| from django.views.decorators.csrf import csrf_exempt | |
| from graphene_django.views import GraphQLView | |
| from jwt_auth.mixins import JSONWebTokenAuthMixin | |
| class AuthGraphQLView(JSONWebTokenAuthMixin, GraphQLView): |
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
| from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator | |
| # First we create a little helper function, becase we will potentially have many PaginatedTypes | |
| # and we will potentially want to turn many querysets into paginated results: | |
| def get_paginator(qs, page_size, page, paginated_type, **kwargs): | |
| p = Paginator(qs, page_size) | |
| try: | |
| page_obj = p.page(page) | |
| except PageNotAnInteger: |
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
| from graphene import relay, String, List | |
| from graphene_django.filter import DjangoFilterConnectionField | |
| from graphene_django.fields import DjangoConnectionField | |
| from app.models import Model | |
| class Object(DjangoObjectType): | |
| class Meta: | |
| model = Model |
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
| # -*- encoding: utf-8 -*- | |
| # -------------------------- | |
| # Ripped from django project | |
| # -------------------------- | |
| from django.contrib.contenttypes.models import ContentType | |
| from django.utils.translation import ugettext as _ | |
| from django.utils.encoding import force_unicode |
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
| #!/bin/bash | |
| export GITHUB_REPO="user/repo" | |
| export GITHUB_USERNAME=$(cat ~/.githubrc 2> /dev/null | grep user.login | cut -d ":" -f2 | xargs) | |
| export GITHUB_PASSWORD=$(cat ~/.githubrc 2> /dev/null | grep user.password | cut -d ":" -f2 | xargs) | |
| if [ -z "$GITHUB_USERNAME" ] | |
| then | |
| read -p "Type your Github username: " GITHUB_USERNAME | |
| echo "user.login: $GITHUB_USERNAME" >> ~/.githubrc | |
| fi |
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
| #!/bin/bash | |
| command_exists () { | |
| type "$1" &> /dev/null ; | |
| } | |
| export GITHUB_REPO="user/repo" | |
| export GITHUB_USERNAME=$(cat ~/.githubrc 2> /dev/null | grep user.login | cut -d ":" -f2 | xargs) | |
| export GITHUB_PASSWORD=$(cat ~/.githubrc 2> /dev/null | grep user.password | cut -d ":" -f2 | xargs) | |
| if [ -z "$GITHUB_USERNAME" ] |
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
| # https://hakibenita.com/how-to-turn-django-admin-into-a-lightweight-dashboard | |
| from django.contrib import admin | |
| from django.db.models import Count, Sum, Min, Max, DateTimeField) | |
| from django.db.models.functions import Trunc | |
| from . import models | |
| def get_next_in_date_hierarchy(request, date_hierarchy): |

