Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: assorted features, fixes and chores #263

Merged
merged 9 commits into from
Nov 9, 2023
7 changes: 0 additions & 7 deletions config/api_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
ContentShareViewSet,
ContentViewViewSet,
)
from mycarehub.users.api.views import UserAPIView

if settings.DEBUG:
router = DefaultRouter()
Expand All @@ -33,12 +32,6 @@

app_name = "api"
urlpatterns = router.urls + [
path("users/<pk>/", UserAPIView.as_view(), name="users-detail"),
path(
"users/",
UserAPIView.as_view(),
name="users-general",
),
path("organisations/<pk>/", OrganisationAPIView.as_view(), name="organisations-detail"),
path(
"organisations/",
Expand Down
14 changes: 5 additions & 9 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@
"wagtail.images",
"wagtail.search",
"wagtail.admin",
"wagtail.core",
"wagtail.contrib.modeladmin",
"wagtail",
"wagtailmedia",
"taggit",
"modelcluster",
Expand All @@ -104,8 +103,6 @@
"wagtail.contrib.search_promotions",
"wagtail.contrib.simple_translation",
"wagtail.locales",
"wagtailreadinglevel",
"wagtailfontawesome",
"django_extensions",
"nested_admin",
]
Expand All @@ -132,7 +129,7 @@
]
AUTH_USER_MODEL = "users.User"

LOGIN_REDIRECT_URL = "wagtailadmin_home"
LOGIN_REDIRECT_URL = "wagtailadmin_login_redirect"
LOGIN_URL = "wagtailadmin_login"

# PASSWORDS
Expand Down Expand Up @@ -164,6 +161,7 @@
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.common.BrokenLinkEmailsMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"allauth.account.middleware.AccountMiddleware",
]

# STATIC
Expand All @@ -189,11 +187,8 @@
"DIRS": [
str(APPS_DIR / "templates"),
],
"APP_DIRS": True,
"OPTIONS": {
"loaders": [
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
],
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
Expand Down Expand Up @@ -296,6 +291,7 @@
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_MIN_LENGTH = 5
ACCOUNT_DEFAULT_HTTP_PROTOCOL = env.str("DJANGO_ACCOUNT_DEFAULT_HTTP_PROTOCOL", default="https")
ACCOUNT_AUTHENTICATED_LOGIN_REDIRECTS = LOGIN_REDIRECT_URL

SOCIALACCOUNT_ADAPTER = "mycarehub.users.adapters.SocialAccountAdapter"
SOCIALACCOUNT_AUTO_SIGNUP = True
Expand Down
31 changes: 17 additions & 14 deletions config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,6 @@
DEFAULT_FILE_STORAGE = "mycarehub.utils.storages.MediaRootGoogleCloudStorage"
MEDIA_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/media/"

# TEMPLATES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
TEMPLATES[-1]["OPTIONS"]["loaders"] = [ # type: ignore[index] # noqa F405
(
"django.template.loaders.cached.Loader",
[
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
],
)
]


# Anymail
# ------------------------------------------------------------------------------
# https://anymail.readthedocs.io/en/stable/installation/#installing-anymail
Expand Down Expand Up @@ -170,5 +156,22 @@
traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=1.0),
)

# Wagtail
# ------------------------------------------------------------------------------
ELASTICSEARCH_ENABLED = env.bool("ELASTICSEARCH_ENABLED", default=False)
if ELASTICSEARCH_ENABLED:
WAGTAILSEARCH_BACKENDS = {
"default": {
"BACKEND": "wagtail.search.backends.elasticsearch8",
"URLS": [env("ELASTICSEARCH_URL")],
"INDEX": env("ELASTICSEARCH_INDEX"),
"TIMEOUT": 5,
"OPTIONS": {},
"INDEX_SETTINGS": {},
"ATOMIC_REBUILD": True,
"AUTO_UPDATE": True,
}
}

# Your stuff...
# ------------------------------------------------------------------------------
12 changes: 0 additions & 12 deletions config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]

# TEMPLATES
# ------------------------------------------------------------------------------
TEMPLATES[-1]["OPTIONS"]["loaders"] = [ # type: ignore[index] # noqa F405
(
"django.template.loaders.cached.Loader",
[
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
],
)
]

# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
Expand Down
4 changes: 4 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
SignedURLView,
media_index,
)
from mycarehub.users.views import CustomLoginView, login_redirect

