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

Update models, serializers, and tests for user registration #17

Merged
merged 25 commits into from
Nov 4, 2023

Conversation

delano
Copy link
Contributor

@delano delano commented Nov 4, 2023

This pull request includes several changes related to user registration functionality. A new route api/auth/register/ has been added to the urls.py file to handle user registration using the RegisterView. Significant changes have been made to serializers/__init__.py with the addition of RegisterSerializer. This new serializer validates the user information and checks the password and password confirmation fields for a match. A register user test has been added as well, located in the new file __test_userview_register.py.

Apart from registration related changes, the file test__userview.py has been renamed to __test__userview.py. Refactored user and registration serializers in afbcore by modularizing the code for better maintainability, and also created a new test for the user view. User and Register serializers previously in __init__.py are now in separate modules: user_serializer.py and register_user_serializer.py. A test for user views has also been implemented in test_user_view.py including methods for setting up, tearing down, and two tests: validating the registration process. Additionally, user model tests have been added and test files have been updated. Fixes #1234.

delano added 25 commits November 2, 2023 17:23
Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
coverage, and ipdb

Signed-off-by: delano <delano@cpan.org>
Includes `User = get_user_model()` fix for "_meta" field error.

Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
models

Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
Several dependencies have been added to requirements.txt including:
- 'appnope'
- 'asttokens'
- 'coverage'
- 'decorator'
- 'executing'
- 'iniconfig'
- 'ipdb'
- 'ipython'
- 'jedi'
- 'matplotlib-inline'
- 'parso'
- 'pexpect'
- 'pluggy'
- 'prompt-toolkit'
- 'ptyprocess'
- 'pure-eval'
- 'pygments'
- 'pytest'
- 'pytest-django'
- 'six'
- 'stack-data'
- 'traitlets'
- 'wcwidth'

Moreover, a few dependencies have been updated such as:
- 'django-unfold' from version 0.14.2 to 0.15.1
- Change usage of 'build' on 'packaging'. Now it also involves 'pytest'

It appears that most of these changes were prompted by the need to use 'ipython' and 'pytest' as these are recurring in the 'via' comments.

Signed-off-by: delano <delano@cpan.org>
New user registration functionality has been implemented. A new route `api/auth/register/` has been added to the `urls.py` file to handle user registration using the `RegisterView`. Significant changes have been made to `serializers/__init__.py` with the addition of `RegisterSerializer`. This new serializer validates the user information and checks the password and password confirmation fields for a match. A register user test has been added as well, located in the new file `__test_userview_register.py`. Apart from registration related changes, the file `test__userview.py` has been renamed to `__test__userview.py`.

Signed-off-by: delano <delano@cpan.org>
Refactored user and registration serializers in `afbcore` by modularizing the code for better maintainability, and also created a new test for the user view. User and Register serializers previously in `__init__.py` are now in separate modules: `user_serializer.py` and `register_user_serializer.py`. A test for user views has also been implemented in `test_user_view.py` including methods for setting up, tearing down, and two tests: validating the registration process.

Signed-off-by: delano <delano@cpan.org>
In the RegisterUserSerializer, additional fields mandatory for user registration have been included, like password2 and optional fields like first_name, last_name. The password matching validation is added, and a new user account can be created using these details.

In the tests, tests for registering a user with valid data, simple password, invalid email, password mismatch and short password scenarios are added. The serializer, in all these test cases, validates the incoming data and asserts the expected behavior. New users are created for successful scenarios, and the input data is compared for verification.

Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
- Split delivery_region into separate file
- Created a new Django migrations file to add numerous new fields to the "branch", "deliveryregion", and "profile" models.
- For both deliveryregion and profile, the fields "created", "modified", and "is_removed" have been added.
- Additional specific attributes added to the deliveryregion model, such as "country", "city", "address lines", "postal code" and "state or province".
- Modification in the afbcore models init file where "DeliveryRegion" has been split from the "delivery" Python file into its own separate file "delivery_region".
- Refactoring on the DeliveryRegion class - now it inherits from the BaseAbstractModel and PhysicalLocationMixin. The DeliveryRegion class was moved from "delivery.py" to a new file called "delivery_region.py". This refactoring adds several utility methods and fields to the DeliveryRegion model.
- Added a comment block in "base.py" suggesting usage of BaseAbstractModel.

Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
Add unique constraint on name field and validate name field on save and clean methods

Signed-off-by: delano <delano@cpan.org>
In the afb settings of our API app, we made a revision to our list of installed apps. The unused applications `crispy_forms`, `tailwind`, and `crispy_tailwind` were removed from the list in order to declutter and streamline our app. Meanwhile, we added `rest_framework` and `django_filters`, the latter of which is a dependency of Django Rest Framework. These new inclusions will enhance the functionality and efficiency of our Django project, with `rest_framework` providing a powerful and flexible toolkit for building Web APIs, and `django_filters` promoting filterable data for Django models.

Signed-off-by: delano <delano@cpan.org>
"Unused apps cleared from INSTALLED_APPS"

Further detailed description:

- Removed "django_browser_reload" from the INSTALLED_APPS list in settings.py. This app was initially included for browser reloading during template development but isn't needed anymore.
- Also removed the commented out 'theme' app as it is not being used. The initial plan was to use it with Tailwind CSS, but the front-end is now a separate Vue app.

Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
- In `settings.py`, middleware `BrowserReloadMiddleware` was removed. This middleware was primarily used in development to reload browsers whenever a change in the project files was detected.

- In `urls.py`, the `__reload__` URL path used for triggering browser reloads was also removed. This path was associated with the browser reload middleware.

- Commented out `MyLoginView` related login path is also removed.

Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
Signed-off-by: delano <delano@cpan.org>
@delano delano self-assigned this Nov 4, 2023
@delano delano force-pushed the feature/20231102-add-rest-profiles branch from e3d8acf to 6cff491 Compare November 4, 2023 20:46
@delano delano merged commit 37042e4 into main Nov 4, 2023
1 of 2 checks passed
@delano delano deleted the feature/20231102-add-rest-profiles branch November 4, 2023 20:47
@delano delano added the feature A planned and/or designed feature in the pipeline label Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A planned and/or designed feature in the pipeline
Projects
Status: ✔️ Done
Development

Successfully merging this pull request may close these issues.

1 participant