diff --git a/flashcards/models.py b/flashcards/models.py index c448caa..1859b23 100644 --- a/flashcards/models.py +++ b/flashcards/models.py @@ -86,7 +86,6 @@ class FlashcardMask(Model): """ ranges = CharField(max_length=255) - class Flashcard(Model): text = CharField(max_length=255, help_text='The text on the card') section = ForeignKey('Section', help_text='The section with which the card is associated') diff --git a/flashcards/tests/test_api.py b/flashcards/tests/test_api.py index fbf925d..55361c1 100644 --- a/flashcards/tests/test_api.py +++ b/flashcards/tests/test_api.py @@ -1,5 +1,6 @@ from django.core import mail from flashcards.models import User +from rest_framework.generics import RetrieveAPIView from rest_framework.status import HTTP_204_NO_CONTENT, HTTP_201_CREATED, HTTP_200_OK, HTTP_401_UNAUTHORIZED from rest_framework.test import APITestCase from re import search @@ -53,6 +54,7 @@ class LoginTests(APITestCase): # since we're not logged in, we shouldn't be able to see this self.assertEqual(response.status_code, HTTP_401_UNAUTHORIZED) + class PasswordResetTest(APITestCase): def setUp(self): # create a user to test things with @@ -63,13 +65,13 @@ class PasswordResetTest(APITestCase): # submit the request to reset the password url = '/api/reset_password' post_data = {'email': 'test@flashy.cards'} - self.client.post(url, post_data, format='json') + self.client.post(url, post_data, format='json') self.assertEqual(len(mail.outbox), 1) self.assertIn('reset your password', mail.outbox[0].body) # capture the reset token from the email - capture = search('https://flashy.cards/app/reset_password/(\d+)/(.*)', - mail.outbox[0].body) + capture = search('https://flashy.cards/app/reset_password/(\d+)/(.*)', + mail.outbox[0].body) patch_data = {'new_password': '54321'} patch_data['uid'] = capture.group(1) reset_token = capture.group(2) @@ -185,4 +187,4 @@ class DeleteUserTest(APITestCase): self.client.login(email='none@none.com', password='1234') self.client.delete(url) - self.assertFalse(User.objects.filter(email='none@none.com').exists()) + self.assertFalse(User.objects.filter(email='none@none.com').exists()) \ No newline at end of file diff --git a/nginxconf/flashy.cards b/nginxconf/flashy.cards index 7e997df..f56dc73 100644 --- a/nginxconf/flashy.cards +++ b/nginxconf/flashy.cards @@ -4,6 +4,28 @@ upstream backend_production { } server { + server_name dev.flashy.cards; + listen 80; + location ^~ /app/ { + alias /srv/flashy-frontend/; + try_files $uri /app/home.html; + } + location ~ /(api|admin|api-auth)/ { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PATCH, PUT'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,Origin,Authorization,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-CSRFToken'; + proxy_pass http://backend_production; + proxy_redirect http://backend_production $scheme://flashy.cards; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header REMOTE_ADDR $remote_addr; + } +} + +server { server_name flashy.cards; listen 443 ssl;