-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
689 additions
and
44 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,5 +104,4 @@ venv.bak/ | |
.mypy_cache/ | ||
|
||
.idea/ | ||
static/ | ||
src/**/migrations | ||
static/ |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
Django==2.2.0 | ||
aniso8601==7.0.0 | ||
appdirs==1.4.4 | ||
distlib==0.3.1 | ||
Django==2.2 | ||
django-cors-headers==3.1.1 | ||
djangorestframework==3.12.2 | ||
et-xmlfile==1.0.1 | ||
filelock==3.0.12 | ||
graphene==2.1.8 | ||
graphene-django==2.15.0 | ||
graphene-generator==0.1.2 | ||
graphql-core==2.3.2 | ||
graphql-relay==2.0.1 | ||
gunicorn==19.6.0 | ||
psycopg2>s=2.8.2 | ||
openpyxl==3.0.7 | ||
promise==2.3 | ||
psycopg2==2.8.6 | ||
pytz==2021.1 | ||
Rx==1.6.1 | ||
singledispatch==3.6.1 | ||
six==1.15.0 | ||
sqlparse==0.4.1 | ||
text-unidecode==1.3 | ||
virtualenv==20.4.3 | ||
xlrd==1.2.0 | ||
django-cors-headers==3.1.1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
aniso8601==7.0.0 | ||
appdirs==1.4.4 | ||
distlib==0.3.1 | ||
Django==2.2 | ||
django-cors-headers==3.1.1 | ||
djangorestframework==3.12.2 | ||
et-xmlfile==1.0.1 | ||
filelock==3.0.12 | ||
graphene==2.1.8 | ||
graphene-django==2.15.0 | ||
graphene-generator==0.1.2 | ||
graphql-core==2.3.2 | ||
graphql-relay==2.0.1 | ||
gunicorn==19.6.0 | ||
openpyxl==3.0.7 | ||
promise==2.3 | ||
psycopg2==2.8.6 | ||
pytz==2021.1 | ||
Rx==1.6.1 | ||
singledispatch==3.6.1 | ||
six==1.15.0 | ||
sqlparse==0.4.1 | ||
text-unidecode==1.3 | ||
virtualenv==20.4.3 | ||
xlrd==1.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
version: "3.3" | ||
services: | ||
nginx: | ||
cpanginx: | ||
image: nginx:latest | ||
container_name: cpa_nginx | ||
ports: | ||
|
@@ -16,7 +16,7 @@ services: | |
VIRTUAL_PORT: 8000 | ||
LETSENCRYPT_HOST: api.cpa.bcc.anapolis.ifg.edu.br | ||
LETSENCRYPT_EMAIL: "[email protected]" | ||
web: | ||
cpaweb: | ||
build: . | ||
container_name: cpa_app | ||
restart: always | ||
|
@@ -33,7 +33,7 @@ services: | |
DATABASE_HOST: db2 | ||
DATABASE_PORT: 5432 | ||
DATABASE_NAME: cpadash | ||
db2: | ||
cpadb: | ||
image: postgres:alpine | ||
container_name: cpa_db | ||
restart: always | ||
|
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import graphene | ||
from graphene_generator.holder import QueriesHolder, MutationsHolder | ||
|
||
|
||
class Query(QueriesHolder, graphene.ObjectType): | ||
pass | ||
|
||
|
||
class Mutation(MutationsHolder, graphene.ObjectType): | ||
pass | ||
|
||
|
||
schema = graphene.Schema(query=Query, mutation=MutationsHolder) |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from rest_framework.views import APIView | ||
from rest_framework.response import Response | ||
from django.contrib.auth.models import User | ||
from django.forms.models import model_to_dict | ||
from graphene_django.views import GraphQLView | ||
import rest_framework | ||
from rest_framework.permissions import IsAuthenticated | ||
from rest_framework.decorators import authentication_classes, permission_classes, api_view | ||
from rest_framework.settings import api_settings | ||
|
||
|
||
class DRFAuthenticatedGraphQLView(GraphQLView): | ||
def parse_body(self, request): | ||
if isinstance(request, rest_framework.request.Request): | ||
return request.data | ||
return super(DRFAuthenticatedGraphQLView, self).parse_body(request) | ||
|
||
@classmethod | ||
def as_view(cls, *args, **kwargs): | ||
view = super(DRFAuthenticatedGraphQLView, cls).as_view(*args, **kwargs) | ||
view = permission_classes((IsAuthenticated,))(view) | ||
view = authentication_classes(api_settings.DEFAULT_AUTHENTICATION_CLASSES)(view) | ||
view = api_view(['GET', 'POST'])(view) | ||
return view | ||
|
||
class AuthView(APIView): | ||
permission_classes = (IsAuthenticated,) # <-- And here | ||
|
||
def get(self, request): | ||
content = { | ||
"username": f'{request.user}' | ||
} | ||
|
||
return Response(content) | ||
|
||
|
||
class UserView(APIView): | ||
permission_classes = (IsAuthenticated,) # <-- And here | ||
|
||
def get(self, request): | ||
user = User.objects.get(username=request.user) | ||
user = model_to_dict(user) | ||
user.pop('password') | ||
user.pop('groups') | ||
user.pop('user_permissions') | ||
|
||
return Response(user) | ||
|
||
def put(self, request): | ||
updated_user = request.data | ||
|
||
user = User.objects.get(username=request.user) | ||
|
||
if updated_user['first_name'] is not None: | ||
user.first_name = updated_user['first_name'] | ||
|
||
if updated_user['last_name'] is not None: | ||
user.last_name = updated_user['last_name'] | ||
|
||
if updated_user['email'] is not None: | ||
user.email = updated_user['email'] | ||
|
||
user.save() | ||
|
||
content = model_to_dict(user) | ||
|
||
return Response(content) |
Oops, something went wrong.