Skip to content

Commit

Permalink
Merge pull request #81 from AnimalFoodBank/delano/28-client-dashboard
Browse files Browse the repository at this point in the history
Delano/28 client dashboard
  • Loading branch information
delano authored Mar 19, 2024
2 parents 84b698a + 32cbc56 commit e181c9a
Show file tree
Hide file tree
Showing 35 changed files with 1,884 additions and 611 deletions.
19 changes: 19 additions & 0 deletions apps/api/afb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"127.0.0.1:3000",
"localhost",
"dev.afb.pet",
"staging.afb.pet",
"dev.animalfoodbank.org",
]

Expand All @@ -84,6 +85,8 @@
"django_extensions", # add this for 'python manage.py runserver_plus'
"rest_framework", # add DRF
"rest_framework.authtoken",
"drf_spectacular",
"drf_spectacular_sidecar",
# "drf_registration",
# 'djoser',
"drfpasswordless",
Expand Down Expand Up @@ -125,6 +128,7 @@
# TODO: Add production URL(s)
"https://localhost",
"https://dev.afb.pet",
"https://staging.afb.pet",
"https://dev.animalfoodbank.org",
]
CORS_ORIGIN_WHITELIST = CORS_ALLOWED_ORIGINS
Expand All @@ -142,6 +146,7 @@
"http://127.0.0.1:8000", # Django dev server
"https://localhost",
"https://dev.afb.pet",
"https://staging.afb.pet",
"https://dev.animalfoodbank.org",
]

Expand Down Expand Up @@ -233,13 +238,27 @@
"rest_framework.permissions.IsAuthenticated",
],
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
"PAGE_SIZE": 25,
"DEFAULT_FILTER_BACKENDS": ["django_filters.rest_framework.DjangoFilterBackend"],
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework.authentication.TokenAuthentication",
],
}

SPECTACULAR_SETTINGS = {
"TITLE": "Your Project API",
"DESCRIPTION": "Your project description",
"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
}

# drfpasswordless
#
# For the default settings see:
Expand Down
2 changes: 0 additions & 2 deletions apps/api/afb/urls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
# Add drf_registration endpoints. These are used for login, registration,
# etc from the frontend.
path("api/accounts/", include("drf_registration.urls")),
# An endpoint for Vueform specific validators.
path("api/validators/unique/", public.VueformUniqueValidatorView.as_view()),
]

urlpatterns.extend( # TODO: remove
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 4.2.11 on 2024-03-09 02:27

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("afbcore", "0001_initial"),
]

operations = [
migrations.RenameField(
model_name="profile",
old_name="first_name",
new_name="preferred_name",
),
migrations.RemoveField(
model_name="profile",
name="last_name",
),
migrations.AlterField(
model_name="profile",
name="address",
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name="profile",
name="address_verbatim",
field=models.CharField(blank=True, max_length=255, null=True),
),
]
26 changes: 26 additions & 0 deletions apps/api/afbcore/migrations/0003_user_first_name_user_last_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.11 on 2024-03-09 02:47

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("afbcore", "0002_rename_first_name_profile_preferred_name_and_more"),
]

operations = [
migrations.AddField(
model_name="user",
name="first_name",
field=models.CharField(
blank=True, max_length=150, verbose_name="first name"
),
),
migrations.AddField(
model_name="user",
name="last_name",
field=models.CharField(
blank=True, max_length=150, verbose_name="last name"
),
),
]
10 changes: 4 additions & 6 deletions apps/api/afbcore/models/users/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class Profile(BaseAbstractModel):
- user: ForeignKey to User model
- role: OneToOneField to Role model
- branches: ManyToManyField to Branch model
- first_name: CharField, max length 64
- last_name: CharField, max length 64
- preferred_name: CharField, max length 64
- email: EmailField, unique
- phone_number: PhoneNumberField, max length 20, region US
- address_verbatim: CharField, max length 255, blank
Expand All @@ -63,8 +62,7 @@ class Profile(BaseAbstractModel):
branches = models.ManyToManyField("Branch", **MANY_TO_MANY_DEFAULTS)

# Name fields
first_name = models.CharField(max_length=64)
last_name = models.CharField(max_length=64)
preferred_name = models.CharField(max_length=64)

# Email - Unique - don't allow duplicates.
email = models.EmailField(unique=True)
Expand Down Expand Up @@ -102,7 +100,7 @@ class Profile(BaseAbstractModel):

# Address - If address is duplicate to another clients, both accounts
# need to be placed on hold and manually reviewed/approved bc people
# are scammers. Has to be a validated address (google?) and not
# are scammers. Has to be a validated address (google?) and notWHich modela
# permitted to be overwritten. The last amount of free form text
# entry as possible. You'd be amazed how many clients don't know
# their postal code and we route by postal code sooooo
Expand All @@ -120,7 +118,7 @@ class Profile(BaseAbstractModel):
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default="active")

def __str__(self):
return f"{self.first_name} {self.last_name}"
return f"{self.preferred_name}"

def get_absolute_url(self):
return reverse("client-create", kwargs={"pk": self.pk})
9 changes: 4 additions & 5 deletions apps/api/afbcore/models/users/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class User(UUIDModel, TimeStampedModel, AbstractUser):
- is_active
- date_joined
- last_login
- first_name
- last_name
Fields inherited from UUIDModel, TimeStampedModel:
- id: UUIDField, primary key
Expand All @@ -122,7 +124,8 @@ class User(UUIDModel, TimeStampedModel, AbstractUser):
email = models.EmailField(_("email address"), unique=True)

# Add a single name field which we'll use instead of the default
# first_name and last_name fields.
# first_name and last_name fields. We leave those fields in place
# for compatibility with other apps that expect them to be present.
name = models.CharField(_("name"), max_length=255)

