Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dougpenny committed Aug 17, 2020
0 parents commit b8a299a
Show file tree
Hide file tree
Showing 245 changed files with 38,552 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Production switch
PRODUCTION=False

DJANGO_SECRET_KEY='''
ALLOWED_HOSTS=''

# Database settings
POSTGRES_PASSWORD=''
POSTGRES_USER=''

# PowerSchool server information
POWERSCHOOL_URL=
POWERSCHOOL_CLIENT_ID=
POWERSCHOOL_CLIENT_SECRET=

# Django ADFS auth settings
ADFS_AUDIENCE=''
ADFS_CLIENT_ID=''
ADFS_RELYING_PARTY_ID=''
ADFS_TENANT_ID=''

# Email settings
EMAIL_HOST=''
EMAIL_HOST_PASSWORD=''
EMAIL_HOST_USER=''
EMAIL_PORT=''
EMAIL_USE_TLS=''
SERVER_EMAIL=''
DEFAULT_FROM_EMAIL=''

# Cafeteria app settings
ORDER_CUTOFF=''
HOMEROOM_CUTOFF=
90 changes: 90 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
.DS_Store
.vscode/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# mkdocs documentation
/site

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# KnightsLunchManager
Empty file added api/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions api/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ApiConfig(AppConfig):
name = 'api'
3 changes: 3 additions & 0 deletions api/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
22 changes: 22 additions & 0 deletions api/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from django.contrib.auth.models import User
from rest_framework import serializers

from menu.models import MenuItem


class MenuItemSerializer(serializers.ModelSerializer):
class Meta:
model = MenuItem
fields = ['id', 'cost', 'days_available', 'schools_available', 'name', 'sequence']


class StudentSerializer(serializers.ModelSerializer):

name = serializers.SerializerMethodField()

def get_name(self, obj):
return obj.first_name + ' ' + obj.last_name + ' - ' + str(obj.profile.grade_level)

class Meta:
model = User
fields = ['id', 'name']
3 changes: 3 additions & 0 deletions api/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
11 changes: 11 additions & 0 deletions api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.urls import path

from api.views import DetailMenuItem
from api.views import ListMenuItem
from api.views import StudentSearch

urlpatterns = [
path('menu/', ListMenuItem.as_view()),
path('menu/<int:pk>/', DetailMenuItem.as_view()),
path('students/basic/', StudentSearch.as_view(), name='basic-student-search'),
]
28 changes: 28 additions & 0 deletions api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from django.contrib.auth.models import User

from rest_framework import filters
from rest_framework import generics
from rest_framework.views import APIView
from rest_framework.response import Response

from api.serializers import MenuItemSerializer
from api.serializers import StudentSerializer
from menu.models import MenuItem
from profiles.models import Profile


class ListMenuItem(generics.ListCreateAPIView):
queryset = MenuItem.objects.all()
serializer_class = MenuItemSerializer


class DetailMenuItem(generics.RetrieveUpdateDestroyAPIView):
queryset = MenuItem.objects.all()
serializer_class = MenuItemSerializer


class StudentSearch(generics.ListCreateAPIView):
search_fields = ['first_name', 'last_name']
filter_backends = [filters.SearchFilter]
queryset = User.objects.filter(profile__role=Profile.STUDENT)
serializer_class = StudentSerializer
Empty file added cafeteria/__init__.py
Empty file.
30 changes: 30 additions & 0 deletions cafeteria/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.contrib import admin

from cafeteria.models import School
from cafeteria.models import Weekday


@admin.register(School)
class SchoolAdmin(admin.ModelAdmin):
fields = ['display_name', 'active', 'name', 'school_number']
readonly_fields = ['name', 'school_number']
list_filter = ['active']
list_display = ('__str__', 'school_number', 'active')

def has_add_permission(self, request):
return False

def has_delete_permission(self, request, obj=None):
return False


@admin.register(Weekday)
class WeekdayAdmin(admin.ModelAdmin):
fields = ['name', 'abbreviation']
list_display = ['name', 'abbreviation']

def has_add_permission(self, request):
return False

def has_delete_permission(self, request, obj=None):
return False
6 changes: 6 additions & 0 deletions cafeteria/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class CafeteriaConfig(AppConfig):
name = 'cafeteria'
verbose_name = 'Cafeteria Administration'
42 changes: 42 additions & 0 deletions cafeteria/fixtures/weekdays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"model": "cafeteria.weekday",
"pk": 1,
"fields": {
"abbreviation": "Mon",
"name": "Monday"
}
},
{
"model": "cafeteria.weekday",
"pk": 2,
"fields": {
"abbreviation": "Tue",
"name": "Tuesday"
}
},
{
"model": "cafeteria.weekday",
"pk": 3,
"fields": {
"abbreviation": "Wed",
"name": "Wednesday"
}
},
{
"model": "cafeteria.weekday",
"pk": 4,
"fields": {
"abbreviation": "Thr",
"name": "Thursday"
}
},
{
"model": "cafeteria.weekday",
"pk": 5,
"fields": {
"abbreviation": "Fri",
"name": "Friday"
}
}
]
Empty file.
Empty file.
Loading

0 comments on commit b8a299a

Please sign in to comment.