Skip to content

Commit

Permalink
Merge pull request #3 from ferdynator/feature-api-docs
Browse files Browse the repository at this point in the history
Feature: Api Docs & Development Setup
  • Loading branch information
biodiv committed Oct 27, 2022
2 parents a5d9fa9 + 543c2f6 commit cdddfc3
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 160 deletions.
15 changes: 15 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
POSTGRES_PASSWORD=postgres
POSTGRES_USER=postgres
POSTGRES_DB=localcosmos

DB_HOST=database
DB_USER=postgres
DB_PASSWORD=postgres
DATABASE_NAME=localcosmos

ALLOWED_HOSTS=localhost
APP_UID=treesofbavaria
SERVE_APP_URL=/
SECRET_KEY=asjdfkujwefksdbkasdbflaubflasd

DJANGO_SETTINGS_MODULE=localcosmos_private.settings
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.10

WORKDIR /opt/localcosmos

RUN apt-get update &&\
apt-get install --no-install-recommends -y libgeos-dev libgdal-dev &&\
apt-get clean autoclean &&\
apt-get autoremove -y &&\
rm -rf /var/lib/{apt,dpkg,cache,log}/

COPY localcosmos_server/requirements.txt /opt/localcosmos
RUN pip install -r /opt/localcosmos/requirements.txt

RUN django-admin startproject localcosmos_private

RUN ls /opt/localcosmos/localcosmos_private

CMD python manage.py runserver 0.0.0.0:8000
25 changes: 25 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.7'

services:
app:
build: .
volumes:
- ./docker/localcosmos_private/settings.py:/opt/localcosmos/localcosmos_private/localcosmos_private/settings.py
- ./docker/localcosmos_private/urls.py:/opt/localcosmos/localcosmos_private/localcosmos_private/urls.py
- ./localcosmos_server:/opt/localcosmos/localcosmos_private/localcosmos_server
env_file: .env
depends_on:
- database
ports:
- 8000:8000
command: sh -c 'cd /opt/localcosmos/localcosmos_private && python manage.py runserver 0.0.0.0:8000'
database:
image: 'postgis/postgis:12-3.3'
volumes:
- database:/var/lib/postgresql/data
ports:
- 5432:5432
env_file: .env

volumes:
database:
11 changes: 7 additions & 4 deletions docker/localcosmos_private/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SECRET_KEY = '-l4*f++k5$u!cr(o#-hio-d9hl)9b&nb37%_6v3l^w#20(rr!*'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ['*']
host_list = os.environ.get('ALLOWED_HOSTS', [])
Expand Down Expand Up @@ -59,7 +59,9 @@
'django_countries',
'corsheaders',
'rest_framework',
'rest_framework.authtoken',
"drf_spectacular",
'rest_framework_simplejwt',
'rest_framework_simplejwt.token_blacklist',

'octicons',
'imagekit',
Expand Down Expand Up @@ -117,7 +119,7 @@
'NAME': os.environ['DATABASE_NAME'],
'USER' : os.environ['DB_USER'],
'PASSWORD' : os.environ['DB_PASSWORD'],
'HOST' : 'localhost',
'HOST' : os.environ['DB_HOST'],
}
}

Expand Down Expand Up @@ -190,4 +192,5 @@
EMAIL_PORT = os.environ.get('EMAIL_PORT', 25)

DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL', 'webmaster@localhost')


from localcosmos_server.settings import *
3 changes: 2 additions & 1 deletion docker/localcosmos_private/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
# path('admin/', admin.site.urls),
path('', include('localcosmos_server.urls')),
]


if settings.DEBUG:
from django.conf.urls.static import static
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
41 changes: 0 additions & 41 deletions localcosmos_server/api/authentication.py

This file was deleted.

2 changes: 2 additions & 0 deletions localcosmos_server/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def update_datasets(self, user, client):


# this uses email or username
# todo: subclass this into the simplejwt:
# see: https://django-rest-framework-simplejwt.readthedocs.io/en/latest/customizing_token_claims.html
def validate(self, attrs):
username = attrs.get('username')
password = attrs.get('password')
Expand Down
6 changes: 2 additions & 4 deletions localcosmos_server/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
urlpatterns = [
# app unspecific
path('', views.APIHome.as_view(), name='api_home'),
path('auth-token/', views.ObtainLCAuthToken.as_view()),
path('user/<int:user_id>/manage/', views.ManageAccount.as_view()),
path('user/<int:user_id>/delete/', views.DeleteAccount.as_view()),
path('user/manage/', views.ManageAccount.as_view()),
path('user/delete/', views.DeleteAccount.as_view()),
path('user/register/', views.RegisterAccount.as_view()),
path('password/reset/', views.PasswordResetRequest.as_view()),
# app specific
path('app/<uuid:app_uuid>/', views.AppAPIHome.as_view(), name='app_api_home'),
path('app/<uuid:app_uuid>/privacy-statement/', views.PrivacyStatement.as_view(), name='app_privacy_statement'),
]

urlpatterns = format_suffix_patterns(urlpatterns, allowed=['json', 'html'])

0 comments on commit cdddfc3

Please sign in to comment.