Commit 7916bfa7a67429425be94adef2c8dc0182133656

Authored by Laura Hawkins
Exists in master

blurp

Showing 6 changed files Side-by-side Diff

1   -Flashy requires Python 2.
  1 +Flashy requires Python 2. Srsly
  2 +
  3 +All of these commands should be run from this directory (the one containing README.md)
2 4  
3 5 Install virtualenv before continuing. This is most easily accomplished with:
4 6  
flashcards/tests/test_api.py View file @ 7916bfa
... ... @@ -255,6 +255,6 @@
255 255 self.assertEqual(response.status_code, HTTP_200_OK)
256 256  
257 257 def test_section_deck(self):
258   - response = self.client.get('/api/sections/deck/')
  258 + response = self.client.get('/api/sections/1/deck/')
259 259 self.assertEqual(response.status_code, HTTP_200_OK)
flashcards/views.py View file @ 7916bfa
1 1 from django.contrib import auth
2   -from django.db.models import Q
3 2 from flashcards.api import StandardResultsSetPagination
4 3 from flashcards.models import Section, User, Flashcard, FlashcardReport, UserFlashcard
5 4 from flashcards.serializers import SectionSerializer, UserUpdateSerializer, RegistrationSerializer, UserSerializer, \
... ... @@ -31,7 +30,7 @@
31 30 Returned in strictly chronological order (material date).
32 31 """
33 32 flashcards = Flashcard.cards_visible_to(request.user).filter( \
34   - section=self.get_object(), is_hidden=False).all()
  33 + section=self.get_object(), is_hidden=False).all()
35 34  
36 35 return Response(FlashcardSerializer(flashcards, many=True).data)
37 36  
... ... @@ -75,7 +74,7 @@
75 74  
76 75 @list_route(methods=['get'], permission_classes=[IsAuthenticated])
77 76 def search(self, request):
78   - query = request.GET.get('q',None)
  77 + query = request.GET.get('q', None)
79 78 if not query: return Response('[]')
80 79 qs = Section.search(query.split(' '))[:8]
81 80 serializer = SectionSerializer(qs, many=True)
... ... @@ -86,8 +85,6 @@
86 85 """
87 86 Gets the contents of a user's deck for a given section.
88 87 """
89   - #query = request.GET.get(Flashcard.objects.all(), None)
90   - #if not query: return Response('[]')
91 88 qs = Flashcard.objects.all()
92 89 qs = qs.filter(userflashcard__user=request.user)
93 90 serializer = FlashcardSerializer(qs, many=True)
... ... @@ -277,7 +274,7 @@
277 274 self.perform_create(serializer)
278 275 headers = self.get_success_headers(serializer.data)
279 276 return Response(serializer.data, status=HTTP_201_CREATED, headers=headers)
280   -
  277 +
281 278 @detail_route(methods=['post'], permission_classes=[IsAuthenticated])
282 279 def report(self, request, pk):
283 280 """
scripts/check_python_version.py View file @ 7916bfa
  1 +
  2 +
  3 +import sys
  4 +
  5 +print(sys.version)
  6 +
  7 +if sys.version == '3':
  8 + print("Flashy requires Python 2 (read the README.md)")
  9 + exit(-1)
scripts/run_local.sh View file @ 7916bfa
1 1 #!/bin/bash -xe
  2 +
2 3 if [ ! -d "../flashy-frontend/" ]; then
3 4 echo "In order to serve the frontend, flashy-frontend must be in the parent dir"
4 5 exit 1
5 6 fi
6   -source venv/bin/activate
  7 +
  8 +if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
  9 + source venv/bin/activate
  10 +elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
  11 + source venv/Scripts/activate
  12 +fi
  13 +
7 14 python manage.py runserver 127.0.0.1:8080
scripts/setup.sh View file @ 7916bfa
1 1 #!/bin/bash -xe
2 2 virtualenv venv
3   -source venv/bin/activate
  3 +
  4 +if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
  5 + source venv/bin/activate
  6 +elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
  7 + source venv/Scripts/activate
  8 +fi
  9 +
4 10 pip install -r requirements.txt
5 11 virtualenv --relocatable venv
6   -#git submodule init
7   -#git submodule update --depth 1
8   -#pip install -e django