Commit cf232414a1ec3aae351b17af4cf827cc7b639ad2

Authored by Andrew Buss
1 parent 61ef8379b7
Exists in master

start writing fixtures

Showing 5 changed files with 66 additions and 3 deletions Inline Diff

# Flashy 1 1 # Flashy
2 2
Flashy is a realtime collaborative flashcard sharing app combined with a spaced-repetition study system. Flashy was developed by CSE 110 students in spring quarter 2015: 3 3 Flashy is a realtime collaborative flashcard sharing app combined with a spaced-repetition study system. Flashy was developed by CSE 110 students in spring quarter 2015:
4 4
- lhawkins 5 5 - lhawkins
- ckwang 6 6 - ckwang
- arnog 7 7 - arnog
- abuss 8 8 - abuss
- rray 9 9 - rray
- rlee 10 10 - rlee
- mjeng 11 11 - mjeng
- kmach 12 12 - kmach
- mrahman 13 13 - mrahman
- namtran 14 14 - namtran
15 15
Flashy's code is divided among the flashy-backend repository (this one!) and the flashy-frontend repository. When running the local server, these repositories should be sibling directories and the flashy-frontend repository must be cloned into a directory of the same name. 16 16 Flashy's code is divided among the flashy-backend repository (this one!) and the flashy-frontend repository. When running the local server, these repositories should be sibling directories and the flashy-frontend repository must be cloned into a directory of the same name.
17 17
Flashy officially supports Ubuntu 14.04 18 18 Flashy officially supports Ubuntu 14.04 with at least 2 GB of RAM. A VM is acceptable but performance may be impaired.
19 19
## Installing Flashy on Ubuntu 14.04 (development/testing) 20 20 ## Installing Flashy on Ubuntu 14.04 (development/testing)
21 21
We recommend installing Flashy on a fresh installation of Ubuntu 14.04. Before installing, make sure all packages are up to date: 22 22 We recommend installing Flashy on a fresh installation of Ubuntu 14.04. Before installing, make sure all packages are up to date:
23 23
sudo apt-get update 24 24 sudo apt-get update
sudo apt-get upgrade 25 25 sudo apt-get upgrade
26 26
It is important that Python 3 *not* be installed, as this causes issues when creating the virtualenv. 27 27 It is important that Python 3 *not* be installed, as this causes issues when creating the virtualenv.
28 28
### Install required packages 29 29 ### Install required packages
30 30
sudo apt-get install python-virtualenv redis-server git python-dev 31 31 sudo apt-get install python-virtualenv redis-server git python-dev
32 32
33 ### Start Redis
34
35 sudo service redis_6379 start
36 echo PING | redis-cli
37
38 Redis should respond PONG to the last command.
39
### Prepare installation directory 33 40 ### Prepare installation directory
34 41
mkdir ~/flashy/ 35 42 mkdir ~/flashy/
cd ~/flashy/ 36 43 cd ~/flashy/
37 44
### Retrieve source 38 45 ### Retrieve source
39 46
Clone the two repositories. Provide credentials in each case. 40 47 Clone the two repositories. Provide credentials in each case.
41 48
git clone https://git.ucsd.edu/110swag/flashy-frontend 42 49 git clone https://git.ucsd.edu/110swag/flashy-frontend
git clone https://git.ucsd.edu/110swag/flashy-backend 43 50 git clone https://git.ucsd.edu/110swag/flashy-backend
44 51
### Prepare backend environment 45 52 ### Prepare backend environment
46 53
When running the setup script, gevent may take a while to install and throw several compiler warnings. These are expected. 47 54 When running the setup script, gevent may take a while to install and throw several compiler warnings. These are expected.
48 55
cd flashy-backend 49 56 cd flashy-backend
scripts/setup.sh 50 57 scripts/setup.sh
source venv/bin/activate 51 58 source venv/bin/activate
python manage.py migrate 52 59 python manage.py migrate
python manage.py loaddata sections 53 60 python manage.py loaddata sections
54 61
### Run backend server 55 62 ### Run backend server
flashcards/management/commands/apply_test_fixture.py View file @ cf23241
File was created 1 from django.core.management import BaseCommand
2 from django.utils.importlib import import_module
3 from flashcards.test_fixtures import base
4
5
6 class Command(BaseCommand):
7 help = 'Apply a test fixture'
8
9 def add_arguments(self, parser):
10 parser.add_argument('fixture_names', nargs='+', type=str)
11
12 def handle(self, *args, **options):
flashcards/test_fixtures/__init__.py View file @ cf23241
File was created 1 __author__ = 'andrew'
flashcards/test_fixtures/base.py View file @ cf23241
File was created 1 from datetime import time
2
3 from flashcards.models import *
4
5
6 def apply():
7 User.objects.filter(email='userx@flashy.cards').delete()
8 User.objects.filter(email='usery@flashy.cards').delete()
9 Section.objects.filter(department_abbreviation='TEST').delete()
10 s = Section.objects.create(instructor='Test Prof',
11 course_title='Intro to Testing',
12 course_num="101",
13 quarter="SP15",
14 department="Test Sciences",
15 department_abbreviation='TEST'
16 )
17 Section.objects.create(instructor='Test Prof',
18 course_title='Advanced Testing',
19 course_num="102",
20 quarter="SP15",
21 department="Test Sciences",
22 department_abbreviation='TEST'
23 )
24 LecturePeriod.objects.create(section=s, week_day=2, start_time=time(8), end_time=time(9))
scripts/apply-test-fixture.sh View file @ cf23241
File was created 1 #!/bin/bash -xe
2
3 if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
4 source venv/bin/activate
5 elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
6 source venv/Scripts/activate