Commit cb93750f authored by David Haynes's avatar David Haynes 🙆

Dear lord I haven't touched this in a year and everything is WRONG

parent 1a8dda9c
Pipeline #3710 failed with stage
in 55 seconds
......@@ -13,5 +13,4 @@ whats_open/secret_key.py
whats_open/assets/
static/admin/
data
whats-open/api/migrations
.vscode
......@@ -34,14 +34,4 @@ whats-open-py3.5:
image: library/python:3.5
type: test
script:
- python manage.py test
whats-open-py3.6:
image: library/python:3.6
type: test
script:
# - if pip list --outdated --format=legacy | grep "Latest" | wc -l > 0; then echo "Please update your dependecies!" && pip list --outdated --format=legacy && exit 1; else exit 0; fi
- coverage run --source=api
--omit=*migrations/*,*admin.py,*__init__.py,*.pyc manage.py test
- coverage html -i && grep pc_cov htmlcov/index.html | egrep -o "[0-9]+\%"
| awk '{ print "covered " $1;}'
- echo "Done 😄"
......@@ -31,4 +31,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Special Schedules can start at a specific time on a date
[2.1.0]: https://git.gmu.edu/srct/whats-open/compare/2.0...2.1
[2.1.1]: https://git.gmu.edu/srct/whats-open/compare/2.1...2.1.1
\ No newline at end of file
[2.1.1]: https://git.gmu.edu/srct/whats-open/compare/2.1...2.1.1
This diff is collapsed.
......@@ -3,7 +3,7 @@
############################################################
# Set the base image to Ubuntu
FROM python:3.6
FROM python:3.7
ENV PYTHONUNBUFFERED 1
# Update the sources list and install all packages
......@@ -23,4 +23,5 @@ WORKDIR /whats-open/
ADD . /whats-open/
# Pip install all required dependecies
RUN pip install -r /whats-open/requirements/base.txt
RUN pip install pipenv
RUN pipenv install --system --deploy
\ No newline at end of file
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
black = "*"
[packages]
django-autoslug-iplweb = "*"
django-cas-client = "==1.3.0"
djangorestframework = "==3.7.7"
django-model-utils = "==3.0.0"
mysqlclient = "==1.3.12"
django-taggit = "==0.22.2"
django-taggit-serializer = "==0.1.5"
djangorestframework-gis = "==0.12.0"
django-filter = "==1.0.4"
django-crispy-forms = "==1.7.0"
coreapi = "==2.3.3"
urllib3 = "==1.22"
docutils = "==0.13.1"
gunicorn = "*"
Django = "<2.1,>=2.0"
Markdown = "==2.6.10"
black = "*"
pylint = "*"
pylint-django = "*"
[requires]
python_version = "3.7"
[pipenv]
allow_prereleases = true
This diff is collapsed.
......@@ -23,10 +23,11 @@ contribute, so if you are struggling, or just want to learn, then we are
willing to help.
Check out some of the other What's Open projects!
- https://git.gmu.edu/srct/whats-open-android
- https://git.gmu.edu/srct/whats-open-ios
- https://git.gmu.edu/srct/whats-open-web
- https://git.gmu.edu/srct/whats-open-alexa
- https://git.gmu.edu/srct/whats-open-android
- https://git.gmu.edu/srct/whats-open-ios
- https://git.gmu.edu/srct/whats-open-web
- https://git.gmu.edu/srct/whats-open-alexa
# Setup instructions for local development
......@@ -113,9 +114,9 @@ environments across machines.
Installing Docker on your system:
- For macOS: https://docs.docker.com/docker-for-mac/
- For Windows: https://docs.docker.com/docker-for-windows/
- For your specific \*nix distro: https://docs.docker.com/engine/installation/
- For macOS: https://docs.docker.com/docker-for-mac/
- For Windows: https://docs.docker.com/docker-for-windows/
- For your specific \*nix distro: https://docs.docker.com/engine/installation/
Additionally, you will need to install docker-compose: https://docs.docker.com/compose/install/
......@@ -148,9 +149,10 @@ pass: admin
Manual Setup involves all of the same steps as Docker, but just done manually.
First, install python, pip, and virtualenv on your system.
* `python` is the programming language used for Django, the web framework used by whats-open.
* `pip` is the python package manager.
* `virtualenv` allows you to isolate pip packages within virtual environments
- `python` is the programming language used for Django, the web framework used by whats-open.
- `pip` is the python package manager.
- `virtualenv` allows you to isolate pip packages within virtual environments
Open a terminal and run the following command:
......@@ -167,10 +169,10 @@ You will also need the following `gdal` packages for GeoDjango support:
```
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt upgrade # if you already have gdal 1.11 installed
sudo apt install gdal-bin python-gdal python3-gdal # if you don't have gdal 1.11 already installed
```
sudo apt update
sudo apt upgrade # if you already have gdal 1.11 installed
sudo apt install gdal-bin python-gdal python3-gdal # if you don't have gdal 1.11 already installed
```
#### Database Setup
......@@ -216,18 +218,17 @@ Run:
GRANT ALL ON test_wopen.* TO 'wopen'@'localhost'; FLUSH PRIVILEGES;
When running test cases, django creates a test database so your 'real' database
doesn't get screwed up. This database is called 'test_' + whatever your normal
doesn't get screwed up. This database is called 'test\_' + whatever your normal
database is named. Note that for permissions it doesn't matter that this database
hasn't yet been created.
The .* is to grant access all tables in the database, and 'flush privileges'
The .\* is to grant access all tables in the database, and 'flush privileges'
reloads privileges to ensure that your user is ready to go.
Exit the mysql shell by typing:
exit
At this point we will need to set some environment variables.
If you are using bash then just copy paste the following into your terminal:
......
......@@ -2,17 +2,10 @@ version: "3"
services:
db:
image: mysql:5.7
deploy:
replicas: 1
restart_policy:
condition: on-failure
command:
mysqld --character-set-server=utf8mb4
command: mysqld --character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci
ports:
- "3306:3306"
networks:
- wopen_net
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_DATABASE: wopen
......@@ -20,18 +13,10 @@ services:
MYSQL_PASSWORD: wopen
api:
image: whats-open-api
deploy:
replicas: 1
restart_policy:
condition: on-failure
build: .
ports:
- "8000:8000"
networks:
- wopen_net
command: /bin/bash ./startup.sh
volumes:
- .:/whats-open
command: ./docker-startup.sh
depends_on:
- db
environment:
......@@ -42,6 +27,3 @@ services:
- WOPEN_DB_HOST=db
- WOPEN_DB_PORT=3306
- WOPEN_SUPERUSER=admin
networks:
wopen_net:
# This file is here because many Platforms as a Service look for
# requirements.txt in the root directory of a project.
-r requirements/production.txt
Django >= 2.0, < 2.1
django-autoslug-iplweb
django-cas-client==1.3.0
djangorestframework==3.7.7
django-model-utils==3.0.0
mysqlclient==1.3.12
setuptools==36.2.0
django-taggit==0.22.2
django-taggit-serializer==0.1.5
djangorestframework-gis==0.12.0
django-filter==1.0.4
django-crispy-forms==1.7.0
markdown==2.6.10
coreapi==2.3.3
urllib3==1.22
docutils==0.13.1
\ No newline at end of file
# Local development dependencies go here
-r test.txt
# Pro-tip: Try not to put anything here. There should be no dependency in
# production that isn't in development.
-r base.txt
gunicorn
\ No newline at end of file
# Test dependencies go here.
-r base.txt
coverage==4.4.1
This diff is collapsed.
This diff is collapsed.
......@@ -15,47 +15,63 @@ from .models import Category, Facility, Schedule, OpenTime, Location, Alert
from rest_framework import serializers
from taggit_serializer.serializers import TagListSerializerField
class AlertSerializer(serializers.ModelSerializer):
"""
"""
class Meta:
model = Alert
fields = '__all__'
fields = "__all__"
class CategorySerializer(serializers.ModelSerializer):
"""
"""
class Meta:
# Choose the model to be serialized
model = Category
# Serialize all of the fields
fields = '__all__'
fields = "__all__"
class LocationSerializer(serializers.ModelSerializer):
"""
Serializer for the Location model.
"""
class Meta:
# Choose the model to be serialized
model = Location
# Serialize all of the fields
fields = '__all__'
fields = "__all__"
class OpenTimeSerializer(serializers.ModelSerializer):
"""
Serializer for the OpenTime model.
"""
class Meta:
# Choose the model to be serialized
model = OpenTime
# Serialize all of the fields
fields = ('schedule', 'modified',
'start_day', 'end_day', 'start_time', 'end_time')
fields = (
"schedule",
"modified",
"start_day",
"end_day",
"start_time",
"end_time",
)
class ScheduleSerializer(serializers.ModelSerializer):
"""
Serializer for the Schedule model.
"""
# Append a serialized OpenTime object
open_times = OpenTimeSerializer(many=True, read_only=True)
......@@ -63,8 +79,18 @@ class ScheduleSerializer(serializers.ModelSerializer):
# Choose the model to be serialized
model = Schedule
# List the fields that we are serializing
fields = ('id', 'open_times', 'modified', 'name', 'valid_start',
'valid_end', 'twenty_four_hours', 'schedule_for_removal', 'promote_to_main')
fields = (
"id",
"open_times",
"modified",
"name",
"valid_start",
"valid_end",
"twenty_four_hours",
"schedule_for_removal",
"promote_to_main",
)
class FacilitySerializer(serializers.HyperlinkedModelSerializer):
"""
......@@ -76,6 +102,7 @@ class FacilitySerializer(serializers.HyperlinkedModelSerializer):
than primary keys.
http://www.django-rest-framework.org/api-guide/serializers/#hyperlinkedmodelserializer
"""
# Append serialized objects
facility_category = CategorySerializer(many=False, read_only=True)
facility_location = LocationSerializer(many=False, read_only=True)
......@@ -89,7 +116,19 @@ class FacilitySerializer(serializers.HyperlinkedModelSerializer):
# Choose the model to be serialized
model = Facility
# List the fields that we are serializing
fields = ('slug', 'facility_name', 'logo', 'facility_location',
'facility_category', 'phone_number', 'facility_product_tags',
'facility_labels', 'facility_classifier', 'tapingo_url',
'note', 'main_schedule', 'special_schedules', 'modified', )
fields = (
"slug",
"facility_name",
"logo",
"facility_location",
"facility_category",
"phone_number",
"facility_product_tags",
"facility_labels",
"facility_classifier",
"tapingo_url",
"note",
"main_schedule",
"special_schedules",
"modified",
)
......@@ -12,8 +12,13 @@ from django.urls import include, path
from django.views.generic.base import RedirectView
# App Imports
from .views import (CategoryViewSet, FacilityViewSet, ScheduleViewSet,
LocationViewSet, AlertViewSet)
from .views import (
CategoryViewSet,
FacilityViewSet,
ScheduleViewSet,
LocationViewSet,
AlertViewSet,
)
# Other Imports
from rest_framework.routers import DefaultRouter
......@@ -22,16 +27,16 @@ from rest_framework.routers import DefaultRouter
ROUTER = DefaultRouter()
# Register views to the API router
ROUTER.register(r'alerts', AlertViewSet, 'alert')
ROUTER.register(r'categories', CategoryViewSet, 'category')
ROUTER.register(r'facilities', FacilityViewSet, 'facility')
ROUTER.register(r'locations', LocationViewSet, 'location')
ROUTER.register(r'schedules', ScheduleViewSet, 'schedule')
ROUTER.register(r"alerts", AlertViewSet, "alert")
ROUTER.register(r"categories", CategoryViewSet, "category")
ROUTER.register(r"facilities", FacilityViewSet, "facility")
ROUTER.register(r"locations", LocationViewSet, "location")
ROUTER.register(r"schedules", ScheduleViewSet, "schedule")
urlpatterns = [
# / - Default route
# We redirect to /api since this is in reality the default page for the API
path('', RedirectView.as_view(url='/api')),
path("", RedirectView.as_view(url="/api")),
# /api - Root API URL
path('api/', include(ROUTER.urls)),
path("api/", include(ROUTER.urls)),
]
This diff is collapsed.
This diff is collapsed.
......@@ -18,8 +18,4 @@ DEBUG = True
CACHE CONFIGURATION
"""
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
}
CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}}
......@@ -14,6 +14,7 @@ from django.core.exceptions import ImproperlyConfigured
# Import the base settings and override where necessary
from .base import *
def get_env_setting(setting):
"""
Get the environment setting or return exception
......@@ -25,11 +26,12 @@ def get_env_setting(setting):
error_msg = "Set the %s env variable" % setting
raise ImproperlyConfigured(error_msg)
"""
HOST CONFIGURATION
"""
# See: https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production
ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = ["*"]
"""
DEBUG CONFIGURATION
......@@ -41,15 +43,11 @@ DEBUG = False
CACHE CONFIGURATION
"""
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
}
CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}}
"""
SECRET CONFIGURATION
"""
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
SECRET_KEY = get_env_setting('WOPEN_SECRET_KEY')
SECRET_KEY = get_env_setting("WOPEN_SECRET_KEY")
########## END SECRET CONFIGURATION
......@@ -16,17 +16,13 @@ admin.autodiscover()
# Define all the top level url patterns in a list
urlpatterns = [
# / - Load in all urls from the `api` app
path('', include('api.urls')),
path("", include("api.urls")),
# /admin/docs - Documentation for admin
path('admin/doc/', include('django.contrib.admindocs.urls')),
path("admin/doc/", include("django.contrib.admindocs.urls")),
# /admin - The admin panels
path('admin/', admin.site.urls),
path("admin/", admin.site.urls),
# /api-auth - API Auth page
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
# /logout - Redirect to the homepage on logout
path('logout/', django.contrib.auth.views.logout, {'next_page': '/'}),
path("logout/", django.contrib.auth.views.logout, {"next_page": "/"}),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment