Skip to content

Commit

Permalink
Merge pull request #157 from AnimalFoodBank/134-updates-from-privacy-…
Browse files Browse the repository at this point in the history
…review-take2

134-updates-from-privacy-review-take2
  • Loading branch information
delano authored May 13, 2024
2 parents ccbdec0 + 7721e89 commit fa10b0a
Show file tree
Hide file tree
Showing 25 changed files with 879 additions and 260 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ DEBUG=False
BASE_HOST = dev.afb.pet
URI_SCHEMA = "https"

STAGING_HOST = staging.example.com
PRODUCTION_HOST = example.com

# Frontend UI
#
# This is the base host URL for the frontend application. In
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,17 @@ jobs:
#----------------------------------------------
- name: Install django ${{ matrix.django-version }}
run: |
poetry add Django@5${{ matrix.django-version }}
poetry add Django@${{ matrix.django-version }}
env:
VIRTUAL_ENV: .venv

- name: Run tests
run: |
poetry run python ./manage.py test
pytest tests/
coverage report
env:
VIRTUAL_ENV: .venv
#--------------------------------------------
# run tests (disabled for now)
#--------------------------------------------
# - name: Run tests
# run: |
# poetry run python ./manage.py test
# pytest tests/
# coverage report
# env:
# VIRTUAL_ENV: .venv
25 changes: 22 additions & 3 deletions apps/api/afb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
URI_SCHEMA = os.getenv("URI_SCHEMA", "https")
BASE_URI = f"{URI_SCHEMA}://{BASE_HOST}"

STAGING_HOST = os.getenv("STAGING_HOST", "example.com")
STAGING_URI = f"{URI_SCHEMA}://{STAGING_HOST}"

PRODUCTION_HOST = os.getenv("PRODUCTION_HOST", "example.com")
PRODUCTION_URI = f"{URI_SCHEMA}://{PRODUCTION_HOST}"

UI_BASE_HOST = os.getenv("UI_BASE_HOST", "localhost")
UI_URI_SCHEMA = os.getenv("UI_URI_SCHEMA", "https")
UI_BASE_URI = f"{URI_SCHEMA}://{UI_BASE_HOST}"
Expand Down Expand Up @@ -190,6 +196,10 @@
BASE_DIR / "static",
]

AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
]

REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
Expand All @@ -210,19 +220,28 @@
"DEFAULT_VERSIONING_CLASS": "rest_framework.versioning.URLPathVersioning",
"ALLOWED_VERSIONS": ["v1"],
"VERSION_PARAM": "version",
"DEFAULT_RENDERER_CLASSES": [
"rest_framework.renderers.JSONRenderer",
# 'rest_framework.renderers.BrowsableAPIRenderer', # DRF's default HTML docs
],
}

# @see https://drf-spectacular.readthedocs.io/en/latest/settings.html
SPECTACULAR_SETTINGS = {
"TITLE": "Your Project API",
"DESCRIPTION": "Your project description",
"TITLE": "AFB Requests API",
"DESCRIPTION": "API for managing food requests at the Animal Food Bank.",
"VERSION": "1.0.0",
# https://drf-spectacular.readthedocs.io/en/latest/client_generation.html
"COMPONENT_SPLIT_REQUEST": True,
"SERVE_INCLUDE_SCHEMA": False,
"SWAGGER_UI_DIST": "SIDECAR", # shorthand to use the sidecar instead
"SWAGGER_UI_FAVICON_HREF": "SIDECAR",
"REDOC_DIST": "SIDECAR",
# OTHER SETTINGS
"SERVERS": [
{"url": f"{BASE_URI}/", "description": "Dev Host"},
{"url": f"{STAGING_URI}/", "description": "Staging Host"},
{"url": f"{PRODUCTION_URI}/", "description": "Production Host"},
],
}

# drfpasswordless
Expand Down
20 changes: 19 additions & 1 deletion apps/api/afb/urls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
from django.contrib import admin as afbcore_admin
from django.urls import include, path
from django.views import defaults as default_views
from drf_spectacular.views import (
SpectacularAPIView,
SpectacularRedocView,
SpectacularSwaggerView,
)
from rest_framework.authtoken.views import obtain_auth_token
from rest_framework.routers import DefaultRouter

Expand All @@ -19,7 +24,7 @@

# e.g. /api/v1/requests/abcdef1234/
urlpatterns = [
path("admin/", afbcore_admin.site.urls, name="admin"),
path("afbadmin/", afbcore_admin.site.urls, name="admin"),
path("api/<str:version>/", include(router.urls)),
path("api/<str:version>/passwordless/", passwordless),
path(
Expand All @@ -32,6 +37,19 @@
authtoken.LogoutView.as_view(),
name="api_token_logout",
),
path(
"api/<str:version>/schema/", SpectacularAPIView.as_view(), name="schema"
),
path(
"api/<str:version>/schema/swagger-ui/",
SpectacularSwaggerView.as_view(url_name="schema"),
name="swagger-ui",
),
path(
"api/<str:version>/schema/redoc/",
SpectacularRedocView.as_view(url_name="schema"),
name="redoc",
),
]

if settings.DEBUG:
Expand Down
3 changes: 0 additions & 3 deletions apps/api/afbcore/tests.py

This file was deleted.

4 changes: 2 additions & 2 deletions apps/ui/components/HelpSlideover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const categories = computed(() => [{
items: [
{ shortcuts: [metaSymbol.value, 'K'], name: 'Command menu' },
{ shortcuts: ['N'], name: 'Notifications' },
{ shortcuts: ['?'], name: 'Help & FAQ' },
{ shortcuts: ['?'], name: 'Help & Support' },
{ shortcuts: ['/'], name: 'Search' }
]
}, {
Expand Down Expand Up @@ -76,7 +76,7 @@ const filteredCategories = computed(() => {
@click="shortcuts = false"
/>

{{ shortcuts ? 'Shortcuts' : 'Help & FAQ' }}
{{ shortcuts ? 'Shortcuts' : 'Help & Support' }}
</template>

<div v-if="shortcuts" class="space-y-6">
Expand Down
6 changes: 3 additions & 3 deletions apps/ui/components/UserDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { metaSymbol } = useShortcuts();
const {
status,
data,
data: authData,
token,
lastRefreshedAt,
getSession,
Expand Down Expand Up @@ -57,7 +57,7 @@ const items = computed(() => [
color="gray"
variant="ghost"
class="w-full"
:label="data?.name || 'AFB Client'"
:label="authData?.name || 'AFB Client'"
:class="[open && 'bg-gray-50 dark:bg-gray-800']"
>
<template #leading>
Expand All @@ -74,7 +74,7 @@ const items = computed(() => [
<div class="text-left">
<p>Signed in as</p>
<p class="truncate font-medium text-gray-900 dark:text-white">
{{ data?.email }}
{{ authData?.email }}
</p>
</div>
</template>
Expand Down
Loading

0 comments on commit fa10b0a

Please sign in to comment.