urlpatterns = [
path("sysadmin/", HomeView.as_view(), name="home"),
Expand Down Expand Up @@ -124,6 +125,8 @@
path("admin/images/", CustomImageIndexView.as_view(), name="wagtailimages-index"),
path("admin/media/", media_index, name="wagtailmedia-index"),
path("admin/documents/", CustomDocumentIndexView.as_view(), name="wagtaildocs-index"),
path("admin/login/", CustomLoginView.as_view(), name="wagtailadmin_login"),
path("admin/redirect/", login_redirect, name="wagtailadmin_redirect"),
path("admin/", include(wagtailadmin_urls)),
path("documents/", include(wagtaildocs_urls)),
re_path(
Expand All @@ -137,4 +140,5 @@

urlpatterns += i18n_patterns(
path("", include(wagtail_urls), name="wagtail"),
prefix_default_language=False,
)
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function scripts() {
}
// Vendor Javascript minification
function vendorScripts() {
return src(paths.vendorsJs)
return src(paths.vendorsJs, {sourcemaps: true})
.pipe(sourcemaps.init())
.pipe(concat("vendors.js"))
.pipe(lec({ verbose: true, eolc: "LF", encoding: "utf8" }))
Expand Down
45 changes: 0 additions & 45 deletions mycarehub/clients/forms.py

This file was deleted.

21 changes: 8 additions & 13 deletions mycarehub/clients/serializers.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from django import forms
from drf_braces.serializers.form_serializer import FormSerializer, make_form_serializer_field
from rest_framework import serializers

from mycarehub.common.serializers import OrganisationSerializer, ProgramSerializer

from .forms import ClientRegistrationForm
from .models import Client


class ClientSerializer(serializers.ModelSerializer):
organisation = OrganisationSerializer()
program = ProgramSerializer()
organisation = OrganisationSerializer(read_only=True)
program = ProgramSerializer(read_only=True)
organisation_id = serializers.UUIDField(write_only=True)
program_id = serializers.UUIDField(write_only=True)
client_id = serializers.UUIDField(write_only=True)

class Meta:
model = Client
Expand All @@ -21,12 +21,7 @@ class Meta:
"date_of_birth",
"program",
"organisation",
"program_id",
"organisation_id",
"client_id",
]


class ClientRegistrationSerializer(FormSerializer):
class Meta:
form = ClientRegistrationForm
field_mapping = {
forms.UUIDField: make_form_serializer_field(serializers.UUIDField),
}
4 changes: 2 additions & 2 deletions mycarehub/clients/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from mycarehub.common.models import Organisation, Program

from .models import Client
from .serializers import ClientRegistrationSerializer, ClientSerializer
from .serializers import ClientSerializer


class ClientAPIView(APIView):
queryset = Client.objects.all()
serializer_class = ClientRegistrationSerializer
serializer_class = ClientSerializer

def get(self, request):
users = Client.objects.all()
Expand Down
2 changes: 0 additions & 2 deletions mycarehub/common/filters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from .base_filters import CommonFieldsFilterset
from .common_filters import FacilityFilter, UserFacilityAllotmentFilter
from .custom_filter_backends import OrganisationFilterBackend

__all__ = [
"CommonFieldsFilterset",
"FacilityFilter",
"OrganisationFilterBackend",
"UserFacilityAllotmentFilter",
Expand Down
54 changes: 0 additions & 54 deletions mycarehub/common/filters/base_filters.py

This file was deleted.

6 changes: 3 additions & 3 deletions mycarehub/common/filters/common_filters.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import django_filters
from rest_framework import filters

from ..models import Facility, UserFacilityAllotment
from .base_filters import CommonFieldsFilterset


class FacilityFilter(CommonFieldsFilterset):
class FacilityFilter(django_filters.FilterSet):
"""Filter facilities."""

search = filters.SearchFilter()
Expand All @@ -16,7 +16,7 @@ class Meta:
fields = "__all__"


class UserFacilityAllotmentFilter(CommonFieldsFilterset):
class UserFacilityAllotmentFilter(django_filters.FilterSet):
search = filters.SearchFilter()

class Meta:
Expand Down
17 changes: 0 additions & 17 deletions mycarehub/common/forms/__init__.py

This file was deleted.

Loading
Loading