broke af
This commit is contained in:
parent
f0f4494553
commit
83fdd5b79a
|
@ -30,7 +30,8 @@ services:
|
||||||
context: ./server
|
context: ./server
|
||||||
volumes:
|
volumes:
|
||||||
- ./server:/usr/src/server
|
- ./server:/usr/src/server
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- 8000:8000
|
- 8000:8000
|
||||||
|
environment:
|
||||||
|
- DEBUG=true
|
||||||
command: ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
command: ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
||||||
|
|
|
@ -20,7 +20,7 @@ export const AppContextProvider = ({ children, baseURL }: Props) => {
|
||||||
const api = axios.create({ baseURL })
|
const api = axios.create({ baseURL })
|
||||||
|
|
||||||
api.interceptors.request.use((config) => {
|
api.interceptors.request.use((config) => {
|
||||||
config.url += '?format=json'
|
// config.url += '?format=json'
|
||||||
return config
|
return config
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -5,19 +5,17 @@ import { Form } from '../../elements/Form'
|
||||||
import { Button } from '../../elements/Button'
|
import { Button } from '../../elements/Button'
|
||||||
import { useForm } from 'antd/lib/form/Form'
|
import { useForm } from 'antd/lib/form/Form'
|
||||||
import { useAppContext } from '../../contexts/AppContext'
|
import { useAppContext } from '../../contexts/AppContext'
|
||||||
import { useStacks } from '../../hooks/getMany/useStacks'
|
|
||||||
|
|
||||||
type FormValues = { email: string; password: string }
|
type FormValues = { username: string; password: string }
|
||||||
|
|
||||||
export const Login = () => {
|
export const Login = () => {
|
||||||
const appContext = useAppContext()
|
const appContext = useAppContext()
|
||||||
const stacks = useStacks('')
|
|
||||||
|
|
||||||
const [form] = useForm<FormValues>()
|
const [form] = useForm<FormValues>()
|
||||||
|
|
||||||
const handleFinish = async ({ email, password }: FormValues) => {
|
const handleFinish = async ({ username, password }: FormValues) => {
|
||||||
const res = await appContext.post('/dj-rest-auth/login', {
|
const res = await appContext.post('/dj-rest-auth/login', {
|
||||||
email,
|
username,
|
||||||
password,
|
password,
|
||||||
})
|
})
|
||||||
console.log(res)
|
console.log(res)
|
||||||
|
@ -27,7 +25,7 @@ export const Login = () => {
|
||||||
<div className="login">
|
<div className="login">
|
||||||
<Form onFinish={handleFinish} form={form}>
|
<Form onFinish={handleFinish} form={form}>
|
||||||
<h1>Log In</h1>
|
<h1>Log In</h1>
|
||||||
<FormItem label="email" name="email">
|
<FormItem label="username" name="username">
|
||||||
<Input />
|
<Input />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="Password" name="password">
|
<FormItem label="Password" name="password">
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from django.contrib.auth.models import User, Group
|
from django.contrib.auth.models import User, Group
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets, permissions
|
||||||
from rest_framework import permissions
|
|
||||||
from server.api import serializers, models
|
from server.api import serializers, models
|
||||||
|
|
||||||
|
|
||||||
class UserViewSet(viewsets.ModelViewSet):
|
class UserViewSet(viewsets.ModelViewSet):
|
||||||
queryset = User.objects.all()
|
queryset = User.objects.all()
|
||||||
serializer_class = serializers.UserSerializer
|
serializer_class = serializers.UserSerializer
|
||||||
|
@ -11,6 +11,7 @@ class UserViewSet(viewsets.ModelViewSet):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return [self.request.user]
|
return [self.request.user]
|
||||||
|
|
||||||
|
|
||||||
class AccountViewSet(viewsets.ModelViewSet):
|
class AccountViewSet(viewsets.ModelViewSet):
|
||||||
queryset = models.Account.objects.all()
|
queryset = models.Account.objects.all()
|
||||||
serializer_class = serializers.AccountSerializer
|
serializer_class = serializers.AccountSerializer
|
||||||
|
@ -19,6 +20,7 @@ class AccountViewSet(viewsets.ModelViewSet):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.queryset.filter(users=self.request.user)
|
return self.queryset.filter(users=self.request.user)
|
||||||
|
|
||||||
|
|
||||||
class StackViewSet(viewsets.ModelViewSet):
|
class StackViewSet(viewsets.ModelViewSet):
|
||||||
queryset = models.Stack.objects.all()
|
queryset = models.Stack.objects.all()
|
||||||
serializer_class = serializers.StackSerializer
|
serializer_class = serializers.StackSerializer
|
||||||
|
@ -27,6 +29,7 @@ class StackViewSet(viewsets.ModelViewSet):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.queryset.filter(account__users=self.request.user)
|
return self.queryset.filter(account__users=self.request.user)
|
||||||
|
|
||||||
|
|
||||||
class TransactionViewSet(viewsets.ModelViewSet):
|
class TransactionViewSet(viewsets.ModelViewSet):
|
||||||
queryset = models.Transaction.objects.all()
|
queryset = models.Transaction.objects.all()
|
||||||
serializer_class = serializers.TransactionSerializer
|
serializer_class = serializers.TransactionSerializer
|
||||||
|
|
|
@ -88,7 +88,7 @@ TEMPLATES = [
|
||||||
]
|
]
|
||||||
|
|
||||||
WSGI_APPLICATION = 'server.wsgi.application'
|
WSGI_APPLICATION = 'server.wsgi.application'
|
||||||
|
APPEND_SLASH = False
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
||||||
|
|
Loading…
Reference in New Issue
Block a user