terms_agreement = models.BooleanField(
Expand All @@ -135,7 +138,3 @@ class User(UUIDModel, TimeStampedModel, AbstractUser):
username = models.CharField(
_("username"), max_length=255, unique=True, null=True, blank=True
)

# Remove the first_name and last_name fields from AbstractUser.
first_name = None
last_name = None
5 changes: 5 additions & 0 deletions apps/api/afbcore/views/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
class VueformUniqueValidatorView(APIView):
"""
This class is used to validate the uniqueness of a user field.
@config Add the following to your `urls.py` file:
path("api/validators/unique/", public.VueformUniqueValidatorView.as_view()),
@see https://vueform.com/docs/validating-elements#rule-unique
"""

permission_classes = (AllowAny,)
Expand Down
4 changes: 4 additions & 0 deletions apps/api/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ python-dotenv
# Local
-e git+file:///Users/d/Projects/opensource/django-rest-framework-passwordless@dev#egg=drfpasswordless

# OpenAPI 3 support for Django REST framework
drf-spectacular
drf-spectacular[sidecar] # Optional, but adds Swagger UI and Redoc rather than CDN

# This is used for the API docs
markdown

Expand Down
70 changes: 54 additions & 16 deletions apps/api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@
# via
# -r requirements.in
# drf-registration
# drf-spectacular
# drfpasswordless
-e git+file:///Users/d/Projects/opensource/drf-registration@dev#egg=drf-registration
# via -r requirements.in
-e git+file:///Users/d/Projects/opensource/django-rest-framework-passwordless@dev#egg=drfpasswordless
# via -r requirements.in
asgiref==3.7.2
# via django
# via
# django
# django-cors-headers
asttokens==2.4.1
# via stack-data
build==1.0.3
attrs==23.2.0
# via
# jsonschema
# referencing
build==1.1.1
# via pip-tools
certifi==2024.2.2
# via requests
Expand All @@ -27,17 +34,18 @@ charset-normalizer==3.3.2
# via requests
click==8.1.7
# via pip-tools
coverage==7.4.1
coverage==7.4.3
# via -r requirements.in
decorator==5.1.1
# via
# ipdb
# ipython
distlib==0.3.8
# via virtualenv
django==4.2.10
django==4.2.11
# via
# -r requirements.in
# django-cors-headers
# django-extensions
# django-filter
# django-model-utils
Expand All @@ -46,35 +54,49 @@ django==4.2.10
# django-vite
# djangorestframework
# drf-registration
# drf-spectacular
# drf-spectacular-sidecar
# drfpasswordless
django-cors-headers==4.3.1
# via -r requirements.in
django-extensions==3.2.3
# via -r requirements.in
django-filter==23.5
django-filter==24.1
# via -r requirements.in
django-model-utils==4.4.0
# via -r requirements.in
django-phonenumber-field==7.3.0
# via -r requirements.in
django-unfold==0.20.3
django-unfold==0.20.5
# via -r requirements.in
django-vite==3.0.3
# via -r requirements.in
drf-spectacular==0.27.1
# via -r requirements.in
drf-spectacular-sidecar==2024.3.4
# via drf-spectacular
executing==2.0.1
# via stack-data
filelock==3.13.1
# via virtualenv
identify==2.5.34
identify==2.5.35
# via pre-commit
idna==3.6
# via requests
inflection==0.5.1
# via drf-spectacular
iniconfig==2.0.0
# via pytest
ipdb==0.13.13
# via -r requirements.in
ipython==8.21.0
ipython==8.22.2
# via ipdb
jedi==0.19.1
# via ipython
jsonschema==4.21.1
# via drf-spectacular
jsonschema-specifications==2023.12.1
# via jsonschema
markdown==3.5.2
# via -r requirements.in
markupsafe==2.1.5
Expand All @@ -91,15 +113,15 @@ parso==0.8.3
# via jedi
pexpect==4.9.0
# via ipython
phonenumbers==8.13.30
phonenumbers==8.13.31
# via django-phonenumber-field
pip-tools==7.3.0
pip-tools==7.4.1
# via -r requirements.in
platformdirs==4.2.0
# via virtualenv
pluggy==1.4.0
# via pytest
pre-commit==3.6.1
pre-commit==3.6.2
# via -r requirements.in
prompt-toolkit==3.0.43
# via ipython
Expand All @@ -112,17 +134,31 @@ pure-eval==0.2.2
pygments==2.17.2
# via ipython
pyproject-hooks==1.0.0
# via build
pytest==8.0.0
# via
# build
# pip-tools
pytest==8.0.2
# via
# -r requirements.in
# pytest-django
pytest-django==4.8.0
# via -r requirements.in
python-dotenv==1.0.1
# via -r requirements.in
pyyaml==6.0.1
# via pre-commit
# via
# drf-spectacular
# pre-commit
referencing==0.33.0
# via
# jsonschema
# jsonschema-specifications
requests==2.31.0
# via drf-registration
rpds-py==0.18.0
# via
# jsonschema
# referencing
six==1.16.0
# via
# asttokens
Expand All @@ -135,9 +171,11 @@ traitlets==5.14.1
# via
# ipython
# matplotlib-inline
urllib3==2.2.0
uritemplate==4.1.1
# via drf-spectacular
urllib3==2.2.1
# via requests
virtualenv==20.25.0
virtualenv==20.25.1
# via pre-commit
wcwidth==0.2.13
# via prompt-toolkit
Expand Down
2 changes: 2 additions & 0 deletions apps/ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ logs

# VSC
.history

*storybook.log
Loading

0 comments on commit e181c9a

Please sign in to comment.